1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-29 19:56:07 -04:00

Undo change to stanza check for nick change return value

This commit is contained in:
James Booth 2013-08-05 23:08:30 +01:00
parent 1525be6133
commit c6e9a7455d
3 changed files with 12 additions and 28 deletions

View File

@ -567,7 +567,7 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
// handle self presence
if (stanza_is_muc_self_presence(stanza, jabber_get_fulljid())) {
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
char *new_nick = stanza_is_room_nick_change(stanza);
char *new_nick = stanza_get_new_nick(stanza);
if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
@ -606,7 +606,7 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
// handle nickname change
if (stanza_is_room_nick_change(stanza) != NULL) {
if (stanza_is_room_nick_change(stanza)) {
char *new_nick = stanza_get_new_nick(stanza);
muc_set_roster_pending_nick_change(room, new_nick, nick);
} else {

View File

@ -543,62 +543,46 @@ stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
return FALSE;
}
char *
gboolean
stanza_is_room_nick_change(xmpp_stanza_t * const stanza)
{
if (stanza == NULL) {
return NULL;
return FALSE;
}
if (strcmp(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0) {
return NULL;
return FALSE;
}
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
if (x == NULL) {
return NULL;
return FALSE;
}
char *ns = xmpp_stanza_get_ns(x);
if (ns == NULL) {
return NULL;
return FALSE;
}
if (strcmp(ns, STANZA_NS_MUC_USER) != 0) {
return NULL;
return FALSE;
}
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
if (x_children == NULL) {
return NULL;
return FALSE;
}
gboolean is_nick_change = FALSE;
while (x_children != NULL) {
if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
if (strcmp(code, "303") == 0) {
is_nick_change = TRUE;
break;
return TRUE;
}
}
x_children = xmpp_stanza_get_next(x_children);
}
if (is_nick_change) {
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
while (x_children != NULL) {
if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_ITEM) == 0) {
char *new_nick = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_NICK);
if (new_nick != NULL) {
return new_nick;
}
}
x_children = xmpp_stanza_get_next(x_children);
}
}
return NULL;
return FALSE;
}
char *

View File

@ -146,7 +146,7 @@ gboolean stanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp);
gboolean stanza_is_muc_presence(xmpp_stanza_t * const stanza);
gboolean stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
const char * const self_jid);
char * stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
gboolean stanza_is_room_nick_change(xmpp_stanza_t * const stanza);
char * stanza_get_new_nick(xmpp_stanza_t * const stanza);