1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added /account set <account> resource <value>

This commit is contained in:
James Booth 2013-01-27 20:34:56 +00:00
parent 972ca34d4b
commit f6176b322b
3 changed files with 19 additions and 2 deletions

View File

@ -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 static void
_fix_legacy_accounts(const char * const account_name) _fix_legacy_accounts(const char * const account_name)
{ {

View File

@ -49,5 +49,6 @@ gboolean accounts_rename(const char * const account_name,
gboolean accounts_account_exists(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_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_server(const char * const account_name, const char * const value);
void accounts_set_resource(const char * const account_name, const char * const value);
#endif #endif

View File

@ -199,12 +199,14 @@ static struct cmd_t main_commands[] =
"set account property value : Set 'property' of 'account' to 'value'.", "set account property value : Set 'property' of 'account' to 'value'.",
"", "",
"The 'property' may be one of.", "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.", "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.", "server : The chat service server, if different to the domain part of the JID.",
"resource : The resource to be used.",
"", "",
"Example : /account add work", "Example : /account add work",
" : /account set work jid myuser@mycompany.com", " : /account set work jid myuser@mycompany.com",
" : /account set work server talk.google.com", " : /account set work server talk.google.com",
" : /account set work resource desktop",
" : /account rename work gtalk", " : /account rename work gtalk",
"", "",
"To log in to this account: '/connect 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); accounts_set_jid(account_name, jid->barejid);
cons_show("Updated jid for account %s: %s", account_name, jid->barejid); cons_show("Updated jid for account %s: %s", account_name, jid->barejid);
if (jid->resourcepart != NULL) { 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("Updated resource for account %s: %s", account_name, jid->resourcepart);
} }
cons_show(""); cons_show("");
@ -1151,6 +1154,10 @@ _cmd_account(gchar **args, struct cmd_help_t help)
accounts_set_server(account_name, value); accounts_set_server(account_name, value);
cons_show("Updated server for account %s: %s", account_name, value); cons_show("Updated server for account %s: %s", account_name, value);
cons_show(""); 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 { } else {
cons_show("Invalid property: %s", property); cons_show("Invalid property: %s", property);
cons_show(""); cons_show("");