Version 0.1.12 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@450 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Mark Spencer 23 years ago
parent 2a2f2c2c04
commit c75c3e8bc2

@ -11,6 +11,7 @@
* the GNU General Public License * the GNU General Public License
*/ */
#include <asterisk/lock.h>
#include <asterisk/file.h> #include <asterisk/file.h>
#include <asterisk/logger.h> #include <asterisk/logger.h>
#include <asterisk/channel.h> #include <asterisk/channel.h>
@ -20,6 +21,7 @@
#include <asterisk/translate.h> #include <asterisk/translate.h>
#include <asterisk/say.h> #include <asterisk/say.h>
#include <asterisk/parking.h> #include <asterisk/parking.h>
#include <asterisk/musiconhold.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@ -39,7 +41,7 @@ static char *app = "Dial";
static char *synopsis = "Place an call and connect to the current channel"; static char *synopsis = "Place an call and connect to the current channel";
static char *descrip = static char *descrip =
" Dial(Technology/resource[&Technology2/resource2...][|timeout][|transfer]):\n" " Dial(Technology/resource[&Technology2/resource2...][|timeout][|options]):\n"
"Requests one or more channels and places specified outgoing calls on them.\n" "Requests one or more channels and places specified outgoing calls on them.\n"
"As soon as a channel answers, the Dial app will answer the originating\n" "As soon as a channel answers, the Dial app will answer the originating\n"
"channel (if it needs to be answered) and will bridge a call with the channel\n" "channel (if it needs to be answered) and will bridge a call with the channel\n"
@ -54,8 +56,11 @@ static char *descrip =
"no-answer).\n" "no-answer).\n"
" This application returns -1 if the originating channel hangs up, or if the\n" " This application returns -1 if the originating channel hangs up, or if the\n"
"call is bridged and either of the parties in the bridge terminate the call.\n" "call is bridged and either of the parties in the bridge terminate the call.\n"
"The transfer string may contain a 't' to allow the called user transfer a\n" "The option string may contain zero or more of the following characters:\n"
"call or 'T' to allow the calling user to transfer the call.\n" " 't' -- allow the called user transfer the calling user\n"
" 'T' -- to allow the calling user to transfer the call.\n"
" 'r' -- indicate ringing to the calling party, pass no audio until answered.\n"
" 'm' -- provide hold music to the calling party until answered.\n"
" In addition to transferring the call, a call may be parked and then picked\n" " In addition to transferring the call, a call may be parked and then picked\n"
"up by another user.\n"; "up by another user.\n";
@ -67,6 +72,8 @@ struct localuser {
struct ast_channel *chan; struct ast_channel *chan;
int stillgoing; int stillgoing;
int allowredirect; int allowredirect;
int ringbackonly;
int musiconhold;
struct localuser *next; struct localuser *next;
}; };
@ -101,6 +108,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
struct ast_channel *watchers[MAX]; struct ast_channel *watchers[MAX];
int pos; int pos;
int single; int single;
int moh=0;
int ringind=0;
struct ast_channel *winner; struct ast_channel *winner;
single = (outgoing && !outgoing->next); single = (outgoing && !outgoing->next);
@ -110,6 +119,16 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
ast_channel_make_compatible(outgoing->chan, in); ast_channel_make_compatible(outgoing->chan, in);
} }
if (outgoing) {
moh = outgoing->musiconhold;
ringind = outgoing->ringbackonly;
if (outgoing->musiconhold) {
ast_moh_start(in, NULL);
} else if (outgoing->ringbackonly) {
ast_indicate(in, AST_CONTROL_RINGING);
}
}
while(*to && !peer) { while(*to && !peer) {
o = outgoing; o = outgoing;
found = -1; found = -1;
@ -186,10 +205,12 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
default: default:
ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
} }
} else if (single && (f->frametype == AST_FRAME_VOICE)) { } else if (single && (f->frametype == AST_FRAME_VOICE) &&
!(outgoing->ringbackonly || outgoing->musiconhold)) {
if (ast_write(in, f)) if (ast_write(in, f))
ast_log(LOG_WARNING, "Unable to forward frame\n"); ast_log(LOG_WARNING, "Unable to forward frame\n");
} else if (single && (f->frametype == AST_FRAME_IMAGE)) { } else if (single && (f->frametype == AST_FRAME_IMAGE) &&
!(outgoing->ringbackonly || outgoing->musiconhold)) {
if (ast_write(in, f)) if (ast_write(in, f))
ast_log(LOG_WARNING, "Unable to forward image\n"); ast_log(LOG_WARNING, "Unable to forward image\n");
} }
@ -217,6 +238,12 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
if (!*to && (option_verbose > 2)) if (!*to && (option_verbose > 2))
ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig); ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig);
} }
if (moh) {
ast_moh_stop(in);
} else if (ringind) {
ast_indicate(in, -1);
}
return peer; return peer;
} }
@ -290,10 +317,15 @@ static int dial_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
goto out; goto out;
} }
if (transfer && (strchr(transfer, 't'))) memset(tmp, 0, sizeof(struct localuser));
if (transfer) {
if (strchr(transfer, 't'))
tmp->allowredirect = 1; tmp->allowredirect = 1;
else if (strchr(transfer, 'r'))
tmp->allowredirect = 0; tmp->ringbackonly = 1;
if (strchr(transfer, 'm'))
tmp->musiconhold = 1;
}
strncpy(numsubst, number, sizeof(numsubst)-1); strncpy(numsubst, number, sizeof(numsubst)-1);
/* If we're dialing by extension, look at the extension to know what to dial */ /* If we're dialing by extension, look at the extension to know what to dial */
if ((newnum = strstr(numsubst, "BYEXTENSION"))) { if ((newnum = strstr(numsubst, "BYEXTENSION"))) {

Loading…
Cancel
Save