1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

jabber: small tidy up

This commit is contained in:
James Booth 2012-11-07 00:48:59 +00:00
parent 444be385a6
commit d2a923126b

View File

@ -467,13 +467,13 @@ static int
_chat_message_handler(xmpp_stanza_t * const stanza) _chat_message_handler(xmpp_stanza_t * const stanza)
{ {
gchar *from = xmpp_stanza_get_attribute(stanza, "from"); gchar *from = xmpp_stanza_get_attribute(stanza, "from");
char from_cpy[strlen(from) + 1]; char from_cpy[strlen(from) + 1];
strcpy(from_cpy, from); strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/"); char *short_from = strtok(from_cpy, "/");
//determine chatstate support of recipient //determine chatstate support of recipient
gboolean recipient_supports = FALSE; gboolean recipient_supports = FALSE;
if ((xmpp_stanza_get_child_by_name(stanza, "active") != NULL) || 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, "composing") != NULL) ||
(xmpp_stanza_get_child_by_name(stanza, "paused") != 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; recipient_supports = TRUE;
} }
// create of update session // create or update chat session
if (!chat_session_exists(short_from)) { if (!chat_session_exists(short_from)) {
chat_session_start(short_from, recipient_supports); chat_session_start(short_from, recipient_supports);
} else { } else {
chat_session_set_recipient_supports(short_from, recipient_supports); chat_session_set_recipient_supports(short_from, recipient_supports);
} }
// deal with chat states // deal with chat states is recipient supports them
if (recipient_supports) { if (recipient_supports) {
// handle <composing/>
if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) { if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) {
if (prefs_get_notify_typing() || prefs_get_intype()) { if (prefs_get_notify_typing() || prefs_get_intype()) {
prof_handle_typing(short_from); prof_handle_typing(short_from);
} }
// handle <paused/>
} else if (xmpp_stanza_get_child_by_name(stanza, "paused") != NULL) {
// do something
// handle <inactive/>
} else if (xmpp_stanza_get_child_by_name(stanza, "inactive") != NULL) {
// do something
// handle <gone/>
} else if (xmpp_stanza_get_child_by_name(stanza, "gone") != NULL) { } else if (xmpp_stanza_get_child_by_name(stanza, "gone") != NULL) {
prof_handle_gone(short_from); prof_handle_gone(short_from);
} else if (xmpp_stanza_get_child_by_name(stanza, "paused") != NULL) {
// handle <active/> // do something
} else { } else if (xmpp_stanza_get_child_by_name(stanza, "inactive") != NULL) {
// do something
} else { // handle <active/>
// do something // do something
} }
} }