From 5cca57f6fb02154b4966725ee602210611ef4b92 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 27 Jan 2013 18:10:30 +0000 Subject: [PATCH] Renamed account_add_login -> account_add, added comments --- src/accounts.c | 15 ++++++--------- src/accounts.h | 2 +- src/command.c | 2 +- src/profanity.c | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/accounts.c b/src/accounts.c index 717c2635..f054be2d 100644 --- a/src/accounts.c +++ b/src/accounts.c @@ -135,13 +135,15 @@ accounts_reset_enabled_search(void) } void -accounts_add_login(const char *account_name, const char *altdomain) +accounts_add(const char *account_name, const char *altdomain) { + // assume account name is barejid, use default resource const char *barejid = account_name; - const char *resource = NULL; + const char *resource = "profanity"; + // check if account name contains resourcepart and split + // into barejid and resourcepart if so Jid *jid = jid_create(account_name); - if (jid != NULL) { barejid = jid->barejid; resource = jid->resourcepart; @@ -151,12 +153,7 @@ accounts_add_login(const char *account_name, const char *altdomain) if (!g_key_file_has_group(accounts, account_name)) { g_key_file_set_boolean(accounts, account_name, "enabled", TRUE); g_key_file_set_string(accounts, account_name, "jid", barejid); - if (resource != NULL) { - g_key_file_set_string(accounts, account_name, "resource", resource); - } else { - g_key_file_set_string(accounts, account_name, "resource", "profanity"); - } - + g_key_file_set_string(accounts, account_name, "resource", resource); if (altdomain != NULL) { g_key_file_set_string(accounts, account_name, "server", altdomain); } diff --git a/src/accounts.h b/src/accounts.h index 327df62e..e37f81eb 100644 --- a/src/accounts.h +++ b/src/accounts.h @@ -38,7 +38,7 @@ char * accounts_find_all(char *prefix); char * accounts_find_enabled(char *prefix); void accounts_reset_all_search(void); void accounts_reset_enabled_search(void); -void accounts_add_login(const char *jid, const char *altdomain); +void accounts_add(const char *jid, const char *altdomain); gchar** accounts_get_list(void); ProfAccount* accounts_get_account(const char * const name); void accounts_free_account(ProfAccount *account); diff --git a/src/command.c b/src/command.c index 4c05b47e..0ad2ad15 100644 --- a/src/command.c +++ b/src/command.c @@ -1079,7 +1079,7 @@ _cmd_account(gchar **args, struct cmd_help_t help) if (account_name == NULL) { cons_show("Usage: %s", help.usage); } else { - accounts_add_login(account_name, NULL); + accounts_add(account_name, NULL); cons_show("Account created."); cons_show(""); } diff --git a/src/profanity.c b/src/profanity.c index 47707595..839d6e53 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -224,7 +224,7 @@ prof_handle_login_success(const char *jid, const char *altdomain) status_bar_print_message(jid); status_bar_refresh(); - accounts_add_login(jid, altdomain); + accounts_add(jid, altdomain); } void