From 6ea9314f982ae5935b8428116b06552ef8a2b996 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 1 Nov 2015 23:08:02 +0000 Subject: [PATCH] mucwin_role_and_affiliation_change takes ProfMucWin --- src/event/server_events.c | 5 ++++- src/ui/mucwin.c | 6 ++++-- src/ui/ui.h | 2 +- tests/unittests/ui/stub_ui.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/event/server_events.c b/src/event/server_events.c index c8a5b760..acfa0c4f 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -588,7 +588,10 @@ sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean c if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { // both changed if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) { - mucwin_role_and_affiliation_change(room, role, affiliation, actor, reason); + ProfMucWin *mucwin = wins_get_muc(room); + if (mucwin) { + mucwin_role_and_affiliation_change(mucwin, role, affiliation, actor, reason); + } // role changed } else if (g_strcmp0(role, old_role) != 0) { diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index e795d3fb..8f9aabf8 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -74,10 +74,12 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con } void -mucwin_role_and_affiliation_change(const char *const roomjid, const char *const role, const char *const affiliation, +mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, const char *const affiliation, const char *const actor, const char *const reason) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); + assert(mucwin != NULL); + + ProfWin *window = (ProfWin*)mucwin; win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); if (actor) { win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); diff --git a/src/ui/ui.h b/src/ui/ui.h index e41a05ef..58f96929 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -164,7 +164,7 @@ void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, voi void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason); void mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, const char *const actor, const char *const reason); -void mucwin_role_and_affiliation_change(const char *const roomjid, const char *const role, +void mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, const char *const affiliation, const char *const actor, const char *const reason); void mucwin_occupant_role_change(const char *const roomjid, const char *const nick, const char *const role, const char *const actor, const char *const reason); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 94b87068..3f672c18 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -195,7 +195,7 @@ void mucwin_role_change(ProfMucWin *mucwin, const char * const role, const char const char * const reason) {} void mucwin_affiliation_change(ProfMucWin *mucwin, const char * const affiliation, const char * const actor, const char * const reason) {} -void mucwin_role_and_affiliation_change(const char * const roomjid, const char * const role, +void mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char * const role, const char * const affiliation, const char * const actor, const char * const reason) {} void mucwin_occupant_role_change(const char * const roomjid, const char * const nick, const char * const role, const char * const actor, const char * const reason) {}