From 43841ee9eec525c52b60d40537781f9f286e053e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 26 Jan 2013 22:25:00 +0000 Subject: Added resource to ProfAccount --- src/accounts.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/accounts.c') diff --git a/src/accounts.c b/src/accounts.c index f2340300..f15d02c0 100644 --- a/src/accounts.c +++ b/src/accounts.c @@ -27,6 +27,7 @@ #include "accounts.h" #include "autocomplete.h" +#include "common.h" #include "files.h" #include "jid.h" #include "log.h" @@ -176,6 +177,12 @@ accounts_get_account(const char * const name) } else { account->server = NULL; } + gchar *resource = g_key_file_get_string(accounts, name, "resource", NULL); + if (resource != NULL) { + account->resource = strdup(resource); + } else { + account->resource = NULL; + } return account; } @@ -185,19 +192,11 @@ void accounts_free_account(ProfAccount *account) { if (account != NULL) { - if (account->name != NULL) { - free(account->name); - account->name = NULL; - } - if (account->jid != NULL) { - free(account->jid); - account->jid = NULL; - } - if (account->server != NULL) { - free(account->server); - account->server = NULL; - } - account = NULL; + FREE_SET_NULL(account->name); + FREE_SET_NULL(account->jid); + FREE_SET_NULL(account->resource); + FREE_SET_NULL(account->server); + FREE_SET_NULL(account); } } @@ -253,6 +252,12 @@ accounts_rename(const char * const account_name, const char * const new_name) free(server); } + char *resource = g_key_file_get_string(accounts, account_name, "resource", NULL); + if (resource != NULL) { + g_key_file_set_string(accounts, new_name, "resource", resource); + free(resource); + } + g_key_file_remove_group(accounts, account_name, NULL); _save_accounts(); -- cgit 1.4.1-2-gfad0