about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-08-05 23:18:19 +0100
committerJames Booth <boothj5@gmail.com>2013-08-05 23:18:19 +0100
commit6651b13bd0a68da3688cf2f29b467194ab3695f9 (patch)
tree5a10d9428ca17307d3a8e09ad273579edf8aec5b /src/xmpp
parent3588a9d7761669f6d1c6776a07cc0555afd4b084 (diff)
parent42eef398b4eb4d311dd97037af715d4d4119adf4 (diff)
downloadprofani-tty-6651b13bd0a68da3688cf2f29b467194ab3695f9.tar.gz
Merge branch 'master' into nextdev
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/presence.c6
-rw-r--r--src/xmpp/stanza.c34
2 files changed, 36 insertions, 4 deletions
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 93870088..a18bf6fe 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -605,13 +605,13 @@ _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);
-        gboolean nick_change = stanza_is_room_nick_change(stanza);
+        char *new_nick = stanza_get_new_nick(stanza);
 
         if ((type != NULL) && (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0)) {
 
             // leave room if not self nick change
-            if (nick_change) {
-                muc_set_room_pending_nick_change(room);
+            if (new_nick != NULL) {
+                muc_set_room_pending_nick_change(room, new_nick);
             } else {
                 prof_handle_leave_room(room);
             }
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 61db0537..7d7a0949 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -31,6 +31,8 @@
 #include "xmpp/stanza.h"
 #include "xmpp/capabilities.h"
 
+#include "muc.h"
+
 static int _field_compare(FormField *f1, FormField *f2);
 
 #if 0
@@ -565,6 +567,37 @@ stanza_is_muc_self_presence(xmpp_stanza_t * const stanza,
         x_children = xmpp_stanza_get_next(x_children);
     }
 
+    // for servers that don't send status 110 or Jid property
+
+    // first check if 'from' attribute identifies this user
+    char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
+    if (from != NULL) {
+        Jid *jidp = jid_create(from);
+        if (muc_room_is_active(jidp)) {
+            char *nick = muc_get_room_nick(jidp->barejid);
+            if (g_strcmp0(jidp->resourcepart, nick) == 0) {
+                return TRUE;
+            }
+        }
+        jid_destroy(jidp);
+    }
+
+    // secondly check if the new nickname maps to a pending nick change for this user
+    if (from != NULL) {
+        Jid *jidp = jid_create(from);
+        if (muc_is_room_pending_nick_change(jidp->barejid)) {
+            char *new_nick = jidp->resourcepart;
+            if (new_nick != NULL) {
+                char *nick = muc_get_room_nick(jidp->barejid);
+                char *old_nick = muc_get_old_nick(jidp->barejid, new_nick);
+                if (g_strcmp0(old_nick, nick) == 0) {
+                    return TRUE;
+                }
+            }
+        }
+        jid_destroy(jidp);
+    }
+
     return FALSE;
 }
 
@@ -608,7 +641,6 @@ stanza_is_room_nick_change(xmpp_stanza_t * const stanza)
     }
 
     return FALSE;
-
 }
 
 char *