diff options
author | Lorenzo Mangani <lorenzo.mangani@gmail.com> | 2014-12-26 17:50:48 +0100 |
---|---|---|
committer | Lorenzo Mangani <lorenzo.mangani@gmail.com> | 2014-12-26 17:50:48 +0100 |
commit | fc9441e0354908120e48ce9ee8bde480c411a680 (patch) | |
tree | 4701f34d661ba13fcf11ff97eae69adb34b5c077 /modules | |
parent | e95e76d8b222c5433005ca6ad53407bcb51b58d7 (diff) |
New cmd R: Create User-Agent from command line (same format as config)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/account/account.c | 4 | ||||
-rw-r--r-- | modules/menu/menu.c | 55 |
2 files changed, 56 insertions, 3 deletions
diff --git a/modules/account/account.c b/modules/account/account.c index 9659bd0..4f87afe 100644 --- a/modules/account/account.c +++ b/modules/account/account.c @@ -65,7 +65,7 @@ static int account_write_template(const char *file) "[2001:df8:0:16:216:6fff:fe91:614c]:5070" ";transport=tcp>\n" "#\n" - "<sip:%s:%s@%s>\n", login, pass, domain); + "#<sip:%s:%s@%s>\n", login, pass, domain); if (f) (void)fclose(f); @@ -129,7 +129,7 @@ static int account_read_file(void) if (list_isempty(uag_list())) { warning("account: No SIP accounts found" - " -- check your config\n"); + " -- check your config or add an account using 'R' command\n"); return ENOENT; } diff --git a/modules/menu/menu.c b/modules/menu/menu.c index 32512ef..f87dada 100644 --- a/modules/menu/menu.c +++ b/modules/menu/menu.c @@ -302,6 +302,59 @@ static int cmd_hangup(struct re_printf *pf, void *unused) } +static int create_ua(struct re_printf *pf, void *arg) +{ + const struct cmd_arg *carg = arg; + struct le *le; + int err = 0; + + (void)pf; + + if (str_isset(carg->prm)) { + + mbuf_rewind(dialbuf); + (void)mbuf_write_str(dialbuf, carg->prm); + + (void)re_hprintf(pf, "Creating UA for %s ...\n", carg->prm); + err = ua_alloc(NULL, carg->prm); + + + } + else if (dialbuf->end > 0) { + + char *uri; + + dialbuf->pos = 0; + err = mbuf_strdup(dialbuf, &uri, dialbuf->end); + if (err) + return err; + + (void)re_hprintf(pf, "Creating UA for %s ...\n", uri); + err |= ua_alloc(NULL, uri); + + mem_deref(uri); + } + + for (le = list_head(uag_list()); le && !err; le = le->next) { + const struct ua *ua = le->data; + + err = re_hprintf(pf, "%s ", ua == uag_cur() ? ">" : " "); + err |= ua_print_status(pf, ua); + } + + err |= re_hprintf(pf, "\n"); + + + if (err) { + (void)re_hprintf(pf, "menu: create_ua failed: %m\n", err); + } + + + + return err; +} + + static int cmd_ua_next(struct re_printf *pf, void *unused) { (void)pf; @@ -364,7 +417,7 @@ static const struct cmd cmdv[] = { {0x1b, 0, "Hangup call", cmd_hangup }, {' ', 0, "Toggle UAs", cmd_ua_next }, {'g', 0, "Print configuration", cmd_config_print }, - + {'R', CMD_PRM, "Create User-Agent", create_ua }, {'#', CMD_PRM, NULL, dial_handler }, {'*', CMD_PRM, NULL, dial_handler }, {'0', CMD_PRM, NULL, dial_handler }, |