about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-02 00:40:23 +0000
committerJames Booth <boothj5@gmail.com>2015-11-02 00:40:23 +0000
commit3341e8c202b606b6d8b4ab1eed376ef9b58eb9e9 (patch)
tree19ba72219b18da8ceecc4293481ccc44f93322c8
parentd81dbdb23370374d972a97c046b76f81f2094f9f (diff)
downloadprofani-tty-3341e8c202b606b6d8b4ab1eed376ef9b58eb9e9.tar.gz
mucwin_handle_affiliation_list takes ProfMucWin
-rw-r--r--src/ui/mucwin.c30
-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, 21 insertions, 18 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 92ab02e7..d13a89f1 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -537,23 +537,23 @@ mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation,
 }
 
 void
-mucwin_handle_affiliation_list(const char *const roomjid, const char *const affiliation, GSList *jids)
+mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation, GSList *jids)
 {
-    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
-    if (window) {
-        if (jids) {
-            win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation);
-            GSList *curr_jid = jids;
-            while (curr_jid) {
-                char *jid = curr_jid->data;
-                win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", jid);
-                curr_jid = g_slist_next(curr_jid);
-            }
-            win_print(window, '!', 0, NULL, 0, 0, "", "");
-        } else {
-            win_vprint(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation);
-            win_print(window, '!', 0, NULL, 0, 0, "", "");
+    assert(mucwin != NULL);
+
+    ProfWin *window = (ProfWin*)mucwin;
+    if (jids) {
+        win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation);
+        GSList *curr_jid = jids;
+        while (curr_jid) {
+            char *jid = curr_jid->data;
+            win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", jid);
+            curr_jid = g_slist_next(curr_jid);
         }
+        win_print(window, '!', 0, NULL, 0, 0, "", "");
+    } else {
+        win_vprint(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation);
+        win_print(window, '!', 0, NULL, 0, 0, "", "");
     }
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 05cc6a84..6dd32000 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -198,7 +198,7 @@ void mucwin_update_occupants(const char *const roomjid);
 void mucwin_show_occupants(const char *const roomjid);
 void mucwin_hide_occupants(const char *const roomjid);
 void mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, const char *const error);
-void mucwin_handle_affiliation_list(const char *const roomjid, const char *const affiliation, GSList *jids);
+void mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation, GSList *jids);
 void mucwin_affiliation_set_error(const char *const roomjid, const char *const jid,
     const char *const affiliation, const char *const error);
 void mucwin_role_set_error(const char *const roomjid, const char *const nick, const char *const role,
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index e352c26b..025690b2 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1369,7 +1369,10 @@ _room_affiliation_list_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *co
     }
 
     muc_jid_autocomplete_add_all(from, jids);
-    mucwin_handle_affiliation_list(from, affiliation, jids);
+    ProfMucWin *mucwin = wins_get_muc(from);
+    if (mucwin) {
+        mucwin_handle_affiliation_list(mucwin, affiliation, jids);
+    }
     free(affiliation);
     g_slist_free(jids);
 
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index 3b3e03d6..505f30f5 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -272,7 +272,7 @@ void ui_handle_room_configuration_form_error(const char * const roomjid, const c
 void ui_handle_room_config_submit_result(const char * const roomjid) {}
 void ui_handle_room_config_submit_result_error(const char * const roomjid, const char * const message) {}
 void mucwin_affiliation_list_error(ProfMucWin *mucwin, const char * const affiliation, const char * const error) {}
-void mucwin_handle_affiliation_list(const char * const roomjid, const char * const affiliation, GSList *jids) {}
+void mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char * const affiliation, GSList *jids) {}
 void mucwin_affiliation_set_error(const char * const roomjid, const char * const jid,
     const char * const affiliation, const char * const error) {}
 void mucwin_role_set_error(const char * const roomjid, const char * const nick, const char * const role,