about summary refs log tree commit diff stats
path: root/src/config/accounts.c
diff options
context:
space:
mode:
authorThorben Günther <admin@xenrox.net>2021-03-11 22:40:19 +0100
committerThorben Günther <admin@xenrox.net>2021-07-01 16:08:00 +0200
commit0fc3343d7538e5f5a3a2b21809219acf36baa3c6 (patch)
treec9e3cc0b6daf9d9898ce2c80f4541395227e4ac4 /src/config/accounts.c
parentaae252e1b54c147bcf9404031e7862c0e955f571 (diff)
downloadprofani-tty-0fc3343d7538e5f5a3a2b21809219acf36baa3c6.tar.gz
Restore last status string when connecting
Diffstat (limited to 'src/config/accounts.c')
-rw-r--r--src/config/accounts.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 6c876055..774adc0d 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -844,8 +844,6 @@ accounts_set_last_status(const char* const account_name, const char* const value
     if (accounts_account_exists(account_name)) {
         if (value) {
             g_key_file_set_string(accounts, account_name, "presence.laststatus", value);
-        } else {
-            g_key_file_remove_key(accounts, account_name, "presence.laststatus", NULL);
         }
         _save_accounts();
     }
@@ -952,6 +950,17 @@ accounts_get_login_presence(const char* const account_name)
     return result;
 }
 
+char*
+accounts_get_login_status(const char* const account_name)
+{
+    gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
+    gchar* status = NULL;
+    if (g_strcmp0(setting, "last") == 0) {
+        status = accounts_get_last_status(account_name);
+    }
+    return status;
+}
+
 static void
 _save_accounts(void)
 {