diff options
author | Damian Minkov <damencho@jitsi.org> | 2008-05-16 12:09:47 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2008-05-16 12:09:47 +0000 |
commit | 89a97e5c55d6be970586e49dcdb1f6206388aa13 (patch) | |
tree | 7e8c9cf32cea519ea3a66e55fa10995b6cf59225 /src/net/java/sip | |
parent | 509881eedcacaab8d3299c37978457e1d5fdf569 (diff) | |
download | jitsi-89a97e5c55d6be970586e49dcdb1f6206388aa13.zip jitsi-89a97e5c55d6be970586e49dcdb1f6206388aa13.tar.gz jitsi-89a97e5c55d6be970586e49dcdb1f6206388aa13.tar.bz2 |
Fix msn contact status after adding it. and when removing contact, remove it also from the group.
Diffstat (limited to 'src/net/java/sip')
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java | 28 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java | 43 |
2 files changed, 56 insertions, 15 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java index 37a5d25..4c6edf9 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java @@ -43,14 +43,14 @@ public class OperationSetPersistentPresenceMsnImpl private String currentStatusMessage = ""; /** - * The presence status that we were last notified of etnering. + * The presence status that we were last notified of entering. * The initial one is OFFLINE */ private PresenceStatus currentStatus = MsnStatusEnum.OFFLINE; /** * The list of listeners interested in receiving changes in our local - * presencestatus. + * presence status. */ private Vector providerPresenceStatusListeners = new Vector(); @@ -116,7 +116,7 @@ public class OperationSetPersistentPresenceMsnImpl } /** - * The server stored contact list that will be encapsulating smack's + * The server stored contact list that will be encapsulating msn's * buddy list. */ private ServerStoredContactListMsnImpl ssContactList = null; @@ -164,11 +164,11 @@ public class OperationSetPersistentPresenceMsnImpl } /** - * Registers a listener that would receive events upong changes in server + * Registers a listener that would receive events upon changes in server * stored groups. * * @param listener a ServerStoredGroupChangeListener impl that would - * receive events upong group changes. + * receive events upon group changes. */ public void addServerStoredGroupChangeListener(ServerStoredGroupListener listener) @@ -178,7 +178,7 @@ public class OperationSetPersistentPresenceMsnImpl /** * Registers a listener that would get notifications any time a new - * subscription was succesfully added, has failed or was removed. + * subscription was successfully added, has failed or was removed. * * @param listener the SubscriptionListener to register */ @@ -312,7 +312,7 @@ public class OperationSetPersistentPresenceMsnImpl } /** - * Returns the status message that was confirmed by the serfver + * Returns the status message that was confirmed by the server * * @return the last status message that we have requested and the aim * server has confirmed. @@ -395,7 +395,7 @@ public class OperationSetPersistentPresenceMsnImpl /** * Requests the provider to enter into a status corresponding to the - * specified paramters. + * specified parameters. * * @param status the PresenceStatus as returned by * getRequestableStatusSet @@ -652,7 +652,7 @@ public class OperationSetPersistentPresenceMsnImpl * @return a PresenceStatus instance representation of the Msn Status * parameter. The returned result is one of the MsnStatusEnum fields. */ - private MsnStatusEnum msnStatusToPresenceStatus(MsnUserStatus status) + MsnStatusEnum msnStatusToPresenceStatus(MsnUserStatus status) { if(status.equals(MsnUserStatus.ONLINE)) return MsnStatusEnum.ONLINE; @@ -772,7 +772,7 @@ public class OperationSetPersistentPresenceMsnImpl implements RegistrationStateChangeListener { /** - * The method is called by a ProtocolProvider implementation whenver + * The method is called by a ProtocolProvider implementation whenever * a change in the registration state of the corresponding provider had * occurred. * @param evt ProviderStatusChangeEvent the event describing the status @@ -922,7 +922,7 @@ public class OperationSetPersistentPresenceMsnImpl * @param newStatus the status that the specified contact is currently in. * @param parentGroup the group containing the contact which caused the event */ - private void fireContactPresenceStatusChangeEvent( + void fireContactPresenceStatusChangeEvent( Contact contact, ContactGroup parentGroup, PresenceStatus oldStatus, @@ -994,7 +994,7 @@ public class OperationSetPersistentPresenceMsnImpl /** * Sets the messenger instance impl of the lib - * which comunicates with the server + * which communicates with the server * @param messenger MsnMessenger */ void setMessenger(MsnMessenger messenger) @@ -1046,13 +1046,13 @@ public class OperationSetPersistentPresenceMsnImpl /** * Waits for status changes from the contacts in the list - * or ouw own account + * or own account */ private class StatusChangedListener extends MsnContactListAdapter { /** - * Indicates that ower status changed + * Indicates that owner status changed * @param messenger the messenger changing the status */ public void ownerStatusChanged(MsnMessenger messenger) diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java index 7f88012..ff1a08f 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java @@ -575,8 +575,20 @@ public class ServerStoredContactListMsnImpl void removeContact(ContactMsnImpl contactToRemove) { logger.trace("Removing msn contact " + contactToRemove.getSourceContact()); + + Email contactsEmail = contactToRemove.getSourceContact().getEmail(); + + MsnGroup[] belongGroups = + contactToRemove.getSourceContact().getBelongGroups(); + + for (int i = 0; i < belongGroups.length; i++) + { + msnProvider.getMessenger(). + removeFriend(contactsEmail, belongGroups[i].getGroupId()); + } + msnProvider.getMessenger(). - removeFriend(contactToRemove.getSourceContact().getEmail(), false); + removeFriend(contactsEmail, false); } @@ -700,6 +712,35 @@ public class ServerStoredContactListMsnImpl //dispatch parentOperationSet.fireSubscriptionEvent( SubscriptionEvent.SUBSCRIPTION_CREATED, contact, parentGroup); + + // sometimes when adding msn contact + // status updates comes before event for adding contact and so + // statuses are not dispatched, we check this here + MsnUserStatus msnStatus = + contact.getSourceContact().getStatus(); + + // for some reason when creating unresolved contact this status is null + if(msnStatus == null) + return; + + PresenceStatus oldStatus + = contact.getPresenceStatus(); + + PresenceStatus newStatus + = parentOperationSet.msnStatusToPresenceStatus( + contact.getSourceContact().getStatus()); + + if(oldStatus.equals(newStatus)) + return; + + contact.updatePresenceStatus(newStatus); + + parentOperationSet.fireContactPresenceStatusChangeEvent( + contact, + parentGroup, + oldStatus, + newStatus + ); } /** |