Added /room <role> command

This commit is contained in:
James Booth
2014-10-01 00:27:25 +01:00
parent 76d2b9e9b5
commit 5879f497ad
6 changed files with 100 additions and 1 deletions

View File

@@ -1899,6 +1899,57 @@ _ui_show_room_info(ProfWin *window, const char * const room)
win_save_print(window, '-', NULL, 0, 0, "", "");
}
static void
_ui_show_room_role_list(ProfWin *window, const char * const room, muc_role_t role)
{
GSList *occupants = muc_occupants_by_role(room, role);
if (!occupants) {
win_save_print(window, '-', NULL, 0, 0, "", "");
switch (role) {
case MUC_ROLE_MODERATOR:
win_save_print(window, '!', NULL, 0, 0, "", "No moderators found.");
break;
case MUC_ROLE_PARTICIPANT:
win_save_print(window, '!', NULL, 0, 0, "", "No participants found.");
break;
case MUC_ROLE_VISITOR:
win_save_print(window, '!', NULL, 0, 0, "", "No visitors found.");
break;
default:
break;
}
win_save_print(window, '-', NULL, 0, 0, "", "");
} else {
win_save_print(window, '-', NULL, 0, 0, "", "");
switch (role) {
case MUC_ROLE_MODERATOR:
win_save_print(window, '!', NULL, 0, 0, "", "Moderators:");
break;
case MUC_ROLE_PARTICIPANT:
win_save_print(window, '!', NULL, 0, 0, "", "Participants:");
break;
case MUC_ROLE_VISITOR:
win_save_print(window, '!', NULL, 0, 0, "", "Visitors:");
break;
default:
break;
}
GSList *curr_occupant = occupants;
while(curr_occupant) {
Occupant *occupant = curr_occupant->data;
if (occupant->role == role) {
win_save_vprint(window, '!', NULL, 0, 0, "", " %s", occupant->nick);
}
curr_occupant = g_slist_next(curr_occupant);
}
win_save_print(window, '-', NULL, 0, 0, "", "");
}
}
static void
_ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
{
@@ -2527,4 +2578,5 @@ ui_init_module(void)
ui_show_lines = _ui_show_lines;
ui_handle_room_configuration_form_error = _ui_handle_room_configuration_form_error;
ui_show_room_info = _ui_show_room_info;
ui_show_room_role_list = _ui_show_room_role_list;
}

View File

@@ -138,6 +138,8 @@ void (*ui_room_subject)(const char * const room_jid,
void (*ui_room_requires_config)(const char * const room_jid);
void (*ui_room_destroyed)(const char * const room_jid);
void (*ui_show_room_info)(ProfWin *window, const char * const room);
void (*ui_show_room_role_list)(ProfWin *window, const char * const room, muc_role_t role);
void (*ui_room_broadcast)(const char * const room_jid,
const char * const message);
void (*ui_room_member_offline)(const char * const room, const char * const nick);