1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

add default account property and commands associated with them

This commit is contained in:
Will Song 2014-11-27 11:42:23 -06:00
parent 94bd9dbdfe
commit de9e621bb7
3 changed files with 35 additions and 0 deletions

View File

@ -243,6 +243,37 @@ cmd_account(gchar **args, struct cmd_help_t help)
cons_show("");
}
}
} else if (strcmp(command, "default") == 0) {
if(g_strv_length(args) == 1){
char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT);
if(def){
cons_show("The default account is %s.", def);
free(def);
} else {
cons_show("No default account.");
}
} else if(g_strv_length(args) == 2){
if(strcmp(args[1], "off") == 0){
prefs_set_string(PREF_DEFAULT_ACCOUNT, NULL);
cons_show("Removed default account.");
} else {
cons_show("Usage: %s", help.usage);
}
} else if(g_strv_length(args) == 3) {
if(strcmp(args[1], "set") == 0){
if(accounts_get_account(args[2])){
prefs_set_string(PREF_DEFAULT_ACCOUNT, args[2]);
cons_show("Default account set to %s.", args[2]);
} else {
cons_show("Account %s does not exist.", args[2]);
}
} else {
cons_show("Usage: %s", help.usage);
}
} else {
cons_show("Usage: %s", help.usage);
}
} else if (strcmp(command, "set") == 0) {
if (g_strv_length(args) != 4) {
cons_show("Usage: %s", help.usage);

View File

@ -521,6 +521,7 @@ _get_group(preference_t pref)
case PREF_AUTOAWAY_MESSAGE:
return PREF_GROUP_PRESENCE;
case PREF_CONNECT_ACCOUNT:
case PREF_DEFAULT_ACCOUNT:
return PREF_GROUP_CONNECTION;
case PREF_OTR_WARN:
case PREF_OTR_LOG:
@ -602,6 +603,8 @@ _get_key(preference_t pref)
return "autoaway.message";
case PREF_CONNECT_ACCOUNT:
return "account";
case PREF_DEFAULT_ACCOUNT:
return "defaccount";
case PREF_OTR_LOG:
return "log";
case PREF_OTR_WARN:

View File

@ -90,6 +90,7 @@ typedef enum {
PREF_AUTOAWAY_MODE,
PREF_AUTOAWAY_MESSAGE,
PREF_CONNECT_ACCOUNT,
PREF_DEFAULT_ACCOUNT,
PREF_LOG_ROTATE,
PREF_LOG_SHARED,
PREF_OTR_LOG,