diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index d5723fe8..279566ba 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -153,43 +153,43 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) } void -mucwin_room_disco_info(const char *const roomjid, GSList *identities, GSList *features) +mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - if (window) { - if ((identities && (g_slist_length(identities) > 0)) || - (features && (g_slist_length(features) > 0))) { - if (identities) { - win_print(window, '!', 0, NULL, 0, 0, "", "Identities:"); - } - while (identities) { - DiscoIdentity *identity = identities->data; // anme trpe, cat - GString *identity_str = g_string_new(" "); - if (identity->name) { - identity_str = g_string_append(identity_str, identity->name); - identity_str = g_string_append(identity_str, " "); - } - if (identity->type) { - identity_str = g_string_append(identity_str, identity->type); - identity_str = g_string_append(identity_str, " "); - } - if (identity->category) { - identity_str = g_string_append(identity_str, identity->category); - } - win_print(window, '!', 0, NULL, 0, 0, "", identity_str->str); - g_string_free(identity_str, TRUE); - identities = g_slist_next(identities); - } + assert(mucwin != NULL); - if (features) { - win_print(window, '!', 0, NULL, 0, 0, "", "Features:"); - } - while (features) { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", features->data); - features = g_slist_next(features); - } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + ProfWin *window = (ProfWin*)mucwin; + if ((identities && (g_slist_length(identities) > 0)) || + (features && (g_slist_length(features) > 0))) { + if (identities) { + win_print(window, '!', 0, NULL, 0, 0, "", "Identities:"); } + while (identities) { + DiscoIdentity *identity = identities->data; // anme trpe, cat + GString *identity_str = g_string_new(" "); + if (identity->name) { + identity_str = g_string_append(identity_str, identity->name); + identity_str = g_string_append(identity_str, " "); + } + if (identity->type) { + identity_str = g_string_append(identity_str, identity->type); + identity_str = g_string_append(identity_str, " "); + } + if (identity->category) { + identity_str = g_string_append(identity_str, identity->category); + } + win_print(window, '!', 0, NULL, 0, 0, "", identity_str->str); + g_string_free(identity_str, TRUE); + identities = g_slist_next(identities); + } + + if (features) { + win_print(window, '!', 0, NULL, 0, 0, "", "Features:"); + } + while (features) { + win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", features->data); + features = g_slist_next(features); + } + win_print(window, '-', 0, NULL, 0, 0, "", ""); } } diff --git a/src/ui/ui.h b/src/ui/ui.h index b8115e8a..c7f6ec2e 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -182,7 +182,7 @@ 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(ProfMucWin *mucwin, const char *const error); -void mucwin_room_disco_info(const char *const roomjid, GSList *identities, GSList *features); +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, const char *const reason); void mucwin_occupant_banned(const char *const roomjid, const char *const nick, const char *const actor, diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 51f5c798..6029fe2b 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1562,8 +1562,9 @@ _room_info_response_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza } muc_set_features(cb_data->room, features); - if (cb_data->display) { - mucwin_room_disco_info(cb_data->room, identities, features); + ProfMucWin *mucwin = wins_get_muc(cb_data->room); + if (mucwin && cb_data->display) { + mucwin_room_disco_info(mucwin, identities, features); } g_slist_free_full(features, free); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index afb62e5e..01222777 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -215,7 +215,7 @@ 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(ProfMucWin *mucwin, const char * const error) {} -void mucwin_room_disco_info(const char * const roomjid, GSList *identities, GSList *features) {} +void mucwin_room_disco_info(ProfMucWin *mucwin, 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) {} void ui_room_kicked(const char * const roomjid, const char * const actor, const char * const reason) {}