about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-09-21 16:51:35 +0100
committerJames Booth <boothj5@gmail.com>2014-09-21 16:51:35 +0100
commitc343b3ecefdacb5e06ebae9c6338324f2f15e4a1 (patch)
tree8516312af523a724666cf3cf988e4b218cd9824c /src/xmpp
parentce43af616eaf38680cf9531063e19442fbc1005b (diff)
downloadprofani-tty-c343b3ecefdacb5e06ebae9c6338324f2f15e4a1.tar.gz
Log errors on caps responses
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/iq.c14
-rw-r--r--src/xmpp/presence.c12
2 files changed, 20 insertions, 6 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index dc6e4cfd..81ba6e09 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -354,6 +354,20 @@ _caps_response_handler(xmpp_conn_t *const conn, xmpp_stanza_t * const stanza,
         return 0;
     }
 
+    char *type = xmpp_stanza_get_type(stanza);
+    // handle error responses
+    if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
+        char *error_message = stanza_get_error_message(stanza);
+        log_warning("Error received for capabilities response from %s: ", from, error_message);
+        free(error_message);
+        return 0;
+    }
+
+    if (query == NULL) {
+        log_warning("No query element found.");
+        return 0;
+    }
+
     char *node = xmpp_stanza_get_attribute(query, STANZA_ATTR_NODE);
     if (node == NULL) {
         log_warning("No node attribute found");
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 4dab35bb..4903a104 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -726,12 +726,6 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 
         log_debug("Room presence received from %s", from_jid->fulljid);
 
-        // send disco info for capabilities, if not cached
-        if (stanza_contains_caps(stanza)) {
-            log_info("Presence contains capabilities.");
-            _handle_caps(stanza);
-        }
-
         status_str = stanza_get_status(stanza, NULL);
 
         if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
@@ -747,6 +741,12 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
                 handle_room_member_offline(from_room, from_nick, "offline", status_str);
             }
         } else {
+            // send disco info for capabilities, if not cached
+            if (stanza_contains_caps(stanza)) {
+                log_info("Presence contains capabilities.");
+                _handle_caps(stanza);
+            }
+
             char *show_str = stanza_get_show(stanza, "online");
             if (!muc_get_roster_received(from_room)) {
                 muc_add_to_roster(from_room, from_nick, show_str, status_str);