aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2013-12-20 15:50:35 +0200
committerDamian Minkov <damencho@jitsi.org>2014-01-07 11:50:00 +0200
commitcbd25f3a73bc200831d248607df50ca3c2f74ff9 (patch)
tree3063f0552714f0321319ddc9fd64a4044b850d6f
parentd51c519a6d099d073c7d8d4be308acf5e6be7211 (diff)
downloadjitsi-cbd25f3a73bc200831d248607df50ca3c2f74ff9.zip
jitsi-cbd25f3a73bc200831d248607df50ca3c2f74ff9.tar.gz
jitsi-cbd25f3a73bc200831d248607df50ca3c2f74ff9.tar.bz2
Fires resources events when connection failed and all contacts are going to offline.
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java106
1 files changed, 49 insertions, 57 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
index ffe4103..060b41e 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
@@ -799,6 +799,7 @@ public class OperationSetPersistentPresenceJabberImpl
PresenceStatus offlineStatus =
parentProvider.getJabberStatusEnum().getStatus(
JabberStatusEnum.OFFLINE);
+
if(newStatus.equals(offlineStatus))
{
//send event notifications saying that all our buddies are
@@ -818,19 +819,7 @@ public class OperationSetPersistentPresenceJabberImpl
ContactJabberImpl contact
= (ContactJabberImpl)contactsIter.next();
- PresenceStatus oldContactStatus
- = contact.getPresenceStatus();
-
- if(!oldContactStatus.isOnline())
- continue;
-
- contact.updatePresenceStatus(offlineStatus);
-
- fireContactPresenceStatusChangeEvent(
- contact,
- contact.getParentContactGroup(),
- oldContactStatus,
- offlineStatus);
+ updateContactStatus(contact, offlineStatus);
}
}
@@ -843,18 +832,7 @@ public class OperationSetPersistentPresenceJabberImpl
ContactJabberImpl contact
= (ContactJabberImpl) contactsIter.next();
- PresenceStatus oldContactStatus
- = contact.getPresenceStatus();
-
- if (!oldContactStatus.isOnline())
- continue;
-
- contact.updatePresenceStatus(offlineStatus);
-
- fireContactPresenceStatusChangeEvent(
- contact
- , contact.getParentContactGroup()
- , oldContactStatus, offlineStatus);
+ updateContactStatus(contact, offlineStatus);
}
}
}
@@ -997,7 +975,8 @@ public class OperationSetPersistentPresenceJabberImpl
// Do not obtain getRoster if we are not connected, or new Roster
// will be created, all the resources that will be returned will be
// unavailable. As we are not connected if set remove all resources
- if(!parentProvider.getConnection().isConnected())
+ if( parentProvider.getConnection() == null
+ || !parentProvider.getConnection().isConnected())
{
if(removeUnavailable)
{
@@ -1135,6 +1114,44 @@ public class OperationSetPersistentPresenceJabberImpl
}
/**
+ * Updates contact status and its resources, fires PresenceStatusChange
+ * events.
+ *
+ * @param contact the contact which presence to update if needed.
+ * @param newStatus the new status.
+ */
+ private void updateContactStatus(
+ ContactJabberImpl contact, PresenceStatus newStatus)
+ {
+ // When status changes this may be related to a change in the
+ // available resources.
+ boolean oldMobileIndicator = contact.isMobile();
+ boolean resourceUpdated = updateResources(contact, true);
+ mobileIndicator.resourcesUpdated(contact);
+
+ PresenceStatus oldStatus
+ = contact.getPresenceStatus();
+
+ // when old and new status are the same do nothing
+ // no change
+ if(oldStatus.equals(newStatus)
+ && oldMobileIndicator == contact.isMobile())
+ {
+ return;
+ }
+
+ contact.updatePresenceStatus(newStatus);
+
+ if (logger.isDebugEnabled())
+ logger.debug("Will Dispatch the contact status event.");
+
+ fireContactPresenceStatusChangeEvent(
+ contact, contact.getParentContactGroup(),
+ oldStatus, newStatus,
+ resourceUpdated);
+ }
+
+ /**
* Manage changes of statuses by resource.
*/
class ContactChangesListener
@@ -1235,7 +1252,8 @@ public class OperationSetPersistentPresenceJabberImpl
= StringUtils.parseBareAddress(presence.getFrom());
List<ChatRoom> chatRooms = parentProvider.getOperationSet(
- OperationSetMultiUserChat.class).getCurrentlyJoinedChatRooms();
+ OperationSetMultiUserChat.class)
+ .getCurrentlyJoinedChatRooms();
for(ChatRoom chatRoom : chatRooms)
{
if(chatRoom.getName().equals(userID))
@@ -1333,36 +1351,10 @@ public class OperationSetPersistentPresenceJabberImpl
// statuses may be the same and only change in status message
sourceContact.setStatusMessage(currentPresence.getStatus());
- // When status changes this may be related to a change in the
- // available resources.
- boolean oldMobileIndicator = sourceContact.isMobile();
- boolean resourceUpdated = updateResources(sourceContact, true);
- mobileIndicator.resourcesUpdated(sourceContact);
-
- PresenceStatus oldStatus
- = sourceContact.getPresenceStatus();
- PresenceStatus newStatus
- = jabberStatusToPresenceStatus(
- currentPresence,
- parentProvider);
-
- // when old and new status are the same do nothing
- // no change
- if(oldStatus.equals(newStatus)
- && oldMobileIndicator == sourceContact.isMobile())
- {
- return;
- }
-
- sourceContact.updatePresenceStatus(newStatus);
-
- ContactGroup parent
- = ssContactList.findContactGroup(sourceContact);
-
- if (logger.isDebugEnabled())
- logger.debug("Will Dispatch the contact status event.");
- fireContactPresenceStatusChangeEvent(sourceContact, parent,
- oldStatus, newStatus, resourceUpdated);
+ updateContactStatus(
+ sourceContact,
+ jabberStatusToPresenceStatus(
+ currentPresence, parentProvider));
}
catch (IllegalStateException ex)
{