diff options
author | James Booth <boothj5@gmail.com> | 2015-11-02 00:47:43 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-11-02 00:47:43 +0000 |
commit | 7bedb6c2949bf1a88c7637ff27a5781e255790a5 (patch) | |
tree | 59aed9c8b68f9eee8b578cd02b37eea7ad66f1e7 | |
parent | 1aa3c0ea4fcb8dceaf7de04961a00b243fcc0e83 (diff) | |
download | profani-tty-7bedb6c2949bf1a88c7637ff27a5781e255790a5.tar.gz |
mucwin_handle_role_list takes ProfMucWin
-rw-r--r-- | src/ui/mucwin.c | 40 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | src/xmpp/iq.c | 5 | ||||
-rw-r--r-- | tests/unittests/ui/stub_ui.c | 2 |
4 files changed, 26 insertions, 23 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index e598c50b..d3d29ee0 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -629,32 +629,32 @@ mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *c } void -mucwin_handle_role_list(const char *const roomjid, const char *const role, GSList *nicks) +mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - if (window) { - if (nicks) { - win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); - GSList *curr_nick = nicks; - while (curr_nick) { - char *nick = curr_nick->data; - Occupant *occupant = muc_roster_item(roomjid, nick); - if (occupant) { - if (occupant->jid) { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", nick, occupant->jid); - } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); - } + assert(mucwin != NULL); + + ProfWin *window = (ProfWin*)mucwin; + if (nicks) { + win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); + GSList *curr_nick = nicks; + while (curr_nick) { + char *nick = curr_nick->data; + Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); + if (occupant) { + if (occupant->jid) { + win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", nick, occupant->jid); } else { win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); } - curr_nick = g_slist_next(curr_nick); + } else { + win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); } - win_print(window, '!', 0, NULL, 0, 0, "", ""); - } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); - win_print(window, '!', 0, NULL, 0, 0, "", ""); + curr_nick = g_slist_next(curr_nick); } + win_print(window, '!', 0, NULL, 0, 0, "", ""); + } else { + win_vprint(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); + win_print(window, '!', 0, NULL, 0, 0, "", ""); } } diff --git a/src/ui/ui.h b/src/ui/ui.h index 57741bbc..fae8491e 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -204,7 +204,7 @@ void mucwin_affiliation_set_error(const char *const roomjid, const char *const j void mucwin_role_set_error(const char *const roomjid, const char *const nick, const char *const role, const char *const error); void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error); -void mucwin_handle_role_list(const char *const roomjid, const char *const role, GSList *nicks); +void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks); void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error); // xml console diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index e62e49bf..4b3d9dcd 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -1422,7 +1422,10 @@ _room_role_list_result_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const sta } } - mucwin_handle_role_list(from, role, nicks); + ProfMucWin *mucwin = wins_get_muc(from); + if (mucwin) { + mucwin_handle_role_list(mucwin, role, nicks); + } free(role); g_slist_free(nicks); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index cc521778..529c5026 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -278,7 +278,7 @@ void mucwin_affiliation_set_error(const char * const roomjid, const char * const void mucwin_role_set_error(const char * const roomjid, const char * const nick, const char * const role, const char * const error) {} void mucwin_role_list_error(ProfMucWin *mucwin, const char * const role, const char * const error) {} -void mucwin_handle_role_list(const char * const roomjid, const char * const role, GSList *nicks) {} +void mucwin_handle_role_list(ProfMucWin *mucwin, const char * const role, GSList *nicks) {} void mucwin_kick_error(ProfMucWin *mucwin, const char * const nick, const char * const error) {} void ui_show_form(ProfMucConfWin *confwin) {} void ui_show_form_field(ProfWin *window, DataForm *form, char *tag) {} |