mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added add/remove subcommands to room config
This commit is contained in:
parent
0239a81c38
commit
b52911f7b4
@ -307,15 +307,17 @@ static struct cmd_t command_defs[] =
|
|||||||
|
|
||||||
{ "/room",
|
{ "/room",
|
||||||
cmd_room, parse_args, 1, 3, NULL,
|
cmd_room, parse_args, 1, 3, NULL,
|
||||||
{ "/room config accept|destroy|config|submit|cancel [tag value]", "Room configuration.",
|
{ "/room config accept|destroy|config|submit|cancel|set|add|remove [tag value]", "Room configuration.",
|
||||||
{ "/room config accept|destroy|config|submit|cancel [tag value]",
|
{ "/room config accept|destroy|config|submit|cancel|set|add|remove [tag value]",
|
||||||
"------------------------------------------------------------",
|
"---------------------------------------------------------------------------",
|
||||||
"config accept - Accept default room configuration.",
|
"config accept - Accept default room configuration.",
|
||||||
"config destroy - Cancel default room configuration.",
|
"config destroy - Cancel default room configuration.",
|
||||||
"config config - Edit room configuration.",
|
"config config - Edit room configuration.",
|
||||||
"config submit - Cancel room configuration.",
|
"config submit - Cancel room configuration.",
|
||||||
"config cancel - Cancel room configuration.",
|
"config cancel - Cancel room configuration.",
|
||||||
"config set tag value - Set room configuration field to value.",
|
"config set tag value - Set room configuration field to value.",
|
||||||
|
"config add tag value - Add value to room configuration field.",
|
||||||
|
"config remove tag value - Remove value from room configuration field.",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
{ "/rooms",
|
{ "/rooms",
|
||||||
@ -1217,6 +1219,8 @@ cmd_init(void)
|
|||||||
autocomplete_add(room_ac, "submit");
|
autocomplete_add(room_ac, "submit");
|
||||||
autocomplete_add(room_ac, "cancel");
|
autocomplete_add(room_ac, "cancel");
|
||||||
autocomplete_add(room_ac, "set");
|
autocomplete_add(room_ac, "set");
|
||||||
|
autocomplete_add(room_ac, "add");
|
||||||
|
autocomplete_add(room_ac, "remove");
|
||||||
|
|
||||||
cmd_history_init();
|
cmd_history_init();
|
||||||
}
|
}
|
||||||
@ -2087,6 +2091,14 @@ _room_autocomplete(char *input, int *size)
|
|||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
result = autocomplete_param_with_ac(input, size, "/room add", form->tag_ac, TRUE);
|
||||||
|
if (result != NULL) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = autocomplete_param_with_ac(input, size, "/room remove", form->tag_ac, TRUE);
|
||||||
|
if (result != NULL) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1810,6 +1810,8 @@ cmd_room(gchar **args, struct cmd_help_t help)
|
|||||||
(g_strcmp0(args[0], "config") != 0) &&
|
(g_strcmp0(args[0], "config") != 0) &&
|
||||||
(g_strcmp0(args[0], "submit") != 0) &&
|
(g_strcmp0(args[0], "submit") != 0) &&
|
||||||
(g_strcmp0(args[0], "set") != 0) &&
|
(g_strcmp0(args[0], "set") != 0) &&
|
||||||
|
(g_strcmp0(args[0], "add") != 0) &&
|
||||||
|
(g_strcmp0(args[0], "remove") != 0) &&
|
||||||
(g_strcmp0(args[0], "cancel") != 0)) {
|
(g_strcmp0(args[0], "cancel") != 0)) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1819,6 +1821,8 @@ cmd_room(gchar **args, struct cmd_help_t help)
|
|||||||
if (win_type == WIN_MUC &&
|
if (win_type == WIN_MUC &&
|
||||||
((g_strcmp0(args[0], "submit") == 0) ||
|
((g_strcmp0(args[0], "submit") == 0) ||
|
||||||
(g_strcmp0(args[0], "cancel") == 0) ||
|
(g_strcmp0(args[0], "cancel") == 0) ||
|
||||||
|
(g_strcmp0(args[0], "add") == 0) ||
|
||||||
|
(g_strcmp0(args[0], "remove") == 0) ||
|
||||||
(g_strcmp0(args[0], "set") == 0))) {
|
(g_strcmp0(args[0], "set") == 0))) {
|
||||||
cons_show("Command '/room %s' only allowed in room configuration windows.", args[0]);
|
cons_show("Command '/room %s' only allowed in room configuration windows.", args[0]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1882,6 +1886,8 @@ cmd_room(gchar **args, struct cmd_help_t help)
|
|||||||
// commands allowed in room config
|
// commands allowed in room config
|
||||||
if ((g_strcmp0(args[0], "submit") == 0) ||
|
if ((g_strcmp0(args[0], "submit") == 0) ||
|
||||||
(g_strcmp0(args[0], "cancel") == 0) ||
|
(g_strcmp0(args[0], "cancel") == 0) ||
|
||||||
|
(g_strcmp0(args[0], "add") == 0) ||
|
||||||
|
(g_strcmp0(args[0], "remove") == 0) ||
|
||||||
(g_strcmp0(args[0], "set") == 0)) {
|
(g_strcmp0(args[0], "set") == 0)) {
|
||||||
|
|
||||||
ProfWin *current = wins_get_current();
|
ProfWin *current = wins_get_current();
|
||||||
@ -1945,12 +1951,60 @@ cmd_room(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ui_current_print_line("Value %s not valid for field: %s", value, tag);
|
ui_current_print_line("Set command not valid for field: %s", value, tag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_strcmp0(args[0], "add") == 0) {
|
||||||
|
char *tag = NULL;
|
||||||
|
char *value = NULL;
|
||||||
|
if (args[1] != NULL) {
|
||||||
|
tag = args[1];
|
||||||
|
} else {
|
||||||
|
ui_current_print_line("/room add command requires a field tag and value");
|
||||||
|
g_strfreev(split_recipient);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (args[2] != NULL) {
|
||||||
|
value = args[2];
|
||||||
|
} else {
|
||||||
|
ui_current_print_line("/room add command requires a field tag and value");
|
||||||
|
g_strfreev(split_recipient);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (!form_tag_exists(current->form, tag)) {
|
||||||
|
ui_current_print_line("Form does not contain a field with tag %s", tag);
|
||||||
|
} else {
|
||||||
|
ui_current_print_line("Add Tag: %s, Value: %s", tag, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_strcmp0(args[0], "remove") == 0) {
|
||||||
|
char *tag = NULL;
|
||||||
|
char *value = NULL;
|
||||||
|
if (args[1] != NULL) {
|
||||||
|
tag = args[1];
|
||||||
|
} else {
|
||||||
|
ui_current_print_line("/room remove command requires a field tag and value");
|
||||||
|
g_strfreev(split_recipient);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (args[2] != NULL) {
|
||||||
|
value = args[2];
|
||||||
|
} else {
|
||||||
|
ui_current_print_line("/room remove command requires a field tag and value");
|
||||||
|
g_strfreev(split_recipient);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (!form_tag_exists(current->form, tag)) {
|
||||||
|
ui_current_print_line("Form does not contain a field with tag %s", tag);
|
||||||
|
} else {
|
||||||
|
ui_current_print_line("Remove Tag: %s, Value: %s", tag, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((g_strcmp0(args[0], "submit") == 0) ||
|
if ((g_strcmp0(args[0], "submit") == 0) ||
|
||||||
(g_strcmp0(args[0], "cancel") == 0)) {
|
(g_strcmp0(args[0], "cancel") == 0)) {
|
||||||
wins_close_current();
|
wins_close_current();
|
||||||
|
Loading…
Reference in New Issue
Block a user