diff options
author | James Booth <boothj5@gmail.com> | 2012-02-27 23:33:29 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-27 23:33:29 +0000 |
commit | ecf5640f464e75c15304075979b1c3273681e31e (patch) | |
tree | 701fd06be79185eece04e6f9b0f6a57aa6831646 /jabber.c | |
parent | 02ba1dafb6fcce971259acd0470fc10754d105ef (diff) | |
download | profani-tty-ecf5640f464e75c15304075979b1c3273681e31e.tar.gz |
Added notification on leave
Diffstat (limited to 'jabber.c')
-rw-r--r-- | jabber.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/jabber.c b/jabber.c index dc2b1f18..6d4888ef 100644 --- a/jabber.c +++ b/jabber.c @@ -302,33 +302,24 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn, char *short_from = strtok(from, "@"); char *type = xmpp_stanza_get_attribute(stanza, "type"); + char *show_str, *status_str; + xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show"); + if (show != NULL) + show_str = xmpp_stanza_get_text(show); + else + show_str = NULL; + + xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status"); + if (status != NULL) + status_str = xmpp_stanza_get_text(status); + else + status_str = NULL; + if (type == NULL) { // online - xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show"); - if (show != NULL) { - char *show_str = xmpp_stanza_get_text(show); - xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status"); - - if (status != NULL) { - char *status_str = xmpp_stanza_get_text(status); - - if (show_str != NULL) - cons_show_contact_online(short_from, show_str, status_str); - } - } + cons_show_contact_online(short_from, show_str, status_str); } else { // offline - xmpp_stanza_t *show = xmpp_stanza_get_child_by_name(stanza, "show"); - if (show != NULL) { - char *show_str = xmpp_stanza_get_text(show); - xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status"); - - if (status != NULL) { - char *status_str = xmpp_stanza_get_text(status); - - if (show_str != NULL) - cons_show_contact_offline(short_from, show_str, status_str); - } - } + cons_show_contact_offline(short_from, show_str, status_str); } return 1; |