From d2a923126b428dfc6decd133f649820c8f7ad407 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 7 Nov 2012 00:48:59 +0000 Subject: [PATCH] jabber: small tidy up --- src/jabber.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/jabber.c b/src/jabber.c index 7bca9523..5187d86b 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -467,13 +467,13 @@ static int _chat_message_handler(xmpp_stanza_t * const stanza) { gchar *from = xmpp_stanza_get_attribute(stanza, "from"); + char from_cpy[strlen(from) + 1]; strcpy(from_cpy, from); char *short_from = strtok(from_cpy, "/"); //determine chatstate support of recipient gboolean recipient_supports = FALSE; - if ((xmpp_stanza_get_child_by_name(stanza, "active") != NULL) || (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) || (xmpp_stanza_get_child_by_name(stanza, "paused") != NULL) || @@ -482,36 +482,26 @@ _chat_message_handler(xmpp_stanza_t * const stanza) recipient_supports = TRUE; } - // create of update session + // create or update chat session if (!chat_session_exists(short_from)) { chat_session_start(short_from, recipient_supports); } else { chat_session_set_recipient_supports(short_from, recipient_supports); } - // deal with chat states + // deal with chat states is recipient supports them if (recipient_supports) { - - // handle if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) { if (prefs_get_notify_typing() || prefs_get_intype()) { prof_handle_typing(short_from); } - - // handle - } else if (xmpp_stanza_get_child_by_name(stanza, "paused") != NULL) { - // do something - - // handle - } else if (xmpp_stanza_get_child_by_name(stanza, "inactive") != NULL) { - // do something - - // handle } else if (xmpp_stanza_get_child_by_name(stanza, "gone") != NULL) { prof_handle_gone(short_from); - - // handle - } else { + } else if (xmpp_stanza_get_child_by_name(stanza, "paused") != NULL) { + // do something + } else if (xmpp_stanza_get_child_by_name(stanza, "inactive") != NULL) { + // do something + } else { // handle // do something } }