From 552d88b931341b035548923b8e099bd25741064c Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 23 Oct 2014 23:07:27 +0100 Subject: Added /account clear [account] server --- src/config/accounts.c | 10 ++++++++++ src/config/accounts.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src/config') diff --git a/src/config/accounts.c b/src/config/accounts.c index 0bea55b4..fffb45e1 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -440,6 +440,15 @@ _accounts_clear_password(const char * const account_name) } } +static void +_accounts_clear_server(const char * const account_name) +{ + if (accounts_account_exists(account_name)) { + g_key_file_remove_key(accounts, account_name, "server", NULL); + _save_accounts(); + } +} + static void _accounts_clear_otr(const char * const account_name) { @@ -862,6 +871,7 @@ accounts_init_module(void) accounts_set_priority_all = _accounts_set_priority_all; accounts_get_priority_for_presence_type = _accounts_get_priority_for_presence_type; accounts_clear_password = _accounts_clear_password; + accounts_clear_server = _accounts_clear_server; accounts_clear_otr = _accounts_clear_otr; accounts_add_otr_policy = _accounts_add_otr_policy; } diff --git a/src/config/accounts.h b/src/config/accounts.h index 299fdf0b..a16c0cfb 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -78,6 +78,7 @@ void (*accounts_set_priority_all)(const char * const account_name, const gint va gint (*accounts_get_priority_for_presence_type)(const char * const account_name, resource_presence_t presence_type); void (*accounts_clear_password)(const char * const account_name); +void (*accounts_clear_server)(const char * const account_name); void (*accounts_clear_otr)(const char * const account_name); void (*accounts_add_otr_policy)(const char * const account_name, const char * const contact_jid, const char * const policy); -- cgit 1.4.1-2-gfad0 From 84765969e0cab6da881dfecc6dee7de7a038f80c Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 23 Oct 2014 23:12:15 +0100 Subject: Added /account clear [account] port --- src/command/command.c | 1 + src/command/commands.c | 4 ++++ src/config/accounts.c | 10 ++++++++++ src/config/accounts.h | 1 + 4 files changed, 16 insertions(+) (limited to 'src/config') diff --git a/src/command/command.c b/src/command/command.c index b8daa7eb..b6fd572c 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1195,6 +1195,7 @@ cmd_init(void) account_clear_ac = autocomplete_new(); autocomplete_add(account_clear_ac, "password"); autocomplete_add(account_clear_ac, "server"); + autocomplete_add(account_clear_ac, "port"); autocomplete_add(account_clear_ac, "otr"); close_ac = autocomplete_new(); diff --git a/src/command/commands.c b/src/command/commands.c index eb361b3e..fa0a423e 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -366,6 +366,10 @@ cmd_account(gchar **args, struct cmd_help_t help) accounts_clear_server(account_name); cons_show("Removed server for account %s", account_name); cons_show(""); + } else if (strcmp(property, "port") == 0) { + accounts_clear_port(account_name); + cons_show("Removed port for account %s", account_name); + cons_show(""); } else if (strcmp(property, "otr") == 0) { accounts_clear_otr(account_name); cons_show("OTR policy removed for account %s", account_name); diff --git a/src/config/accounts.c b/src/config/accounts.c index fffb45e1..00cfba18 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -449,6 +449,15 @@ _accounts_clear_server(const char * const account_name) } } +static void +_accounts_clear_port(const char * const account_name) +{ + if (accounts_account_exists(account_name)) { + g_key_file_remove_key(accounts, account_name, "port", NULL); + _save_accounts(); + } +} + static void _accounts_clear_otr(const char * const account_name) { @@ -872,6 +881,7 @@ accounts_init_module(void) accounts_get_priority_for_presence_type = _accounts_get_priority_for_presence_type; accounts_clear_password = _accounts_clear_password; accounts_clear_server = _accounts_clear_server; + accounts_clear_port = _accounts_clear_port; accounts_clear_otr = _accounts_clear_otr; accounts_add_otr_policy = _accounts_add_otr_policy; } diff --git a/src/config/accounts.h b/src/config/accounts.h index a16c0cfb..97c125eb 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -79,6 +79,7 @@ gint (*accounts_get_priority_for_presence_type)(const char * const account_name, resource_presence_t presence_type); void (*accounts_clear_password)(const char * const account_name); void (*accounts_clear_server)(const char * const account_name); +void (*accounts_clear_port)(const char * const account_name); void (*accounts_clear_otr)(const char * const account_name); void (*accounts_add_otr_policy)(const char * const account_name, const char * const contact_jid, const char * const policy); -- cgit 1.4.1-2-gfad0