about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-03-17 21:53:34 +0000
committerJames Booth <boothj5@gmail.com>2013-03-17 21:53:34 +0000
commite22970b304b8045be1599e6f5127d2d8d19265fe (patch)
tree0f554a8c98182b0898618741ab3ba4c94695c397 /src/xmpp
parente7202120cbde8e33d6b21b6cde5ee4278da4e524 (diff)
downloadprofani-tty-e22970b304b8045be1599e6f5127d2d8d19265fe.tar.gz
Refactor resource handling in available handler
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/presence.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index da0a97d1..366aa64c 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -425,22 +425,20 @@ _available_handler(xmpp_conn_t * const conn,
         }
     }
 
-    // if not self presence
-    if (strcmp(my_jid->barejid, from_jid->barejid) !=0) {
-        // create the resource, if fulljid
-        if (from_jid->resourcepart != NULL) {
-            resource_presence_t presence = resource_presence_from_string(show_str);
-            Resource *resource = resource_new(from_jid->resourcepart, presence,
-                status_str, priority, caps_key);
-            prof_handle_contact_online(from_jid->barejid, resource, last_activity);
-        }
-    } else {
-        // handle self presenc, if fulljid
-        if (from_jid->resourcepart != NULL) {
-            resource_presence_t presence = resource_presence_from_string(show_str);
-            Resource *resource = resource_new(from_jid->resourcepart, presence,
-                status_str, priority, caps_key);
+    // handle resource, if exists
+    if (from_jid->resourcepart != NULL) {
+        resource_presence_t presence = resource_presence_from_string(show_str);
+        Resource *resource = resource_new(from_jid->resourcepart, presence,
+            status_str, priority, caps_key);
+
+        // self presence
+        if (strcmp(my_jid->barejid, from_jid->barejid) ==0) {
             connection_add_available_resource(resource);
+
+        // contact presence
+        } else {
+            prof_handle_contact_online(from_jid->barejid, resource,
+                last_activity);
         }
     }