Commit 6eb122fc 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@5940 b35dd754-fafc-0310-a699-88a17e54d16e
parent 554a7774
...@@ -2,7 +2,7 @@ Name | Version ...@@ -2,7 +2,7 @@ Name | Version
--------------------------------------------- ---------------------------------------------
cindy.jar | 2.4.4 cindy.jar | 2.4.4
irclib.jar | 1.04 irclib.jar | 1.04
jml.jar | svn-20061103 jml.jar | svn-20061105
joscar-client.jar | svn-20061103 joscar-client.jar | svn-20061103
joscar-common.jar | svn-20061026 joscar-common.jar | svn-20061026
joscar-protocol.jar | svn-20061103 joscar-protocol.jar | svn-20061103
......
...@@ -842,7 +842,7 @@ public abstract class BaseTransport implements Component, RosterEventListener, P ...@@ -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) * @param groups List of group the item is to be placed in. (can be null)
* @throws UserNotFoundException if userjid not found. * @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 { try {
Roster roster = rosterManager.getRoster(userjid.getNode()); Roster roster = rosterManager.getRoster(userjid.getNode());
try { try {
......
...@@ -148,10 +148,12 @@ public class MSNSession extends TransportSession { ...@@ -148,10 +148,12 @@ public class MSNSession extends TransportSession {
Log.debug("MSN: Found belong group for "+friend+" as "+group); Log.debug("MSN: Found belong group for "+friend+" as "+group);
friendGroups.add(group.getGroupName()); friendGroups.add(group.getGroupName());
} }
if (friendGroups.size() < 1) { if (friendGroups.size() > 0) {
friendGroups.add("MSN Contacts"); legacyusers.add(new TransportBuddy(friend.getEmail().toString(), friend.getFriendlyName(), friendGroups.get(0)));
}
else {
legacyusers.add(new TransportBuddy(friend.getEmail().toString(), friend.getFriendlyName(), null));
} }
legacyusers.add(new TransportBuddy(friend.getEmail().toString(), friend.getFriendlyName(), friendGroups.get(0)));
} }
try { try {
getTransport().syncLegacyRoster(getJID(), legacyusers); getTransport().syncLegacyRoster(getJID(), legacyusers);
...@@ -180,6 +182,14 @@ public class MSNSession extends TransportSession { ...@@ -180,6 +182,14 @@ public class MSNSession extends TransportSession {
nickname = item.getNickname(); nickname = item.getNickname();
} }
msnMessenger.addFriend(contact, nickname); 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()); syncContactGroups(contact, item.getGroups());
} }
...@@ -222,9 +232,6 @@ public class MSNSession extends TransportSession { ...@@ -222,9 +232,6 @@ public class MSNSession extends TransportSession {
* @param groups List of groups contact should be in. * @param groups List of groups contact should be in.
*/ */
public void syncContactGroups(Email contact, List<String> groups) { public void syncContactGroups(Email contact, List<String> groups) {
if (groups.isEmpty()) {
groups.add("Transport Buddies");
}
MsnContact msnContact = msnContacts.get(contact.toString()); MsnContact msnContact = msnContacts.get(contact.toString());
// Create groups that do not currently exist. // Create groups that do not currently exist.
for (String group : groups) { for (String group : groups) {
...@@ -239,14 +246,16 @@ public class MSNSession extends TransportSession { ...@@ -239,14 +246,16 @@ public class MSNSession extends TransportSession {
// Make sure contact belongs to groups that we want. // Make sure contact belongs to groups that we want.
for (String group : groups) { for (String group : groups) {
MsnGroup msnGroup = msnGroups.get(group); MsnGroup msnGroup = msnGroups.get(group);
if (!msnContact.belongGroup(msnGroup)) { if (msnContact == null || !msnContact.belongGroup(msnGroup)) {
msnMessenger.copyFriend(contact, group); msnMessenger.copyFriend(contact, group);
} }
} }
// Now we will clean up groups that we should no longer belong to. // Now we will clean up groups that we should no longer belong to.
for (MsnGroup msnGroup : msnContact.getBelongGroups()) { if (msnContact != null) {
if (!groups.contains(msnGroup.getGroupName())) { for (MsnGroup msnGroup : msnContact.getBelongGroups()) {
msnMessenger.removeFriend(contact, msnGroup.getGroupId()); if (!groups.contains(msnGroup.getGroupName())) {
msnMessenger.removeFriend(contact, msnGroup.getGroupId());
}
} }
} }
} }
......
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