diff options
author | James Booth <boothj5@gmail.com> | 2015-04-23 21:56:48 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-04-23 21:56:48 +0100 |
commit | bc9e6b79cdc246f7e97f6ddff7ea81474a698b05 (patch) | |
tree | 388ed13935bbb56a81ba0861a3ae874bdacef2ff /src/command/commands.c | |
parent | ba286c54ef69f9adde8bd8aa4d54857dee5414cb (diff) | |
download | profani-tty-bc9e6b79cdc246f7e97f6ddff7ea81474a698b05.tar.gz |
Tidied account login
Diffstat (limited to 'src/command/commands.c')
-rw-r--r-- | src/command/commands.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index 9ca70ef0..2d9e1dfc 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -203,17 +203,42 @@ cmd_connect(gchar **args, struct cmd_help_t help) char *jid; g_free(def); + // connect with account ProfAccount *account = accounts_get_account(lower); if (account) { - jid = account_create_full_jid(account); - gboolean res = client_connect_account(account, &conn_status); - if (!res) { - g_free(lower); - return TRUE; + // use password if set + if (account->password) { + conn_status = client_connect_account(account); + + // use eval_password if set + } else if (account->eval_password) { + gboolean res = account_eval_password(account); + if (res) { + conn_status = client_connect_account(account); + free(account->password); + account->password = NULL; + } else { + cons_show("Error evaluating password, see logs for details."); + g_free(lower); + return TRUE; + } + + // no account password setting, prompt + } else { + account->password = ui_ask_password(); + conn_status = client_connect_account(account); + free(account->password); + account->password = NULL; } + + jid = account_create_full_jid(account); + + // connect with JID } else { jid = strdup(lower); - conn_status = client_connect_jid(jid, altdomain, port); + char *passwd = ui_ask_password(); + conn_status = client_connect_jid(jid, passwd, altdomain, port); + free(passwd); } if (conn_status == JABBER_DISCONNECTED) { |