mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
whitespace fixes only.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103249 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
@@ -126,19 +126,19 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
int betweenWordsSilence = dfltBetweenWordsSilence;
|
int betweenWordsSilence = dfltBetweenWordsSilence;
|
||||||
int maximumNumberOfWords = dfltMaximumNumberOfWords;
|
int maximumNumberOfWords = dfltMaximumNumberOfWords;
|
||||||
int silenceThreshold = dfltSilenceThreshold;
|
int silenceThreshold = dfltSilenceThreshold;
|
||||||
int maximumWordLength = dfltMaximumWordLength;
|
int maximumWordLength = dfltMaximumWordLength;
|
||||||
int maxWaitTimeForFrame = dfltMaxWaitTimeForFrame;
|
int maxWaitTimeForFrame = dfltMaxWaitTimeForFrame;
|
||||||
|
|
||||||
AST_DECLARE_APP_ARGS(args,
|
AST_DECLARE_APP_ARGS(args,
|
||||||
AST_APP_ARG(argInitialSilence);
|
AST_APP_ARG(argInitialSilence);
|
||||||
AST_APP_ARG(argGreeting);
|
AST_APP_ARG(argGreeting);
|
||||||
AST_APP_ARG(argAfterGreetingSilence);
|
AST_APP_ARG(argAfterGreetingSilence);
|
||||||
AST_APP_ARG(argTotalAnalysisTime);
|
AST_APP_ARG(argTotalAnalysisTime);
|
||||||
AST_APP_ARG(argMinimumWordLength);
|
AST_APP_ARG(argMinimumWordLength);
|
||||||
AST_APP_ARG(argBetweenWordsSilence);
|
AST_APP_ARG(argBetweenWordsSilence);
|
||||||
AST_APP_ARG(argMaximumNumberOfWords);
|
AST_APP_ARG(argMaximumNumberOfWords);
|
||||||
AST_APP_ARG(argSilenceThreshold);
|
AST_APP_ARG(argSilenceThreshold);
|
||||||
AST_APP_ARG(argMaximumWordLength);
|
AST_APP_ARG(argMaximumWordLength);
|
||||||
);
|
);
|
||||||
|
|
||||||
ast_verb(3, "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, chan->readformat);
|
ast_verb(3, "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, chan->readformat);
|
||||||
@@ -163,8 +163,8 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
maximumNumberOfWords = atoi(args.argMaximumNumberOfWords);
|
maximumNumberOfWords = atoi(args.argMaximumNumberOfWords);
|
||||||
if (!ast_strlen_zero(args.argSilenceThreshold))
|
if (!ast_strlen_zero(args.argSilenceThreshold))
|
||||||
silenceThreshold = atoi(args.argSilenceThreshold);
|
silenceThreshold = atoi(args.argSilenceThreshold);
|
||||||
if (!ast_strlen_zero(args.argMaximumWordLength))
|
if (!ast_strlen_zero(args.argMaximumWordLength))
|
||||||
maximumWordLength = atoi(args.argMaximumWordLength);
|
maximumWordLength = atoi(args.argMaximumWordLength);
|
||||||
} else {
|
} else {
|
||||||
ast_debug(1, "AMD using the default parameters.\n");
|
ast_debug(1, "AMD using the default parameters.\n");
|
||||||
}
|
}
|
||||||
@@ -253,16 +253,16 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
ast_verb(3, "AMD: Channel [%s]. Changed state to STATE_IN_SILENCE\n", chan->name);
|
ast_verb(3, "AMD: Channel [%s]. Changed state to STATE_IN_SILENCE\n", chan->name);
|
||||||
}
|
}
|
||||||
/* Find words less than word duration */
|
/* Find words less than word duration */
|
||||||
if (consecutiveVoiceDuration < minimumWordLength && consecutiveVoiceDuration > 0){
|
if (consecutiveVoiceDuration < minimumWordLength && consecutiveVoiceDuration > 0){
|
||||||
ast_verb(3, "AMD: Channel [%s]. Short Word Duration: %d\n", chan->name, consecutiveVoiceDuration);
|
ast_verb(3, "AMD: Channel [%s]. Short Word Duration: %d\n", chan->name, consecutiveVoiceDuration);
|
||||||
}
|
}
|
||||||
currentState = STATE_IN_SILENCE;
|
currentState = STATE_IN_SILENCE;
|
||||||
consecutiveVoiceDuration = 0;
|
consecutiveVoiceDuration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inInitialSilence == 1 && silenceDuration >= initialSilence) {
|
if (inInitialSilence == 1 && silenceDuration >= initialSilence) {
|
||||||
ast_verb(3, "AMD: Channel [%s]. ANSWERING MACHINE: silenceDuration:%d initialSilence:%d\n",
|
ast_verb(3, "AMD: Channel [%s]. ANSWERING MACHINE: silenceDuration:%d initialSilence:%d\n",
|
||||||
chan->name, silenceDuration, initialSilence);
|
chan->name, silenceDuration, initialSilence);
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
strcpy(amdStatus , "MACHINE");
|
strcpy(amdStatus , "MACHINE");
|
||||||
sprintf(amdCause , "INITIALSILENCE-%d-%d", silenceDuration, initialSilence);
|
sprintf(amdCause , "INITIALSILENCE-%d-%d", silenceDuration, initialSilence);
|
||||||
@@ -272,7 +272,7 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
if (silenceDuration >= afterGreetingSilence && inGreeting == 1) {
|
if (silenceDuration >= afterGreetingSilence && inGreeting == 1) {
|
||||||
ast_verb(3, "AMD: Channel [%s]. HUMAN: silenceDuration:%d afterGreetingSilence:%d\n",
|
ast_verb(3, "AMD: Channel [%s]. HUMAN: silenceDuration:%d afterGreetingSilence:%d\n",
|
||||||
chan->name, silenceDuration, afterGreetingSilence);
|
chan->name, silenceDuration, afterGreetingSilence);
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
strcpy(amdStatus , "HUMAN");
|
strcpy(amdStatus , "HUMAN");
|
||||||
sprintf(amdCause , "HUMAN-%d-%d", silenceDuration, afterGreetingSilence);
|
sprintf(amdCause , "HUMAN-%d-%d", silenceDuration, afterGreetingSilence);
|
||||||
@@ -283,7 +283,7 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
} else {
|
} else {
|
||||||
consecutiveVoiceDuration += framelength;
|
consecutiveVoiceDuration += framelength;
|
||||||
voiceDuration += framelength;
|
voiceDuration += framelength;
|
||||||
|
|
||||||
/* If I have enough consecutive voice to say that I am in a Word, I can only increment the
|
/* If I have enough consecutive voice to say that I am in a Word, I can only increment the
|
||||||
number of words if my previous state was Silence, which means that I moved into a word. */
|
number of words if my previous state was Silence, which means that I moved into a word. */
|
||||||
if (consecutiveVoiceDuration >= minimumWordLength && currentState == STATE_IN_SILENCE) {
|
if (consecutiveVoiceDuration >= minimumWordLength && currentState == STATE_IN_SILENCE) {
|
||||||
@@ -292,13 +292,13 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
previousState = currentState;
|
previousState = currentState;
|
||||||
currentState = STATE_IN_WORD;
|
currentState = STATE_IN_WORD;
|
||||||
}
|
}
|
||||||
if (consecutiveVoiceDuration >= maximumWordLength){
|
if (consecutiveVoiceDuration >= maximumWordLength){
|
||||||
ast_verb(3, "AMD: Channel [%s]. Maximum Word Length detected. [%d]\n", chan->name, consecutiveVoiceDuration);
|
ast_verb(3, "AMD: Channel [%s]. Maximum Word Length detected. [%d]\n", chan->name, consecutiveVoiceDuration);
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
strcpy(amdStatus , "MACHINE");
|
strcpy(amdStatus , "MACHINE");
|
||||||
sprintf(amdCause , "MAXWORDLENGTH-%d", consecutiveVoiceDuration);
|
sprintf(amdCause , "MAXWORDLENGTH-%d", consecutiveVoiceDuration);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (iWordsCount >= maximumNumberOfWords) {
|
if (iWordsCount >= maximumNumberOfWords) {
|
||||||
ast_verb(3, "AMD: Channel [%s]. ANSWERING MACHINE: iWordsCount:%d\n", chan->name, iWordsCount);
|
ast_verb(3, "AMD: Channel [%s]. ANSWERING MACHINE: iWordsCount:%d\n", chan->name, iWordsCount);
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
@@ -307,7 +307,7 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
res = 1;
|
res = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inGreeting == 1 && voiceDuration >= greeting) {
|
if (inGreeting == 1 && voiceDuration >= greeting) {
|
||||||
ast_verb(3, "AMD: Channel [%s]. ANSWERING MACHINE: voiceDuration:%d greeting:%d\n", chan->name, voiceDuration, greeting);
|
ast_verb(3, "AMD: Channel [%s]. ANSWERING MACHINE: voiceDuration:%d greeting:%d\n", chan->name, voiceDuration, greeting);
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
@@ -316,13 +316,13 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
|
|||||||
res = 1;
|
res = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (voiceDuration >= minimumWordLength ) {
|
if (voiceDuration >= minimumWordLength ) {
|
||||||
if (silenceDuration > 0)
|
if (silenceDuration > 0)
|
||||||
ast_verb(3, "AMD: Channel [%s]. Detected Talk, previous silence duration: %d\n", chan->name, silenceDuration);
|
ast_verb(3, "AMD: Channel [%s]. Detected Talk, previous silence duration: %d\n", chan->name, silenceDuration);
|
||||||
silenceDuration = 0;
|
silenceDuration = 0;
|
||||||
}
|
}
|
||||||
if (consecutiveVoiceDuration >= minimumWordLength && inGreeting == 0){
|
if (consecutiveVoiceDuration >= minimumWordLength && inGreeting == 0) {
|
||||||
/* Only go in here once to change the greeting flag when we detect the 1st word */
|
/* Only go in here once to change the greeting flag when we detect the 1st word */
|
||||||
if (silenceDuration > 0)
|
if (silenceDuration > 0)
|
||||||
ast_verb(3, "AMD: Channel [%s]. Before Greeting Time: silenceDuration: %d voiceDuration: %d\n", chan->name, silenceDuration, voiceDuration);
|
ast_verb(3, "AMD: Channel [%s]. Before Greeting Time: silenceDuration: %d voiceDuration: %d\n", chan->name, silenceDuration, voiceDuration);
|
||||||
@@ -401,7 +401,7 @@ static int load_config(int reload)
|
|||||||
dfltMaximumNumberOfWords = atoi(var->value);
|
dfltMaximumNumberOfWords = atoi(var->value);
|
||||||
} else if (!strcasecmp(var->name, "maximum_word_length")) {
|
} else if (!strcasecmp(var->name, "maximum_word_length")) {
|
||||||
dfltMaximumWordLength = atoi(var->value);
|
dfltMaximumWordLength = atoi(var->value);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "%s: Cat:%s. Unknown keyword %s at line %d of amd.conf\n",
|
ast_log(LOG_WARNING, "%s: Cat:%s. Unknown keyword %s at line %d of amd.conf\n",
|
||||||
app, cat, var->name, var->lineno);
|
app, cat, var->name, var->lineno);
|
||||||
@@ -416,8 +416,8 @@ static int load_config(int reload)
|
|||||||
|
|
||||||
ast_verb(3, "AMD defaults: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
|
ast_verb(3, "AMD defaults: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
|
||||||
"totalAnalysisTime [%d] minimumWordLength [%d] betweenWordsSilence [%d] maximumNumberOfWords [%d] silenceThreshold [%d] maximumWordLength [%d]\n",
|
"totalAnalysisTime [%d] minimumWordLength [%d] betweenWordsSilence [%d] maximumNumberOfWords [%d] silenceThreshold [%d] maximumWordLength [%d]\n",
|
||||||
dfltInitialSilence, dfltGreeting, dfltAfterGreetingSilence, dfltTotalAnalysisTime,
|
dfltInitialSilence, dfltGreeting, dfltAfterGreetingSilence, dfltTotalAnalysisTime,
|
||||||
dfltMinimumWordLength, dfltBetweenWordsSilence, dfltMaximumNumberOfWords, dfltSilenceThreshold, dfltMaximumWordLength);
|
dfltMinimumWordLength, dfltBetweenWordsSilence, dfltMaximumNumberOfWords, dfltSilenceThreshold, dfltMaximumWordLength);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -447,4 +447,4 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Answering Machine Detect
|
|||||||
.load = load_module,
|
.load = load_module,
|
||||||
.unload = unload_module,
|
.unload = unload_module,
|
||||||
.reload = reload,
|
.reload = reload,
|
||||||
);
|
);
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
* \brief Execute arbitrary authenticate commands
|
* \brief Execute arbitrary authenticate commands
|
||||||
*
|
*
|
||||||
* \author Mark Spencer <markster@digium.com>
|
* \author Mark Spencer <markster@digium.com>
|
||||||
*
|
*
|
||||||
* \ingroup applications
|
* \ingroup applications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
|
|||||||
AST_APP_ARG(options);
|
AST_APP_ARG(options);
|
||||||
AST_APP_ARG(maxdigits);
|
AST_APP_ARG(maxdigits);
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ast_strlen_zero(data)) {
|
if (ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "Authenticate requires an argument(password)\n");
|
ast_log(LOG_WARNING, "Authenticate requires an argument(password)\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -99,11 +99,11 @@ static int auth_exec(struct ast_channel *chan, void *data)
|
|||||||
if ((res = ast_answer(chan)))
|
if ((res = ast_answer(chan)))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
argcopy = ast_strdupa(data);
|
argcopy = ast_strdupa(data);
|
||||||
|
|
||||||
AST_STANDARD_APP_ARGS(arglist, argcopy);
|
AST_STANDARD_APP_ARGS(arglist, argcopy);
|
||||||
|
|
||||||
if (!ast_strlen_zero(arglist.options))
|
if (!ast_strlen_zero(arglist.options))
|
||||||
ast_app_parse_options(auth_app_options, &flags, NULL, arglist.options);
|
ast_app_parse_options(auth_app_options, &flags, NULL, arglist.options);
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
if (arglist.password[0] != '/') {
|
if (arglist.password[0] != '/') {
|
||||||
/* Compare against a fixed password */
|
/* Compare against a fixed password */
|
||||||
if (!strcmp(passwd, arglist.password))
|
if (!strcmp(passwd, arglist.password))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
|
|||||||
/* Compare against a file */
|
/* Compare against a file */
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char buf[256] = "", md5passwd[33] = "", *md5secret = NULL;
|
char buf[256] = "", md5passwd[33] = "", *md5secret = NULL;
|
||||||
|
|
||||||
if (!(f = fopen(arglist.password, "r"))) {
|
if (!(f = fopen(arglist.password, "r"))) {
|
||||||
ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", arglist.password, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", arglist.password, strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
@@ -198,7 +198,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((retries < 3) && !res) {
|
if ((retries < 3) && !res) {
|
||||||
if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE))
|
if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE))
|
||||||
ast_cdr_setaccount(chan, passwd);
|
ast_cdr_setaccount(chan, passwd);
|
||||||
if (!(res = ast_streamfile(chan, "auth-thankyou", chan->language)))
|
if (!(res = ast_streamfile(chan, "auth-thankyou", chan->language)))
|
||||||
res = ast_waitstream(chan, "");
|
res = ast_waitstream(chan, "");
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
*
|
*
|
||||||
* \brief Applications connected with CDR engine
|
* \brief Applications connected with CDR engine
|
||||||
*
|
*
|
||||||
* \author Martin Pycko <martinp@digium.com>
|
* \author Martin Pycko <martinp@digium.com>
|
||||||
@@ -32,7 +32,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
|
|
||||||
static char *nocdr_descrip =
|
static char *nocdr_descrip =
|
||||||
" NoCDR(): This application will tell Asterisk not to maintain a CDR for the\n"
|
" NoCDR(): This application will tell Asterisk not to maintain a CDR for the\n"
|
||||||
"current call.\n";
|
"current call.\n";
|
||||||
|
|
||||||
|
@@ -18,9 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
*
|
*
|
||||||
* \brief Check if Channel is Available
|
* \brief Check if Channel is Available
|
||||||
*
|
*
|
||||||
* \author Mark Spencer <markster@digium.com>
|
* \author Mark Spencer <markster@digium.com>
|
||||||
* \author James Golovich <james@gnuinter.net>
|
* \author James Golovich <james@gnuinter.net>
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ static char *app = "ChanIsAvail";
|
|||||||
|
|
||||||
static char *synopsis = "Check channel availability";
|
static char *synopsis = "Check channel availability";
|
||||||
|
|
||||||
static char *descrip =
|
static char *descrip =
|
||||||
" ChanIsAvail(Technology/resource[&Technology2/resource2...][,options]): \n"
|
" ChanIsAvail(Technology/resource[&Technology2/resource2...][,options]): \n"
|
||||||
"This application will check to see if any of the specified channels are\n"
|
"This application will check to see if any of the specified channels are\n"
|
||||||
"available.\n"
|
"available.\n"
|
||||||
@@ -75,7 +75,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
info = ast_strdupa(data);
|
info = ast_strdupa(data);
|
||||||
|
|
||||||
AST_STANDARD_APP_ARGS(args, info);
|
AST_STANDARD_APP_ARGS(args, info);
|
||||||
|
|
||||||
@@ -105,16 +105,16 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
|
|||||||
number++;
|
number++;
|
||||||
|
|
||||||
if (string_compare) {
|
if (string_compare) {
|
||||||
/* ast_parse_device_state checks for "SIP/1234" as a channel name.
|
/* ast_parse_device_state checks for "SIP/1234" as a channel name.
|
||||||
ast_device_state will ask the SIP driver for the channel state. */
|
ast_device_state will ask the SIP driver for the channel state. */
|
||||||
|
|
||||||
snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
|
snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
|
||||||
status = inuse = ast_parse_device_state(trychan);
|
status = inuse = ast_parse_device_state(trychan);
|
||||||
} else if (option_state) {
|
} else if (option_state) {
|
||||||
/* If the pbx says in use then don't bother trying further.
|
/* If the pbx says in use then don't bother trying further.
|
||||||
This is to permit testing if someone's on a call, even if the
|
This is to permit testing if someone's on a call, even if the
|
||||||
channel can permit more calls (ie callwaiting, sip calls, etc). */
|
channel can permit more calls (ie callwaiting, sip calls, etc). */
|
||||||
|
|
||||||
snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
|
snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
|
||||||
status = inuse = ast_device_state(trychan);
|
status = inuse = ast_device_state(trychan);
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
|
|
||||||
static char *app = "ChannelRedirect";
|
static char *app = "ChannelRedirect";
|
||||||
static char *synopsis = "Redirects given channel to a dialplan target.";
|
static char *synopsis = "Redirects given channel to a dialplan target.";
|
||||||
static char *descrip =
|
static char *descrip =
|
||||||
"ChannelRedirect(channel,[[context,]extension,]priority)\n"
|
"ChannelRedirect(channel,[[context,]extension,]priority)\n"
|
||||||
" Sends the specified channel to the specified extension priority\n";
|
" Sends the specified channel to the specified extension priority\n";
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */
|
#include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */
|
||||||
#include "asterisk/file.h"
|
#include "asterisk/file.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/audiohook.h"
|
#include "asterisk/audiohook.h"
|
||||||
@@ -50,7 +50,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
|
|
||||||
static const char *tdesc = "Listen to a channel, and optionally whisper into it";
|
static const char *tdesc = "Listen to a channel, and optionally whisper into it";
|
||||||
static const char *app_chan = "ChanSpy";
|
static const char *app_chan = "ChanSpy";
|
||||||
static const char *desc_chan =
|
static const char *desc_chan =
|
||||||
" ChanSpy([chanprefix][,options]): This application is used to listen to the\n"
|
" ChanSpy([chanprefix][,options]): This application is used to listen to the\n"
|
||||||
"audio from an Asterisk channel. This includes the audio coming in and\n"
|
"audio from an Asterisk channel. This includes the audio coming in and\n"
|
||||||
"out of the channel being spied on. If the 'chanprefix' parameter is specified,\n"
|
"out of the channel being spied on. If the 'chanprefix' parameter is specified,\n"
|
||||||
@@ -94,7 +94,7 @@ static const char *desc_chan =
|
|||||||
;
|
;
|
||||||
|
|
||||||
static const char *app_ext = "ExtenSpy";
|
static const char *app_ext = "ExtenSpy";
|
||||||
static const char *desc_ext =
|
static const char *desc_ext =
|
||||||
" ExtenSpy(exten[@context][,options]): This application is used to listen to the\n"
|
" ExtenSpy(exten[@context][,options]): This application is used to listen to the\n"
|
||||||
"audio from an Asterisk channel. This includes the audio coming in and\n"
|
"audio from an Asterisk channel. This includes the audio coming in and\n"
|
||||||
"out of the channel being spied on. Only channels created by outgoing calls for the\n"
|
"out of the channel being spied on. Only channels created by outgoing calls for the\n"
|
||||||
@@ -131,15 +131,15 @@ static const char *desc_ext =
|
|||||||
;
|
;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPTION_QUIET = (1 << 0), /* Quiet, no announcement */
|
OPTION_QUIET = (1 << 0), /* Quiet, no announcement */
|
||||||
OPTION_BRIDGED = (1 << 1), /* Only look at bridged calls */
|
OPTION_BRIDGED = (1 << 1), /* Only look at bridged calls */
|
||||||
OPTION_VOLUME = (1 << 2), /* Specify initial volume */
|
OPTION_VOLUME = (1 << 2), /* Specify initial volume */
|
||||||
OPTION_GROUP = (1 << 3), /* Only look at channels in group */
|
OPTION_GROUP = (1 << 3), /* Only look at channels in group */
|
||||||
OPTION_RECORD = (1 << 4),
|
OPTION_RECORD = (1 << 4),
|
||||||
OPTION_WHISPER = (1 << 5),
|
OPTION_WHISPER = (1 << 5),
|
||||||
OPTION_PRIVATE = (1 << 6), /* Private Whisper mode */
|
OPTION_PRIVATE = (1 << 6), /* Private Whisper mode */
|
||||||
OPTION_READONLY = (1 << 7), /* Don't mix the two channels */
|
OPTION_READONLY = (1 << 7), /* Don't mix the two channels */
|
||||||
OPTION_EXIT = (1 << 8), /* Exit to a valid single digit extension */
|
OPTION_EXIT = (1 << 8), /* Exit to a valid single digit extension */
|
||||||
OPTION_ENFORCED = (1 << 9), /* Enforced mode */
|
OPTION_ENFORCED = (1 << 9), /* Enforced mode */
|
||||||
} chanspy_opt_flags;
|
} chanspy_opt_flags;
|
||||||
|
|
||||||
@@ -184,11 +184,11 @@ static void spy_release(struct ast_channel *chan, void *data)
|
|||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spy_generate(struct ast_channel *chan, void *data, int len, int samples)
|
static int spy_generate(struct ast_channel *chan, void *data, int len, int samples)
|
||||||
{
|
{
|
||||||
struct chanspy_translation_helper *csth = data;
|
struct chanspy_translation_helper *csth = data;
|
||||||
struct ast_frame *f = NULL;
|
struct ast_frame *f = NULL;
|
||||||
|
|
||||||
ast_audiohook_lock(&csth->spy_audiohook);
|
ast_audiohook_lock(&csth->spy_audiohook);
|
||||||
if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
|
if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
|
||||||
/* Channel is already gone more than likely */
|
/* Channel is already gone more than likely */
|
||||||
@@ -199,10 +199,10 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl
|
|||||||
f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
|
f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
|
||||||
|
|
||||||
ast_audiohook_unlock(&csth->spy_audiohook);
|
ast_audiohook_unlock(&csth->spy_audiohook);
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ast_write(chan, f)) {
|
if (ast_write(chan, f)) {
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -219,10 +219,10 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl
|
|||||||
static struct ast_generator spygen = {
|
static struct ast_generator spygen = {
|
||||||
.alloc = spy_alloc,
|
.alloc = spy_alloc,
|
||||||
.release = spy_release,
|
.release = spy_release,
|
||||||
.generate = spy_generate,
|
.generate = spy_generate,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_audiohook *audiohook)
|
static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_audiohook *audiohook)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct ast_channel *peer = NULL;
|
struct ast_channel *peer = NULL;
|
||||||
@@ -232,13 +232,13 @@ static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, s
|
|||||||
res = ast_audiohook_attach(chan, audiohook);
|
res = ast_audiohook_attach(chan, audiohook);
|
||||||
|
|
||||||
if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
|
if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
|
||||||
ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
|
ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd,
|
static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd,
|
||||||
const struct ast_flags *flags, char *exitcontext)
|
const struct ast_flags *flags, char *exitcontext)
|
||||||
{
|
{
|
||||||
struct chanspy_translation_helper csth;
|
struct chanspy_translation_helper csth;
|
||||||
int running = 0, res, x = 0;
|
int running = 0, res, x = 0;
|
||||||
@@ -256,7 +256,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int
|
|||||||
memset(&csth, 0, sizeof(csth));
|
memset(&csth, 0, sizeof(csth));
|
||||||
|
|
||||||
ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");
|
ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");
|
||||||
|
|
||||||
if (start_spying(spyee, chan, &csth.spy_audiohook)) {
|
if (start_spying(spyee, chan, &csth.spy_audiohook)) {
|
||||||
ast_audiohook_destroy(&csth.spy_audiohook);
|
ast_audiohook_destroy(&csth.spy_audiohook);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -321,7 +321,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int
|
|||||||
running = -1;
|
running = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ast_test_flag(flags, OPTION_EXIT)) {
|
if (ast_test_flag(flags, OPTION_EXIT)) {
|
||||||
char tmp[2];
|
char tmp[2];
|
||||||
tmp[0] = res;
|
tmp[0] = res;
|
||||||
@@ -376,15 +376,15 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int
|
|||||||
ast_audiohook_destroy(&csth.spy_audiohook);
|
ast_audiohook_destroy(&csth.spy_audiohook);
|
||||||
|
|
||||||
ast_verb(2, "Done Spying on channel %s\n", name);
|
ast_verb(2, "Done Spying on channel %s\n", name);
|
||||||
|
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ast_channel *next_channel(const struct ast_channel *last, const char *spec,
|
static struct ast_channel *next_channel(const struct ast_channel *last, const char *spec,
|
||||||
const char *exten, const char *context)
|
const char *exten, const char *context)
|
||||||
{
|
{
|
||||||
struct ast_channel *this;
|
struct ast_channel *this;
|
||||||
|
|
||||||
redo:
|
redo:
|
||||||
if (!ast_strlen_zero(spec))
|
if (!ast_strlen_zero(spec))
|
||||||
this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
|
this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
|
||||||
@@ -404,8 +404,8 @@ static struct ast_channel *next_channel(const struct ast_channel *last, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
||||||
int volfactor, const int fd, const char *mygroup, const char *myenforced,
|
int volfactor, const int fd, const char *mygroup, const char *myenforced,
|
||||||
const char *spec, const char *exten, const char *context)
|
const char *spec, const char *exten, const char *context)
|
||||||
{
|
{
|
||||||
struct ast_channel *peer, *prev, *next;
|
struct ast_channel *peer, *prev, *next;
|
||||||
char nameprefix[AST_NAME_STRLEN];
|
char nameprefix[AST_NAME_STRLEN];
|
||||||
@@ -420,9 +420,9 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
|||||||
|
|
||||||
if (ast_test_flag(flags, OPTION_EXIT)) {
|
if (ast_test_flag(flags, OPTION_EXIT)) {
|
||||||
const char *c;
|
const char *c;
|
||||||
if ((c = pbx_builtin_getvar_helper(chan, "SPY_EXIT_CONTEXT")))
|
if ((c = pbx_builtin_getvar_helper(chan, "SPY_EXIT_CONTEXT")))
|
||||||
ast_copy_string(exitcontext, c, sizeof(exitcontext));
|
ast_copy_string(exitcontext, c, sizeof(exitcontext));
|
||||||
else if (!ast_strlen_zero(chan->macrocontext))
|
else if (!ast_strlen_zero(chan->macrocontext))
|
||||||
ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext));
|
ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext));
|
||||||
else
|
else
|
||||||
ast_copy_string(exitcontext, chan->context, sizeof(exitcontext));
|
ast_copy_string(exitcontext, chan->context, sizeof(exitcontext));
|
||||||
@@ -469,15 +469,15 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
|||||||
else
|
else
|
||||||
ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
|
ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset for the next loop around, unless overridden later */
|
/* reset for the next loop around, unless overridden later */
|
||||||
waitms = 100;
|
waitms = 100;
|
||||||
peer = prev = next = NULL;
|
peer = prev = next = NULL;
|
||||||
num_spyed_upon = 0;
|
num_spyed_upon = 0;
|
||||||
|
|
||||||
for (peer = next_channel(peer, spec, exten, context);
|
for (peer = next_channel(peer, spec, exten, context);
|
||||||
peer;
|
peer;
|
||||||
prev = peer, peer = next ? next : next_channel(peer, spec, exten, context), next = NULL) {
|
prev = peer, peer = next ? next : next_channel(peer, spec, exten, context), next = NULL) {
|
||||||
const char *group;
|
const char *group;
|
||||||
int igrp = !mygroup;
|
int igrp = !mygroup;
|
||||||
char *groups[25];
|
char *groups[25];
|
||||||
@@ -490,7 +490,7 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
|||||||
char *ext;
|
char *ext;
|
||||||
char *form_enforced;
|
char *form_enforced;
|
||||||
int ienf = !myenforced;
|
int ienf = !myenforced;
|
||||||
|
|
||||||
if (peer == prev)
|
if (peer == prev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -507,9 +507,9 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
|||||||
if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
|
if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
|
||||||
dup_group = ast_strdupa(group);
|
dup_group = ast_strdupa(group);
|
||||||
num_groups = ast_app_separate_args(dup_group, ':', groups,
|
num_groups = ast_app_separate_args(dup_group, ':', groups,
|
||||||
sizeof(groups) / sizeof(groups[0]));
|
sizeof(groups) / sizeof(groups[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x = 0; x < num_groups; x++) {
|
for (x = 0; x < num_groups; x++) {
|
||||||
if (!strcmp(mygroup, groups[x])) {
|
if (!strcmp(mygroup, groups[x])) {
|
||||||
igrp = 1;
|
igrp = 1;
|
||||||
@@ -517,33 +517,33 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!igrp)
|
if (!igrp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (myenforced) {
|
if (myenforced) {
|
||||||
|
|
||||||
/* We don't need to allocate more space than just the
|
/* We don't need to allocate more space than just the
|
||||||
length of (peer->name) for ext as we will cut the
|
length of (peer->name) for ext as we will cut the
|
||||||
channel name's ending before copying into ext */
|
channel name's ending before copying into ext */
|
||||||
|
|
||||||
ext = alloca(strlen(peer->name));
|
ext = alloca(strlen(peer->name));
|
||||||
|
|
||||||
form_enforced = alloca(strlen(myenforced) + 3);
|
form_enforced = alloca(strlen(myenforced) + 3);
|
||||||
|
|
||||||
strcpy(form_enforced, ":");
|
strcpy(form_enforced, ":");
|
||||||
strcat(form_enforced, myenforced);
|
strcat(form_enforced, myenforced);
|
||||||
strcat(form_enforced, ":");
|
strcat(form_enforced, ":");
|
||||||
|
|
||||||
buffer = ast_strdupa(peer->name);
|
buffer = ast_strdupa(peer->name);
|
||||||
|
|
||||||
if ((end = strchr(buffer, '-'))) {
|
if ((end = strchr(buffer, '-'))) {
|
||||||
*end++ = ':';
|
*end++ = ':';
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(ext, ":");
|
strcpy(ext, ":");
|
||||||
strcat(ext, buffer);
|
strcat(ext, buffer);
|
||||||
|
|
||||||
if (strcasestr(form_enforced, ext))
|
if (strcasestr(form_enforced, ext))
|
||||||
ienf = 1;
|
ienf = 1;
|
||||||
@@ -556,10 +556,10 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
|||||||
strncat(peer_name, peer->name, AST_NAME_STRLEN);
|
strncat(peer_name, peer->name, AST_NAME_STRLEN);
|
||||||
ptr = strchr(peer_name, '/');
|
ptr = strchr(peer_name, '/');
|
||||||
*ptr++ = '\0';
|
*ptr++ = '\0';
|
||||||
|
|
||||||
for (s = peer_name; s < ptr; s++)
|
for (s = peer_name; s < ptr; s++)
|
||||||
*s = tolower(*s);
|
*s = tolower(*s);
|
||||||
|
|
||||||
if (!ast_test_flag(flags, OPTION_QUIET)) {
|
if (!ast_test_flag(flags, OPTION_QUIET)) {
|
||||||
if (ast_fileexists(peer_name, NULL, NULL) != -1) {
|
if (ast_fileexists(peer_name, NULL, NULL) != -1) {
|
||||||
res = ast_streamfile(chan, peer_name, chan->language);
|
res = ast_streamfile(chan, peer_name, chan->language);
|
||||||
@@ -569,13 +569,13 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
|
|||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
res = ast_say_character_str(chan, peer_name, "", chan->language);
|
res = ast_say_character_str(chan, peer_name, "", chan->language);
|
||||||
if ((num = atoi(ptr)))
|
if ((num = atoi(ptr)))
|
||||||
ast_say_digits(chan, atoi(ptr), "", chan->language);
|
ast_say_digits(chan, atoi(ptr), "", chan->language);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitms = 5000;
|
waitms = 5000;
|
||||||
res = channel_spy(chan, peer, &volfactor, fd, flags, exitcontext);
|
res = channel_spy(chan, peer, &volfactor, fd, flags, exitcontext);
|
||||||
num_spyed_upon++;
|
num_spyed_upon++;
|
||||||
|
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
goto exit;
|
goto exit;
|
||||||
@@ -631,7 +631,7 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
|
|||||||
mygroup = opts[OPT_ARG_GROUP];
|
mygroup = opts[OPT_ARG_GROUP];
|
||||||
|
|
||||||
if (ast_test_flag(&flags, OPTION_RECORD) &&
|
if (ast_test_flag(&flags, OPTION_RECORD) &&
|
||||||
!(recbase = opts[OPT_ARG_RECORD]))
|
!(recbase = opts[OPT_ARG_RECORD]))
|
||||||
recbase = "chanspy";
|
recbase = "chanspy";
|
||||||
|
|
||||||
if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
|
if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
|
||||||
@@ -708,13 +708,13 @@ static int extenspy_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
if (args.options) {
|
if (args.options) {
|
||||||
char *opts[OPT_ARG_ARRAY_SIZE];
|
char *opts[OPT_ARG_ARRAY_SIZE];
|
||||||
|
|
||||||
ast_app_parse_options(spy_opts, &flags, opts, args.options);
|
ast_app_parse_options(spy_opts, &flags, opts, args.options);
|
||||||
if (ast_test_flag(&flags, OPTION_GROUP))
|
if (ast_test_flag(&flags, OPTION_GROUP))
|
||||||
mygroup = opts[OPT_ARG_GROUP];
|
mygroup = opts[OPT_ARG_GROUP];
|
||||||
|
|
||||||
if (ast_test_flag(&flags, OPTION_RECORD) &&
|
if (ast_test_flag(&flags, OPTION_RECORD) &&
|
||||||
!(recbase = opts[OPT_ARG_RECORD]))
|
!(recbase = opts[OPT_ARG_RECORD]))
|
||||||
recbase = "chanspy";
|
recbase = "chanspy";
|
||||||
|
|
||||||
if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
|
if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
|
||||||
|
@@ -17,14 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
*
|
*
|
||||||
* \brief Trivial application to control playback of a sound file
|
* \brief Trivial application to control playback of a sound file
|
||||||
*
|
*
|
||||||
* \author Mark Spencer <markster@digium.com>
|
* \author Mark Spencer <markster@digium.com>
|
||||||
*
|
*
|
||||||
* \ingroup applications
|
* \ingroup applications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
@@ -37,7 +37,7 @@ static const char *app = "ControlPlayback";
|
|||||||
|
|
||||||
static const char *synopsis = "Play a file with fast forward and rewind";
|
static const char *synopsis = "Play a file with fast forward and rewind";
|
||||||
|
|
||||||
static const char *descrip =
|
static const char *descrip =
|
||||||
" ControlPlayback(file[,skipms[,ff[,rew[,stop[,pause[,restart,options]]]]]]]):\n"
|
" ControlPlayback(file[,skipms[,ff[,rew[,stop[,pause[,restart,options]]]]]]]):\n"
|
||||||
"This application will play back the given filename. By default, the '*' key\n"
|
"This application will play back the given filename. By default, the '*' key\n"
|
||||||
"can be used to rewind, and the '#' key can be used to fast-forward.\n"
|
"can be used to rewind, and the '#' key can be used to fast-forward.\n"
|
||||||
@@ -71,7 +71,8 @@ enum {
|
|||||||
|
|
||||||
AST_APP_OPTIONS(cpb_opts, BEGIN_OPTIONS
|
AST_APP_OPTIONS(cpb_opts, BEGIN_OPTIONS
|
||||||
AST_APP_OPTION_ARG('o', OPT_OFFSET, OPT_ARG_OFFSET),
|
AST_APP_OPTION_ARG('o', OPT_OFFSET, OPT_ARG_OFFSET),
|
||||||
END_OPTIONS );
|
END_OPTIONS
|
||||||
|
);
|
||||||
|
|
||||||
static int is_on_phonepad(char key)
|
static int is_on_phonepad(char key)
|
||||||
{
|
{
|
||||||
@@ -148,7 +149,7 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
|
|||||||
args.restart = NULL;
|
args.restart = NULL;
|
||||||
|
|
||||||
if (args.options) {
|
if (args.options) {
|
||||||
ast_app_parse_options(cpb_opts, &opts, opt_args, args.options);
|
ast_app_parse_options(cpb_opts, &opts, opt_args, args.options);
|
||||||
if (ast_test_flag(&opts, OPT_OFFSET))
|
if (ast_test_flag(&opts, OPT_OFFSET))
|
||||||
offsetms = atol(opt_args[OPT_ARG_OFFSET]);
|
offsetms = atol(opt_args[OPT_ARG_OFFSET]);
|
||||||
}
|
}
|
||||||
|
@@ -59,9 +59,9 @@ static char *dt_synopsis = "Delete a family or keytree from the database";
|
|||||||
static int deltree_exec(struct ast_channel *chan, void *data)
|
static int deltree_exec(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
char *argv, *family, *keytree;
|
char *argv, *family, *keytree;
|
||||||
|
|
||||||
argv = ast_strdupa(data);
|
argv = ast_strdupa(data);
|
||||||
|
|
||||||
if (strchr(argv, '/')) {
|
if (strchr(argv, '/')) {
|
||||||
family = strsep(&argv, "/");
|
family = strsep(&argv, "/");
|
||||||
keytree = strsep(&argv, "\0");
|
keytree = strsep(&argv, "\0");
|
||||||
@@ -75,12 +75,12 @@ static int deltree_exec(struct ast_channel *chan, void *data)
|
|||||||
family = argv;
|
family = argv;
|
||||||
keytree = 0;
|
keytree = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keytree)
|
if (keytree)
|
||||||
ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree);
|
ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree);
|
||||||
else
|
else
|
||||||
ast_verb(3, "DBdeltree: family=%s\n", family);
|
ast_verb(3, "DBdeltree: family=%s\n", family);
|
||||||
|
|
||||||
if (ast_db_deltree(family, keytree))
|
if (ast_db_deltree(family, keytree))
|
||||||
ast_verb(3, "DBdeltree: Error deleting key from database.\n");
|
ast_verb(3, "DBdeltree: Error deleting key from database.\n");
|
||||||
|
|
||||||
@@ -91,14 +91,14 @@ static int del_exec(struct ast_channel *chan, void *data)
|
|||||||
{
|
{
|
||||||
char *argv, *family, *key;
|
char *argv, *family, *key;
|
||||||
static int deprecation_warning = 0;
|
static int deprecation_warning = 0;
|
||||||
|
|
||||||
if (!deprecation_warning) {
|
if (!deprecation_warning) {
|
||||||
deprecation_warning = 1;
|
deprecation_warning = 1;
|
||||||
ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n");
|
ast_log(LOG_WARNING, "The DBdel application has been deprecated in favor of the DB_DELETE dialplan function!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
argv = ast_strdupa(data);
|
argv = ast_strdupa(data);
|
||||||
|
|
||||||
if (strchr(argv, '/')) {
|
if (strchr(argv, '/')) {
|
||||||
family = strsep(&argv, "/");
|
family = strsep(&argv, "/");
|
||||||
key = strsep(&argv, "\0");
|
key = strsep(&argv, "\0");
|
||||||
@@ -112,7 +112,7 @@ static int del_exec(struct ast_channel *chan, void *data)
|
|||||||
} else {
|
} else {
|
||||||
ast_debug(1, "Ignoring, no parameters\n");
|
ast_debug(1, "Ignoring, no parameters\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ static int load_module(void)
|
|||||||
|
|
||||||
retval = ast_register_application(d_app, del_exec, d_synopsis, d_descrip);
|
retval = ast_register_application(d_app, del_exec, d_synopsis, d_descrip);
|
||||||
retval |= ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip);
|
retval |= ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
349
apps/app_dial.c
349
apps/app_dial.c
@@ -21,7 +21,7 @@
|
|||||||
* \brief dial() & retrydial() - Trivial application to dial a channel and send an URL on answer
|
* \brief dial() & retrydial() - Trivial application to dial a channel and send an URL on answer
|
||||||
*
|
*
|
||||||
* \author Mark Spencer <markster@digium.com>
|
* \author Mark Spencer <markster@digium.com>
|
||||||
*
|
*
|
||||||
* \ingroup applications
|
* \ingroup applications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#include "asterisk/paths.h" /* use ast_config_AST_DATA_DIR */
|
#include "asterisk/paths.h" /* use ast_config_AST_DATA_DIR */
|
||||||
#include "asterisk/lock.h"
|
#include "asterisk/lock.h"
|
||||||
#include "asterisk/file.h"
|
#include "asterisk/file.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
@@ -78,10 +78,10 @@ static char *descrip =
|
|||||||
"continue if no requested channels can be called, or if the timeout expires.\n\n"
|
"continue if no requested channels can be called, or if the timeout expires.\n\n"
|
||||||
" This application sets the following channel variables upon completion:\n"
|
" This application sets the following channel variables upon completion:\n"
|
||||||
" DIALEDTIME - This is the time from dialing a channel until when it\n"
|
" DIALEDTIME - This is the time from dialing a channel until when it\n"
|
||||||
" is disconnected.\n"
|
" is disconnected.\n"
|
||||||
" ANSWEREDTIME - This is the amount of time for actual call.\n"
|
" ANSWEREDTIME - This is the amount of time for actual call.\n"
|
||||||
" DIALSTATUS - This is the status of the call:\n"
|
" DIALSTATUS - This is the status of the call:\n"
|
||||||
" CHANUNAVAIL | CONGESTION | NOANSWER | BUSY | ANSWER | CANCEL\n"
|
" CHANUNAVAIL | CONGESTION | NOANSWER | BUSY | ANSWER | CANCEL\n"
|
||||||
" DONTCALL | TORTURE | INVALIDARGS\n"
|
" DONTCALL | TORTURE | INVALIDARGS\n"
|
||||||
" For the Privacy and Screening Modes, the DIALSTATUS variable will be set to\n"
|
" For the Privacy and Screening Modes, the DIALSTATUS variable will be set to\n"
|
||||||
"DONTCALL if the called party chooses to send the calling party to the 'Go Away'\n"
|
"DONTCALL if the called party chooses to send the calling party to the 'Go Away'\n"
|
||||||
@@ -121,7 +121,7 @@ static char *descrip =
|
|||||||
" the specified priority and the called party to the specified priority+1.\n"
|
" the specified priority and the called party to the specified priority+1.\n"
|
||||||
" Optionally, an extension, or extension and context may be specified. \n"
|
" Optionally, an extension, or extension and context may be specified. \n"
|
||||||
" Otherwise, the current extension is used. You cannot use any additional\n"
|
" Otherwise, the current extension is used. You cannot use any additional\n"
|
||||||
" action post answer options in conjunction with this option.\n"
|
" action post answer options in conjunction with this option.\n"
|
||||||
" h - Allow the called party to hang up by sending the '*' DTMF digit.\n"
|
" h - Allow the called party to hang up by sending the '*' DTMF digit.\n"
|
||||||
" H - Allow the calling party to hang up by hitting the '*' DTMF digit.\n"
|
" H - Allow the calling party to hang up by hitting the '*' DTMF digit.\n"
|
||||||
" i - Asterisk will ignore any forwarding requests it may receive on this\n"
|
" i - Asterisk will ignore any forwarding requests it may receive on this\n"
|
||||||
@@ -147,7 +147,7 @@ static char *descrip =
|
|||||||
" M(x[^arg]) - Execute the Macro for the *called* channel before connecting\n"
|
" M(x[^arg]) - Execute the Macro for the *called* channel before connecting\n"
|
||||||
" to the calling channel. Arguments can be specified to the Macro\n"
|
" to the calling channel. Arguments can be specified to the Macro\n"
|
||||||
" using '^' as a delimeter. The Macro can set the variable\n"
|
" using '^' as a delimeter. The Macro can set the variable\n"
|
||||||
" MACRO_RESULT to specify the following actions after the Macro is\n"
|
" MACRO_RESULT to specify the following actions after the Macro is\n"
|
||||||
" finished executing.\n"
|
" finished executing.\n"
|
||||||
" * ABORT Hangup both legs of the call.\n"
|
" * ABORT Hangup both legs of the call.\n"
|
||||||
" * CONGESTION Behave as if line congestion was encountered.\n"
|
" * CONGESTION Behave as if line congestion was encountered.\n"
|
||||||
@@ -186,7 +186,7 @@ static char *descrip =
|
|||||||
" r - Indicate ringing to the calling party. Pass no audio to the calling\n"
|
" r - Indicate ringing to the calling party. Pass no audio to the calling\n"
|
||||||
" party until the called channel has answered.\n"
|
" party until the called channel has answered.\n"
|
||||||
" S(x) - Hang up the call after 'x' seconds *after* the called party has\n"
|
" S(x) - Hang up the call after 'x' seconds *after* the called party has\n"
|
||||||
" answered the call.\n"
|
" answered the call.\n"
|
||||||
" t - Allow the called party to transfer the calling party by sending the\n"
|
" t - Allow the called party to transfer the calling party by sending the\n"
|
||||||
" DTMF sequence defined in features.conf.\n"
|
" DTMF sequence defined in features.conf.\n"
|
||||||
" T - Allow the calling party to transfer the called party by sending the\n"
|
" T - Allow the calling party to transfer the called party by sending the\n"
|
||||||
@@ -194,7 +194,7 @@ static char *descrip =
|
|||||||
" U(x[^arg]) - Execute via Gosub the routine 'x' for the *called* channel before connecting\n"
|
" U(x[^arg]) - Execute via Gosub the routine 'x' for the *called* channel before connecting\n"
|
||||||
" to the calling channel. Arguments can be specified to the Gosub\n"
|
" to the calling channel. Arguments can be specified to the Gosub\n"
|
||||||
" using '^' as a delimeter. The Gosub routine can set the variable\n"
|
" using '^' as a delimeter. The Gosub routine can set the variable\n"
|
||||||
" GOSUB_RESULT to specify the following actions after the Gosub returns.\n"
|
" GOSUB_RESULT to specify the following actions after the Gosub returns.\n"
|
||||||
" * ABORT Hangup both legs of the call.\n"
|
" * ABORT Hangup both legs of the call.\n"
|
||||||
" * CONGESTION Behave as if line congestion was encountered.\n"
|
" * CONGESTION Behave as if line congestion was encountered.\n"
|
||||||
" * BUSY Behave as if a busy signal was encountered.\n"
|
" * BUSY Behave as if a busy signal was encountered.\n"
|
||||||
@@ -214,7 +214,7 @@ static char *descrip =
|
|||||||
" the DTMF sequence defined for one-touch automixmonitor in features.conf\n"
|
" the DTMF sequence defined for one-touch automixmonitor in features.conf\n"
|
||||||
" X - Allow the calling party to enable recording of the call by sending\n"
|
" X - Allow the calling party to enable recording of the call by sending\n"
|
||||||
" the DTMF sequence defined for one-touch automixmonitor in features.conf\n";
|
" the DTMF sequence defined for one-touch automixmonitor in features.conf\n";
|
||||||
|
|
||||||
/* RetryDial App by Anthony Minessale II <anthmct@yahoo.com> Jan/2005 */
|
/* RetryDial App by Anthony Minessale II <anthmct@yahoo.com> Jan/2005 */
|
||||||
static char *rapp = "RetryDial";
|
static char *rapp = "RetryDial";
|
||||||
static char *rsynopsis = "Place a call, retrying on failure allowing optional exit extension.";
|
static char *rsynopsis = "Place a call, retrying on failure allowing optional exit extension.";
|
||||||
@@ -264,10 +264,10 @@ enum {
|
|||||||
OPT_CALLER_MIXMONITOR = (1 << 30),
|
OPT_CALLER_MIXMONITOR = (1 << 30),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DIAL_STILLGOING (1 << 31)
|
#define DIAL_STILLGOING (1 << 31)
|
||||||
#define DIAL_NOFORWARDHTML ((uint64_t)1 << 32) /* flags are now 64 bits, so keep it up! */
|
#define DIAL_NOFORWARDHTML ((uint64_t)1 << 32) /* flags are now 64 bits, so keep it up! */
|
||||||
#define OPT_CANCEL_ELSEWHERE ((uint64_t)1 << 33)
|
#define OPT_CANCEL_ELSEWHERE ((uint64_t)1 << 33)
|
||||||
#define OPT_PEER_H ((uint64_t)1 << 34)
|
#define OPT_PEER_H ((uint64_t)1 << 34)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPT_ARG_ANNOUNCE = 0,
|
OPT_ARG_ANNOUNCE = 0,
|
||||||
@@ -404,7 +404,7 @@ static void handle_cause(int cause, struct cause_args *num)
|
|||||||
s = (new_val); \
|
s = (new_val); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri)
|
static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri)
|
||||||
{
|
{
|
||||||
char rexten[2] = { exten, '\0' };
|
char rexten[2] = { exten, '\0' };
|
||||||
|
|
||||||
@@ -433,29 +433,29 @@ static const char *get_cid_name(char *name, int namelen, struct ast_channel *cha
|
|||||||
|
|
||||||
static void senddialevent(struct ast_channel *src, struct ast_channel *dst, const char *dialstring)
|
static void senddialevent(struct ast_channel *src, struct ast_channel *dst, const char *dialstring)
|
||||||
{
|
{
|
||||||
manager_event(EVENT_FLAG_CALL, "Dial",
|
manager_event(EVENT_FLAG_CALL, "Dial",
|
||||||
"SubEvent: Begin\r\n"
|
"SubEvent: Begin\r\n"
|
||||||
"Channel: %s\r\n"
|
"Channel: %s\r\n"
|
||||||
"Destination: %s\r\n"
|
"Destination: %s\r\n"
|
||||||
"CallerIDNum: %s\r\n"
|
"CallerIDNum: %s\r\n"
|
||||||
"CallerIDName: %s\r\n"
|
"CallerIDName: %s\r\n"
|
||||||
"UniqueID: %s\r\n"
|
"UniqueID: %s\r\n"
|
||||||
"DestUniqueID: %s\r\n"
|
"DestUniqueID: %s\r\n"
|
||||||
"Dialstring: %s\r\n",
|
"Dialstring: %s\r\n",
|
||||||
src->name, dst->name, S_OR(src->cid.cid_num, "<unknown>"),
|
src->name, dst->name, S_OR(src->cid.cid_num, "<unknown>"),
|
||||||
S_OR(src->cid.cid_name, "<unknown>"), src->uniqueid,
|
S_OR(src->cid.cid_name, "<unknown>"), src->uniqueid,
|
||||||
dst->uniqueid, dialstring ? dialstring : "");
|
dst->uniqueid, dialstring ? dialstring : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void senddialendevent(const struct ast_channel *src, const char *dialstatus)
|
static void senddialendevent(const struct ast_channel *src, const char *dialstatus)
|
||||||
{
|
{
|
||||||
manager_event(EVENT_FLAG_CALL, "Dial",
|
manager_event(EVENT_FLAG_CALL, "Dial",
|
||||||
"SubEvent: End\r\n"
|
"SubEvent: End\r\n"
|
||||||
"Channel: %s\r\n"
|
"Channel: %s\r\n"
|
||||||
"UniqueID: %s\r\n"
|
"UniqueID: %s\r\n"
|
||||||
"DialStatus: %s\r\n",
|
"DialStatus: %s\r\n",
|
||||||
src->name, src->uniqueid, dialstatus);
|
src->name, src->uniqueid, dialstatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* helper function for wait_for_answer()
|
* helper function for wait_for_answer()
|
||||||
@@ -503,7 +503,7 @@ static void do_forward(struct chanlist *o,
|
|||||||
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
||||||
}
|
}
|
||||||
if (!c) {
|
if (!c) {
|
||||||
ast_clear_flag64(o, DIAL_STILLGOING);
|
ast_clear_flag64(o, DIAL_STILLGOING);
|
||||||
handle_cause(cause, num);
|
handle_cause(cause, num);
|
||||||
} else {
|
} else {
|
||||||
char *new_cid_num, *new_cid_name;
|
char *new_cid_num, *new_cid_name;
|
||||||
@@ -513,7 +513,7 @@ static void do_forward(struct chanlist *o,
|
|||||||
if (ast_test_flag64(o, OPT_FORCECLID)) {
|
if (ast_test_flag64(o, OPT_FORCECLID)) {
|
||||||
new_cid_num = ast_strdup(S_OR(in->macroexten, in->exten));
|
new_cid_num = ast_strdup(S_OR(in->macroexten, in->exten));
|
||||||
new_cid_name = NULL; /* XXX no name ? */
|
new_cid_name = NULL; /* XXX no name ? */
|
||||||
src = c; /* XXX possible bug in previous code, which used 'winner' ? it may have changed */
|
src = c; /* XXX possible bug in previous code, which used 'winner' ? it may have changed */
|
||||||
} else {
|
} else {
|
||||||
new_cid_num = ast_strdup(in->cid.cid_num);
|
new_cid_num = ast_strdup(in->cid.cid_num);
|
||||||
new_cid_name = ast_strdup(in->cid.cid_name);
|
new_cid_name = ast_strdup(in->cid.cid_name);
|
||||||
@@ -530,7 +530,7 @@ static void do_forward(struct chanlist *o,
|
|||||||
S_REPLACE(c->cid.cid_rdnis, ast_strdup(S_OR(in->macroexten, in->exten)));
|
S_REPLACE(c->cid.cid_rdnis, ast_strdup(S_OR(in->macroexten, in->exten)));
|
||||||
if (ast_call(c, tmpchan, 0)) {
|
if (ast_call(c, tmpchan, 0)) {
|
||||||
ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
|
ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
|
||||||
ast_clear_flag64(o, DIAL_STILLGOING);
|
ast_clear_flag64(o, DIAL_STILLGOING);
|
||||||
ast_hangup(original);
|
ast_hangup(original);
|
||||||
c = o->chan = NULL;
|
c = o->chan = NULL;
|
||||||
num->nochan++;
|
num->nochan++;
|
||||||
@@ -549,11 +549,11 @@ static void do_forward(struct chanlist *o,
|
|||||||
|
|
||||||
/* argument used for some functions. */
|
/* argument used for some functions. */
|
||||||
struct privacy_args {
|
struct privacy_args {
|
||||||
int sentringing;
|
int sentringing;
|
||||||
int privdb_val;
|
int privdb_val;
|
||||||
char privcid[256];
|
char privcid[256];
|
||||||
char privintro[1024];
|
char privintro[1024];
|
||||||
char status[256];
|
char status[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
||||||
@@ -570,7 +570,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
#ifdef HAVE_EPOLL
|
#ifdef HAVE_EPOLL
|
||||||
struct chanlist *epollo;
|
struct chanlist *epollo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (single) {
|
if (single) {
|
||||||
/* Turn off hold music, etc */
|
/* Turn off hold music, etc */
|
||||||
ast_deactivate_generator(in);
|
ast_deactivate_generator(in);
|
||||||
@@ -581,11 +581,11 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
#ifdef HAVE_EPOLL
|
#ifdef HAVE_EPOLL
|
||||||
for (epollo = outgoing; epollo; epollo = epollo->next)
|
for (epollo = outgoing; epollo; epollo = epollo->next)
|
||||||
ast_poll_channel_add(in, epollo->chan);
|
ast_poll_channel_add(in, epollo->chan);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (*to && !peer) {
|
while (*to && !peer) {
|
||||||
struct chanlist *o;
|
struct chanlist *o;
|
||||||
int pos = 0; /* how many channels do we handle */
|
int pos = 0; /* how many channels do we handle */
|
||||||
int numlines = prestart;
|
int numlines = prestart;
|
||||||
struct ast_channel *winner;
|
struct ast_channel *winner;
|
||||||
struct ast_channel *watchers[AST_MAX_WATCHERS];
|
struct ast_channel *watchers[AST_MAX_WATCHERS];
|
||||||
@@ -597,11 +597,11 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
watchers[pos++] = o->chan;
|
watchers[pos++] = o->chan;
|
||||||
numlines++;
|
numlines++;
|
||||||
}
|
}
|
||||||
if (pos == 1) { /* only the input channel is available */
|
if (pos == 1) { /* only the input channel is available */
|
||||||
if (numlines == (num.busy + num.congestion + num.nochan)) {
|
if (numlines == (num.busy + num.congestion + num.nochan)) {
|
||||||
ast_verb(2, "Everyone is busy/congested at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
|
ast_verb(2, "Everyone is busy/congested at this time (%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
|
||||||
if (num.busy)
|
if (num.busy)
|
||||||
strcpy(pa->status, "BUSY");
|
strcpy(pa->status, "BUSY");
|
||||||
else if (num.congestion)
|
else if (num.congestion)
|
||||||
strcpy(pa->status, "CONGESTION");
|
strcpy(pa->status, "CONGESTION");
|
||||||
else if (num.nochan)
|
else if (num.nochan)
|
||||||
@@ -624,12 +624,12 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
ast_verb(3, "%s answered %s\n", c->name, in->name);
|
ast_verb(3, "%s answered %s\n", c->name, in->name);
|
||||||
peer = c;
|
peer = c;
|
||||||
ast_copy_flags64(peerflags, o,
|
ast_copy_flags64(peerflags, o,
|
||||||
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
||||||
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
||||||
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
||||||
OPT_CALLEE_PARK | OPT_CALLER_PARK |
|
OPT_CALLEE_PARK | OPT_CALLER_PARK |
|
||||||
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
|
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
|
||||||
DIAL_NOFORWARDHTML);
|
DIAL_NOFORWARDHTML);
|
||||||
ast_copy_string(c->dialcontext, "", sizeof(c->dialcontext));
|
ast_copy_string(c->dialcontext, "", sizeof(c->dialcontext));
|
||||||
ast_copy_string(c->exten, "", sizeof(c->exten));
|
ast_copy_string(c->exten, "", sizeof(c->exten));
|
||||||
}
|
}
|
||||||
@@ -662,12 +662,12 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
ast_verb(3, "%s answered %s\n", c->name, in->name);
|
ast_verb(3, "%s answered %s\n", c->name, in->name);
|
||||||
peer = c;
|
peer = c;
|
||||||
ast_copy_flags64(peerflags, o,
|
ast_copy_flags64(peerflags, o,
|
||||||
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
||||||
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
||||||
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
||||||
OPT_CALLEE_PARK | OPT_CALLER_PARK |
|
OPT_CALLEE_PARK | OPT_CALLER_PARK |
|
||||||
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
|
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
|
||||||
DIAL_NOFORWARDHTML);
|
DIAL_NOFORWARDHTML);
|
||||||
ast_copy_string(c->dialcontext, "", sizeof(c->dialcontext));
|
ast_copy_string(c->dialcontext, "", sizeof(c->dialcontext));
|
||||||
ast_copy_string(c->exten, "", sizeof(c->exten));
|
ast_copy_string(c->exten, "", sizeof(c->exten));
|
||||||
if (CAN_EARLY_BRIDGE(peerflags))
|
if (CAN_EARLY_BRIDGE(peerflags))
|
||||||
@@ -683,7 +683,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
in->hangupcause = c->hangupcause;
|
in->hangupcause = c->hangupcause;
|
||||||
ast_hangup(c);
|
ast_hangup(c);
|
||||||
c = o->chan = NULL;
|
c = o->chan = NULL;
|
||||||
ast_clear_flag64(o, DIAL_STILLGOING);
|
ast_clear_flag64(o, DIAL_STILLGOING);
|
||||||
handle_cause(AST_CAUSE_BUSY, &num);
|
handle_cause(AST_CAUSE_BUSY, &num);
|
||||||
break;
|
break;
|
||||||
case AST_CONTROL_CONGESTION:
|
case AST_CONTROL_CONGESTION:
|
||||||
@@ -748,7 +748,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
} else if (single) {
|
} else if (single) {
|
||||||
/* XXX are we sure the logic is correct ? or we should just switch on f->frametype ? */
|
/* XXX are we sure the logic is correct ? or we should just switch on f->frametype ? */
|
||||||
if (f->frametype == AST_FRAME_VOICE && !ast_test_flag64(outgoing, OPT_RINGBACK|OPT_MUSICBACK)) {
|
if (f->frametype == AST_FRAME_VOICE && !ast_test_flag64(outgoing, OPT_RINGBACK|OPT_MUSICBACK)) {
|
||||||
if (ast_write(in, f))
|
if (ast_write(in, f))
|
||||||
ast_log(LOG_WARNING, "Unable to forward voice frame\n");
|
ast_log(LOG_WARNING, "Unable to forward voice frame\n");
|
||||||
} else if (f->frametype == AST_FRAME_IMAGE && !ast_test_flag64(outgoing, OPT_RINGBACK|OPT_MUSICBACK)) {
|
} else if (f->frametype == AST_FRAME_IMAGE && !ast_test_flag64(outgoing, OPT_RINGBACK|OPT_MUSICBACK)) {
|
||||||
if (ast_write(in, f))
|
if (ast_write(in, f))
|
||||||
@@ -796,8 +796,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) &&
|
if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) &&
|
||||||
(f->subclass == '*')) { /* hmm it it not guaranteed to be '*' anymore. */
|
(f->subclass == '*')) { /* hmm it it not guaranteed to be '*' anymore. */
|
||||||
ast_verb(3, "User hit %c to disconnect call.\n", f->subclass);
|
ast_verb(3, "User hit %c to disconnect call.\n", f->subclass);
|
||||||
*to = 0;
|
*to = 0;
|
||||||
strcpy(pa->status, "CANCEL");
|
strcpy(pa->status, "CANCEL");
|
||||||
@@ -808,19 +808,18 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Forward HTML stuff */
|
/* Forward HTML stuff */
|
||||||
if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag64(outgoing, DIAL_NOFORWARDHTML))
|
if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag64(outgoing, DIAL_NOFORWARDHTML))
|
||||||
if (ast_channel_sendhtml(outgoing->chan, f->subclass, f->data, f->datalen) == -1)
|
if (ast_channel_sendhtml(outgoing->chan, f->subclass, f->data, f->datalen) == -1)
|
||||||
ast_log(LOG_WARNING, "Unable to send URL\n");
|
ast_log(LOG_WARNING, "Unable to send URL\n");
|
||||||
|
|
||||||
|
|
||||||
if (single && ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_DTMF_BEGIN) || (f->frametype == AST_FRAME_DTMF_END))) {
|
if (single && ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_DTMF_BEGIN) || (f->frametype == AST_FRAME_DTMF_END))) {
|
||||||
if (ast_write(outgoing->chan, f))
|
if (ast_write(outgoing->chan, f))
|
||||||
ast_log(LOG_WARNING, "Unable to forward voice or dtmf\n");
|
ast_log(LOG_WARNING, "Unable to forward voice or dtmf\n");
|
||||||
}
|
}
|
||||||
if (single && (f->frametype == AST_FRAME_CONTROL) &&
|
if (single && (f->frametype == AST_FRAME_CONTROL) &&
|
||||||
((f->subclass == AST_CONTROL_HOLD) ||
|
((f->subclass == AST_CONTROL_HOLD) ||
|
||||||
(f->subclass == AST_CONTROL_UNHOLD) ||
|
(f->subclass == AST_CONTROL_UNHOLD) ||
|
||||||
(f->subclass == AST_CONTROL_VIDUPDATE))) {
|
(f->subclass == AST_CONTROL_VIDUPDATE))) {
|
||||||
ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name);
|
ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name);
|
||||||
ast_indicate_data(outgoing->chan, f->subclass, f->data, f->datalen);
|
ast_indicate_data(outgoing->chan, f->subclass, f->data, f->datalen);
|
||||||
}
|
}
|
||||||
@@ -828,31 +827,27 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
|
|||||||
}
|
}
|
||||||
if (!*to)
|
if (!*to)
|
||||||
ast_verb(3, "Nobody picked up in %d ms\n", orig);
|
ast_verb(3, "Nobody picked up in %d ms\n", orig);
|
||||||
if (!*to || ast_check_hangup(in)) {
|
if (!*to || ast_check_hangup(in))
|
||||||
ast_cdr_noanswer(in->cdr);
|
ast_cdr_noanswer(in->cdr);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (peer && !ast_cdr_log_unanswered()) {
|
if (peer && !ast_cdr_log_unanswered()) {
|
||||||
/* suppress the CDR's that didn't win */
|
/* suppress the CDR's that didn't win */
|
||||||
struct chanlist *o;
|
struct chanlist *o;
|
||||||
for (o = outgoing; o; o = o->next) {
|
for (o = outgoing; o; o = o->next) {
|
||||||
struct ast_channel *c = o->chan;
|
struct ast_channel *c = o->chan;
|
||||||
if (c && c != peer && c->cdr) {
|
if (c && c != peer && c->cdr)
|
||||||
ast_set_flag(c->cdr, AST_CDR_FLAG_POST_DISABLED);
|
ast_set_flag(c->cdr, AST_CDR_FLAG_POST_DISABLED);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (!peer && !ast_cdr_log_unanswered()) {
|
} else if (!peer && !ast_cdr_log_unanswered()) {
|
||||||
/* suppress the CDR's that didn't win */
|
/* suppress the CDR's that didn't win */
|
||||||
struct chanlist *o;
|
struct chanlist *o;
|
||||||
for (o = outgoing; o; o = o->next) {
|
for (o = outgoing; o; o = o->next) {
|
||||||
struct ast_channel *c = o->chan;
|
struct ast_channel *c = o->chan;
|
||||||
if (c && c->cdr) {
|
if (c && c->cdr)
|
||||||
ast_set_flag(c->cdr, AST_CDR_FLAG_POST_DISABLED);
|
ast_set_flag(c->cdr, AST_CDR_FLAG_POST_DISABLED);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_EPOLL
|
#ifdef HAVE_EPOLL
|
||||||
for (epollo = outgoing; epollo; epollo = epollo->next) {
|
for (epollo = outgoing; epollo; epollo = epollo->next) {
|
||||||
if (epollo->chan)
|
if (epollo->chan)
|
||||||
@@ -870,7 +865,6 @@ static void replace_macro_delimiter(char *s)
|
|||||||
*s = ',';
|
*s = ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* returns true if there is a valid privacy reply */
|
/* returns true if there is a valid privacy reply */
|
||||||
static int valid_priv_reply(struct ast_flags64 *opts, int res)
|
static int valid_priv_reply(struct ast_flags64 *opts, int res)
|
||||||
{
|
{
|
||||||
@@ -906,7 +900,7 @@ static int do_timelimit(struct ast_channel *chan, struct ast_bridge_config *conf
|
|||||||
ast_log(LOG_WARNING, "Dial does not accept L(%s), hanging up.\n", limit_str);
|
ast_log(LOG_WARNING, "Dial does not accept L(%s), hanging up.\n", limit_str);
|
||||||
config->timelimit = config->play_warning = config->warning_freq = 0;
|
config->timelimit = config->play_warning = config->warning_freq = 0;
|
||||||
config->warning_sound = NULL;
|
config->warning_sound = NULL;
|
||||||
return -1; /* error */
|
return -1; /* error */
|
||||||
} else if ( (delta = config->play_warning - config->timelimit) > 0) {
|
} else if ( (delta = config->play_warning - config->timelimit) > 0) {
|
||||||
int w = config->warning_freq;
|
int w = config->warning_freq;
|
||||||
|
|
||||||
@@ -933,13 +927,13 @@ static int do_timelimit(struct ast_channel *chan, struct ast_bridge_config *conf
|
|||||||
|
|
||||||
var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLER");
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLER");
|
||||||
play_to_caller = var ? ast_true(var) : 1;
|
play_to_caller = var ? ast_true(var) : 1;
|
||||||
|
|
||||||
var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLEE");
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLEE");
|
||||||
play_to_callee = var ? ast_true(var) : 0;
|
play_to_callee = var ? ast_true(var) : 0;
|
||||||
|
|
||||||
if (!play_to_caller && !play_to_callee)
|
if (!play_to_caller && !play_to_callee)
|
||||||
play_to_caller = 1;
|
play_to_caller = 1;
|
||||||
|
|
||||||
var = pbx_builtin_getvar_helper(chan, "LIMIT_WARNING_FILE");
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_WARNING_FILE");
|
||||||
config->warning_sound = S_OR(var, "timeleft");
|
config->warning_sound = S_OR(var, "timeleft");
|
||||||
|
|
||||||
@@ -959,7 +953,7 @@ static int do_timelimit(struct ast_channel *chan, struct ast_bridge_config *conf
|
|||||||
if (!config->play_warning && !config->start_sound && !config->end_sound && config->timelimit) {
|
if (!config->play_warning && !config->start_sound && !config->end_sound && config->timelimit) {
|
||||||
*calldurationlimit = config->timelimit / 1000;
|
*calldurationlimit = config->timelimit / 1000;
|
||||||
ast_verb(3, "Setting call duration limit to %d seconds.\n",
|
ast_verb(3, "Setting call duration limit to %d seconds.\n",
|
||||||
*calldurationlimit);
|
*calldurationlimit);
|
||||||
config->timelimit = play_to_caller = play_to_callee =
|
config->timelimit = play_to_caller = play_to_callee =
|
||||||
config->play_warning = config->warning_freq = 0;
|
config->play_warning = config->warning_freq = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -973,25 +967,25 @@ static int do_timelimit(struct ast_channel *chan, struct ast_bridge_config *conf
|
|||||||
ast_verb(4, "warning_sound = %s\n", config->warning_sound);
|
ast_verb(4, "warning_sound = %s\n", config->warning_sound);
|
||||||
ast_verb(4, "end_sound = %s\n", S_OR(config->end_sound, ""));
|
ast_verb(4, "end_sound = %s\n", S_OR(config->end_sound, ""));
|
||||||
}
|
}
|
||||||
if (play_to_caller)
|
if (play_to_caller)
|
||||||
ast_set_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING);
|
ast_set_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING);
|
||||||
if (play_to_callee)
|
if (play_to_callee)
|
||||||
ast_set_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING);
|
ast_set_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
||||||
struct ast_flags64 *opts, char **opt_args, struct privacy_args *pa)
|
struct ast_flags64 *opts, char **opt_args, struct privacy_args *pa)
|
||||||
{
|
{
|
||||||
|
|
||||||
int res2;
|
int res2;
|
||||||
int loopcount = 0;
|
int loopcount = 0;
|
||||||
|
|
||||||
/* Get the user's intro, store it in priv-callerintros/$CID,
|
/* Get the user's intro, store it in priv-callerintros/$CID,
|
||||||
unless it is already there-- this should be done before the
|
unless it is already there-- this should be done before the
|
||||||
call is actually dialed */
|
call is actually dialed */
|
||||||
|
|
||||||
/* all ring indications and moh for the caller has been halted as soon as the
|
/* all ring indications and moh for the caller has been halted as soon as the
|
||||||
target extension was picked up. We are going to have to kill some
|
target extension was picked up. We are going to have to kill some
|
||||||
time and make the caller believe the peer hasn't picked up yet */
|
time and make the caller believe the peer hasn't picked up yet */
|
||||||
|
|
||||||
@@ -1010,13 +1004,13 @@ static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
|||||||
res2 = ast_autoservice_start(chan);
|
res2 = ast_autoservice_start(chan);
|
||||||
/* Now Stream the File */
|
/* Now Stream the File */
|
||||||
for (loopcount = 0; loopcount < 3; loopcount++) {
|
for (loopcount = 0; loopcount < 3; loopcount++) {
|
||||||
if (res2 && loopcount == 0) /* error in ast_autoservice_start() */
|
if (res2 && loopcount == 0) /* error in ast_autoservice_start() */
|
||||||
break;
|
break;
|
||||||
if (!res2) /* on timeout, play the message again */
|
if (!res2) /* on timeout, play the message again */
|
||||||
res2 = ast_play_and_wait(peer, "priv-callpending");
|
res2 = ast_play_and_wait(peer, "priv-callpending");
|
||||||
if (!valid_priv_reply(opts, res2))
|
if (!valid_priv_reply(opts, res2))
|
||||||
res2 = 0;
|
res2 = 0;
|
||||||
/* priv-callpending script:
|
/* priv-callpending script:
|
||||||
"I have a caller waiting, who introduces themselves as:"
|
"I have a caller waiting, who introduces themselves as:"
|
||||||
*/
|
*/
|
||||||
if (!res2)
|
if (!res2)
|
||||||
@@ -1035,7 +1029,7 @@ static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
|||||||
\par priv-callee-options script:
|
\par priv-callee-options script:
|
||||||
"Dial 1 if you wish this caller to reach you directly in the future,
|
"Dial 1 if you wish this caller to reach you directly in the future,
|
||||||
and immediately connect to their incoming call
|
and immediately connect to their incoming call
|
||||||
Dial 2 if you wish to send this caller to voicemail now and
|
Dial 2 if you wish to send this caller to voicemail now and
|
||||||
forevermore.
|
forevermore.
|
||||||
Dial 3 to send this caller to the torture menus, now and forevermore.
|
Dial 3 to send this caller to the torture menus, now and forevermore.
|
||||||
Dial 4 to send this caller to a simple "go away" menu, now and forevermore.
|
Dial 4 to send this caller to a simple "go away" menu, now and forevermore.
|
||||||
@@ -1066,7 +1060,7 @@ static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
|||||||
static const int _flag[] = { AST_PRIVACY_ALLOW, AST_PRIVACY_DENY, AST_PRIVACY_TORTURE, AST_PRIVACY_KILL, AST_PRIVACY_ALLOW};
|
static const int _flag[] = { AST_PRIVACY_ALLOW, AST_PRIVACY_DENY, AST_PRIVACY_TORTURE, AST_PRIVACY_KILL, AST_PRIVACY_ALLOW};
|
||||||
int i = res2 - '1';
|
int i = res2 - '1';
|
||||||
ast_verb(3, "--Set privacy database entry %s/%s to %s\n",
|
ast_verb(3, "--Set privacy database entry %s/%s to %s\n",
|
||||||
opt_args[OPT_ARG_PRIVACY], pa->privcid, _val[i]);
|
opt_args[OPT_ARG_PRIVACY], pa->privcid, _val[i]);
|
||||||
ast_privacy_set(opt_args[OPT_ARG_PRIVACY], pa->privcid, _flag[i]);
|
ast_privacy_set(opt_args[OPT_ARG_PRIVACY], pa->privcid, _flag[i]);
|
||||||
}
|
}
|
||||||
switch (res2) {
|
switch (res2) {
|
||||||
@@ -1086,7 +1080,7 @@ static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
|||||||
if (ast_test_flag64(opts, OPT_PRIVACY))
|
if (ast_test_flag64(opts, OPT_PRIVACY))
|
||||||
break;
|
break;
|
||||||
/* if not privacy, then 5 is the same as "default" case */
|
/* if not privacy, then 5 is the same as "default" case */
|
||||||
default: /* bad input or -1 if failure to start autoservice */
|
default: /* bad input or -1 if failure to start autoservice */
|
||||||
/* well, if the user messes up, ... he had his chance... What Is The Best Thing To Do? */
|
/* well, if the user messes up, ... he had his chance... What Is The Best Thing To Do? */
|
||||||
/* well, there seems basically two choices. Just patch the caller thru immediately,
|
/* well, there seems basically two choices. Just patch the caller thru immediately,
|
||||||
or,... put 'em thru to voicemail. */
|
or,... put 'em thru to voicemail. */
|
||||||
@@ -1097,8 +1091,8 @@ static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res2 == '1') { /* the only case where we actually connect */
|
if (res2 == '1') { /* the only case where we actually connect */
|
||||||
/* if the intro is NOCALLERID, then there's no reason to leave it on disk, it'll
|
/* if the intro is NOCALLERID, then there's no reason to leave it on disk, it'll
|
||||||
just clog things up, and it's not useful information, not being tied to a CID */
|
just clog things up, and it's not useful information, not being tied to a CID */
|
||||||
if (strncmp(pa->privcid, "NOCALLERID", 10) == 0 || ast_test_flag64(opts, OPT_SCREEN_NOINTRO)) {
|
if (strncmp(pa->privcid, "NOCALLERID", 10) == 0 || ast_test_flag64(opts, OPT_SCREEN_NOINTRO)) {
|
||||||
ast_filedelete(pa->privintro, NULL);
|
ast_filedelete(pa->privintro, NULL);
|
||||||
@@ -1107,7 +1101,7 @@ static int do_privacy(struct ast_channel *chan, struct ast_channel *peer,
|
|||||||
else
|
else
|
||||||
ast_verb(3, "Successfully deleted %s intro file\n", pa->privintro);
|
ast_verb(3, "Successfully deleted %s intro file\n", pa->privintro);
|
||||||
}
|
}
|
||||||
return 0; /* the good exit path */
|
return 0; /* the good exit path */
|
||||||
} else {
|
} else {
|
||||||
ast_hangup(peer); /* hang up on the callee -- he didn't want to talk anyway! */
|
ast_hangup(peer); /* hang up on the callee -- he didn't want to talk anyway! */
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1147,11 +1141,11 @@ static int setup_privacy_args(struct privacy_args *pa,
|
|||||||
l = callerid;
|
l = callerid;
|
||||||
pa->privdb_val = AST_PRIVACY_UNKNOWN;
|
pa->privdb_val = AST_PRIVACY_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_copy_string(pa->privcid, l, sizeof(pa->privcid));
|
ast_copy_string(pa->privcid, l, sizeof(pa->privcid));
|
||||||
|
|
||||||
if (strncmp(pa->privcid, "NOCALLERID", 10) != 0 && ast_test_flag64(opts, OPT_SCREEN_NOCLID)) {
|
if (strncmp(pa->privcid, "NOCALLERID", 10) != 0 && ast_test_flag64(opts, OPT_SCREEN_NOCLID)) {
|
||||||
/* if callerid is set and OPT_SCREEN_NOCLID is set also */
|
/* if callerid is set and OPT_SCREEN_NOCLID is set also */
|
||||||
ast_verb(3, "CallerID set (%s); N option set; Screening should be off\n", pa->privcid);
|
ast_verb(3, "CallerID set (%s); N option set; Screening should be off\n", pa->privcid);
|
||||||
pa->privdb_val = AST_PRIVACY_ALLOW;
|
pa->privdb_val = AST_PRIVACY_ALLOW;
|
||||||
} else if (ast_test_flag64(opts, OPT_SCREEN_NOCLID) && strncmp(pa->privcid, "NOCALLERID", 10) == 0) {
|
} else if (ast_test_flag64(opts, OPT_SCREEN_NOCLID) && strncmp(pa->privcid, "NOCALLERID", 10) == 0) {
|
||||||
@@ -1169,8 +1163,8 @@ static int setup_privacy_args(struct privacy_args *pa,
|
|||||||
ast_copy_string(pa->status, "TORTURE", sizeof(pa->status));
|
ast_copy_string(pa->status, "TORTURE", sizeof(pa->status));
|
||||||
return 0; /* is this right??? */
|
return 0; /* is this right??? */
|
||||||
} else if (pa->privdb_val == AST_PRIVACY_UNKNOWN) {
|
} else if (pa->privdb_val == AST_PRIVACY_UNKNOWN) {
|
||||||
/* Get the user's intro, store it in priv-callerintros/$CID,
|
/* Get the user's intro, store it in priv-callerintros/$CID,
|
||||||
unless it is already there-- this should be done before the
|
unless it is already there-- this should be done before the
|
||||||
call is actually dialed */
|
call is actually dialed */
|
||||||
|
|
||||||
/* make sure the priv-callerintros dir actually exists */
|
/* make sure the priv-callerintros dir actually exists */
|
||||||
@@ -1211,16 +1205,16 @@ static int setup_privacy_args(struct privacy_args *pa,
|
|||||||
ast_waitstream(chan, "");
|
ast_waitstream(chan, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1; /* success */
|
return 1; /* success */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags64 *peerflags, int *continue_exec)
|
static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags64 *peerflags, int *continue_exec)
|
||||||
{
|
{
|
||||||
int res = -1; /* default: error */
|
int res = -1; /* default: error */
|
||||||
char *rest, *cur; /* scan the list of destinations */
|
char *rest, *cur; /* scan the list of destinations */
|
||||||
struct chanlist *outgoing = NULL; /* list of destinations */
|
struct chanlist *outgoing = NULL; /* list of destinations */
|
||||||
struct ast_channel *peer;
|
struct ast_channel *peer;
|
||||||
int to; /* timeout */
|
int to; /* timeout */
|
||||||
struct cause_args num = { chan, 0, 0, 0 };
|
struct cause_args num = { chan, 0, 0, 0 };
|
||||||
int cause;
|
int cause;
|
||||||
char numsubst[256];
|
char numsubst[256];
|
||||||
@@ -1241,10 +1235,10 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
char *parse;
|
char *parse;
|
||||||
int opermode = 0;
|
int opermode = 0;
|
||||||
AST_DECLARE_APP_ARGS(args,
|
AST_DECLARE_APP_ARGS(args,
|
||||||
AST_APP_ARG(peers);
|
AST_APP_ARG(peers);
|
||||||
AST_APP_ARG(timeout);
|
AST_APP_ARG(timeout);
|
||||||
AST_APP_ARG(options);
|
AST_APP_ARG(options);
|
||||||
AST_APP_ARG(url);
|
AST_APP_ARG(url);
|
||||||
);
|
);
|
||||||
struct ast_flags64 opts = { 0, };
|
struct ast_flags64 opts = { 0, };
|
||||||
char *opt_args[OPT_ARG_ARRAY_SIZE];
|
char *opt_args[OPT_ARG_ARRAY_SIZE];
|
||||||
@@ -1258,11 +1252,11 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse = ast_strdupa(data);
|
parse = ast_strdupa(data);
|
||||||
|
|
||||||
AST_STANDARD_APP_ARGS(args, parse);
|
AST_STANDARD_APP_ARGS(args, parse);
|
||||||
|
|
||||||
if (!ast_strlen_zero(args.options) &&
|
if (!ast_strlen_zero(args.options) &&
|
||||||
ast_app_parse_options64(dial_exec_options, &opts, opt_args, args.options)) {
|
ast_app_parse_options64(dial_exec_options, &opts, opt_args, args.options)) {
|
||||||
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
|
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -1307,12 +1301,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
res = setup_privacy_args(&pa, &opts, opt_args, chan);
|
res = setup_privacy_args(&pa, &opts, opt_args, chan);
|
||||||
if (res <= 0)
|
if (res <= 0)
|
||||||
goto out;
|
goto out;
|
||||||
res = -1; /* reset default */
|
res = -1; /* reset default */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (continue_exec)
|
if (continue_exec)
|
||||||
*continue_exec = 0;
|
*continue_exec = 0;
|
||||||
|
|
||||||
/* If a channel group has been specified, get it for use when we create peer channels */
|
/* If a channel group has been specified, get it for use when we create peer channels */
|
||||||
if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP_ONCE"))) {
|
if ((outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP_ONCE"))) {
|
||||||
outbound_group = ast_strdupa(outbound_group);
|
outbound_group = ast_strdupa(outbound_group);
|
||||||
@@ -1320,13 +1314,13 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
} else {
|
} else {
|
||||||
outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
|
outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING);
|
ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING);
|
||||||
/* loop through the list of dial destinations */
|
/* loop through the list of dial destinations */
|
||||||
rest = args.peers;
|
rest = args.peers;
|
||||||
while ((cur = strsep(&rest, "&")) ) {
|
while ((cur = strsep(&rest, "&")) ) {
|
||||||
struct chanlist *tmp;
|
struct chanlist *tmp;
|
||||||
struct ast_channel *tc; /* channel for this destination */
|
struct ast_channel *tc; /* channel for this destination */
|
||||||
/* Get a technology/[device:]number pair */
|
/* Get a technology/[device:]number pair */
|
||||||
char *number = cur;
|
char *number = cur;
|
||||||
char *interface = ast_strdupa(number);
|
char *interface = ast_strdupa(number);
|
||||||
@@ -1343,14 +1337,14 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
goto out;
|
goto out;
|
||||||
if (opts.flags) {
|
if (opts.flags) {
|
||||||
ast_copy_flags64(tmp, &opts,
|
ast_copy_flags64(tmp, &opts,
|
||||||
OPT_CANCEL_ELSEWHERE |
|
OPT_CANCEL_ELSEWHERE |
|
||||||
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
||||||
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
||||||
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
||||||
OPT_CALLEE_PARK | OPT_CALLER_PARK |
|
OPT_CALLEE_PARK | OPT_CALLER_PARK |
|
||||||
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
|
OPT_CALLEE_MIXMONITOR | OPT_CALLER_MIXMONITOR |
|
||||||
OPT_RINGBACK | OPT_MUSICBACK | OPT_FORCECLID);
|
OPT_RINGBACK | OPT_MUSICBACK | OPT_FORCECLID);
|
||||||
ast_set2_flag64(tmp, args.url, DIAL_NOFORWARDHTML);
|
ast_set2_flag64(tmp, args.url, DIAL_NOFORWARDHTML);
|
||||||
}
|
}
|
||||||
ast_copy_string(numsubst, number, sizeof(numsubst));
|
ast_copy_string(numsubst, number, sizeof(numsubst));
|
||||||
/* Request the peer */
|
/* Request the peer */
|
||||||
@@ -1363,7 +1357,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
dialed_interfaces = datastore->data;
|
dialed_interfaces = datastore->data;
|
||||||
else {
|
else {
|
||||||
if (!(datastore = ast_channel_datastore_alloc(&dialed_interface_info, NULL))) {
|
if (!(datastore = ast_channel_datastore_alloc(&dialed_interface_info, NULL))) {
|
||||||
ast_log(LOG_WARNING, "Unable to create channel datastore for dialed interfaces. Aborting!\n");
|
ast_log(LOG_WARNING, "Unable to create channel datastore for dialed interfaces. Aborting!\n");
|
||||||
ast_free(tmp);
|
ast_free(tmp);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -1386,7 +1380,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
AST_LIST_LOCK(dialed_interfaces);
|
AST_LIST_LOCK(dialed_interfaces);
|
||||||
AST_LIST_TRAVERSE(dialed_interfaces, di, list) {
|
AST_LIST_TRAVERSE(dialed_interfaces, di, list) {
|
||||||
if (!strcasecmp(di->interface, interface)) {
|
if (!strcasecmp(di->interface, interface)) {
|
||||||
ast_log(LOG_WARNING, "Skipping dialing interface '%s' again since it has already been dialed\n",
|
ast_log(LOG_WARNING, "Skipping dialing interface '%s' again since it has already been dialed\n",
|
||||||
di->interface);
|
di->interface);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1420,9 +1414,9 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
if (!tc) {
|
if (!tc) {
|
||||||
/* If we can't, just go on to the next call */
|
/* If we can't, just go on to the next call */
|
||||||
ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n",
|
ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n",
|
||||||
tech, cause, ast_cause2str(cause));
|
tech, cause, ast_cause2str(cause));
|
||||||
handle_cause(cause, &num);
|
handle_cause(cause, &num);
|
||||||
if (!rest) /* we are on the last destination */
|
if (!rest) /* we are on the last destination */
|
||||||
chan->hangupcause = cause;
|
chan->hangupcause = cause;
|
||||||
ast_free(tmp);
|
ast_free(tmp);
|
||||||
continue;
|
continue;
|
||||||
@@ -1472,7 +1466,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
else
|
else
|
||||||
ast_copy_string(tc->exten, chan->exten, sizeof(tc->exten));
|
ast_copy_string(tc->exten, chan->exten, sizeof(tc->exten));
|
||||||
|
|
||||||
res = ast_call(tc, numsubst, 0); /* Place the call, but don't wait on the answer */
|
res = ast_call(tc, numsubst, 0); /* Place the call, but don't wait on the answer */
|
||||||
|
|
||||||
/* Save the info in cdr's that we called them */
|
/* Save the info in cdr's that we called them */
|
||||||
if (chan->cdr)
|
if (chan->cdr)
|
||||||
@@ -1493,10 +1487,10 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
if (!ast_test_flag64(peerflags, OPT_ORIGINAL_CLID))
|
if (!ast_test_flag64(peerflags, OPT_ORIGINAL_CLID))
|
||||||
ast_set_callerid(tc, S_OR(chan->macroexten, chan->exten), get_cid_name(cidname, sizeof(cidname), chan), NULL);
|
ast_set_callerid(tc, S_OR(chan->macroexten, chan->exten), get_cid_name(cidname, sizeof(cidname), chan), NULL);
|
||||||
}
|
}
|
||||||
/* Put them in the list of outgoing thingies... We're ready now.
|
/* Put them in the list of outgoing thingies... We're ready now.
|
||||||
XXX If we're forcibly removed, these outgoing calls won't get
|
XXX If we're forcibly removed, these outgoing calls won't get
|
||||||
hung up XXX */
|
hung up XXX */
|
||||||
ast_set_flag64(tmp, DIAL_STILLGOING);
|
ast_set_flag64(tmp, DIAL_STILLGOING);
|
||||||
tmp->chan = tc;
|
tmp->chan = tc;
|
||||||
tmp->next = outgoing;
|
tmp->next = outgoing;
|
||||||
outgoing = tmp;
|
outgoing = tmp;
|
||||||
@@ -1558,11 +1552,11 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
} else {
|
} else {
|
||||||
const char *number;
|
const char *number;
|
||||||
time_t end_time, answer_time = time(NULL);
|
time_t end_time, answer_time = time(NULL);
|
||||||
char toast[80]; /* buffer to set variables */
|
char toast[80]; /* buffer to set variables */
|
||||||
|
|
||||||
strcpy(pa.status, "ANSWER");
|
strcpy(pa.status, "ANSWER");
|
||||||
/* Ah ha! Someone answered within the desired timeframe. Of course after this
|
/* Ah ha! Someone answered within the desired timeframe. Of course after this
|
||||||
we will always return with -1 so that it is hung up properly after the
|
we will always return with -1 so that it is hung up properly after the
|
||||||
conversation. */
|
conversation. */
|
||||||
hanguptree(outgoing, peer, 1);
|
hanguptree(outgoing, peer, 1);
|
||||||
outgoing = NULL;
|
outgoing = NULL;
|
||||||
@@ -1576,10 +1570,10 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
if (!number)
|
if (!number)
|
||||||
number = numsubst;
|
number = numsubst;
|
||||||
pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number);
|
pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number);
|
||||||
if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) {
|
if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) {
|
||||||
ast_debug(1, "app_dial: sendurl=%s.\n", args.url);
|
ast_debug(1, "app_dial: sendurl=%s.\n", args.url);
|
||||||
ast_channel_sendurl( peer, args.url );
|
ast_channel_sendurl( peer, args.url );
|
||||||
}
|
}
|
||||||
if ( (ast_test_flag64(&opts, OPT_PRIVACY) || ast_test_flag64(&opts, OPT_SCREENING)) && pa.privdb_val == AST_PRIVACY_UNKNOWN) {
|
if ( (ast_test_flag64(&opts, OPT_PRIVACY) || ast_test_flag64(&opts, OPT_SCREENING)) && pa.privdb_val == AST_PRIVACY_UNKNOWN) {
|
||||||
if (do_privacy(chan, peer, &opts, opt_args, &pa)) {
|
if (do_privacy(chan, peer, &opts, opt_args, &pa)) {
|
||||||
res = 0;
|
res = 0;
|
||||||
@@ -1596,12 +1590,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
if (!res)
|
if (!res)
|
||||||
res = ast_streamfile(peer, opt_args[OPT_ARG_ANNOUNCE], peer->language);
|
res = ast_streamfile(peer, opt_args[OPT_ARG_ANNOUNCE], peer->language);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
digit = ast_waitstream(peer, AST_DIGIT_ANY);
|
digit = ast_waitstream(peer, AST_DIGIT_ANY);
|
||||||
}
|
}
|
||||||
/* Ok, done. stop autoservice */
|
/* Ok, done. stop autoservice */
|
||||||
res = ast_autoservice_stop(chan);
|
res = ast_autoservice_stop(chan);
|
||||||
if (digit > 0 && !res)
|
if (digit > 0 && !res)
|
||||||
res = ast_senddigit(chan, digit, 0);
|
res = ast_senddigit(chan, digit, 0);
|
||||||
else
|
else
|
||||||
res = digit;
|
res = digit;
|
||||||
|
|
||||||
@@ -1634,7 +1628,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
|
|
||||||
theapp = pbx_findapp("Macro");
|
theapp = pbx_findapp("Macro");
|
||||||
|
|
||||||
if (theapp && !res) { /* XXX why check res here ? */
|
if (theapp && !res) { /* XXX why check res here ? */
|
||||||
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]);
|
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]);
|
||||||
res = pbx_exec(peer, theapp, opt_args[OPT_ARG_CALLEE_MACRO]);
|
res = pbx_exec(peer, theapp, opt_args[OPT_ARG_CALLEE_MACRO]);
|
||||||
ast_debug(1, "Macro exited with status %d\n", res);
|
ast_debug(1, "Macro exited with status %d\n", res);
|
||||||
@@ -1658,14 +1652,14 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
res = -1;
|
res = -1;
|
||||||
} else if (!strcasecmp(macro_result, "CONGESTION") || !strcasecmp(macro_result, "CHANUNAVAIL")) {
|
} else if (!strcasecmp(macro_result, "CONGESTION") || !strcasecmp(macro_result, "CHANUNAVAIL")) {
|
||||||
ast_copy_string(pa.status, macro_result, sizeof(pa.status));
|
ast_copy_string(pa.status, macro_result, sizeof(pa.status));
|
||||||
ast_set_flag64(peerflags, OPT_GO_ON);
|
ast_set_flag64(peerflags, OPT_GO_ON);
|
||||||
res = -1;
|
res = -1;
|
||||||
} else if (!strcasecmp(macro_result, "CONTINUE")) {
|
} else if (!strcasecmp(macro_result, "CONTINUE")) {
|
||||||
/* hangup peer and keep chan alive assuming the macro has changed
|
/* hangup peer and keep chan alive assuming the macro has changed
|
||||||
the context / exten / priority or perhaps
|
the context / exten / priority or perhaps
|
||||||
the next priority in the current exten is desired.
|
the next priority in the current exten is desired.
|
||||||
*/
|
*/
|
||||||
ast_set_flag64(peerflags, OPT_GO_ON);
|
ast_set_flag64(peerflags, OPT_GO_ON);
|
||||||
res = -1;
|
res = -1;
|
||||||
} else if (!strcasecmp(macro_result, "ABORT")) {
|
} else if (!strcasecmp(macro_result, "ABORT")) {
|
||||||
/* Hangup both ends unless the caller has the g flag */
|
/* Hangup both ends unless the caller has the g flag */
|
||||||
@@ -1695,7 +1689,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
|
|
||||||
theapp = pbx_findapp("Gosub");
|
theapp = pbx_findapp("Gosub");
|
||||||
|
|
||||||
if (theapp && !res) { /* XXX why check res here ? */
|
if (theapp && !res) { /* XXX why check res here ? */
|
||||||
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_GOSUB]);
|
replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_GOSUB]);
|
||||||
|
|
||||||
/* Set where we came from */
|
/* Set where we came from */
|
||||||
@@ -1720,7 +1714,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res);
|
ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res);
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
|
ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
|
||||||
|
|
||||||
res = 0;
|
res = 0;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_ERROR, "Could not find application Gosub\n");
|
ast_log(LOG_ERROR, "Could not find application Gosub\n");
|
||||||
@@ -1741,14 +1735,14 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
res = -1;
|
res = -1;
|
||||||
} else if (!strcasecmp(gosub_result, "CONGESTION") || !strcasecmp(gosub_result, "CHANUNAVAIL")) {
|
} else if (!strcasecmp(gosub_result, "CONGESTION") || !strcasecmp(gosub_result, "CHANUNAVAIL")) {
|
||||||
ast_copy_string(pa.status, gosub_result, sizeof(pa.status));
|
ast_copy_string(pa.status, gosub_result, sizeof(pa.status));
|
||||||
ast_set_flag64(peerflags, OPT_GO_ON);
|
ast_set_flag64(peerflags, OPT_GO_ON);
|
||||||
res = -1;
|
res = -1;
|
||||||
} else if (!strcasecmp(gosub_result, "CONTINUE")) {
|
} else if (!strcasecmp(gosub_result, "CONTINUE")) {
|
||||||
/* hangup peer and keep chan alive assuming the macro has changed
|
/* hangup peer and keep chan alive assuming the macro has changed
|
||||||
the context / exten / priority or perhaps
|
the context / exten / priority or perhaps
|
||||||
the next priority in the current exten is desired.
|
the next priority in the current exten is desired.
|
||||||
*/
|
*/
|
||||||
ast_set_flag64(peerflags, OPT_GO_ON);
|
ast_set_flag64(peerflags, OPT_GO_ON);
|
||||||
res = -1;
|
res = -1;
|
||||||
} else if (!strcasecmp(gosub_result, "ABORT")) {
|
} else if (!strcasecmp(gosub_result, "ABORT")) {
|
||||||
/* Hangup both ends unless the caller has the g flag */
|
/* Hangup both ends unless the caller has the g flag */
|
||||||
@@ -1769,7 +1763,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
if (calldurationlimit > 0) {
|
if (calldurationlimit > 0) {
|
||||||
peer->whentohangup = time(NULL) + calldurationlimit;
|
peer->whentohangup = time(NULL) + calldurationlimit;
|
||||||
}
|
}
|
||||||
if (!ast_strlen_zero(dtmfcalled)) {
|
if (!ast_strlen_zero(dtmfcalled)) {
|
||||||
ast_verb(3, "Sending DTMF '%s' to the called party.\n", dtmfcalled);
|
ast_verb(3, "Sending DTMF '%s' to the called party.\n", dtmfcalled);
|
||||||
res = ast_dtmf_stream(peer, chan, dtmfcalled, 250, 0);
|
res = ast_dtmf_stream(peer, chan, dtmfcalled, 250, 0);
|
||||||
}
|
}
|
||||||
@@ -1779,7 +1773,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res) { /* some error */
|
if (res) { /* some error */
|
||||||
res = -1;
|
res = -1;
|
||||||
end_time = time(NULL);
|
end_time = time(NULL);
|
||||||
} else {
|
} else {
|
||||||
@@ -1793,7 +1787,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
ast_set_flag(&(config.features_caller), AST_FEATURE_DISCONNECT);
|
ast_set_flag(&(config.features_caller), AST_FEATURE_DISCONNECT);
|
||||||
if (ast_test_flag64(peerflags, OPT_CALLEE_MONITOR))
|
if (ast_test_flag64(peerflags, OPT_CALLEE_MONITOR))
|
||||||
ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
|
ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
|
||||||
if (ast_test_flag64(peerflags, OPT_CALLER_MONITOR))
|
if (ast_test_flag64(peerflags, OPT_CALLER_MONITOR))
|
||||||
ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
|
ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
|
||||||
if (ast_test_flag64(peerflags, OPT_CALLEE_PARK))
|
if (ast_test_flag64(peerflags, OPT_CALLEE_PARK))
|
||||||
ast_set_flag(&(config.features_callee), AST_FEATURE_PARKCALL);
|
ast_set_flag(&(config.features_callee), AST_FEATURE_PARKCALL);
|
||||||
@@ -1841,13 +1835,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
|
|
||||||
snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
|
snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
|
||||||
pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
|
pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
|
||||||
|
|
||||||
|
|
||||||
if (ast_test_flag64(&opts, OPT_PEER_H)) {
|
if (ast_test_flag64(&opts, OPT_PEER_H)) {
|
||||||
ast_log(LOG_NOTICE, "PEER context: %s; PEER exten: %s; PEER priority: %d\n",
|
ast_log(LOG_NOTICE, "PEER context: %s; PEER exten: %s; PEER priority: %d\n",
|
||||||
peer->context, peer->exten, peer->priority);
|
peer->context, peer->exten, peer->priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(peer->context, chan->context);
|
strcpy(peer->context, chan->context);
|
||||||
|
|
||||||
if (ast_test_flag64(&opts, OPT_PEER_H) && ast_exists_extension(peer, peer->context, "h", 1, peer->cid.cid_num)) {
|
if (ast_test_flag64(&opts, OPT_PEER_H) && ast_exists_extension(peer, peer->context, "h", 1, peer->cid.cid_num)) {
|
||||||
@@ -1855,12 +1848,12 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
int found;
|
int found;
|
||||||
strcpy(peer->exten, "h");
|
strcpy(peer->exten, "h");
|
||||||
peer->priority = 1;
|
peer->priority = 1;
|
||||||
autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
|
autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */
|
||||||
ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP);
|
ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP);
|
||||||
|
|
||||||
while ((res = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num, &found, 1))) {
|
while ((res = ast_spawn_extension(peer, peer->context, peer->exten, peer->priority, peer->cid.cid_num, &found, 1)))
|
||||||
peer->priority++;
|
peer->priority++;
|
||||||
}
|
|
||||||
if (found && res) {
|
if (found && res) {
|
||||||
/* Something bad happened, or a hangup has been requested. */
|
/* Something bad happened, or a hangup has been requested. */
|
||||||
ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
|
ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", peer->context, peer->exten, peer->priority, peer->name);
|
||||||
@@ -1873,7 +1866,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
chan->hangupcause = peer->hangupcause;
|
chan->hangupcause = peer->hangupcause;
|
||||||
ast_hangup(peer);
|
ast_hangup(peer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (moh) {
|
if (moh) {
|
||||||
moh = 0;
|
moh = 0;
|
||||||
@@ -1883,11 +1876,11 @@ out:
|
|||||||
ast_indicate(chan, -1);
|
ast_indicate(chan, -1);
|
||||||
}
|
}
|
||||||
ast_channel_early_bridge(chan, NULL);
|
ast_channel_early_bridge(chan, NULL);
|
||||||
hanguptree(outgoing, NULL, 0); /* In this case, there's no answer anywhere */
|
hanguptree(outgoing, NULL, 0); /* In this case, there's no answer anywhere */
|
||||||
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
|
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
|
||||||
senddialendevent(chan, pa.status);
|
senddialendevent(chan, pa.status);
|
||||||
ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
|
ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
|
||||||
|
|
||||||
if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_KEEPALIVE)) {
|
if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_KEEPALIVE)) {
|
||||||
if (calldurationlimit)
|
if (calldurationlimit)
|
||||||
chan->whentohangup = 0;
|
chan->whentohangup = 0;
|
||||||
@@ -1923,14 +1916,13 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
|
|||||||
if (ast_strlen_zero(data)) {
|
if (ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "RetryDial requires an argument!\n");
|
ast_log(LOG_WARNING, "RetryDial requires an argument!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
parse = ast_strdupa(data);
|
parse = ast_strdupa(data);
|
||||||
AST_STANDARD_APP_ARGS(args, parse);
|
AST_STANDARD_APP_ARGS(args, parse);
|
||||||
|
|
||||||
if ((sleep = atoi(args.sleep))) {
|
if ((sleep = atoi(args.sleep)))
|
||||||
sleep *= 1000;
|
sleep *= 1000;
|
||||||
}
|
|
||||||
|
|
||||||
loops = atoi(args.retries);
|
loops = atoi(args.retries);
|
||||||
|
|
||||||
@@ -1938,13 +1930,13 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_log(LOG_ERROR, "%s requires a 4th argument (dialdata)\n", rapp);
|
ast_log(LOG_ERROR, "%s requires a 4th argument (dialdata)\n", rapp);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sleep < 1000)
|
if (sleep < 1000)
|
||||||
sleep = 10000;
|
sleep = 10000;
|
||||||
|
|
||||||
if (!loops)
|
if (!loops)
|
||||||
loops = -1; /* run forever */
|
loops = -1; /* run forever */
|
||||||
|
|
||||||
context = pbx_builtin_getvar_helper(chan, "EXITCONTEXT");
|
context = pbx_builtin_getvar_helper(chan, "EXITCONTEXT");
|
||||||
|
|
||||||
res = 0;
|
res = 0;
|
||||||
@@ -1963,7 +1955,7 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
|
|||||||
if (ast_test_flag64(&peerflags, OPT_DTMF_EXIT)) {
|
if (ast_test_flag64(&peerflags, OPT_DTMF_EXIT)) {
|
||||||
if (!ast_strlen_zero(args.announce)) {
|
if (!ast_strlen_zero(args.announce)) {
|
||||||
if (ast_fileexists(args.announce, NULL, chan->language) > 0) {
|
if (ast_fileexists(args.announce, NULL, chan->language) > 0) {
|
||||||
if (!(res = ast_streamfile(chan, args.announce, chan->language)))
|
if (!(res = ast_streamfile(chan, args.announce, chan->language)))
|
||||||
ast_waitstream(chan, AST_DIGIT_ANY);
|
ast_waitstream(chan, AST_DIGIT_ANY);
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
|
ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
|
||||||
@@ -2019,12 +2011,11 @@ static int unload_module(void)
|
|||||||
res = ast_unregister_application(app);
|
res = ast_unregister_application(app);
|
||||||
res |= ast_unregister_application(rapp);
|
res |= ast_unregister_application(rapp);
|
||||||
|
|
||||||
if ((con = ast_context_find("app_dial_gosub_virtual_context")))
|
if ((con = ast_context_find("app_dial_gosub_virtual_context"))) {
|
||||||
{
|
|
||||||
ast_context_remove_extension2(con, "s", 1, NULL);
|
ast_context_remove_extension2(con, "s", 1, NULL);
|
||||||
ast_context_destroy(con, "app_dial"); /* leave nothing behind */
|
ast_context_destroy(con, "app_dial"); /* leave nothing behind */
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2043,7 +2034,7 @@ static int load_module(void)
|
|||||||
|
|
||||||
res = ast_register_application(app, dial_exec, synopsis, descrip);
|
res = ast_register_application(app, dial_exec, synopsis, descrip);
|
||||||
res |= ast_register_application(rapp, retrydial_exec, rsynopsis, rdescrip);
|
res |= ast_register_application(rapp, retrydial_exec, rsynopsis, rdescrip);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "asterisk/paths.h" /* use ast_config_AST_SPOOL_DIR */
|
#include "asterisk/paths.h" /* use ast_config_AST_SPOOL_DIR */
|
||||||
#include "asterisk/file.h"
|
#include "asterisk/file.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
@@ -61,7 +61,7 @@ typedef enum {
|
|||||||
|
|
||||||
#define ast_toggle_flag(it,flag) if(ast_test_flag(it, flag)) ast_clear_flag(it, flag); else ast_set_flag(it, flag)
|
#define ast_toggle_flag(it,flag) if(ast_test_flag(it, flag)) ast_clear_flag(it, flag); else ast_set_flag(it, flag)
|
||||||
|
|
||||||
static int play_and_wait(struct ast_channel *chan, char *file, char *digits)
|
static int play_and_wait(struct ast_channel *chan, char *file, char *digits)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
if (!ast_streamfile(chan, file, chan->language)) {
|
if (!ast_streamfile(chan, file, chan->language)) {
|
||||||
@@ -94,14 +94,14 @@ static int dictate_exec(struct ast_channel *chan, void *data)
|
|||||||
len = 0,
|
len = 0,
|
||||||
maxlen = 0,
|
maxlen = 0,
|
||||||
mode = 0;
|
mode = 0;
|
||||||
|
|
||||||
snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
|
snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
|
||||||
if (!ast_strlen_zero(data)) {
|
if (!ast_strlen_zero(data)) {
|
||||||
parse = ast_strdupa(data);
|
parse = ast_strdupa(data);
|
||||||
AST_STANDARD_APP_ARGS(args, parse);
|
AST_STANDARD_APP_ARGS(args, parse);
|
||||||
} else
|
} else
|
||||||
args.argc = 0;
|
args.argc = 0;
|
||||||
|
|
||||||
if (args.argc && !ast_strlen_zero(args.base)) {
|
if (args.argc && !ast_strlen_zero(args.base)) {
|
||||||
base = args.base;
|
base = args.base;
|
||||||
} else {
|
} else {
|
||||||
@@ -109,7 +109,7 @@ static int dictate_exec(struct ast_channel *chan, void *data)
|
|||||||
}
|
}
|
||||||
if (args.argc > 1 && args.filename) {
|
if (args.argc > 1 && args.filename) {
|
||||||
filename = args.filename;
|
filename = args.filename;
|
||||||
}
|
}
|
||||||
oldr = chan->readformat;
|
oldr = chan->readformat;
|
||||||
if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
|
if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
|
||||||
ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
|
ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
|
||||||
@@ -120,7 +120,7 @@ static int dictate_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_safe_sleep(chan, 200);
|
ast_safe_sleep(chan, 200);
|
||||||
for (res = 0; !res;) {
|
for (res = 0; !res;) {
|
||||||
if (ast_strlen_zero(filename)) {
|
if (ast_strlen_zero(filename)) {
|
||||||
if (ast_app_getdata(chan, "dictate/enter_filename", filein, sizeof(filein), 0) ||
|
if (ast_app_getdata(chan, "dictate/enter_filename", filein, sizeof(filein), 0) ||
|
||||||
ast_strlen_zero(filein)) {
|
ast_strlen_zero(filein)) {
|
||||||
res = -1;
|
res = -1;
|
||||||
break;
|
break;
|
||||||
@@ -282,7 +282,7 @@ static int dictate_exec(struct ast_channel *chan, void *data)
|
|||||||
case DMODE_RECORD:
|
case DMODE_RECORD:
|
||||||
if (lastop != DMODE_RECORD) {
|
if (lastop != DMODE_RECORD) {
|
||||||
int oflags = O_CREAT | O_WRONLY;
|
int oflags = O_CREAT | O_WRONLY;
|
||||||
if (ast_test_flag(&flags, DFLAG_PAUSE)) {
|
if (ast_test_flag(&flags, DFLAG_PAUSE)) {
|
||||||
digit = play_and_wait(chan, "dictate/record_mode", AST_DIGIT_ANY);
|
digit = play_and_wait(chan, "dictate/record_mode", AST_DIGIT_ANY);
|
||||||
if (digit == 0) {
|
if (digit == 0) {
|
||||||
digit = play_and_wait(chan, "dictate/paused", AST_DIGIT_ANY);
|
digit = play_and_wait(chan, "dictate/paused", AST_DIGIT_ANY);
|
||||||
|
@@ -93,8 +93,8 @@ static int pickup_by_exten(struct ast_channel *chan, const char *exten, const ch
|
|||||||
|
|
||||||
while ((target = ast_channel_walk_locked(target))) {
|
while ((target = ast_channel_walk_locked(target))) {
|
||||||
if ((!strcasecmp(target->macroexten, exten) || !strcasecmp(target->exten, exten)) &&
|
if ((!strcasecmp(target->macroexten, exten) || !strcasecmp(target->exten, exten)) &&
|
||||||
!strcasecmp(target->dialcontext, context) &&
|
!strcasecmp(target->dialcontext, context) &&
|
||||||
can_pickup(target)) {
|
can_pickup(target)) {
|
||||||
res = pickup_do(chan, target);
|
res = pickup_do(chan, target);
|
||||||
ast_channel_unlock(target);
|
ast_channel_unlock(target);
|
||||||
break;
|
break;
|
||||||
@@ -114,8 +114,8 @@ static int pickup_by_mark(struct ast_channel *chan, const char *mark)
|
|||||||
|
|
||||||
while ((target = ast_channel_walk_locked(target))) {
|
while ((target = ast_channel_walk_locked(target))) {
|
||||||
if ((tmp = pbx_builtin_getvar_helper(target, PICKUPMARK)) &&
|
if ((tmp = pbx_builtin_getvar_helper(target, PICKUPMARK)) &&
|
||||||
!strcasecmp(tmp, mark) &&
|
!strcasecmp(tmp, mark) &&
|
||||||
can_pickup(target)) {
|
can_pickup(target)) {
|
||||||
res = pickup_do(chan, target);
|
res = pickup_do(chan, target);
|
||||||
ast_channel_unlock(target);
|
ast_channel_unlock(target);
|
||||||
break;
|
break;
|
||||||
@@ -160,7 +160,7 @@ static int unload_module(void)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = ast_unregister_application(app);
|
res = ast_unregister_application(app);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,17 +21,17 @@
|
|||||||
* \brief Provide a directory of extensions
|
* \brief Provide a directory of extensions
|
||||||
*
|
*
|
||||||
* \author Mark Spencer <markster@digium.com>
|
* \author Mark Spencer <markster@digium.com>
|
||||||
*
|
*
|
||||||
* \ingroup applications
|
* \ingroup applications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "asterisk/paths.h" /* use ast_config_AST_SPOOL_DIR */
|
#include "asterisk/paths.h" /* use ast_config_AST_SPOOL_DIR */
|
||||||
#include "asterisk/file.h"
|
#include "asterisk/file.h"
|
||||||
#include "asterisk/pbx.h"
|
#include "asterisk/pbx.h"
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
@@ -91,7 +91,7 @@ enum {
|
|||||||
struct directory_item {
|
struct directory_item {
|
||||||
char exten[AST_MAX_EXTENSION + 1];
|
char exten[AST_MAX_EXTENSION + 1];
|
||||||
char name[AST_MAX_EXTENSION + 1];
|
char name[AST_MAX_EXTENSION + 1];
|
||||||
char key[50]; /* Text to order items. Either lastname+firstname or firstname+lastname */
|
char key[50]; /* Text to order items. Either lastname+firstname or firstname+lastname */
|
||||||
|
|
||||||
AST_LIST_ENTRY(directory_item) entry;
|
AST_LIST_ENTRY(directory_item) entry;
|
||||||
};
|
};
|
||||||
@@ -300,7 +300,7 @@ static int compare(const char *text, const char *template)
|
|||||||
* '*' for skipped entry from directory
|
* '*' for skipped entry from directory
|
||||||
*/
|
*/
|
||||||
static int play_mailbox_owner(struct ast_channel *chan, const char *context,
|
static int play_mailbox_owner(struct ast_channel *chan, const char *context,
|
||||||
const char *ext, const char *name, struct ast_flags *flags)
|
const char *ext, const char *name, struct ast_flags *flags)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
char fn[256];
|
char fn[256];
|
||||||
@@ -337,7 +337,7 @@ static int play_mailbox_owner(struct ast_channel *chan, const char *context,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ODBC_STORAGE
|
#ifdef ODBC_STORAGE
|
||||||
ast_filedelete(fn, NULL);
|
ast_filedelete(fn, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -378,7 +378,7 @@ static int select_item_seq(struct ast_channel *chan, struct directory_item **ite
|
|||||||
res = ast_waitfordigit(chan, 3000);
|
res = ast_waitfordigit(chan, 3000);
|
||||||
ast_stopstream(chan);
|
ast_stopstream(chan);
|
||||||
|
|
||||||
if (res == '1') { /* Name selected */
|
if (res == '1') { /* Name selected */
|
||||||
return select_entry(chan, context, dialcontext, item, flags) ? -1 : 1;
|
return select_entry(chan, context, dialcontext, item, flags) ? -1 : 1;
|
||||||
} else if (res == '*') {
|
} else if (res == '*') {
|
||||||
/* Skip to next match in list */
|
/* Skip to next match in list */
|
||||||
@@ -502,8 +502,8 @@ static struct ast_config *realtime_directory(char *context)
|
|||||||
fullname = ast_variable_retrieve(rtdata, mailbox, "fullname");
|
fullname = ast_variable_retrieve(rtdata, mailbox, "fullname");
|
||||||
hidefromdir = ast_variable_retrieve(rtdata, mailbox, "hidefromdir");
|
hidefromdir = ast_variable_retrieve(rtdata, mailbox, "hidefromdir");
|
||||||
snprintf(tmp, sizeof(tmp), "no-password,%s,hidefromdir=%s",
|
snprintf(tmp, sizeof(tmp), "no-password,%s,hidefromdir=%s",
|
||||||
fullname ? fullname : "",
|
fullname ? fullname : "",
|
||||||
hidefromdir ? hidefromdir : "no");
|
hidefromdir ? hidefromdir : "no");
|
||||||
var = ast_variable_new(mailbox, tmp, "");
|
var = ast_variable_new(mailbox, tmp, "");
|
||||||
if (var)
|
if (var)
|
||||||
ast_variable_append(cat, var);
|
ast_variable_append(cat, var);
|
||||||
@@ -595,7 +595,7 @@ static int search_directory(const char *context, struct ast_config *vmcfg, struc
|
|||||||
continue;
|
continue;
|
||||||
if (!ast_true(ast_config_option(ucfg, cat, "hasdirectory")))
|
if (!ast_true(ast_config_option(ucfg, cat, "hasdirectory")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Find all candidate extensions */
|
/* Find all candidate extensions */
|
||||||
pos = ast_variable_retrieve(ucfg, cat, "fullname");
|
pos = ast_variable_retrieve(ucfg, cat, "fullname");
|
||||||
if (!pos)
|
if (!pos)
|
||||||
@@ -639,8 +639,8 @@ static void sort_items(struct directory_item **sorted, int count)
|
|||||||
static int goto_exten(struct ast_channel *chan, const char *dialcontext, char *ext)
|
static int goto_exten(struct ast_channel *chan, const char *dialcontext, char *ext)
|
||||||
{
|
{
|
||||||
if (!ast_goto_if_exists(chan, dialcontext, ext, 1) ||
|
if (!ast_goto_if_exists(chan, dialcontext, ext, 1) ||
|
||||||
(!ast_strlen_zero(chan->macrocontext) &&
|
(!ast_strlen_zero(chan->macrocontext) &&
|
||||||
!ast_goto_if_exists(chan, chan->macrocontext, ext, 1))) {
|
!ast_goto_if_exists(chan, chan->macrocontext, ext, 1))) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Can't find extension '%s' in current context. "
|
ast_log(LOG_WARNING, "Can't find extension '%s' in current context. "
|
||||||
@@ -667,11 +667,11 @@ static int do_directory(struct ast_channel *chan, struct ast_config *vmcfg, stru
|
|||||||
|
|
||||||
if (digit == '0' && !goto_exten(chan, dialcontext, "o")) {
|
if (digit == '0' && !goto_exten(chan, dialcontext, "o")) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (digit == '*' && !goto_exten(chan, dialcontext, "a")) {
|
if (digit == '*' && !goto_exten(chan, dialcontext, "a")) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ext[0] = digit;
|
ext[0] = digit;
|
||||||
if (ast_readstring(chan, ext + 1, NUMDIGITS - 1, 3000, 3000, "#") < 0)
|
if (ast_readstring(chan, ext + 1, NUMDIGITS - 1, 3000, 3000, "#") < 0)
|
||||||
@@ -759,7 +759,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
|
|||||||
if (args.options && ast_app_parse_options(directory_app_options, &flags, opts, args.options))
|
if (args.options && ast_app_parse_options(directory_app_options, &flags, opts, args.options))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (ast_strlen_zero(args.dialcontext))
|
if (ast_strlen_zero(args.dialcontext))
|
||||||
args.dialcontext = args.vmcontext;
|
args.dialcontext = args.vmcontext;
|
||||||
|
|
||||||
cfg = realtime_directory(args.vmcontext);
|
cfg = realtime_directory(args.vmcontext);
|
||||||
@@ -767,7 +767,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_log(LOG_ERROR, "Unable to read the configuration data!\n");
|
ast_log(LOG_ERROR, "Unable to read the configuration data!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ucfg = ast_config_load("users.conf", config_flags);
|
ucfg = ast_config_load("users.conf", config_flags);
|
||||||
|
|
||||||
dirintro = ast_variable_retrieve(cfg, args.vmcontext, "directoryintro");
|
dirintro = ast_variable_retrieve(cfg, args.vmcontext, "directoryintro");
|
||||||
@@ -776,7 +776,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
|
|||||||
if (ast_strlen_zero(dirintro))
|
if (ast_strlen_zero(dirintro))
|
||||||
dirintro = ast_test_flag(&flags, OPT_LISTBYFIRSTNAME) ? "dir-intro-fn" : "dir-intro";
|
dirintro = ast_test_flag(&flags, OPT_LISTBYFIRSTNAME) ? "dir-intro-fn" : "dir-intro";
|
||||||
|
|
||||||
if (chan->_state != AST_STATE_UP)
|
if (chan->_state != AST_STATE_UP)
|
||||||
res = ast_answer(chan);
|
res = ast_answer(chan);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@@ -22,10 +22,10 @@
|
|||||||
* \brief DISA -- Direct Inward System Access Application
|
* \brief DISA -- Direct Inward System Access Application
|
||||||
*
|
*
|
||||||
* \author Jim Dixon <jim@lambdatel.com>
|
* \author Jim Dixon <jim@lambdatel.com>
|
||||||
*
|
*
|
||||||
* \ingroup applications
|
* \ingroup applications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "asterisk.h"
|
#include "asterisk.h"
|
||||||
|
|
||||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
@@ -49,7 +49,7 @@ static char *app = "DISA";
|
|||||||
|
|
||||||
static char *synopsis = "DISA (Direct Inward System Access)";
|
static char *synopsis = "DISA (Direct Inward System Access)";
|
||||||
|
|
||||||
static char *descrip =
|
static char *descrip =
|
||||||
"DISA(<numeric passcode>[,<context>[,<cid>[,mailbox[,options]]]]) or\n"
|
"DISA(<numeric passcode>[,<context>[,<cid>[,mailbox[,options]]]]) or\n"
|
||||||
"DISA(<filename>[,,,,options])\n"
|
"DISA(<filename>[,,,,options])\n"
|
||||||
"The DISA, Direct Inward System Access, application allows someone from \n"
|
"The DISA, Direct Inward System Access, application allows someone from \n"
|
||||||
@@ -138,7 +138,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_log(LOG_WARNING, "DISA requires an argument (passcode/passcode file)\n");
|
ast_log(LOG_WARNING, "DISA requires an argument (passcode/passcode file)\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_debug(1, "Digittimeout: %d\n", digittimeout);
|
ast_debug(1, "Digittimeout: %d\n", digittimeout);
|
||||||
ast_debug(1, "Responsetimeout: %d\n", firstdigittimeout);
|
ast_debug(1, "Responsetimeout: %d\n", firstdigittimeout);
|
||||||
|
|
||||||
@@ -146,8 +146,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
AST_STANDARD_APP_ARGS(args, tmp);
|
AST_STANDARD_APP_ARGS(args, tmp);
|
||||||
|
|
||||||
if (ast_strlen_zero(args.context))
|
if (ast_strlen_zero(args.context))
|
||||||
args.context = "disa";
|
args.context = "disa";
|
||||||
if (ast_strlen_zero(args.mailbox))
|
if (ast_strlen_zero(args.mailbox))
|
||||||
args.mailbox = "";
|
args.mailbox = "";
|
||||||
if (!ast_strlen_zero(args.options))
|
if (!ast_strlen_zero(args.options))
|
||||||
@@ -180,10 +180,10 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
|||||||
/* if outa time, give em reorder */
|
/* if outa time, give em reorder */
|
||||||
if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > ((k&2) ? digittimeout : firstdigittimeout)) {
|
if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > ((k&2) ? digittimeout : firstdigittimeout)) {
|
||||||
ast_debug(1,"DISA %s entry timeout on chan %s\n",
|
ast_debug(1,"DISA %s entry timeout on chan %s\n",
|
||||||
((k&1) ? "extension" : "password"),chan->name);
|
((k&1) ? "extension" : "password"),chan->name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = ast_waitfor(chan, -1) < 0)) {
|
if ((res = ast_waitfor(chan, -1) < 0)) {
|
||||||
ast_debug(1, "Waitfor returned %d\n", res);
|
ast_debug(1, "Waitfor returned %d\n", res);
|
||||||
continue;
|
continue;
|
||||||
@@ -210,7 +210,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
|
|
||||||
if (!i) {
|
if (!i) {
|
||||||
k |= 2; /* We have the first digit */
|
k |= 2; /* We have the first digit */
|
||||||
ast_playtones_stop(chan);
|
ast_playtones_stop(chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
|||||||
while(fgets(pwline,sizeof(pwline) - 1,fp)) {
|
while(fgets(pwline,sizeof(pwline) - 1,fp)) {
|
||||||
if (!pwline[0])
|
if (!pwline[0])
|
||||||
continue;
|
continue;
|
||||||
if (pwline[strlen(pwline) - 1] == '\n')
|
if (pwline[strlen(pwline) - 1] == '\n')
|
||||||
pwline[strlen(pwline) - 1] = 0;
|
pwline[strlen(pwline) - 1] = 0;
|
||||||
if (!pwline[0])
|
if (!pwline[0])
|
||||||
continue;
|
continue;
|
||||||
@@ -243,7 +243,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
AST_STANDARD_APP_ARGS(args, pwline);
|
AST_STANDARD_APP_ARGS(args, pwline);
|
||||||
|
|
||||||
ast_debug(1, "Mailbox: %s\n",args.mailbox);
|
ast_debug(1, "Mailbox: %s\n",args.mailbox);
|
||||||
|
|
||||||
/* password must be in valid format (numeric) */
|
/* password must be in valid format (numeric) */
|
||||||
|
@@ -38,7 +38,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
|
|
||||||
static char *app = "DumpChan";
|
static char *app = "DumpChan";
|
||||||
static char *synopsis = "Dump Info About The Calling Channel";
|
static char *synopsis = "Dump Info About The Calling Channel";
|
||||||
static char *desc =
|
static char *desc =
|
||||||
" DumpChan([<min_verbose_level>])\n"
|
" DumpChan([<min_verbose_level>])\n"
|
||||||
"Displays information on channel and listing of all channel\n"
|
"Displays information on channel and listing of all channel\n"
|
||||||
"variables. If min_verbose_level is specified, output is only\n"
|
"variables. If min_verbose_level is specified, output is only\n"
|
||||||
@@ -54,7 +54,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
|
|||||||
char cgrp[BUFSIZ/2];
|
char cgrp[BUFSIZ/2];
|
||||||
char pgrp[BUFSIZ/2];
|
char pgrp[BUFSIZ/2];
|
||||||
char formatbuf[BUFSIZ/2];
|
char formatbuf[BUFSIZ/2];
|
||||||
|
|
||||||
now = ast_tvnow();
|
now = ast_tvnow();
|
||||||
memset(buf, 0, size);
|
memset(buf, 0, size);
|
||||||
if (!c)
|
if (!c)
|
||||||
@@ -67,64 +67,64 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
|
|||||||
sec = elapsed_seconds % 60;
|
sec = elapsed_seconds % 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buf,size,
|
snprintf(buf,size,
|
||||||
"Name= %s\n"
|
"Name= %s\n"
|
||||||
"Type= %s\n"
|
"Type= %s\n"
|
||||||
"UniqueID= %s\n"
|
"UniqueID= %s\n"
|
||||||
"CallerIDNum= %s\n"
|
"CallerIDNum= %s\n"
|
||||||
"CallerIDName= %s\n"
|
"CallerIDName= %s\n"
|
||||||
"DNIDDigits= %s\n"
|
"DNIDDigits= %s\n"
|
||||||
"RDNIS= %s\n"
|
"RDNIS= %s\n"
|
||||||
"Language= %s\n"
|
"Language= %s\n"
|
||||||
"State= %s (%d)\n"
|
"State= %s (%d)\n"
|
||||||
"Rings= %d\n"
|
"Rings= %d\n"
|
||||||
"NativeFormat= %s\n"
|
"NativeFormat= %s\n"
|
||||||
"WriteFormat= %s\n"
|
"WriteFormat= %s\n"
|
||||||
"ReadFormat= %s\n"
|
"ReadFormat= %s\n"
|
||||||
"RawWriteFormat= %s\n"
|
"RawWriteFormat= %s\n"
|
||||||
"RawReadFormat= %s\n"
|
"RawReadFormat= %s\n"
|
||||||
"1stFileDescriptor= %d\n"
|
"1stFileDescriptor= %d\n"
|
||||||
"Framesin= %d %s\n"
|
"Framesin= %d %s\n"
|
||||||
"Framesout= %d %s\n"
|
"Framesout= %d %s\n"
|
||||||
"TimetoHangup= %ld\n"
|
"TimetoHangup= %ld\n"
|
||||||
"ElapsedTime= %dh%dm%ds\n"
|
"ElapsedTime= %dh%dm%ds\n"
|
||||||
"Context= %s\n"
|
"Context= %s\n"
|
||||||
"Extension= %s\n"
|
"Extension= %s\n"
|
||||||
"Priority= %d\n"
|
"Priority= %d\n"
|
||||||
"CallGroup= %s\n"
|
"CallGroup= %s\n"
|
||||||
"PickupGroup= %s\n"
|
"PickupGroup= %s\n"
|
||||||
"Application= %s\n"
|
"Application= %s\n"
|
||||||
"Data= %s\n"
|
"Data= %s\n"
|
||||||
"Blocking_in= %s\n",
|
"Blocking_in= %s\n",
|
||||||
c->name,
|
c->name,
|
||||||
c->tech->type,
|
c->tech->type,
|
||||||
c->uniqueid,
|
c->uniqueid,
|
||||||
S_OR(c->cid.cid_num, "(N/A)"),
|
S_OR(c->cid.cid_num, "(N/A)"),
|
||||||
S_OR(c->cid.cid_name, "(N/A)"),
|
S_OR(c->cid.cid_name, "(N/A)"),
|
||||||
S_OR(c->cid.cid_dnid, "(N/A)"),
|
S_OR(c->cid.cid_dnid, "(N/A)"),
|
||||||
S_OR(c->cid.cid_rdnis, "(N/A)"),
|
S_OR(c->cid.cid_rdnis, "(N/A)"),
|
||||||
c->language,
|
c->language,
|
||||||
ast_state2str(c->_state),
|
ast_state2str(c->_state),
|
||||||
c->_state,
|
c->_state,
|
||||||
c->rings,
|
c->rings,
|
||||||
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
|
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
|
||||||
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->writeformat),
|
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->writeformat),
|
||||||
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->readformat),
|
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->readformat),
|
||||||
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawwriteformat),
|
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawwriteformat),
|
||||||
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawreadformat),
|
ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->rawreadformat),
|
||||||
c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
|
c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
|
||||||
c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup,
|
c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup,
|
||||||
hour,
|
hour,
|
||||||
min,
|
min,
|
||||||
sec,
|
sec,
|
||||||
c->context,
|
c->context,
|
||||||
c->exten,
|
c->exten,
|
||||||
c->priority,
|
c->priority,
|
||||||
ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
|
ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
|
||||||
ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
|
ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
|
||||||
( c->appl ? c->appl : "(N/A)" ),
|
( c->appl ? c->appl : "(N/A)" ),
|
||||||
( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
|
( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
|
||||||
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
|
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -135,15 +135,15 @@ static int dumpchan_exec(struct ast_channel *chan, void *data)
|
|||||||
char info[1024];
|
char info[1024];
|
||||||
int level = 0;
|
int level = 0;
|
||||||
static char *line = "================================================================================";
|
static char *line = "================================================================================";
|
||||||
|
|
||||||
if (!ast_strlen_zero(data))
|
if (!ast_strlen_zero(data))
|
||||||
level = atoi(data);
|
level = atoi(data);
|
||||||
|
|
||||||
pbx_builtin_serialize_variables(chan, &vars);
|
pbx_builtin_serialize_variables(chan, &vars);
|
||||||
serialize_showchan(chan, info, sizeof(info));
|
serialize_showchan(chan, info, sizeof(info));
|
||||||
if (level > 0)
|
if (level > 0)
|
||||||
ast_verb(level, "\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, vars->str, line);
|
ast_verb(level, "\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, vars->str, line);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
* \brief Echo application -- play back what you hear to evaluate latency
|
* \brief Echo application -- play back what you hear to evaluate latency
|
||||||
*
|
*
|
||||||
* \author Mark Spencer <markster@digium.com>
|
* \author Mark Spencer <markster@digium.com>
|
||||||
*
|
*
|
||||||
* \ingroup applications
|
* \ingroup applications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ static char *app = "Echo";
|
|||||||
|
|
||||||
static char *synopsis = "Echo audio, video, or DTMF back to the calling party";
|
static char *synopsis = "Echo audio, video, or DTMF back to the calling party";
|
||||||
|
|
||||||
static char *descrip =
|
static char *descrip =
|
||||||
" Echo(): This application will echo any audio, video, or DTMF frames read from\n"
|
" Echo(): This application will echo any audio, video, or DTMF frames read from\n"
|
||||||
"the calling channel back to itself. If the DTMF digit '#' is received, the\n"
|
"the calling channel back to itself. If the DTMF digit '#' is received, the\n"
|
||||||
"application will exit.\n";
|
"application will exit.\n";
|
||||||
|
@@ -37,7 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
|
|
||||||
/* Maximum length of any variable */
|
/* Maximum length of any variable */
|
||||||
#define MAXRESULT 1024
|
#define MAXRESULT 1024
|
||||||
|
|
||||||
/*! Note
|
/*! Note
|
||||||
*
|
*
|
||||||
@@ -76,7 +76,7 @@ static char *tryexec_descrip =
|
|||||||
|
|
||||||
static char *app_execif = "ExecIf";
|
static char *app_execif = "ExecIf";
|
||||||
static char *execif_synopsis = "Executes dialplan application, conditionally";
|
static char *execif_synopsis = "Executes dialplan application, conditionally";
|
||||||
static char *execif_descrip =
|
static char *execif_descrip =
|
||||||
" ExecIF (<expr>?<appiftrue>(<args>)[:<appiffalse>(<args>)])\n"
|
" ExecIF (<expr>?<appiftrue>(<args>)[:<appiffalse>(<args>)])\n"
|
||||||
"If <expr> is true, execute and return the result of <appiftrue>(<args>).\n"
|
"If <expr> is true, execute and return the result of <appiftrue>(<args>).\n"
|
||||||
"If <expr> is true, but <appiftrue> is not found, then the application\n"
|
"If <expr> is true, but <appiftrue> is not found, then the application\n"
|
||||||
@@ -90,7 +90,7 @@ static int exec_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
if (ast_strlen_zero(data))
|
if (ast_strlen_zero(data))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
s = ast_strdupa(data);
|
s = ast_strdupa(data);
|
||||||
args[0] = 0;
|
args[0] = 0;
|
||||||
appname = strsep(&s, "(");
|
appname = strsep(&s, "(");
|
||||||
@@ -180,7 +180,7 @@ static int execif_exec(struct ast_channel *chan, void *data)
|
|||||||
*end = '\0';
|
*end = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pbx_checkcondition(expr.expr)) {
|
if (pbx_checkcondition(expr.expr)) {
|
||||||
if (!ast_strlen_zero(apps.t) && (app = pbx_findapp(apps.t))) {
|
if (!ast_strlen_zero(apps.t) && (app = pbx_findapp(apps.t))) {
|
||||||
res = pbx_exec(chan, app, S_OR(truedata, ""));
|
res = pbx_exec(chan, app, S_OR(truedata, ""));
|
||||||
} else {
|
} else {
|
||||||
|
@@ -50,7 +50,7 @@ static const char *app = "ExternalIVR";
|
|||||||
|
|
||||||
static const char *synopsis = "Interfaces with an external IVR application";
|
static const char *synopsis = "Interfaces with an external IVR application";
|
||||||
|
|
||||||
static const char *descrip =
|
static const char *descrip =
|
||||||
" ExternalIVR(command[,arg[,arg...]]): Forks a process to run the supplied command,\n"
|
" ExternalIVR(command[,arg[,arg...]]): Forks a process to run the supplied command,\n"
|
||||||
"and starts a generator on the channel. The generator's play list is\n"
|
"and starts a generator on the channel. The generator's play list is\n"
|
||||||
"controlled by the external application, which can add and clear entries\n"
|
"controlled by the external application, which can add and clear entries\n"
|
||||||
@@ -86,7 +86,7 @@ struct gen_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void send_child_event(FILE *handle, const char event, const char *data,
|
static void send_child_event(FILE *handle, const char event, const char *data,
|
||||||
const struct ast_channel *chan)
|
const struct ast_channel *chan)
|
||||||
{
|
{
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ static void *gen_alloc(struct ast_channel *chan, void *params)
|
|||||||
{
|
{
|
||||||
struct ivr_localuser *u = params;
|
struct ivr_localuser *u = params;
|
||||||
struct gen_state *state;
|
struct gen_state *state;
|
||||||
|
|
||||||
if (!(state = ast_calloc(1, sizeof(*state))))
|
if (!(state = ast_calloc(1, sizeof(*state))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ static int gen_nextfile(struct gen_state *state)
|
|||||||
{
|
{
|
||||||
struct ivr_localuser *u = state->u;
|
struct ivr_localuser *u = state->u;
|
||||||
char *file_to_stream;
|
char *file_to_stream;
|
||||||
|
|
||||||
u->abort_current_sound = 0;
|
u->abort_current_sound = 0;
|
||||||
u->playing_silence = 0;
|
u->playing_silence = 0;
|
||||||
gen_closestream(state);
|
gen_closestream(state);
|
||||||
@@ -155,7 +155,7 @@ static int gen_nextfile(struct gen_state *state)
|
|||||||
ast_chan_log(LOG_WARNING, u->chan, "File '%s' could not be opened: %s\n", file_to_stream, strerror(errno));
|
ast_chan_log(LOG_WARNING, u->chan, "File '%s' could not be opened: %s\n", file_to_stream, strerror(errno));
|
||||||
if (!u->playing_silence) {
|
if (!u->playing_silence) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,9 +168,9 @@ static struct ast_frame *gen_readframe(struct gen_state *state)
|
|||||||
{
|
{
|
||||||
struct ast_frame *f = NULL;
|
struct ast_frame *f = NULL;
|
||||||
struct ivr_localuser *u = state->u;
|
struct ivr_localuser *u = state->u;
|
||||||
|
|
||||||
if (u->abort_current_sound ||
|
if (u->abort_current_sound ||
|
||||||
(u->playing_silence && AST_LIST_FIRST(&u->playlist))) {
|
(u->playing_silence && AST_LIST_FIRST(&u->playlist))) {
|
||||||
gen_closestream(state);
|
gen_closestream(state);
|
||||||
AST_LIST_LOCK(&u->playlist);
|
AST_LIST_LOCK(&u->playlist);
|
||||||
gen_nextfile(state);
|
gen_nextfile(state);
|
||||||
@@ -225,7 +225,7 @@ static struct ast_generator gen =
|
|||||||
static struct playlist_entry *make_entry(const char *filename)
|
static struct playlist_entry *make_entry(const char *filename)
|
||||||
{
|
{
|
||||||
struct playlist_entry *entry;
|
struct playlist_entry *entry;
|
||||||
|
|
||||||
if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(filename) + 10))) /* XXX why 10 ? */
|
if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(filename) + 10))) /* XXX why 10 ? */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -262,10 +262,10 @@ static int app_exec(struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
u->abort_current_sound = 0;
|
u->abort_current_sound = 0;
|
||||||
u->chan = chan;
|
u->chan = chan;
|
||||||
|
|
||||||
if (ast_strlen_zero(data)) {
|
if (ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n");
|
ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = ast_strdupa(data);
|
buf = ast_strdupa(data);
|
||||||
@@ -515,7 +515,7 @@ static int app_exec(struct ast_channel *chan, void *data)
|
|||||||
command = ast_strip(input);
|
command = ast_strip(input);
|
||||||
ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", command);
|
ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", command);
|
||||||
}
|
}
|
||||||
} else if ((ready_fd < 0) && ms) {
|
} else if ((ready_fd < 0) && ms) {
|
||||||
if (errno == 0 || errno == EINTR)
|
if (errno == 0 || errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user