diff options
author | James Booth <boothj5@gmail.com> | 2013-12-08 22:06:06 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-12-08 22:06:06 +0000 |
commit | b7a5179fa6855ca7a0a0e2c411b9b0ad83321166 (patch) | |
tree | cb81c2fb1424b5353310bd11311f19e8338472cb /src/command | |
parent | f0f2c7957f345de70fad81e2aab20604daaf54e7 (diff) | |
parent | 3ce0d0f87770dbe9c992be76dc9bafa558c3f89b (diff) | |
download | profani-tty-b7a5179fa6855ca7a0a0e2c411b9b0ad83321166.tar.gz |
Merge branch 'master' into otr
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/src/command/command.c b/src/command/command.c index 3828ddcf..3883be1d 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -83,6 +83,7 @@ static char * _notify_autocomplete(char *input, int *size); static char * _titlebar_autocomplete(char *input, int *size); static char * _theme_autocomplete(char *input, int *size); static char * _autoaway_autocomplete(char *input, int *size); +static char * _autoconnect_autocomplete(char *input, int *size); static char * _account_autocomplete(char *input, int *size); static char * _who_autocomplete(char *input, int *size); static char * _roster_autocomplete(char *input, int *size); @@ -583,13 +584,15 @@ static struct cmd_t command_defs[] = NULL } } }, { "/autoconnect", - _cmd_autoconnect, parse_args, 0, 1, cons_autoconnect_setting, - { "/autoconnect [account]", "Set account to autoconnect with.", - { "/autoconnect [account]", - "----------------------", - "Set the account to autoconnect with.", - "Will be overridden by any command line options specified.", - "Passing no account will clear the setting.", + _cmd_autoconnect, parse_args, 1, 2, cons_autoconnect_setting, + { "/autoconnect set|off [account]", "Set account to autoconnect with.", + { "/autoconnect set|off [account]", + "------------------------------", + "Enable or disable autoconnect on start up.", + "The setting can be overridden by the -a (--account) command line option.", + "", + "Example: /autoconnect set jc@stuntteam.org (autoconnect with the specified account).", + "Example: /autoconnect off (disable autoconnect).", NULL } } }, { "/vercheck", @@ -892,6 +895,7 @@ static Autocomplete sub_ac; static Autocomplete log_ac; static Autocomplete autoaway_ac; static Autocomplete autoaway_mode_ac; +static Autocomplete autoconnect_ac; static Autocomplete titlebar_ac; static Autocomplete theme_ac; static Autocomplete theme_load_ac; @@ -979,6 +983,10 @@ cmd_init(void) autocomplete_add(autoaway_mode_ac, "idle"); autocomplete_add(autoaway_mode_ac, "off"); + autoconnect_ac = autocomplete_new(); + autocomplete_add(autoconnect_ac, "set"); + autocomplete_add(autoconnect_ac, "off"); + theme_ac = autocomplete_new(); autocomplete_add(theme_ac, "list"); autocomplete_add(theme_ac, "set"); @@ -1048,6 +1056,7 @@ cmd_close(void) autocomplete_free(prefs_ac); autocomplete_free(autoaway_ac); autocomplete_free(autoaway_mode_ac); + autocomplete_free(autoconnect_ac); autocomplete_free(theme_ac); if (theme_load_ac != NULL) { autocomplete_free(theme_load_ac); @@ -1117,6 +1126,7 @@ cmd_reset_autocomplete() autocomplete_reset(commands_ac); autocomplete_reset(autoaway_ac); autocomplete_reset(autoaway_mode_ac); + autocomplete_reset(autoconnect_ac); autocomplete_reset(theme_ac); if (theme_load_ac != NULL) { autocomplete_reset(theme_load_ac); @@ -1330,13 +1340,6 @@ _cmd_complete_parameters(char *input, int *size) return; } - result = autocomplete_param_with_func(input, size, "/autoconnect", accounts_find_enabled); - if (result != NULL) { - inp_replace_input(input, result, size); - g_free(result); - return; - } - gchar *cmds[] = { "/help", "/prefs", "/log", "/disco", "/close", "/wins" }; Autocomplete completers[] = { help_ac, prefs_ac, log_ac, disco_ac, close_ac, wins_ac }; @@ -1352,7 +1355,7 @@ _cmd_complete_parameters(char *input, int *size) autocompleter acs[] = { _who_autocomplete, _sub_autocomplete, _notify_autocomplete, _autoaway_autocomplete, _titlebar_autocomplete, _theme_autocomplete, _account_autocomplete, _roster_autocomplete, _group_autocomplete, - _bookmark_autocomplete }; + _bookmark_autocomplete, _autoconnect_autocomplete }; for (i = 0; i < ARRAY_SIZE(acs); i++) { result = acs[i](input, size); @@ -3525,12 +3528,14 @@ _cmd_splash(gchar **args, struct cmd_help_t help) static gboolean _cmd_autoconnect(gchar **args, struct cmd_help_t help) { - if (args[0] == NULL) { - prefs_set_string(PREF_CONNECT_ACCOUNT, NULL); - cons_show("Autoconnect account disabled."); + if (strcmp(args[0], "off") == 0) { + prefs_set_string(PREF_CONNECT_ACCOUNT, NULL); + cons_show("Autoconnect account disabled."); + } else if (strcmp(args[0], "set") == 0) { + prefs_set_string(PREF_CONNECT_ACCOUNT, args[1]); + cons_show("Autoconnect account set to: %s.", args[1]); } else { - prefs_set_string(PREF_CONNECT_ACCOUNT, args[0]); - cons_show("Autoconnect account set to: %s.", args[0]); + cons_show("Usage: %s", help.usage); } return true; } @@ -3879,6 +3884,24 @@ _autoaway_autocomplete(char *input, int *size) } static char * +_autoconnect_autocomplete(char *input, int *size) +{ + char *result = NULL; + + result = autocomplete_param_with_func(input, size, "/autoconnect set", accounts_find_enabled); + if (result != NULL) { + return result; + } + + result = autocomplete_param_with_ac(input, size, "/autoconnect", autoconnect_ac); + if (result != NULL) { + return result; + } + + return NULL; +} + +static char * _theme_autocomplete(char *input, int *size) { char *result = NULL; |