about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/muc.c13
-rw-r--r--src/muc.h2
-rw-r--r--src/server_events.c2
-rw-r--r--src/xmpp/iq.c9
-rw-r--r--src/xmpp/xmpp.h2
-rw-r--r--tests/xmpp/stub_xmpp.c2
6 files changed, 26 insertions, 4 deletions
diff --git a/src/muc.c b/src/muc.c
index 1c5e1825..ae48d66b 100644
--- a/src/muc.c
+++ b/src/muc.c
@@ -210,6 +210,19 @@ muc_set_requires_config(const char * const room, gboolean val)
     }
 }
 
+void
+muc_set_features(const char * const room, GSList *features)
+{
+    ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
+    if (chat_room && features) {
+        if (g_slist_find_custom(features, "muc_membersonly", (GCompareFunc)g_strcmp0)) {
+            chat_room->member_type = MUC_MEMBER_TYPE_MEMBERS_ONLY;
+        } else {
+            chat_room->member_type = MUC_MEMBER_TYPE_PUBLIC;
+        }
+    }
+}
+
 /*
  * Returns TRUE if the user is currently in the room
  */
diff --git a/src/muc.h b/src/muc.h
index 60cf7108..2c7b3e7e 100644
--- a/src/muc.h
+++ b/src/muc.h
@@ -82,6 +82,8 @@ gboolean muc_autojoin(const char * const room);
 
 GList* muc_rooms(void);
 
+void muc_set_features(const char * const room, GSList *features);
+
 char* muc_nick(const char * const room);
 char* muc_password(const char * const room);
 
diff --git a/src/server_events.c b/src/server_events.c
index f9f5afe4..882c308c 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -164,6 +164,7 @@ handle_disco_info(const char *from, GSList *identities, GSList *features)
 void
 handle_room_disco_info(const char * const room, GSList *identities, GSList *features)
 {
+    muc_set_features(room, features);
     ui_show_room_disco_info(room, identities, features);
 }
 
@@ -699,6 +700,7 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea
         }
 
         // TODO send disco info request to room
+        iq_room_info_request(room);
 
         muc_invites_remove(room);
         muc_roster_set_complete(room);
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 028c586e..573a50ef 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -178,14 +178,14 @@ iq_disco_info_request(gchar *jid)
 }
 
 void
-iq_room_info_request(gchar *room)
+iq_room_info_request(const char * const room)
 {
     xmpp_conn_t * const conn = connection_get_conn();
     xmpp_ctx_t * const ctx = connection_get_ctx();
     char *id = create_unique_id("room_disco_info");
     xmpp_stanza_t *iq = stanza_create_disco_info_iq(ctx, id, room, NULL);
 
-    xmpp_id_handler_add(conn, _disco_info_response_handler, id, room);
+    xmpp_id_handler_add(conn, _disco_info_response_handler, id, strdup(room));
 
     free(id);
 
@@ -1362,6 +1362,7 @@ _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
         char *error_message = stanza_get_error_message(stanza);
         if (room) {
             handle_room_info_error(room, error_message);
+            free(room);
         } else {
             handle_disco_info_error(from, error_message);
         }
@@ -1422,6 +1423,10 @@ _disco_info_response_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
         g_slist_free_full(features, free);
         g_slist_free_full(identities, (GDestroyNotify)_identity_destroy);
     }
+
+    if (room) {
+        free(room);
+    }
     return 1;
 }
 
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 7deb71db..af9e30cc 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -192,7 +192,7 @@ void iq_send_caps_request_for_jid(const char * const to, const char * const id,
     const char * const node, const char * const ver);
 void iq_send_caps_request_legacy(const char * const to, const char * const id,
     const char * const node, const char * const ver);
-void iq_room_info_request(gchar *room);
+void iq_room_info_request(const char * const room);
 void iq_room_affiliation_list(const char * const room, char *affiliation);
 void iq_room_affiliation_set(const char * const room, const char * const jid, char *affiliation,
     const char * const reason);
diff --git a/tests/xmpp/stub_xmpp.c b/tests/xmpp/stub_xmpp.c
index 53a01c95..21c9862d 100644
--- a/tests/xmpp/stub_xmpp.c
+++ b/tests/xmpp/stub_xmpp.c
@@ -151,7 +151,7 @@ void iq_send_caps_request_for_jid(const char * const to, const char * const id,
     const char * const node, const char * const ver) {}
 void iq_send_caps_request_legacy(const char * const to, const char * const id,
     const char * const node, const char * const ver) {}
-void iq_room_info_request(gchar *room) {}
+void iq_room_info_request(const char * const room) {}
 void iq_room_affiliation_list(const char * const room, char *affiliation) {}
 void iq_room_affiliation_set(const char * const room, const char * const jid, char *affiliation,
     const char * const reason) {}