summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-07-09 19:03:10 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-07-09 19:03:10 +0200
commite6aae167f2c650028e702f933a85b44be03f5de0 (patch)
treecdb0c099da6e913e835f0dd3f5efe61ceae324f4 /src
parent40c4d6517707cee05fe0f2cfa3efc76bac962f29 (diff)
account: move password prompt to module
Diffstat (limited to 'src')
-rw-r--r--src/account.c37
1 files changed, 28 insertions, 9 deletions
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
*
@@ -540,6 +546,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
*
* @param acc User-Agent account