about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-02-24 15:07:33 +0000
committerJames Booth <boothj5@gmail.com>2013-02-24 15:07:33 +0000
commit9f8a7f52a5e1a43224d9418c1e64463d2affc5b1 (patch)
treebd0951eabf67c2560034db76acc446a6f246f4ca /src/xmpp
parentd1e28e44caefef8ebd0df0817cea2a6859e41faa (diff)
downloadprofani-tty-9f8a7f52a5e1a43224d9418c1e64463d2affc5b1.tar.gz
Add resource only when resourcepart in JID #152
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/presence.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 28e2039e..b9f2b8d4 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -420,19 +420,23 @@ _available_handler(xmpp_conn_t * const conn,
         }
     }
 
-    // if not self presence (TODO allow self presence from other resources?)
+    // if not self presence
     if (strcmp(my_jid->barejid, from_jid->barejid) !=0) {
-        // create the resource
-        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);
+        // 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 presence
-        resource_presence_t presence = resource_presence_from_string(show_str);
-        Resource *resource = resource_new(from_jid->resourcepart, presence,
-            status_str, priority, caps_key);
-        connection_add_available_resource(resource);
+        // 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);
+            connection_add_available_resource(resource);
+        }
     }
 
     jid_destroy(my_jid);