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 01:04:53 +0100
committerJames Booth <boothj5@gmail.com>2014-09-21 01:05:16 +0100
commitc2e173479f694d1db391f4daa1f9a66b0596994d (patch)
treefc5414fde87c3c827a6169fb673d9d176862390f /src/xmpp
parent06856ecea1d4df06549de9a84ea61f800655441b (diff)
downloadprofani-tty-c2e173479f694d1db391f4daa1f9a66b0596994d.tar.gz
Fixed muc presence check, remove logging from presence handler
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/presence.c17
-rw-r--r--src/xmpp/stanza.c16
2 files changed, 11 insertions, 22 deletions
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index a4cc549e..f1871006 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -502,16 +502,8 @@ static int
 _available_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata)
 {
-    char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
-    if (from) {
-        log_info("Available presence handler fired for: %s", from);
-    } else {
-        log_info("Available presence handler fired");
-    }
-
     // handler still fires if error
     if (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_ERROR) == 0) {
-        log_info("Available presence of type error, exiting handler");
         return 1;
     }
 
@@ -520,16 +512,21 @@ _available_handler(xmpp_conn_t * const conn,
             (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBE) == 0) ||
             (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_SUBSCRIBED) == 0) ||
             (g_strcmp0(xmpp_stanza_get_type(stanza), STANZA_TYPE_UNSUBSCRIBED) == 0)) {
-        log_info("Available presence of subscription type, exiting handler");
         return 1;
     }
 
     // handler still fires for muc presence
     if (stanza_is_muc_presence(stanza)) {
-        log_info("Available presence MUC type, exiting handler");
         return 1;
     }
 
+    char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    if (from) {
+        log_info("Available presence handler fired for: %s", from);
+    } else {
+        log_info("Available presence handler fired");
+    }
+
     // exit when no from attribute
     if (!from) {
         log_warning("No from attribute found.");
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index cca07539..1a962c53 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -765,21 +765,13 @@ stanza_is_muc_presence(xmpp_stanza_t * const stanza)
         return FALSE;
     }
 
-    xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
-
-    if (x == NULL) {
-        return FALSE;
-    }
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);
 
-    char *ns = xmpp_stanza_get_ns(x);
-    if (ns == NULL) {
-        return FALSE;
-    }
-    if (strcmp(ns, STANZA_NS_MUC_USER) != 0) {
+    if (x) {
+        return TRUE;
+    } else {
         return FALSE;
     }
-
-    return TRUE;
 }
 
 gboolean