Undo change to stanza check for nick change return value
This commit is contained in:
@@ -567,7 +567,7 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
|||||||
// handle self presence
|
// handle self presence
|
||||||
if (stanza_is_muc_self_presence(stanza, jabber_get_fulljid())) {
|
if (stanza_is_muc_self_presence(stanza, jabber_get_fulljid())) {
|
||||||
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
|
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)) {
|
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)) {
|
if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
|
||||||
|
|
||||||
// handle nickname change
|
// 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);
|
char *new_nick = stanza_get_new_nick(stanza);
|
||||||
muc_set_roster_pending_nick_change(room, new_nick, nick);
|
muc_set_roster_pending_nick_change(room, new_nick, nick);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -543,62 +543,46 @@ stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
gboolean
|
||||||
stanza_is_room_nick_change(xmpp_stanza_t * const stanza)
|
stanza_is_room_nick_change(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
if (stanza == NULL) {
|
if (stanza == NULL) {
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (strcmp(xmpp_stanza_get_name(stanza), STANZA_NAME_PRESENCE) != 0) {
|
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);
|
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
|
||||||
|
|
||||||
if (x == NULL) {
|
if (x == NULL) {
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ns = xmpp_stanza_get_ns(x);
|
char *ns = xmpp_stanza_get_ns(x);
|
||||||
if (ns == NULL) {
|
if (ns == NULL) {
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (strcmp(ns, STANZA_NS_MUC_USER) != 0) {
|
if (strcmp(ns, STANZA_NS_MUC_USER) != 0) {
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
|
xmpp_stanza_t *x_children = xmpp_stanza_get_children(x);
|
||||||
if (x_children == NULL) {
|
if (x_children == NULL) {
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean is_nick_change = FALSE;
|
|
||||||
while (x_children != NULL) {
|
while (x_children != NULL) {
|
||||||
if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
|
if (strcmp(xmpp_stanza_get_name(x_children), STANZA_NAME_STATUS) == 0) {
|
||||||
char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
|
char *code = xmpp_stanza_get_attribute(x_children, STANZA_ATTR_CODE);
|
||||||
if (strcmp(code, "303") == 0) {
|
if (strcmp(code, "303") == 0) {
|
||||||
is_nick_change = TRUE;
|
return TRUE;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x_children = xmpp_stanza_get_next(x_children);
|
x_children = xmpp_stanza_get_next(x_children);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_nick_change) {
|
return FALSE;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|||||||
@@ -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_presence(xmpp_stanza_t * const stanza);
|
||||||
gboolean stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
|
gboolean stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
|
||||||
const char * const self_jid);
|
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);
|
char * stanza_get_new_nick(xmpp_stanza_t * const stanza);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user