mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added /account set command, set server or jid
This commit is contained in:
parent
c80383e298
commit
8415f57b32
@ -218,6 +218,31 @@ accounts_rename(const char * const account_name, const char * const new_name)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
accounts_account_exists(const char * const account_name)
|
||||
{
|
||||
return g_key_file_has_group(accounts, 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();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
accounts_set_server(const char * const account_name, const char * const value)
|
||||
{
|
||||
if (accounts_account_exists(account_name)) {
|
||||
g_key_file_set_string(accounts, account_name, "server", value);
|
||||
_save_accounts();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_save_accounts(void)
|
||||
{
|
||||
|
@ -43,5 +43,8 @@ gboolean accounts_enable(const char * const name);
|
||||
gboolean accounts_disable(const char * const name);
|
||||
gboolean accounts_rename(const char * const account_name,
|
||||
const char * const new_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);
|
||||
|
||||
#endif
|
||||
|
@ -1048,6 +1048,32 @@ _cmd_account(gchar **args, struct cmd_help_t help)
|
||||
cons_show("");
|
||||
}
|
||||
}
|
||||
} else if (strcmp(command, "set") == 0) {
|
||||
if (g_strv_length(args) != 4) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
} else {
|
||||
char *account_name = args[1];
|
||||
char *property = args[2];
|
||||
char *value = args[3];
|
||||
|
||||
if (!accounts_account_exists(account_name)) {
|
||||
cons_show("Account %s doesn't exist");
|
||||
cons_show("");
|
||||
} else {
|
||||
if (strcmp(property, "jid") == 0) {
|
||||
accounts_set_jid(account_name, value);
|
||||
cons_show("Updated jid for account %s: %s", account_name, value);
|
||||
cons_show("");
|
||||
} else if (strcmp(property, "server") == 0) {
|
||||
accounts_set_server(account_name, value);
|
||||
cons_show("Updated server for account %s: %s", account_name, value);
|
||||
cons_show("");
|
||||
} else {
|
||||
cons_show("Invalid property: %s", property);
|
||||
cons_show("");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cons_show("");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user