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("");