about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-27 21:42:34 +0000
committerJames Booth <boothj5@gmail.com>2014-01-27 21:42:34 +0000
commitda94dcf3cfa65ca888b323ba08d76bf068e03937 (patch)
tree28d4325aa43c825eabdcab20eb89993958819eb3 /src/xmpp
parentf26686aeca95f57205a2c26c7b1d5c00b8a63348 (diff)
downloadprofani-tty-da94dcf3cfa65ca888b323ba08d76bf068e03937.tar.gz
Moved connection_error_handler to _presence_error_handler
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/connection.c43
-rw-r--r--src/xmpp/connection.h2
-rw-r--r--src/xmpp/presence.c48
3 files changed, 47 insertions, 46 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 4833d56c..36b63e8b 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -322,49 +322,6 @@ _connection_free_session_data(void)
     presence_clear_sub_requests();
 }
 
-int
-connection_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
-    void * const userdata)
-{
-    xmpp_ctx_t *ctx = connection_get_ctx();
-    gchar *err_msg = NULL;
-    gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
-    xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
-    xmpp_stanza_t *text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
-
-    if (error_stanza == NULL) {
-        log_debug("error message without <error/> received");
-    } else {
-
-        // check for text
-        if (text_stanza != NULL) {
-            err_msg = xmpp_stanza_get_text(text_stanza);
-            if (err_msg != NULL) {
-                handle_error_message(from, err_msg);
-                xmpp_free(ctx, err_msg);
-            }
-
-            // TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
-
-        // otherwise show defined-condition
-        } else {
-            xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error_stanza);
-
-            if (err_cond == NULL) {
-                log_debug("error message without <defined-condition/> or <text/> received");
-
-            } else {
-                err_msg = xmpp_stanza_get_name(err_cond);
-                handle_error_message(from, err_msg);
-
-                // TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
-            }
-        }
-    }
-
-    return 1;
-}
-
 static jabber_conn_status_t
 _jabber_connect(const char * const fulljid, const char * const passwd,
     const char * const altdomain, int port)
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h
index f11bc8c8..bf7d145e 100644
--- a/src/xmpp/connection.h
+++ b/src/xmpp/connection.h
@@ -29,8 +29,6 @@
 
 xmpp_conn_t *connection_get_conn(void);
 xmpp_ctx_t *connection_get_ctx(void);
-int connection_error_handler(xmpp_conn_t * const conn,
-    xmpp_stanza_t * const stanza, void * const userdata);
 void connection_set_priority(int priority);
 void connection_set_presence_message(const char * const message);
 void connection_add_available_resource(Resource *resource);
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 9b11c898..f61d605d 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -55,6 +55,8 @@ static int _available_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata);
 static int _muc_user_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata);
+static int _presence_error_handler(xmpp_conn_t * const conn,
+    xmpp_stanza_t * const stanza, void * const userdata);
 
 static char* _get_caps_key(xmpp_stanza_t * const stanza);
 static void _send_room_presence(xmpp_conn_t *conn, xmpp_stanza_t *presence);
@@ -72,7 +74,7 @@ presence_add_handlers(void)
     xmpp_conn_t * const conn = connection_get_conn();
     xmpp_ctx_t * const ctx = connection_get_ctx();
 
-    HANDLE(NULL,               STANZA_TYPE_ERROR,        connection_error_handler);
+    HANDLE(NULL,               STANZA_TYPE_ERROR,        _presence_error_handler);
     HANDLE(STANZA_NS_MUC_USER, NULL,                     _muc_user_handler);
     HANDLE(NULL,               STANZA_TYPE_UNAVAILABLE,  _unavailable_handler);
     HANDLE(NULL,               STANZA_TYPE_SUBSCRIBE,    _subscribe_handler);
@@ -330,6 +332,50 @@ _presence_leave_chat_room(const char * const room_jid)
 }
 
 static int
+_presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
+    void * const userdata)
+{
+    xmpp_ctx_t *ctx = connection_get_ctx();
+    gchar *err_msg = NULL;
+    gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+    xmpp_stanza_t *text_stanza = xmpp_stanza_get_child_by_name(error_stanza, STANZA_NAME_TEXT);
+
+    if (error_stanza == NULL) {
+        log_debug("error message without <error/> received");
+    } else {
+
+        // check for text
+        if (text_stanza != NULL) {
+            err_msg = xmpp_stanza_get_text(text_stanza);
+            if (err_msg != NULL) {
+                handle_error_message(from, err_msg);
+                xmpp_free(ctx, err_msg);
+            }
+
+            // TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
+
+        // otherwise show defined-condition
+        } else {
+            xmpp_stanza_t *err_cond = xmpp_stanza_get_children(error_stanza);
+
+            if (err_cond == NULL) {
+                log_debug("error message without <defined-condition/> or <text/> received");
+
+            } else {
+                err_msg = xmpp_stanza_get_name(err_cond);
+                handle_error_message(from, err_msg);
+
+                // TODO : process 'type' attribute from <error/> [RFC6120, 8.3.2]
+            }
+        }
+    }
+
+    return 1;
+}
+
+
+static int
 _unsubscribed_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata)
 {