diff options
author | James Booth <boothj5@gmail.com> | 2012-10-29 01:27:37 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-29 01:27:37 +0000 |
commit | dbb744532482baab8e012af500dbeda29600d2e1 (patch) | |
tree | 292c42316680e1756d76ff8edc831a05af5499c3 /src | |
parent | a85ba5e2cb07736bd8cc4e8caf264795f8f18eb3 (diff) | |
download | profani-tty-dbb744532482baab8e012af500dbeda29600d2e1.tar.gz |
Fixed offline bug
Diffstat (limited to 'src')
-rw-r--r-- | src/jabber.c | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/src/jabber.c b/src/jabber.c index af83c037..e2e146e8 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -439,41 +439,28 @@ _presence_handler(xmpp_conn_t * const conn, char *from = xmpp_stanza_get_attribute(stanza, "from"); char *short_from = strtok(from, "/"); char *type = xmpp_stanza_get_attribute(stanza, "type"); - - if (type != NULL) { - // allow all subscription requests for now - if (strcmp(type, "subscribe") == 0) { - xmpp_stanza_t *presence; - - presence = xmpp_stanza_new(jabber_conn.ctx); - xmpp_stanza_set_name(presence, "presence"); - xmpp_stanza_set_type(presence, "subscribed"); - xmpp_stanza_set_attribute(presence, "to", short_from); - xmpp_send(jabber_conn.conn, presence); - xmpp_stanza_release(presence); - return 1; - } - } - 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 (strcmp(short_jid, short_from) !=0) { - if (type == NULL) { + if ((type != NULL) && (strcmp(type, "unavailable") == 0)) { + if (strcmp(short_jid, short_from) !=0) { + prof_handle_contact_offline(short_from, "offline", status_str); + } + } else { + + 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 = "online"; + + if (strcmp(short_jid, short_from) !=0) { prof_handle_contact_online(short_from, show_str, status_str); - } else { - prof_handle_contact_offline(short_from, show_str, status_str); } } |