diff options
author | James Booth <boothj5@gmail.com> | 2013-12-16 01:11:36 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-12-16 01:11:36 +0000 |
commit | 95d08db2925dbaabf5ff88323554ba1afd1fc1cf (patch) | |
tree | de13ecab5eaeec7f582df003981e1fe2b94b89ab /src | |
parent | 2470f642c73a7b13181bf51a6f3c2ee126e9e733 (diff) | |
parent | 52f6ad6fe19149a351fba673aa378508cd7c0558 (diff) | |
download | profani-tty-95d08db2925dbaabf5ff88323554ba1afd1fc1cf.tar.gz |
Merge branch 'master' into otr
Conflicts: src/command/commands.c
Diffstat (limited to 'src')
-rw-r--r-- | src/command/commands.c | 28 | ||||
-rw-r--r-- | src/config/accounts.c | 10 | ||||
-rw-r--r-- | src/config/accounts.h | 1 | ||||
-rw-r--r-- | src/ui/core.c | 13 | ||||
-rw-r--r-- | src/ui/ui.h | 1 |
5 files changed, 29 insertions, 24 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index 5babefe8..147ccf42 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -45,7 +45,6 @@ #include "xmpp/xmpp.h" #include "xmpp/bookmark.h" -static char * _ask_password(void); static void _update_presence(const resource_presence_t presence, const char * const show, gchar **args); static gboolean _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help, @@ -74,19 +73,15 @@ cmd_connect(gchar **args, struct cmd_help_t help) ProfAccount *account = accounts_get_account(lower); if (account != NULL) { - if (account->resource != NULL) { - jid = create_fulljid(account->jid, account->resource); - } else { - jid = strdup(account->jid); - } - + jid = accounts_create_full_jid(account); if (account->password == NULL) { - account->password = _ask_password(); + account->password = ui_ask_password(); } cons_show("Connecting with account %s as %s", account->name, jid); conn_status = jabber_connect_with_account(account); + accounts_free_account(account); } else { - char *passwd = _ask_password(); + char *passwd = ui_ask_password(); jid = strdup(lower); cons_show("Connecting as %s", jid); conn_status = jabber_connect_with_details(jid, passwd, altdomain); @@ -99,7 +94,6 @@ cmd_connect(gchar **args, struct cmd_help_t help) log_debug("Connection attempt for %s failed", jid); } - accounts_free_account(account); free(jid); result = TRUE; @@ -2267,20 +2261,6 @@ cmd_otr(gchar **args, struct cmd_help_t help) #endif } - -// helper function that asks the user for a password and saves it in passwd -static char * -_ask_password(void) { - char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1)); - status_bar_get_password(); - status_bar_refresh(); - inp_block(); - inp_get_password(passwd); - inp_non_block(); - - return passwd; -} - // helper function for status change commands static void _update_presence(const resource_presence_t resource_presence, diff --git a/src/config/accounts.c b/src/config/accounts.c index 0422a991..6431cd9e 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -292,6 +292,16 @@ accounts_get_account(const char * const name) } } +char * +accounts_create_full_jid(ProfAccount *account) +{ + if (account->resource != NULL) { + return create_fulljid(account->jid, account->resource); + } else { + return strdup(account->jid); + } +} + void accounts_free_account(ProfAccount *account) { diff --git a/src/config/accounts.h b/src/config/accounts.h index 96289952..caa8e84c 100644 --- a/src/config/accounts.h +++ b/src/config/accounts.h @@ -81,5 +81,6 @@ void accounts_set_priority_all(const char * const account_name, const gint value gint accounts_get_priority_for_presence_type(const char * const account_name, resource_presence_t presence_type); void accounts_clear_password(const char * const account_name); +char * accounts_create_full_jid(ProfAccount *account); #endif diff --git a/src/ui/core.c b/src/ui/core.c index 507cfb02..1ff41b7d 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1330,6 +1330,19 @@ ui_win_unread(int index) } } +char * +ui_ask_password(void) +{ + char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1)); + status_bar_get_password(); + status_bar_refresh(); + inp_block(); + inp_get_password(passwd); + inp_non_block(); + + return passwd; +} + static void _ui_draw_win_title(void) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 5ec4debd..f6bb98ac 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -80,6 +80,7 @@ char * ui_recipient(int index); void ui_close_win(int index); gboolean ui_win_exists(int index); int ui_win_unread(int index); +char * ui_ask_password(void); // ui events void ui_contact_typing(const char * const from); |