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