about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/accounts.c31
-rw-r--r--src/config/accounts.h4
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/config/preferences.h3
4 files changed, 36 insertions, 6 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 4eb4b8e3..6bfc7bef 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -39,10 +39,12 @@ static GKeyFile *accounts;
 static Autocomplete all_ac;
 static Autocomplete enabled_ac;
 
+// used to rename account (copies properties to new account)
 static gchar *string_keys[] = {
     "jid",
     "server",
     "resource",
+    "password",
     "presence.last",
     "presence.login",
     "muc.service",
@@ -191,6 +193,14 @@ accounts_get_account(const char * const name)
             _save_accounts();
         }
 
+        gchar *password = g_key_file_get_string(accounts, name, "password", NULL);
+        if (password != NULL) {
+            account->password = strdup(password);
+            g_free(password);
+        } else {
+            account->password = NULL;
+        }
+
         account->enabled = g_key_file_get_boolean(accounts, name, "enabled", NULL);
 
         gchar *server = g_key_file_get_string(accounts, name, "server", NULL);
@@ -288,6 +298,7 @@ accounts_free_account(ProfAccount *account)
     if (account != NULL) {
         free(account->name);
         free(account->jid);
+        free(account->password);
         free(account->resource);
         free(account->server);
         free(account->last_presence);
@@ -339,16 +350,17 @@ accounts_rename(const char * const account_name, const char * const new_name)
         g_key_file_get_boolean(accounts, account_name, "enabled", NULL));
 
     g_key_file_set_integer(accounts, new_name, "priority.online",
-        g_key_file_get_boolean(accounts, account_name, "priority.online", NULL));
+        g_key_file_get_integer(accounts, account_name, "priority.online", NULL));
     g_key_file_set_integer(accounts, new_name, "priority.chat",
-        g_key_file_get_boolean(accounts, account_name, "priority.chat", NULL));
+        g_key_file_get_integer(accounts, account_name, "priority.chat", NULL));
     g_key_file_set_integer(accounts, new_name, "priority.away",
-        g_key_file_get_boolean(accounts, account_name, "priority.away", NULL));
+        g_key_file_get_integer(accounts, account_name, "priority.away", NULL));
     g_key_file_set_integer(accounts, new_name, "priority.xa",
-        g_key_file_get_boolean(accounts, account_name, "priority.xa", NULL));
+        g_key_file_get_integer(accounts, account_name, "priority.xa", NULL));
     g_key_file_set_integer(accounts, new_name, "priority.dnd",
-        g_key_file_get_boolean(accounts, account_name, "priority.dnd", NULL));
+        g_key_file_get_integer(accounts, account_name, "priority.dnd", NULL));
 
+    // copy other string properties
     int i;
     for (i = 0; i < ARRAY_SIZE(string_keys); i++) {
         char *value = g_key_file_get_string(accounts, account_name, string_keys[i], NULL);
@@ -423,6 +435,15 @@ accounts_set_resource(const char * const account_name, const char * const value)
 }
 
 void
+accounts_set_password(const char * const account_name, const char * const value)
+{
+    if (accounts_account_exists(account_name)) {
+        g_key_file_set_string(accounts, account_name, "password", value);
+        _save_accounts();
+    }
+}
+
+void
 accounts_set_muc_service(const char * const account_name, const char * const value)
 {
     if (accounts_account_exists(account_name)) {
diff --git a/src/config/accounts.h b/src/config/accounts.h
index 4c74a523..118b5c80 100644
--- a/src/config/accounts.h
+++ b/src/config/accounts.h
@@ -23,11 +23,14 @@
 #ifndef ACCOUNTS_H
 #define ACCOUNTS_H
 
+#define MAX_PASSWORD_SIZE 64
+
 #include "common.h"
 
 typedef struct prof_account_t {
     gchar *name;
     gchar *jid;
+    gchar *password;
     gchar *resource;
     gchar *server;
     gchar *last_presence;
@@ -62,6 +65,7 @@ gboolean accounts_account_exists(const char * const account_name);
 void accounts_set_jid(const char * const account_name, const char * const value);
 void accounts_set_server(const char * const account_name, const char * const value);
 void accounts_set_resource(const char * const account_name, const char * const value);
+void accounts_set_password(const char * const account_name, const char * const value);
 void accounts_set_muc_service(const char * const account_name, const char * const value);
 void accounts_set_muc_nick(const char * const account_name, const char * const value);
 void accounts_set_last_presence(const char * const account_name, const char * const value);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 1d417e41..18f10dee 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -309,6 +309,8 @@ _get_group(preference_t pref)
         case PREF_AUTOAWAY_MODE:
         case PREF_AUTOAWAY_MESSAGE:
             return "presence";
+        case PREF_CONNECT_ACCOUNT:
+            return "connection";
         default:
             return NULL;
     }
@@ -361,6 +363,8 @@ _get_key(preference_t pref)
             return "autoaway.mode";
         case PREF_AUTOAWAY_MESSAGE:
             return "autoaway.message";
+        case PREF_CONNECT_ACCOUNT:
+            return "account";
         default:
             return NULL;
     }
diff --git a/src/config/preferences.h b/src/config/preferences.h
index cb1f9204..5affe002 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -56,7 +56,8 @@ typedef enum {
     PREF_GRLOG,
     PREF_AUTOAWAY_CHECK,
     PREF_AUTOAWAY_MODE,
-    PREF_AUTOAWAY_MESSAGE
+    PREF_AUTOAWAY_MESSAGE,
+    PREF_CONNECT_ACCOUNT
 } preference_t;
 
 void prefs_load(void);