mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Tidied _roster_result_handler
This commit is contained in:
parent
a2c6211732
commit
f69ccbf0cc
@ -290,13 +290,15 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
_roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata)
|
||||||
void * const userdata)
|
|
||||||
{
|
{
|
||||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||||
|
|
||||||
|
if (g_strcmp0(id, "roster") != 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// handle initial roster response
|
// handle initial roster response
|
||||||
if (g_strcmp0(id, "roster") == 0) {
|
|
||||||
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||||
xmpp_stanza_t *item = xmpp_stanza_get_children(query);
|
xmpp_stanza_t *item = xmpp_stanza_get_children(query);
|
||||||
|
|
||||||
@ -307,9 +309,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|||||||
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
||||||
|
|
||||||
// do not set nickname to empty string, set to NULL instead
|
// do not set nickname to empty string, set to NULL instead
|
||||||
if (name && (strlen(name) == 0)) {
|
if (name && (strlen(name) == 0)) name = NULL;
|
||||||
name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean pending_out = FALSE;
|
gboolean pending_out = FALSE;
|
||||||
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
|
const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
|
||||||
@ -320,7 +320,6 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|||||||
GSList *groups = _get_groups_from_item(item);
|
GSList *groups = _get_groups_from_item(item);
|
||||||
|
|
||||||
gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
|
gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
|
||||||
|
|
||||||
if (!added) {
|
if (!added) {
|
||||||
log_warning("Attempt to add contact twice: %s", barejid_lower);
|
log_warning("Attempt to add contact twice: %s", barejid_lower);
|
||||||
}
|
}
|
||||||
@ -333,7 +332,6 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|||||||
|
|
||||||
resource_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name());
|
resource_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name());
|
||||||
presence_update(conn_presence, NULL, 0);
|
presence_update(conn_presence, NULL, 0);
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user