From 982bc8e066066f3027c33f628b1a0be233a4a1bc Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 2 Nov 2015 00:51:12 +0000 Subject: [PATCH] mucwin_affiliation_set_error takes ProfMucWin --- src/ui/mucwin.c | 10 +++++----- src/ui/ui.h | 4 ++-- src/xmpp/iq.c | 5 ++++- tests/unittests/ui/stub_ui.c | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index ec39bbed..8217faf5 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -715,13 +715,13 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) } void -mucwin_affiliation_set_error(const char *const roomjid, const char *const jid, const char *const affiliation, +mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const char *const affiliation, const char *const error) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - if (window) { - win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error); - } + assert(mucwin != NULL); + + ProfWin *window = (ProfWin*)mucwin; + win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index fae8491e..351998c3 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -199,8 +199,8 @@ 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(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_affiliation_set_error(ProfMucWin *mucwin, 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, const char *const error); void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 4b3d9dcd..9d0763df 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1284,7 +1284,10 @@ _room_affiliation_set_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *con if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { char *error_message = stanza_get_error_message(stanza); log_debug("Error setting affiliation %s list for room %s, user %s: %s", affiliation_set->privilege, from, affiliation_set->item, error_message); - mucwin_affiliation_set_error(from, affiliation_set->item, affiliation_set->privilege, error_message); + ProfMucWin *mucwin = wins_get_muc(from); + if (mucwin) { + mucwin_affiliation_set_error(mucwin, affiliation_set->item, affiliation_set->privilege, error_message); + } free(error_message); } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 529c5026..2dc55567 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -273,8 +273,8 @@ 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(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_affiliation_set_error(ProfMucWin *mucwin, 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, const char * const error) {} void mucwin_role_list_error(ProfMucWin *mucwin, const char * const role, const char * const error) {}