diff --git a/src/event/server_events.c b/src/event/server_events.c index bee0e949..57758a52 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -498,7 +498,10 @@ sv_ev_room_occupent_kicked(const char *const room, const char *const nick, const const char *const reason) { muc_roster_remove(room, nick); - mucwin_occupant_kicked(room, nick, actor, reason); + ProfMucWin *mucwin = wins_get_muc(room); + if (mucwin) { + mucwin_occupant_kicked(mucwin, nick, actor, reason); + } occupantswin_occupants(room); } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index f8bf77e2..db7ebd64 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -241,27 +241,25 @@ mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick) } void -mucwin_occupant_kicked(const char *const roomjid, const char *const nick, const char *const actor, +mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *const actor, const char *const reason) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - if (window == NULL) { - log_error("Received kick for room participant %s, but no window open for %s.", nick, roomjid); - } else { - GString *message = g_string_new(nick); - g_string_append(message, " has been kicked from the room"); - if (actor) { - g_string_append(message, " by "); - g_string_append(message, actor); - } - if (reason) { - g_string_append(message, ", reason: "); - g_string_append(message, reason); - } + assert(mucwin != NULL); - win_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); - g_string_free(message, TRUE); + ProfWin *window = (ProfWin*)mucwin; + GString *message = g_string_new(nick); + g_string_append(message, " has been kicked from the room"); + if (actor) { + g_string_append(message, " by "); + g_string_append(message, actor); } + if (reason) { + g_string_append(message, ", reason: "); + g_string_append(message, reason); + } + + win_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + g_string_free(message, TRUE); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 6b225679..453943c0 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -183,7 +183,7 @@ 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(ProfMucWin *mucwin, const char *const error); void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features); -void mucwin_occupant_kicked(const char *const roomjid, const char *const nick, const char *const actor, +void mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *const actor, const char *const reason); void mucwin_occupant_banned(const char *const roomjid, const char *const nick, 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 b92aeca9..9426ea59 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -219,7 +219,7 @@ void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *feat void ui_room_destroyed(const char * const roomjid, const char * const reason, const char * const new_jid, const char * const password) {} void ui_room_kicked(const char * const roomjid, const char * const actor, const char * const reason) {} -void mucwin_occupant_kicked(const char * const roomjid, const char * const nick, const char * const actor, +void mucwin_occupant_kicked(ProfMucWin *mucwin, const char * const nick, const char * const actor, const char * const reason) {} void ui_room_banned(const char * const roomjid, const char * const actor, const char * const reason) {} void mucwin_occupant_banned(const char * const roomjid, const char * const nick, const char * const actor,