Implemented setting and listing roles

This commit is contained in:
James Booth
2014-10-06 21:42:09 +01:00
parent 2aeaad230e
commit 965f048b18
10 changed files with 366 additions and 21 deletions

View File

@@ -2277,15 +2277,27 @@ static char *
_room_autocomplete(char *input, int *size)
{
char *result = NULL;
gboolean parse_result;
result = autocomplete_param_with_ac(input, size, "/room affiliation set", room_affiliation_ac, TRUE);
if (result != NULL) {
return result;
}
char *recipient = ui_current_recipient();
Autocomplete nick_ac = muc_roster_ac(recipient);
result = autocomplete_param_with_ac(input, size, "/room affiliation list", room_affiliation_ac, TRUE);
if (result != NULL) {
return result;
input[*size] = '\0';
gchar **args = parse_args(input, 4, 4, &parse_result);
if ((strncmp(input, "/room", 5) == 0) && (parse_result == TRUE)) {
GString *beginning = g_string_new("/room ");
g_string_append(beginning, args[0]);
g_string_append(beginning, " ");
g_string_append(beginning, args[1]);
g_string_append(beginning, " ");
g_string_append(beginning, args[2]);
result = autocomplete_param_with_ac(input, size, beginning->str, nick_ac, TRUE);
g_string_free(beginning, TRUE);
if (result != NULL) {
return result;
}
}
result = autocomplete_param_with_ac(input, size, "/room role set", room_role_ac, TRUE);
@@ -2298,6 +2310,16 @@ _room_autocomplete(char *input, int *size)
return result;
}
result = autocomplete_param_with_ac(input, size, "/room affiliation set", room_affiliation_ac, TRUE);
if (result != NULL) {
return result;
}
result = autocomplete_param_with_ac(input, size, "/room affiliation list", room_affiliation_ac, TRUE);
if (result != NULL) {
return result;
}
result = autocomplete_param_with_ac(input, size, "/room affiliation", room_cmd_ac, TRUE);
if (result != NULL) {
return result;
@@ -2313,8 +2335,6 @@ _room_autocomplete(char *input, int *size)
return result;
}
char *recipient = ui_current_recipient();
Autocomplete nick_ac = muc_roster_ac(recipient);
if (nick_ac != NULL) {
result = autocomplete_param_with_ac(input, size, "/room kick", nick_ac, TRUE);
if (result != NULL) {

View File

@@ -2237,7 +2237,44 @@ cmd_room(gchar **args, struct cmd_help_t help)
}
if (g_strcmp0(args[0], "role") == 0) {
cons_show("/room role...");
char *cmd = args[1];
if (cmd == NULL) {
cons_show("Usage: %s", help.usage);
return TRUE;
}
char *role = args[2];
if ((g_strcmp0(role, "visitor") != 0) &&
(g_strcmp0(role, "participant") != 0) &&
(g_strcmp0(role, "moderator") != 0) &&
(g_strcmp0(role, "none") != 0)) {
cons_show("Usage: %s", help.usage);
return TRUE;
}
if (g_strcmp0(cmd, "list") == 0) {
if (g_strcmp0(role, "none") == 0) {
win_save_print(window, '!', NULL, 0, 0, "", "Cannot list users with no role.");
} else if (g_strcmp0(role, "visitor") == 0) {
win_save_print(window, '!', NULL, 0, 0, "", "Cannot list users with visitor role.");
} else {
iq_room_role_list(room, role);
}
return TRUE;
}
if (g_strcmp0(cmd, "set") == 0) {
char *nick = args[3];
if (nick == NULL) {
cons_show("Usage: %s", help.usage);
return TRUE;
} else {
char *reason = args[4];
iq_room_role_set(room, nick, role, reason);
return TRUE;
}
}
return TRUE;
}