From 3341e8c202b606b6d8b4ab1eed376ef9b58eb9e9 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 2 Nov 2015 00:40:23 +0000 Subject: mucwin_handle_affiliation_list takes ProfMucWin --- src/ui/mucwin.c | 30 +++++++++++++++--------------- src/ui/ui.h | 2 +- src/xmpp/iq.c | 5 ++++- tests/unittests/ui/stub_ui.c | 2 +- 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, -- cgit 1.4.1-2-gfad0