diff options
author | James Booth <boothj5@gmail.com> | 2014-10-05 03:05:46 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-10-05 03:05:46 +0100 |
commit | 7584ddaa62033f876b78a4de8b32d8e1e90e0619 (patch) | |
tree | 4aec278429ca06f5b8a986cecf99badbc60b70a1 /src/command | |
parent | 2026ab4b6ee7dca156b6b72d9889f2039279af27 (diff) | |
download | profani-tty-7584ddaa62033f876b78a4de8b32d8e1e90e0619.tar.gz |
Added /room subject command
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 13 | ||||
-rw-r--r-- | src/command/commands.c | 31 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c index 8a0baf3f..1f8977b7 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -976,6 +976,7 @@ static Autocomplete room_ac; static Autocomplete room_affiliation_ac; static Autocomplete room_role_ac; static Autocomplete room_cmd_ac; +static Autocomplete room_subject_ac; static Autocomplete form_ac; /* @@ -1249,6 +1250,7 @@ cmd_init(void) autocomplete_add(room_ac, "destroy"); autocomplete_add(room_ac, "config"); autocomplete_add(room_ac, "info"); + autocomplete_add(room_ac, "subject"); autocomplete_add(room_ac, "role"); autocomplete_add(room_ac, "affiliation"); @@ -1268,6 +1270,10 @@ cmd_init(void) autocomplete_add(room_cmd_ac, "list"); autocomplete_add(room_cmd_ac, "set"); + room_subject_ac = autocomplete_new(); + autocomplete_add(room_subject_ac, "set"); + autocomplete_add(room_subject_ac, "clear"); + form_ac = autocomplete_new(); autocomplete_add(form_ac, "submit"); autocomplete_add(form_ac, "cancel"); @@ -1323,6 +1329,7 @@ cmd_uninit(void) autocomplete_free(room_affiliation_ac); autocomplete_free(room_role_ac); autocomplete_free(room_cmd_ac); + autocomplete_free(room_subject_ac); autocomplete_free(form_ac); } @@ -1452,6 +1459,7 @@ cmd_reset_autocomplete() autocomplete_reset(room_affiliation_ac); autocomplete_reset(room_role_ac); autocomplete_reset(room_cmd_ac); + autocomplete_reset(room_subject_ac); autocomplete_reset(form_ac); if (ui_current_win_type() == WIN_MUC_CONFIG) { @@ -2298,6 +2306,11 @@ _room_autocomplete(char *input, int *size) return result; } + result = autocomplete_param_with_ac(input, size, "/room subject", room_subject_ac, TRUE); + if (result != NULL) { + return result; + } + result = autocomplete_param_with_ac(input, size, "/room", room_ac, TRUE); if (result != NULL) { return result; diff --git a/src/command/commands.c b/src/command/commands.c index 8a6150c0..ad8e93ea 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2126,6 +2126,7 @@ cmd_room(gchar **args, struct cmd_help_t help) if ((g_strcmp0(args[0], "accept") != 0) && (g_strcmp0(args[0], "destroy") != 0) && (g_strcmp0(args[0], "config") != 0) && + (g_strcmp0(args[0], "subject") != 0) && (g_strcmp0(args[0], "role") != 0) && (g_strcmp0(args[0], "affiliation") != 0) && (g_strcmp0(args[0], "info") != 0)) { @@ -2148,6 +2149,36 @@ cmd_room(gchar **args, struct cmd_help_t help) return TRUE; } + if (g_strcmp0(args[0], "subject") == 0) { + if (args[1] == NULL) { + char *subject = muc_subject(room); + if (subject) { + win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Room subject: "); + win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject); + } else { + win_save_print(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room has no subject"); + } + return TRUE; + } + + if (g_strcmp0(args[1], "set") == 0) { + if (args[2]) { + message_send_groupchat_subject(room, args[2]); + } else { + cons_show("Usage: %s", help.usage); + } + return TRUE; + } + + if (g_strcmp0(args[1], "clear") == 0) { + message_send_groupchat_subject(room, NULL); + return TRUE; + } + + cons_show("Usage: %s", help.usage); + return TRUE; + } + if (g_strcmp0(args[0], "affiliation") == 0) { char *cmd = args[1]; if (cmd == NULL) { |