about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-31 01:51:48 +0000
committerJames Booth <boothj5@gmail.com>2013-01-31 01:51:48 +0000
commit4886577302d393a9b354cedf3b5fdc0a210127c8 (patch)
tree9c8609a4e7a4b51e418cf12804c299a95b9977a9
parent8a69fffd86d01222cdb2b69d434ee6e15a6eeda3 (diff)
parent8c03bb97764725ed676ce4414aadd9fda441622b (diff)
downloadprofani-tty-4886577302d393a9b354cedf3b5fdc0a210127c8.tar.gz
Merge branch 'master' into priority
-rw-r--r--src/accounts.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/accounts.c b/src/accounts.c
index 8a765b9a..662ef254 100644
--- a/src/accounts.c
+++ b/src/accounts.c
@@ -39,6 +39,8 @@ static GKeyFile *accounts;
 static Autocomplete all_ac;
 static Autocomplete enabled_ac;
 
+static gchar *string_keys[] = {"jid", "server", "resource", "presence.last", "presence.login"};
+
 static void _fix_legacy_accounts(const char * const account_name);
 static void _save_accounts(void);
 
@@ -129,6 +131,8 @@ accounts_add(const char *account_name, const char *altdomain)
         if (altdomain != NULL) {
             g_key_file_set_string(accounts, account_name, "server", altdomain);
         }
+        g_key_file_set_string(accounts, account_name, "presence.last", "online");
+        g_key_file_set_string(accounts, account_name, "presence.login", "online");
 
         _save_accounts();
         autocomplete_add(all_ac, strdup(account_name));
@@ -254,22 +258,13 @@ accounts_rename(const char * const account_name, const char * const new_name)
     g_key_file_set_boolean(accounts, new_name, "enabled",
         g_key_file_get_boolean(accounts, account_name, "enabled", NULL));
 
-    char *jid = g_key_file_get_string(accounts, account_name, "jid", NULL);
-    if (jid != NULL) {
-        g_key_file_set_string(accounts, new_name, "jid", jid);
-        free(jid);
-    }
-
-    char *server = g_key_file_get_string(accounts, account_name, "server", NULL);
-    if (server != NULL) {
-        g_key_file_set_string(accounts, new_name, "server", server);
-        free(server);
-    }
-
-    char *resource = g_key_file_get_string(accounts, account_name, "resource", NULL);
-    if (resource != NULL) {
-        g_key_file_set_string(accounts, new_name, "resource", resource);
-        free(resource);
+    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);
+        if (value != NULL) {
+            g_key_file_set_string(accounts, new_name, string_keys[i], value);
+            free(value);
+        }
     }
 
     g_key_file_remove_group(accounts, account_name, NULL);