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

Fixed offline bug

This commit is contained in:
James Booth 2012-10-29 01:27:37 +00:00
parent a85ba5e2cb
commit dbb7445324

View File

@ -439,41 +439,28 @@ _presence_handler(xmpp_conn_t * const conn,
char *from = xmpp_stanza_get_attribute(stanza, "from"); char *from = xmpp_stanza_get_attribute(stanza, "from");
char *short_from = strtok(from, "/"); char *short_from = strtok(from, "/");
char *type = xmpp_stanza_get_attribute(stanza, "type"); 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; 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"); xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, "status");
if (status != NULL) if (status != NULL)
status_str = xmpp_stanza_get_text(status); status_str = xmpp_stanza_get_text(status);
else else
status_str = NULL; status_str = NULL;
if (strcmp(short_jid, short_from) !=0) { if ((type != NULL) && (strcmp(type, "unavailable") == 0)) {
if (type == NULL) { 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); prof_handle_contact_online(short_from, show_str, status_str);
} else {
prof_handle_contact_offline(short_from, show_str, status_str);
} }
} }