Commit 6ca240d6 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-51] Some work on groupless contacts.

Updated versions.
Improved add functionality a tad, still working.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@5940 b35dd754-fafc-0310-a699-88a17e54d16e
parent 15a75c3d
......@@ -2,7 +2,7 @@ Name | Version
---------------------------------------------
cindy.jar | 2.4.4
irclib.jar | 1.04
jml.jar | svn-20061103
jml.jar | svn-20061105
joscar-client.jar | svn-20061103
joscar-common.jar | svn-20061026
joscar-protocol.jar | svn-20061103
......
......@@ -842,7 +842,7 @@ public abstract class BaseTransport implements Component, RosterEventListener, P
* @param groups List of group the item is to be placed in. (can be null)
* @throws UserNotFoundException if userjid not found.
*/
public void addOrUpdateRosterItem(JID userjid, JID contactjid, String nickname, ArrayList<String> groups) throws UserNotFoundException {
public void addOrUpdateRosterItem(JID userjid, JID contactjid, String nickname, List<String> groups) throws UserNotFoundException {
try {
Roster roster = rosterManager.getRoster(userjid.getNode());
try {
......
......@@ -148,11 +148,13 @@ public class MSNSession extends TransportSession {
Log.debug("MSN: Found belong group for "+friend+" as "+group);
friendGroups.add(group.getGroupName());
}
if (friendGroups.size() < 1) {
friendGroups.add("MSN Contacts");
}
if (friendGroups.size() > 0) {
legacyusers.add(new TransportBuddy(friend.getEmail().toString(), friend.getFriendlyName(), friendGroups.get(0)));
}
else {
legacyusers.add(new TransportBuddy(friend.getEmail().toString(), friend.getFriendlyName(), null));
}
}
try {
getTransport().syncLegacyRoster(getJID(), legacyusers);
}
......@@ -180,6 +182,14 @@ public class MSNSession extends TransportSession {
nickname = item.getNickname();
}
msnMessenger.addFriend(contact, nickname);
try {
lockRoster();
getTransport().addOrUpdateRosterItem(getJID(), item.getJid(), nickname, item.getGroups());
unlockRoster();
}
catch (UserNotFoundException e) {
Log.error("MSN: Unable to find roster when adding contact.");
}
syncContactGroups(contact, item.getGroups());
}
......@@ -222,9 +232,6 @@ public class MSNSession extends TransportSession {
* @param groups List of groups contact should be in.
*/
public void syncContactGroups(Email contact, List<String> groups) {
if (groups.isEmpty()) {
groups.add("Transport Buddies");
}
MsnContact msnContact = msnContacts.get(contact.toString());
// Create groups that do not currently exist.
for (String group : groups) {
......@@ -239,17 +246,19 @@ public class MSNSession extends TransportSession {
// Make sure contact belongs to groups that we want.
for (String group : groups) {
MsnGroup msnGroup = msnGroups.get(group);
if (!msnContact.belongGroup(msnGroup)) {
if (msnContact == null || !msnContact.belongGroup(msnGroup)) {
msnMessenger.copyFriend(contact, group);
}
}
// Now we will clean up groups that we should no longer belong to.
if (msnContact != null) {
for (MsnGroup msnGroup : msnContact.getBelongGroups()) {
if (!groups.contains(msnGroup.getGroupName())) {
msnMessenger.removeFriend(contact, msnGroup.getGroupId());
}
}
}
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment