From 27b6842f194c02d2f7f15ba8fb79f6a57f70360c Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 24 Jan 2013 00:08:31 +0000 Subject: [PATCH] Started refactor of iq handlers --- src/jabber.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/jabber.c b/src/jabber.c index 55e3ed66..e4873b32 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -806,6 +806,19 @@ _connection_handler(xmpp_conn_t * const conn, } } +static int +_iq_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, + xmpp_ctx_t * const ctx, const char * const id, const char * const from) +{ + if (id != NULL) { + log_error("IQ error received, id: %s.", id); + } else { + log_error("IQ error recieved."); + } + + return 1; +} + static int _iq_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) @@ -815,14 +828,22 @@ _iq_handler(xmpp_conn_t * const conn, char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); - if (g_strcmp0(type, "error")) { - if (id != NULL) { - log_error("IQ error received, id: %s.", id); - } else { - log_error("IQ error recieved."); - } + if (g_strcmp0(type, "error") == 0) { + return _iq_error_handler(conn, stanza, ctx, id, from); + } +/* + if (g_strcmp0(type, "get") == 0) { + return _iq_get_handler(conn, stanza, ctx, id, from); } + if (g_strcmp0(type, "set") == 0) { + return _iq_set_handler(conn, stanza, ctx, id, from); + } + + if (g_strcmp0(type, "result") == 0) { + return _iq_result_handler(conn, stanza, ctx, id, from); + } +*/ // handle the initial roster request if (g_strcmp0(id, "roster") == 0) { return _roster_handler(conn, stanza, ctx, id, type, from);