From 363fda82c16efc8d296a50867edd6fcd45271c11 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 1 Nov 2015 23:30:44 +0000 Subject: [PATCH] mucwin_room_info_error takes ProfMucWin --- src/ui/mucwin.c | 12 ++++++------ src/ui/ui.h | 2 +- src/xmpp/iq.c | 6 ++++-- tests/unittests/ui/stub_ui.c | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 2dad9d8f..d5723fe8 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -143,13 +143,13 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons } void -mucwin_room_info_error(const char *const roomjid, const char *const error) +mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - if (window) { - win_vprint(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); - win_print(window, '-', 0, NULL, 0, 0, "", ""); - } + assert(mucwin != NULL); + + ProfWin *window = (ProfWin*)mucwin; + win_vprint(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); + win_print(window, '-', 0, NULL, 0, 0, "", ""); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 242d8695..b8115e8a 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -181,7 +181,7 @@ void mucwin_requires_config(const char *const roomjid); 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(const char *const roomjid, const char *const error); +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_occupant_kicked(const char *const roomjid, const char *const nick, const char *const actor, const char *const reason); diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 034be2a2..51f5c798 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -54,6 +54,7 @@ #include "muc.h" #include "profanity.h" #include "ui/ui.h" +#include "window_list.h" #include "config/preferences.h" #include "event/server_events.h" #include "xmpp/capabilities.h" @@ -1505,9 +1506,10 @@ _room_info_response_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza // handle error responses if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { - if (cb_data->display) { + ProfMucWin *mucwin = wins_get_muc(cb_data->room); + if (mucwin && cb_data->display) { char *error_message = stanza_get_error_message(stanza); - mucwin_room_info_error(cb_data->room, error_message); + mucwin_room_info_error(mucwin, error_message); free(error_message); } free(cb_data->room); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 75ef158d..afb62e5e 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -214,7 +214,7 @@ void ui_room_destroy(const char * const roomjid) {} 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(const char * const roomjid, const char * const error) {} +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 ui_room_destroyed(const char * const roomjid, const char * const reason, const char * const new_jid, const char * const password) {}