about summary refs log tree commit diff stats
path: root/src/accounts.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-27 20:23:42 +0000
committerJames Booth <boothj5@gmail.com>2013-01-27 20:23:42 +0000
commit972ca34d4b45f8a34997d480dec9cdcd39bae811 (patch)
tree57abad987380c18a9ef67edf9bc87f3e98534663 /src/accounts.c
parentb9361542992118393fe6c39a8e0a2ec916696485 (diff)
downloadprofani-tty-972ca34d4b45f8a34997d480dec9cdcd39bae811.tar.gz
Refactored connecting, and reconnecting
The user either logs in with an account, in which case its name, and the
password is kept for reconnects. Or the user can login with a jid (and
server) which does not currently exist as a local account.  On success
an account is created, with the jid as the name.
Diffstat (limited to 'src/accounts.c')
-rw-r--r--src/accounts.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/accounts.c b/src/accounts.c
index 7454dfaa..286f135b 100644
--- a/src/accounts.c
+++ b/src/accounts.c
@@ -270,9 +270,15 @@ accounts_account_exists(const char * const account_name)
 void
 accounts_set_jid(const char * const account_name, const char * const value)
 {
-    if (accounts_account_exists(account_name)) {
-        g_key_file_set_string(accounts, account_name, "jid", value);
-        _save_accounts();
+    Jid *jid = jid_create(value);
+    if (jid != NULL) {
+        if (accounts_account_exists(account_name)) {
+            g_key_file_set_string(accounts, account_name, "jid", jid->barejid);
+            if (jid->resourcepart != NULL) {
+                g_key_file_set_string(accounts, account_name, "resource", jid->resourcepart);
+            }
+            _save_accounts();
+        }
     }
 }