[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java

damencho at dev.java.net damencho at dev.java.net
Thu Apr 12 10:51:47 CEST 2007


User: damencho
Date: 2007-04-12 08:51:47+0000
Log:
 Fixing jabber statuses.

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/protocol/jabber/
================================================================================

File [changed]: OperationSetPersistentPresenceJabberImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java?r1=1.12&r2=1.13
Delta lines:  +15 -9
--------------------
--- OperationSetPersistentPresenceJabberImpl.java	2007-04-04 12:53:06+0000	1.12
+++ OperationSetPersistentPresenceJabberImpl.java	2007-04-12 08:51:44+0000	1.13
@@ -456,7 +456,7 @@
                 getPresence(contactIdentifier);
 
         if(presence != null)
-            return jabberStatusToPresenceStatus(presence.getMode());
+            return jabberStatusToPresenceStatus(presence);
         else
             return JabberStatusEnum.OFFLINE;
     }
@@ -657,8 +657,19 @@
      * @return a PresenceStatus instance representation of the Jabber Status
      * parameter. The returned result is one of the JabberStatusEnum fields.
      */
-    private JabberStatusEnum jabberStatusToPresenceStatus(Presence.Mode mode)
+    private JabberStatusEnum jabberStatusToPresenceStatus(Presence presence)
     {
+        // fixing issue: 336
+        // from the smack api : 
+        // A null presence mode value is interpreted to be the same thing 
+        // as Presence.Mode.available.
+        if(presence.getMode() == null && presence.isAvailable())
+            return JabberStatusEnum.AVAILABLE;
+        else if(presence.getMode() == null && !presence.isAvailable())
+            return JabberStatusEnum.OFFLINE;
+        
+        Presence.Mode mode = presence.getMode();
+        
         if(mode.equals(Presence.Mode.available))
             return JabberStatusEnum.AVAILABLE;
         else if(mode.equals(Presence.Mode.away))
@@ -1021,8 +1032,7 @@
                 PresenceStatus oldStatus
                     = sourceContact.getPresenceStatus();
 
-                PresenceStatus newStatus
-                    = queryContactStatus(userID);
+                PresenceStatus newStatus = jabberStatusToPresenceStatus(presence);
 
                 // when old and new status are the same do nothing
                 // no change
@@ -1038,10 +1048,6 @@
                 fireContactPresenceStatusChangeEvent(sourceContact, parent,
                     oldStatus, newStatus);
             }
-            catch (OperationFailedException ex)
-            {
-                logger.error("Failed changing status", ex);
-            }
             catch (IllegalStateException ex)
             {
                 logger.error("Failed changing status", ex);




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list