about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xmpp.h3
-rw-r--r--src/xmpp_conn.c2
-rw-r--r--src/xmpp_presence.c17
3 files changed, 17 insertions, 5 deletions
diff --git a/src/xmpp.h b/src/xmpp.h
index d1f88055..bb651faa 100644
--- a/src/xmpp.h
+++ b/src/xmpp.h
@@ -172,12 +172,11 @@ char* jabber_get_account_name(void);
 void iq_add_handlers(void);
 
 // presence functions
+void presence_add_handlers(void);
 void presence_init(void);
 void presence_subscription(const char * const jid, const jabber_subscr_t action);
 GList* presence_get_subscription_requests(void);
 void presence_free_sub_requests(void);
-int presence_handler(xmpp_conn_t * const conn,
-    xmpp_stanza_t * const stanza, void * const userdata);
 void presence_join_room(Jid *jid);
 void presence_change_room_nick(const char * const room, const char * const nick);
 void presence_leave_chat_room(const char * const room_jid);
diff --git a/src/xmpp_conn.c b/src/xmpp_conn.c
index 2d1a3076..130a04b2 100644
--- a/src/xmpp_conn.c
+++ b/src/xmpp_conn.c
@@ -663,8 +663,8 @@ _connection_handler(xmpp_conn_t * const conn,
         chat_sessions_init();
 
         xmpp_handler_add(conn, _message_handler, NULL, STANZA_NAME_MESSAGE, NULL, ctx);
-        xmpp_handler_add(conn, presence_handler, NULL, STANZA_NAME_PRESENCE, NULL, ctx);
 
+        presence_add_handlers();
         iq_add_handlers();
 
         if (prefs_get_autoping() != 0) {
diff --git a/src/xmpp_presence.c b/src/xmpp_presence.c
index 897204f7..125e1400 100644
--- a/src/xmpp_presence.c
+++ b/src/xmpp_presence.c
@@ -33,6 +33,11 @@
 #include "xmpp.h"
 
 static GHashTable *sub_requests;
+
+#define HANDLE(ns, type, func) xmpp_handler_add(conn, func, ns, STANZA_NAME_PRESENCE, type, ctx)
+
+static int _presence_handler(xmpp_conn_t * const conn,
+    xmpp_stanza_t * const stanza, void * const userdata);
 static char* _handle_presence_caps(xmpp_stanza_t * const stanza);
 static int _room_presence_handler(const char * const jid,
     xmpp_stanza_t * const stanza);
@@ -44,6 +49,14 @@ presence_init(void)
 }
 
 void
+presence_add_handlers(void)
+{
+    xmpp_conn_t * const conn = jabber_get_conn();
+    xmpp_ctx_t * const ctx = jabber_get_ctx();
+    HANDLE(NULL, NULL, _presence_handler);
+}
+
+void
 presence_subscription(const char * const jid, const jabber_subscr_t action)
 {
     xmpp_ctx_t *ctx = jabber_get_ctx();
@@ -234,8 +247,8 @@ presence_update(jabber_presence_t status, const char * const msg,
 }
 
 
-int
-presence_handler(xmpp_conn_t * const conn,
+static int
+_presence_handler(xmpp_conn_t * const conn,
     xmpp_stanza_t * const stanza, void * const userdata)
 {
     const char *jid = xmpp_conn_get_jid(conn);