about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-13 22:25:00 +0000
committerJames Booth <boothj5@gmail.com>2016-01-13 22:25:29 +0000
commit7938db0a25e640b94ed40582eef83573ada168d0 (patch)
treefab0302e98af4868d8a24ec96359d6bfee037e8d /src/xmpp
parent850ac3c6c03f8a7c437117fcef22f861ab214919 (diff)
downloadprofani-tty-7938db0a25e640b94ed40582eef83573ada168d0.tar.gz
Use offline presence for software version responses from non contacts
fixes #714
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/iq.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 507c776f..4cf3313e 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -983,15 +983,19 @@ _version_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
         presence = string_from_resource_presence(occupant->presence);
     } else {
         PContact contact = roster_get_contact(jidp->barejid);
-        Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
-        if (!resource) {
-            ui_handle_software_version_error(jidp->fulljid, "Unknown resource");
-            if (name_str) xmpp_free(ctx, name_str);
-            if (version_str) xmpp_free(ctx, version_str);
-            if (os_str) xmpp_free(ctx, os_str);
-            return 0;
+        if (contact) {
+            Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
+            if (!resource) {
+                ui_handle_software_version_error(jidp->fulljid, "Unknown resource");
+                if (name_str) xmpp_free(ctx, name_str);
+                if (version_str) xmpp_free(ctx, version_str);
+                if (os_str) xmpp_free(ctx, os_str);
+                return 0;
+            }
+            presence = string_from_resource_presence(resource->presence);
+        } else {
+            presence = "offline";
         }
-        presence = string_from_resource_presence(resource->presence);
     }
 
     ui_show_software_version(jidp->fulljid, presence, name_str, version_str, os_str);