diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 1999-12-18 07:01:48 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 1999-12-18 07:01:48 +0000 |
commit | 8a317c03a2bf05b95e939bff76e48e06e93a1777 (patch) | |
tree | 4330d2a970481cdd4f9b929248ccdf11036365df /apps | |
parent | 53b26418053e05bd30974b1d336167f90860e85b (diff) |
Version 0.1.1 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@141 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/app_dial.c | 50 | ||||
-rwxr-xr-x | apps/app_voicemail.c | 10 |
2 files changed, 41 insertions, 19 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 021f0d7a8..a8070e6fc 100755 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -3,7 +3,7 @@ * * Trivial application to dial a channel * - * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC + * Copyright (C) 1999, Mark Spencer * * Mark Spencer <markster@linux-support.net> * @@ -17,6 +17,7 @@ #include <asterisk/pbx.h> #include <asterisk/options.h> #include <asterisk/module.h> +#include <asterisk/translate.h> #include <stdlib.h> #include <errno.h> #include <unistd.h> @@ -205,6 +206,8 @@ static int bridge_call(struct ast_channel *chan, struct ast_channel *peer, int a if (chan->state != AST_STATE_UP) if (ast_answer(chan)) return -1; + peer->appl = "Bridged Call"; + peer->data = chan->name; cs[0] = chan; cs[1] = peer; for (/* ever */;;) { @@ -214,7 +217,9 @@ static int bridge_call(struct ast_channel *chan, struct ast_channel *peer, int a continue; } f = ast_read(who); - if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) + if (!f || ((f->frametype == AST_FRAME_CONTROL) && + ((f->subclass == AST_CONTROL_HANGUP) || + (f->subclass == AST_CONTROL_BUSY)))) return -1; if ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_DTMF)) { @@ -281,9 +286,11 @@ static int dial_exec(struct ast_channel *chan, void *data) struct localuser *u; char *info, *peers, *timeout, *tech, *number, *rest, *cur; struct localuser *outgoing=NULL, *tmp; - struct ast_channel *peer; + struct ast_channel *peer, *npeer; int to; int allowredir=0; + char numsubst[AST_MAX_EXTENSION]; + char *newnum; if (!data) { ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout)\n"); @@ -292,8 +299,9 @@ static int dial_exec(struct ast_channel *chan, void *data) LOCAL_USER_ADD(u); - /* Parse our arguments */ - info = strdup((char *)data); + /* Parse our arguments XXX Check for failure XXX */ + info = malloc(strlen((char *)data) + AST_MAX_EXTENSION); + strncpy(info, (char *)data, strlen((char *)data) + AST_MAX_EXTENSION); peers = strtok(info, "|"); if (!peers) { ast_log(LOG_WARNING, "Dial argument takes format (technology1/number1&technology2/number2...|optional timeout)\n"); @@ -305,11 +313,11 @@ static int dial_exec(struct ast_channel *chan, void *data) cur = strtok(rest, "&"); /* Remember where to start next time */ rest = strtok(NULL, "\128"); - /* Get a technology/number pair */ + /* Get a technology/[device:]number pair */ tech = strtok(cur, "/"); number = strtok(NULL, "&"); if (!number) { - ast_log(LOG_WARNING, "Dial argument takes format (technology1/number1&technology2/number2...|optional timeout)\n"); + ast_log(LOG_WARNING, "Dial argument takes format (technology1/[device:]number1&technology2/[device:]number2...|optional timeout)\n"); goto out; } tmp = malloc(sizeof(struct localuser)); @@ -318,36 +326,39 @@ static int dial_exec(struct ast_channel *chan, void *data) goto out; } tmp->allowredirect = 1; + strncpy(numsubst, number, sizeof(numsubst)); /* If we're dialing by extension, look at the extension to know what to dial */ - if (!strcasecmp(number, "BYEXTENSION")) { - if (option_debug) - ast_log(LOG_DEBUG, "Dialing by extension %s\n", chan->exten); - number = chan->exten; + if ((newnum = strstr(numsubst, "BYEXTENSION"))) { + snprintf(newnum, sizeof(numsubst) - (newnum - numsubst), "%s", chan->exten); /* By default, if we're dialing by extension, don't permit redirecting */ tmp->allowredirect = 0; + if (option_debug) + ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst); } /* Request the peer */ - tmp->chan = ast_request(tech, chan->format, number); + tmp->chan = ast_request(tech, chan->format, numsubst); if (!tmp->chan) { /* If we can't, just go on to the next call */ ast_log(LOG_WARNING, "Unable to create channel of type '%s'\n", tech); free(tmp); continue; } + tmp->chan->appl = "AppDial"; + tmp->chan->data = "(Outgoing Line)"; /* Place the call, but don't wait on the answer */ - res = ast_call(tmp->chan, number, 0); + res = ast_call(tmp->chan, numsubst, 0); if (res) { /* Again, keep going even if there's an error */ if (option_debug) ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res); else if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", number); + ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", numsubst); ast_hangup(tmp->chan); free(tmp); continue; } else if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", number); + ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", numsubst); /* Put them in the list of outgoing thingies... We're ready now. XXX If we're forcibly removed, these outgoing calls won't get hung up XXX */ @@ -376,7 +387,14 @@ static int dial_exec(struct ast_channel *chan, void *data) conversation. */ hanguptree(outgoing, peer); outgoing = NULL; - res = bridge_call(chan, peer, allowredir); + /* Build a translator if necessary */ + if (peer->format & chan->format) + npeer = peer; + else + npeer = ast_translator_create(peer, chan->format, AST_DIRECTION_BOTH); + res = bridge_call(chan, npeer, allowredir); + if (npeer != peer) + ast_translator_destroy(npeer); ast_hangup(peer); } out: diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index d32a0ef9d..f2893b3f6 100755 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3,7 +3,7 @@ * * Voicemail System (did you ever think it could be so easy?) * - * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC + * Copyright (C) 1999, Mark Spencer * * Mark Spencer <markster@linux-support.net> * @@ -153,7 +153,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent) ast_log(LOG_WARNING, "No such configuration file %s\n", VOICEMAIL_CONFIG); return -1; } - if ((copy = ast_variable_retrieve(cfg, chan->context, ext))) { + if ((copy = ast_variable_retrieve(cfg, NULL, ext))) { /* Make sure they have an entry in the config */ copy = strdup(copy); passwd = strtok(copy, ","); @@ -320,11 +320,15 @@ static int vm_execmain(struct ast_channel *chan, void *data) /* Prompt for, and read in the username */ if (ast_readstring(chan, username, sizeof(username), 2000, 5000, "#")) goto out; + if (!strlen(username)) { + res = 0; + goto out; + } if (ast_streamfile(chan, "vm-password")) goto out; if (ast_readstring(chan, password, sizeof(password), 2000, 5000, "#")) goto out; - copy = ast_variable_retrieve(cfg, chan->context, username); + copy = ast_variable_retrieve(cfg, NULL, username); if (copy) { copy = strdup(copy); strtok(copy, ","); |