about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-01 23:33:50 +0000
committerJames Booth <boothj5@gmail.com>2015-11-01 23:33:50 +0000
commitd21faa46097f9a4bfcef92c9355427c103beb549 (patch)
tree7beea7f1973577ea13950f2e67b00f9d1a8673ef
parent363fda82c16efc8d296a50867edd6fcd45271c11 (diff)
downloadprofani-tty-d21faa46097f9a4bfcef92c9355427c103beb549.tar.gz
mucwin_room_disco_info takes ProfMucWin
-rw-r--r--src/ui/mucwin.c64
-rw-r--r--src/ui/ui.h2
-rw-r--r--src/xmpp/iq.c5
-rw-r--r--tests/unittests/ui/stub_ui.c2
4 files changed, 37 insertions, 36 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index d5723fe8..279566ba 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -153,43 +153,43 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error)
 }
 
 void
-mucwin_room_disco_info(const char *const roomjid, GSList *identities, GSList *features)
+mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features)
 {
-    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
-    if (window) {
-        if ((identities && (g_slist_length(identities) > 0)) ||
-            (features && (g_slist_length(features) > 0))) {
-            if (identities) {
-                win_print(window, '!', 0, NULL, 0, 0, "", "Identities:");
-            }
-            while (identities) {
-                DiscoIdentity *identity = identities->data;  // anme trpe, cat
-                GString *identity_str = g_string_new("  ");
-                if (identity->name) {
-                    identity_str = g_string_append(identity_str, identity->name);
-                    identity_str = g_string_append(identity_str, " ");
-                }
-                if (identity->type) {
-                    identity_str = g_string_append(identity_str, identity->type);
-                    identity_str = g_string_append(identity_str, " ");
-                }
-                if (identity->category) {
-                    identity_str = g_string_append(identity_str, identity->category);
-                }
-                win_print(window, '!', 0, NULL, 0, 0, "", identity_str->str);
-                g_string_free(identity_str, TRUE);
-                identities = g_slist_next(identities);
-            }
+    assert(mucwin != NULL);
 
-            if (features) {
-                win_print(window, '!', 0, NULL, 0, 0, "", "Features:");
+    ProfWin *window = (ProfWin*)mucwin;
+    if ((identities && (g_slist_length(identities) > 0)) ||
+        (features && (g_slist_length(features) > 0))) {
+        if (identities) {
+            win_print(window, '!', 0, NULL, 0, 0, "", "Identities:");
+        }
+        while (identities) {
+            DiscoIdentity *identity = identities->data;  // anme trpe, cat
+            GString *identity_str = g_string_new("  ");
+            if (identity->name) {
+                identity_str = g_string_append(identity_str, identity->name);
+                identity_str = g_string_append(identity_str, " ");
             }
-            while (features) {
-                win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", features->data);
-                features = g_slist_next(features);
+            if (identity->type) {
+                identity_str = g_string_append(identity_str, identity->type);
+                identity_str = g_string_append(identity_str, " ");
             }
-            win_print(window, '-', 0, NULL, 0, 0, "", "");
+            if (identity->category) {
+                identity_str = g_string_append(identity_str, identity->category);
+            }
+            win_print(window, '!', 0, NULL, 0, 0, "", identity_str->str);
+            g_string_free(identity_str, TRUE);
+            identities = g_slist_next(identities);
         }
+
+        if (features) {
+            win_print(window, '!', 0, NULL, 0, 0, "", "Features:");
+        }
+        while (features) {
+            win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", features->data);
+            features = g_slist_next(features);
+        }
+        win_print(window, '-', 0, NULL, 0, 0, "", "");
     }
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index b8115e8a..c7f6ec2e 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -182,7 +182,7 @@ void mucwin_info(ProfMucWin *mucwin);
 void mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role);
 void mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation);
 void mucwin_room_info_error(ProfMucWin *mucwin, const char *const error);
-void mucwin_room_disco_info(const char *const roomjid, GSList *identities, GSList *features);
+void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features);
 void mucwin_occupant_kicked(const char *const roomjid, const char *const nick, const char *const actor,
     const char *const reason);
 void mucwin_occupant_banned(const char *const roomjid, const char *const nick, const char *const actor,
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 51f5c798..6029fe2b 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1562,8 +1562,9 @@ _room_info_response_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza
         }
 
         muc_set_features(cb_data->room, features);
-        if (cb_data->display) {
-            mucwin_room_disco_info(cb_data->room, identities, features);
+        ProfMucWin *mucwin = wins_get_muc(cb_data->room);
+        if (mucwin && cb_data->display) {
+            mucwin_room_disco_info(mucwin, identities, features);
         }
 
         g_slist_free_full(features, free);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index afb62e5e..01222777 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -215,7 +215,7 @@ void mucwin_info(ProfMucWin *mucwin) {}
 void mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) {}
 void mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) {}
 void mucwin_room_info_error(ProfMucWin *mucwin, const char * const error) {}
-void mucwin_room_disco_info(const char * const roomjid, GSList *identities, GSList *features) {}
+void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) {}
 void ui_room_destroyed(const char * const roomjid, const char * const reason, const char * const new_jid,
     const char * const password) {}
 void ui_room_kicked(const char * const roomjid, const char * const actor, const char * const reason) {}