diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 396f6331..e1c5bac3 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -561,7 +561,7 @@ mucwin_affiliation_list_error(const char *const roomjid, const char *const affil } void -ui_handle_room_affiliation_list(const char *const roomjid, const char *const affiliation, GSList *jids) +mucwin_handle_affiliation_list(const char *const roomjid, const char *const affiliation, GSList *jids) { ProfWin *window = (ProfWin*)wins_get_muc(roomjid); if (window) { @@ -581,6 +581,66 @@ ui_handle_room_affiliation_list(const char *const roomjid, const char *const aff } } +void +ui_show_room_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) +{ + ProfWin *window = (ProfWin*) mucwin; + GSList *occupants = muc_occupants_by_affiliation(mucwin->roomjid, affiliation); + + if (!occupants) { + switch (affiliation) { + case MUC_AFFILIATION_OWNER: + win_print(window, '!', 0, NULL, 0, 0, "", "No owners found."); + break; + case MUC_AFFILIATION_ADMIN: + win_print(window, '!', 0, NULL, 0, 0, "", "No admins found."); + break; + case MUC_AFFILIATION_MEMBER: + win_print(window, '!', 0, NULL, 0, 0, "", "No members found."); + break; + case MUC_AFFILIATION_OUTCAST: + win_print(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); + break; + default: + break; + } + win_print(window, '-', 0, NULL, 0, 0, "", ""); + } else { + switch (affiliation) { + case MUC_AFFILIATION_OWNER: + win_print(window, '!', 0, NULL, 0, 0, "", "Owners:"); + break; + case MUC_AFFILIATION_ADMIN: + win_print(window, '!', 0, NULL, 0, 0, "", "Admins:"); + break; + case MUC_AFFILIATION_MEMBER: + win_print(window, '!', 0, NULL, 0, 0, "", "Members:"); + break; + case MUC_AFFILIATION_OUTCAST: + win_print(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); + break; + default: + break; + } + + GSList *curr_occupant = occupants; + while(curr_occupant) { + Occupant *occupant = curr_occupant->data; + if (occupant->affiliation == affiliation) { + if (occupant->jid) { + win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); + } else { + win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); + } + } + + curr_occupant = g_slist_next(curr_occupant); + } + + win_print(window, '-', 0, NULL, 0, 0, "", ""); + } +} + void ui_handle_room_role_list_error(const char *const roomjid, const char *const role, const char *const error) { @@ -707,66 +767,6 @@ ui_show_room_role_list(ProfMucWin *mucwin, muc_role_t role) } } -void -ui_show_room_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) -{ - ProfWin *window = (ProfWin*) mucwin; - GSList *occupants = muc_occupants_by_affiliation(mucwin->roomjid, affiliation); - - if (!occupants) { - switch (affiliation) { - case MUC_AFFILIATION_OWNER: - win_print(window, '!', 0, NULL, 0, 0, "", "No owners found."); - break; - case MUC_AFFILIATION_ADMIN: - win_print(window, '!', 0, NULL, 0, 0, "", "No admins found."); - break; - case MUC_AFFILIATION_MEMBER: - win_print(window, '!', 0, NULL, 0, 0, "", "No members found."); - break; - case MUC_AFFILIATION_OUTCAST: - win_print(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); - break; - default: - break; - } - win_print(window, '-', 0, NULL, 0, 0, "", ""); - } else { - switch (affiliation) { - case MUC_AFFILIATION_OWNER: - win_print(window, '!', 0, NULL, 0, 0, "", "Owners:"); - break; - case MUC_AFFILIATION_ADMIN: - win_print(window, '!', 0, NULL, 0, 0, "", "Admins:"); - break; - case MUC_AFFILIATION_MEMBER: - win_print(window, '!', 0, NULL, 0, 0, "", "Members:"); - break; - case MUC_AFFILIATION_OUTCAST: - win_print(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); - break; - default: - break; - } - - GSList *curr_occupant = occupants; - while(curr_occupant) { - Occupant *occupant = curr_occupant->data; - if (occupant->affiliation == affiliation) { - if (occupant->jid) { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); - } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); - } - } - - curr_occupant = g_slist_next(curr_occupant); - } - - win_print(window, '-', 0, NULL, 0, 0, "", ""); - } -} - void ui_room_update_occupants(const char *const roomjid) { diff --git a/src/ui/ui.h b/src/ui/ui.h index b0fa4867..b138386d 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -157,7 +157,7 @@ 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(const char *const roomjid, const char *const affiliation, const char *const error); -void ui_handle_room_affiliation_list(const char *const roomjid, const char *const affiliation, GSList *jids); +void mucwin_handle_affiliation_list(const char *const roomjid, const char *const affiliation, GSList *jids); void ui_handle_room_affiliation_set_error(const char *const roomjid, const char *const jid, const char *const affiliation, const char *const error); void ui_handle_room_role_set_error(const char *const roomjid, const char *const nick, const char *const role, diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 3f70587e..06ef7e10 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1365,7 +1365,7 @@ _room_affiliation_list_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *co } muc_jid_autocomplete_add_all(from, jids); - ui_handle_room_affiliation_list(from, affiliation, jids); + mucwin_handle_affiliation_list(from, affiliation, jids); free(affiliation); g_slist_free(jids); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index b9a44dd5..5275648e 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -277,7 +277,7 @@ 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(const char * const roomjid, const char * const affiliation, const char * const error) {} -void ui_handle_room_affiliation_list(const char * const roomjid, const char * const affiliation, GSList *jids) {} +void mucwin_handle_affiliation_list(const char * const roomjid, const char * const affiliation, GSList *jids) {} void ui_handle_room_affiliation_set_error(const char * const roomjid, const char * const jid, const char * const affiliation, const char * const error) {} void ui_handle_room_role_set_error(const char * const roomjid, const char * const nick, const char * const role,