From e6aae167f2c650028e702f933a85b44be03f5de0 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 9 Jul 2017 19:03:10 +0200 Subject: account: move password prompt to module --- src/account.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/account.c b/src/account.c index 8f10940..1b2e468 100644 --- a/src/account.c +++ b/src/account.c @@ -386,16 +386,8 @@ int account_alloc(struct account **accp, const char *sipaddr) goto out; /* optional password prompt */ - if (!pl_isset(&acc->laddr.uri.password)) { - (void)re_printf("Please enter password for %r@%r: ", - &acc->luri.user, &acc->luri.host); + if (pl_isset(&acc->laddr.uri.password)) { - /* TODO: move interactive code away from CORE, to a module */ - err = ui_password_prompt(&acc->auth_pass); - if (err) - goto out; - } - else { err = re_sdprintf(&acc->auth_pass, "%H", uri_password_unescape, &acc->laddr.uri.password); @@ -433,6 +425,20 @@ int account_alloc(struct account **accp, const char *sipaddr) } +int account_set_auth_pass(struct account *acc, const char *pass) +{ + if (!acc) + return EINVAL; + + acc->auth_pass = mem_deref(acc->auth_pass); + + if (pass) + return str_dup(&acc->auth_pass, pass); + + return 0; +} + + /** * Sets the displayed name. Pass null in dname to disable display name * @@ -539,6 +545,19 @@ const char *account_auth_user(const struct account *acc) } +/** + * Get the SIP authentication password of an account + * + * @param acc User-Agent account + * + * @return Authentication password + */ +const char *account_auth_pass(const struct account *acc) +{ + return acc ? acc->auth_pass : NULL; +} + + /** * Get the outbound SIP server of an account * -- cgit v1.2.3