diff options
author | James Booth <boothj5@gmail.com> | 2013-01-26 22:25:00 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-01-26 22:25:00 +0000 |
commit | 43841ee9eec525c52b60d40537781f9f286e053e (patch) | |
tree | 301a3a175bac0c76fad83879ba9aeab7b043bef0 /src/accounts.c | |
parent | a8d80ef5586b2590c1bcd060beea0250d2a5eac5 (diff) | |
download | profani-tty-43841ee9eec525c52b60d40537781f9f286e053e.tar.gz |
Added resource to ProfAccount
Diffstat (limited to 'src/accounts.c')
-rw-r--r-- | src/accounts.c | 31 |
1 files changed, 18 insertions, 13 deletions
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(); |