about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-27 20:34:56 +0000
committerJames Booth <boothj5@gmail.com>2013-01-27 20:34:56 +0000
commitf6176b322b471dc577cb9d78c08c8ddd0bf397a7 (patch)
tree920ca6cd0ca36987c0c2fab34caef94fc51d036a /src
parent972ca34d4b45f8a34997d480dec9cdcd39bae811 (diff)
downloadprofani-tty-f6176b322b471dc577cb9d78c08c8ddd0bf397a7.tar.gz
Added /account set <account> resource <value>
Diffstat (limited to 'src')
-rw-r--r--src/accounts.c9
-rw-r--r--src/accounts.h1
-rw-r--r--src/command.c11
3 files changed, 19 insertions, 2 deletions
diff --git a/src/accounts.c b/src/accounts.c
index 286f135b..14851bef 100644
--- a/src/accounts.c
+++ b/src/accounts.c
@@ -291,6 +291,15 @@ 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)
+{
+    if (accounts_account_exists(account_name)) {
+        g_key_file_set_string(accounts, account_name, "resource", value);
+        _save_accounts();
+    }
+}
+
 static void
 _fix_legacy_accounts(const char * const account_name)
 {
diff --git a/src/accounts.h b/src/accounts.h
index e37f81eb..7839cee2 100644
--- a/src/accounts.h
+++ b/src/accounts.h
@@ -49,5 +49,6 @@ gboolean accounts_rename(const char * const account_name,
 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);
 
 #endif
diff --git a/src/command.c b/src/command.c
index 00260c93..50913c6c 100644
--- a/src/command.c
+++ b/src/command.c
@@ -199,12 +199,14 @@ static struct cmd_t main_commands[] =
           "set account property value : Set 'property' of 'account' to 'value'.",
           "",
           "The 'property' may be one of.",
-          "jid    : The Jabber ID of the account, the account name will be used if this property is not set.",
-          "server : The chat service server, if different to the domain part of the JID.",
+          "jid      : The Jabber ID of the account, the account name will be used if this property is not set.",
+          "server   : The chat service server, if different to the domain part of the JID.",
+          "resource : The resource to be used.",
           "",
           "Example : /account add work",
           "        : /account set work jid myuser@mycompany.com",
           "        : /account set work server talk.google.com",
+          "        : /account set work resource desktop",
           "        : /account rename work gtalk",
           "",
           "To log in to this account: '/connect gtalk'",
@@ -1142,6 +1144,7 @@ _cmd_account(gchar **args, struct cmd_help_t help)
                         accounts_set_jid(account_name, jid->barejid);
                         cons_show("Updated jid for account %s: %s", account_name, jid->barejid);
                         if (jid->resourcepart != NULL) {
+                            accounts_set_resource(account_name, jid->resourcepart);
                             cons_show("Updated resource for account %s: %s", account_name, jid->resourcepart);
                         }
                         cons_show("");
@@ -1151,6 +1154,10 @@ _cmd_account(gchar **args, struct cmd_help_t help)
                     accounts_set_server(account_name, value);
                     cons_show("Updated server for account %s: %s", account_name, value);
                     cons_show("");
+                } else if (strcmp(property, "resource") == 0) {
+                    accounts_set_resource(account_name, value);
+                    cons_show("Updated resource for account %s: %s", account_name, value);
+                    cons_show("");
                 } else {
                     cons_show("Invalid property: %s", property);
                     cons_show("");