about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/bookmark.c2
-rw-r--r--src/xmpp/presence.c22
-rw-r--r--src/xmpp/stanza.h1
3 files changed, 22 insertions, 3 deletions
diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c
index 2e4f70db..c73f3db3 100644
--- a/src/xmpp/bookmark.c
+++ b/src/xmpp/bookmark.c
@@ -260,7 +260,7 @@ _bookmark_handle_result(xmpp_conn_t * const conn,
                 room_jid = jid_create_from_bare_and_resource(jid, name);
                 if (!muc_room_is_active(room_jid->barejid)) {
                     presence_join_room(jid, name, NULL);
-                    handle_bookmark_autojoin(jid);
+                    muc_join_room(jid, name, NULL, TRUE);
                 }
                 jid_destroy(room_jid);
             } else {
diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c
index 433c05f3..1cb86645 100644
--- a/src/xmpp/presence.c
+++ b/src/xmpp/presence.c
@@ -283,7 +283,6 @@ _presence_join_room(char *room, char *nick, char * passwd)
     xmpp_send(conn, presence);
     xmpp_stanza_release(presence);
 
-    muc_join_room(jid->barejid, jid->resourcepart, passwd);
     jid_destroy(jid);
 }
 
@@ -342,11 +341,31 @@ _presence_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     char *id = xmpp_stanza_get_id(stanza);
     char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
     xmpp_stanza_t *error_stanza = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_ERROR);
+    xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
+    char *xmlns = xmpp_stanza_get_ns(x);
     char *type = NULL;
     if (error_stanza != NULL) {
         type = xmpp_stanza_get_attribute(error_stanza, STANZA_ATTR_TYPE);
     }
 
+    // handle MUC join errors
+    if (g_strcmp0(xmlns, STANZA_NS_MUC) == 0) {
+        Jid *fulljid = jid_create(from);
+
+        char *error_cond = NULL;
+        xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_ns(error_stanza, STANZA_NS_STANZAS);
+        if (reason_st != NULL) {
+            error_cond = xmpp_stanza_get_name(reason_st);
+        }
+        if (error_cond == NULL) {
+            error_cond = "unknown";
+        }
+
+        log_info("Error joining room: %s, reason: %s", fulljid->barejid, error_cond);
+        handle_room_join_error(fulljid->barejid, error_cond);
+        return 1;
+    }
+
     // stanza_get_error never returns NULL
     char *err_msg = stanza_get_error_message(stanza);
 
@@ -676,7 +695,6 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
         // handle roster complete
         } else if (!muc_get_roster_received(room)) {
             handle_room_roster_complete(room);
-
         }
 
     // handle presence from room members
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index d71d3ea1..486421a2 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -124,6 +124,7 @@
 #define STANZA_TEXT_XA "xa"
 #define STANZA_TEXT_ONLINE "online"
 
+#define STANZA_NS_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas"
 #define STANZA_NS_CHATSTATES "http://jabber.org/protocol/chatstates"
 #define STANZA_NS_MUC "http://jabber.org/protocol/muc"
 #define STANZA_NS_MUC_USER "http://jabber.org/protocol/muc#user"
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257