about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-04-07 19:19:02 +0100
committerJames Booth <boothj5@gmail.com>2013-04-07 19:19:02 +0100
commitf4041f049ce4f66ad6fa9ef167e0a095b35d9f60 (patch)
treeb259c6e816a1fa10e98bc6b8e77ba670a7030dbd /src/xmpp
parentb6095ca9550941df5872a25979924053391cb6d1 (diff)
downloadprofani-tty-f4041f049ce4f66ad6fa9ef167e0a095b35d9f60.tar.gz
Handle when servers do not send fulljid with presence
A default resource "__prof_default" is created, and invisible to the
user for most purposes.
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/presence.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index ea7c51b6..94ea5bb6 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -339,6 +339,10 @@ _unavailable_handler(xmpp_conn_t * const conn,
     if (strcmp(my_jid->barejid, from_jid->barejid) !=0) {
         if (from_jid->resourcepart != NULL) {
             prof_handle_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str);
+
+        // hack for servers that do not send full jid with unavailable presence
+        } else {
+            prof_handle_contact_offline(from_jid->barejid, "__prof_default", status_str);
         }
     } else {
         if (from_jid->resourcepart != NULL) {
@@ -409,21 +413,26 @@ _available_handler(xmpp_conn_t * const conn,
         }
     }
 
-    // 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,
+    resource_presence_t presence = resource_presence_from_string(show_str);
+    Resource *resource = NULL;
+
+    // hack for servers that do not send fulljid with initial presence
+    if (from_jid->resourcepart == NULL) {
+        resource = resource_new("__prof_default", presence,
+            status_str, priority, caps_key);
+    } else {
+        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);
+    // 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);
-        }
+    // contact presence
+    } else {
+        prof_handle_contact_online(from_jid->barejid, resource,
+            last_activity);
     }
 
     jid_destroy(my_jid);