about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/commands.c31
-rw-r--r--src/config/preferences.c3
-rw-r--r--src/config/preferences.h1
3 files changed, 35 insertions, 0 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index fc95f521..ba6b44fc 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -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);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index baf3e853..4ae4e91d 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -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:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index d2a3fafd..5193455a 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -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,