diff options
author | James Booth <boothj5@gmail.com> | 2012-02-19 20:04:42 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-02-19 20:04:42 +0000 |
commit | 3970a4d736813fd00a93bc8cccc09fd48283a38d (patch) | |
tree | 34427e93fdacd93a4c18e61762cf8d6ff989ad5e | |
parent | ae1e037d0c6f5df403cda7e1167860d726983339 (diff) | |
download | profani-tty-3970a4d736813fd00a93bc8cccc09fd48283a38d.tar.gz |
Tidied message handler
-rw-r--r-- | jabber.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/jabber.c b/jabber.c index d55b56fd..77c4906c 100644 --- a/jabber.c +++ b/jabber.c @@ -128,15 +128,15 @@ void jabber_roster_request(void) static int _jabber_message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata) { - char *message; - - if(!xmpp_stanza_get_child_by_name(stanza, "body")) - return 1; - if(!strcmp(xmpp_stanza_get_attribute(stanza, "type"), "error")) + xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body"); + if(body == NULL) return 1; - message = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "body")); + char *type = xmpp_stanza_get_attribute(stanza, "type"); + if(strcmp(type, "error") == 0) + return 1; + char *message = xmpp_stanza_get_text(body); char *from = xmpp_stanza_get_attribute(stanza, "from"); win_show_incomming_msg(from, message); |