Fri Nov 12 12:11:19 2010

Asterisk developer's documentation


Module: Dial plan applications

Applications support the dialplan. They register dynamically with. More...

Files

file  app_adsiprog.c
 

Program Asterisk ADSI Scripts into phone.


file  app_alarmreceiver.c
 

Central Station Alarm receiver for Ademco Contact ID.


file  app_authenticate.c
 

Execute arbitrary authenticate commands.


file  app_cdr.c
 

Applications connected with CDR engine.


file  app_chanisavail.c
 

Check if Channel is Available.


file  app_channelredirect.c
 

ChannelRedirect application.


file  app_chanspy.c
 

ChanSpy: Listen in on any channel.


file  app_confbridge.c
 

Conference Bridge application.


file  app_controlplayback.c
 

Trivial application to control playback of a sound file.


file  app_dahdibarge.c
 

DAHDI Barge support.


file  app_dahdiras.c
 

Execute an ISDN RAS.


file  app_dahdiscan.c
 

DAHDI Scanner.


file  app_db.c
 

Database access functions.


file  app_dial.c
 

dial() & retrydial() - Trivial application to dial a channel and send an URL on answer


file  app_dictate.c
 

Virtual Dictation Machine Application For Asterisk.


file  app_directed_pickup.c
 

Directed Call Pickup Support.


file  app_directory.c
 

Provide a directory of extensions.


file  app_disa.c
 

DISA -- Direct Inward System Access Application.


file  app_dumpchan.c
 

Application to dump channel variables.


file  app_echo.c
 

Echo application -- play back what you hear to evaluate latency.


file  app_exec.c
 

Exec application.


file  app_externalivr.c
 

External IVR application interface.


file  app_festival.c
 

Connect to festival.


file  app_flash.c
 

App to flash a DAHDI trunk.


file  app_followme.c
 

Find-Me Follow-Me application.


file  app_forkcdr.c
 

Fork CDR application.


file  app_getcpeid.c
 

Get ADSI CPE ID.


file  app_ices.c
 

Stream to an icecast server via ICES (see contrib/asterisk-ices.xml).


file  app_image.c
 

App to transmit an image.


file  app_ivrdemo.c
 

IVR Demo application.


file  app_jack.c
 

Jack Application.


file  app_macro.c
 

Dial plan macro Implementation.


file  app_meetme.c
 

Meet me conference bridge and Shared Line Appearances.


file  app_milliwatt.c
 

Digital Milliwatt Test.


file  app_minivm.c
 

MiniVoiceMail - A Minimal Voicemail System for Asterisk.


file  app_mixmonitor.c
 

MixMonitor() - Record a call and mix the audio during the recording.


file  app_morsecode.c
 

Morsecode application.


file  app_mp3.c
 

Silly application to play an MP3 file -- uses mpg123.


file  app_nbscat.c
 

Silly application to play an NBScat file -- uses nbscat8k.


file  app_originate.c
 

Originate application.


file  app_osplookup.c
 

Open Settlement Protocol (OSP) Applications.


file  app_page.c
 

page() - Paging application


file  app_parkandannounce.c
 

ParkAndAnnounce application for Asterisk.


file  app_playback.c
 

Trivial application to playback a sound file.


file  app_playtones.c
 

Playtones application.


file  app_privacy.c
 

Block all calls without Caller*ID, require phone # to be entered.


file  app_queue.c
 

True call queues with optional send URL on answer.


file  app_read.c
 

Trivial application to read a variable.


file  app_readexten.c
 

Trivial application to read an extension into a variable.


file  app_readfile.c
 

ReadFile application -- Reads in a File for you.


file  app_record.c
 

Trivial application to record a sound file.


file  app_sayunixtime.c
 

SayUnixTime application.


file  app_senddtmf.c
 

App to send DTMF digits.


file  app_sendtext.c
 

App to transmit a text message.


file  app_setcallerid.c
 

App to set callerid presentation.


file  app_skel.c
 

Skeleton application.


file  app_sms.c
 

SMS application - ETSI ES 201 912 protocol 1 implementation.


file  app_softhangup.c
 

SoftHangup application.


file  app_speech_utils.c
 

Speech Recognition Utility Applications.


file  app_stack.c
 

Stack applications Gosub, Return, etc.


file  app_system.c
 

Execute arbitrary system commands.


file  app_talkdetect.c
 

Playback a file with audio detect.


file  app_test.c
 

Applications to test connection and produce report in text file.


file  app_transfer.c
 

Transfer a caller.


file  app_url.c
 

App to transmit a URL.


file  app_userevent.c
 

UserEvent application -- send manager event.


file  app_verbose.c
 

Verbose logging application.


file  app_voicemail.c
 

Comedian Mail - Voicemail System.


file  app_waitforring.c
 

Wait for Ring Application.


file  app_waitforsilence.c
 

Wait for Silence

  • Waits for up to 'x' milliseconds of silence, 'y' times
  • WaitForSilence(500,2) will wait for 1/2 second of silence, twice
  • WaitForSilence(1000,1) will wait for 1 second of silence, once
  • WaitForSilence(300,3,10) will wait for 300ms of silence, 3 times, and return after 10sec
    .

file  app_waituntil.c
 

Sleep until the given epoch.


file  app_while.c
 

While Loop Implementation.


file  app_zapateller.c
 

Playback the special information tone to get rid of telemarketers.


file  res_ael_share.c
 

Shareable AEL code -- mainly between internal and external modules.


file  res_realtime.c
 

RealTime CLI.


Functions

static int iax2_prov_app (struct ast_channel *chan, void *data)
static int pbx_builtin_answer (struct ast_channel *, void *)
static int pbx_builtin_background (struct ast_channel *, void *)
static int pbx_builtin_busy (struct ast_channel *, void *)
static int pbx_builtin_congestion (struct ast_channel *, void *)
static int pbx_builtin_execiftime (struct ast_channel *, void *)
static int pbx_builtin_goto (struct ast_channel *, void *)
static int pbx_builtin_gotoiftime (struct ast_channel *, void *)
static int pbx_builtin_hangup (struct ast_channel *, void *)
static int pbx_builtin_proceeding (struct ast_channel *, void *)
static int pbx_builtin_progress (struct ast_channel *, void *)
static int pbx_builtin_resetcdr (struct ast_channel *, void *)
static int pbx_builtin_ringing (struct ast_channel *, void *)
static int pbx_builtin_setamaflags (struct ast_channel *, void *)
static int pbx_builtin_wait (struct ast_channel *, void *)
static int pbx_builtin_waitexten (struct ast_channel *, void *)

Detailed Description

Applications support the dialplan. They register dynamically with.

Asterisk Dial Plan Applications

See also:
ast_register_application() and unregister with
ast_unregister_application()
See also

Function Documentation

static int iax2_prov_app ( struct ast_channel chan,
void *  data 
) [static]

iax2provision

Definition at line 11373 of file chan_iax2.c.

References iax2_trunk_peer::addr, ast_inet_ntoa(), ast_log(), ast_strlen_zero(), ast_verb, iax2_provision(), LOG_NOTICE, PTR_TO_CALLNO, iax2_trunk_peer::sockfd, ast_channel::tech, and ast_channel::tech_pvt.

Referenced by load_module().

11374 {
11375    int res;
11376    char *sdata;
11377    char *opts;
11378    int force =0;
11379    unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
11380    if (ast_strlen_zero(data))
11381       data = "default";
11382    sdata = ast_strdupa(data);
11383    opts = strchr(sdata, '|');
11384    if (opts)
11385       *opts='\0';
11386 
11387    if (chan->tech != &iax2_tech) {
11388       ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
11389       return -1;
11390    } 
11391    if (!callno || !iaxs[callno] || !iaxs[callno]->addr.sin_addr.s_addr) {
11392       ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
11393       return -1;
11394    }
11395    res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
11396    ast_verb(3, "Provisioned IAXY at '%s' with '%s'= %d\n",
11397       ast_inet_ntoa(iaxs[callno]->addr.sin_addr),
11398       sdata, res);
11399    return res;
11400 }

static int pbx_builtin_answer ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8504 of file pbx.c.

References __ast_answer(), ast_channel::_state, AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strlen_zero(), and parse().

08505 {
08506    int delay = 0;
08507    int answer_cdr = 1;
08508    char *parse;
08509    AST_DECLARE_APP_ARGS(args,
08510       AST_APP_ARG(delay);
08511       AST_APP_ARG(answer_cdr);
08512    );
08513 
08514    if (ast_strlen_zero(data)) {
08515       return __ast_answer(chan, 0, 1);
08516    }
08517 
08518    parse = ast_strdupa(data);
08519 
08520    AST_STANDARD_APP_ARGS(args, parse);
08521 
08522    if (!ast_strlen_zero(args.delay) && (chan->_state != AST_STATE_UP))
08523       delay = atoi(data);
08524 
08525    if (delay < 0) {
08526       delay = 0;
08527    }
08528 
08529    if (!ast_strlen_zero(args.answer_cdr) && !strcasecmp(args.answer_cdr, "nocdr")) {
08530       answer_cdr = 0;
08531    }
08532 
08533    return __ast_answer(chan, delay, answer_cdr);
08534 }

static int pbx_builtin_background ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8798 of file pbx.c.

References ast_channel::_state, ast_answer(), AST_APP_ARG, ast_app_parse_options(), ast_canmatch_extension(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, AST_FLAG_DISABLE_WORKAROUNDS, ast_log(), ast_matchmore_extension(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_waitstream(), ast_waitstream_exten(), BACKGROUND_MATCHEXTEN, BACKGROUND_NOANSWER, background_opts, BACKGROUND_PLAYBACK, BACKGROUND_SKIP, ast_channel::cid, ast_callerid::cid_num, ast_channel::context, ast_channel::exten, ast_flags::flags, ast_channel::language, LOG_WARNING, ast_channel::name, parse(), pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and ast_channel::priority.

08799 {
08800    int res = 0;
08801    int mres = 0;
08802    struct ast_flags flags = {0};
08803    char *parse, exten[2] = "";
08804    AST_DECLARE_APP_ARGS(args,
08805       AST_APP_ARG(filename);
08806       AST_APP_ARG(options);
08807       AST_APP_ARG(lang);
08808       AST_APP_ARG(context);
08809    );
08810 
08811    if (ast_strlen_zero(data)) {
08812       ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
08813       return -1;
08814    }
08815 
08816    parse = ast_strdupa(data);
08817 
08818    AST_STANDARD_APP_ARGS(args, parse);
08819 
08820    if (ast_strlen_zero(args.lang))
08821       args.lang = (char *)chan->language; /* XXX this is const */
08822 
08823    if (ast_strlen_zero(args.context)) {
08824       const char *context;
08825       ast_channel_lock(chan);
08826       if ((context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"))) {
08827          args.context = ast_strdupa(context);
08828       } else {
08829          args.context = chan->context;
08830       }
08831       ast_channel_unlock(chan);
08832    }
08833 
08834    if (args.options) {
08835       if (!strcasecmp(args.options, "skip"))
08836          flags.flags = BACKGROUND_SKIP;
08837       else if (!strcasecmp(args.options, "noanswer"))
08838          flags.flags = BACKGROUND_NOANSWER;
08839       else
08840          ast_app_parse_options(background_opts, &flags, NULL, args.options);
08841    }
08842 
08843    /* Answer if need be */
08844    if (chan->_state != AST_STATE_UP) {
08845       if (ast_test_flag(&flags, BACKGROUND_SKIP)) {
08846          goto done;
08847       } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
08848          res = ast_answer(chan);
08849       }
08850    }
08851 
08852    if (!res) {
08853       char *back = args.filename;
08854       char *front;
08855 
08856       ast_stopstream(chan);      /* Stop anything playing */
08857       /* Stream the list of files */
08858       while (!res && (front = strsep(&back, "&")) ) {
08859          if ( (res = ast_streamfile(chan, front, args.lang)) ) {
08860             ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data);
08861             res = 0;
08862             mres = 1;
08863             break;
08864          }
08865          if (ast_test_flag(&flags, BACKGROUND_PLAYBACK)) {
08866             res = ast_waitstream(chan, "");
08867          } else if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) {
08868             res = ast_waitstream_exten(chan, args.context);
08869          } else {
08870             res = ast_waitstream(chan, AST_DIGIT_ANY);
08871          }
08872          ast_stopstream(chan);
08873       }
08874    }
08875 
08876    /*
08877     * If the single digit DTMF is an extension in the specified context, then
08878     * go there and signal no DTMF.  Otherwise, we should exit with that DTMF.
08879     * If we're in Macro, we'll exit and seek that DTMF as the beginning of an
08880     * extension in the Macro's calling context.  If we're not in Macro, then
08881     * we'll simply seek that extension in the calling context.  Previously,
08882     * someone complained about the behavior as it related to the interior of a
08883     * Gosub routine, and the fix (#14011) inadvertently broke FreePBX
08884     * (#14940).  This change should fix both of these situations, but with the
08885     * possible incompatibility that if a single digit extension does not exist
08886     * (but a longer extension COULD have matched), it would have previously
08887     * gone immediately to the "i" extension, but will now need to wait for a
08888     * timeout.
08889     *
08890     * Later, we had to add a flag to disable this workaround, because AGI
08891     * users can EXEC Background and reasonably expect that the DTMF code will
08892     * be returned (see #16434).
08893     */
08894    if (!ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS) &&
08895          (exten[0] = res) &&
08896          ast_canmatch_extension(chan, args.context, exten, 1, chan->cid.cid_num) &&
08897          !ast_matchmore_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
08898       snprintf(chan->exten, sizeof(chan->exten), "%c", res);
08899       ast_copy_string(chan->context, args.context, sizeof(chan->context));
08900       chan->priority = 0;
08901       res = 0;
08902    }
08903 done:
08904    pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", mres ? "FAILED" : "SUCCESS");
08905    return res;
08906 }

static int pbx_builtin_busy ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8474 of file pbx.c.

References ast_channel::_state, ast_cdr_busy(), AST_CONTROL_BUSY, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, ast_channel::cdr, and wait_for_hangup().

Referenced by __ast_pbx_run().

08475 {
08476    ast_indicate(chan, AST_CONTROL_BUSY);
08477    /* Don't change state of an UP channel, just indicate
08478       busy in audio */
08479    if (chan->_state != AST_STATE_UP) {
08480       ast_setstate(chan, AST_STATE_BUSY);
08481       ast_cdr_busy(chan->cdr);
08482    }
08483    wait_for_hangup(chan, data);
08484    return -1;
08485 }

static int pbx_builtin_congestion ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8490 of file pbx.c.

References ast_channel::_state, AST_CONTROL_CONGESTION, ast_indicate(), ast_setstate(), AST_STATE_BUSY, AST_STATE_UP, and wait_for_hangup().

Referenced by __ast_pbx_run().

08491 {
08492    ast_indicate(chan, AST_CONTROL_CONGESTION);
08493    /* Don't change state of an UP channel, just indicate
08494       congestion in audio */
08495    if (chan->_state != AST_STATE_UP)
08496       ast_setstate(chan, AST_STATE_BUSY);
08497    wait_for_hangup(chan, data);
08498    return -1;
08499 }

static int pbx_builtin_execiftime ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8659 of file pbx.c.

References ast_build_timing(), ast_check_timing(), ast_destroy_timing(), ast_log(), ast_strlen_zero(), LOG_WARNING, pbx_exec(), pbx_findapp(), s, and S_OR.

08660 {
08661    char *s, *appname;
08662    struct ast_timing timing;
08663    struct ast_app *app;
08664    static const char *usage = "ExecIfTime requires an argument:\n  <time range>,<days of week>,<days of month>,<months>[,<timezone>]?<appname>[(<appargs>)]";
08665 
08666    if (ast_strlen_zero(data)) {
08667       ast_log(LOG_WARNING, "%s\n", usage);
08668       return -1;
08669    }
08670 
08671    appname = ast_strdupa(data);
08672 
08673    s = strsep(&appname, "?"); /* Separate the timerange and application name/data */
08674    if (!appname) {   /* missing application */
08675       ast_log(LOG_WARNING, "%s\n", usage);
08676       return -1;
08677    }
08678 
08679    if (!ast_build_timing(&timing, s)) {
08680       ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
08681       ast_destroy_timing(&timing);
08682       return -1;
08683    }
08684 
08685    if (!ast_check_timing(&timing))  { /* outside the valid time window, just return */
08686       ast_destroy_timing(&timing);
08687       return 0;
08688    }
08689    ast_destroy_timing(&timing);
08690 
08691    /* now split appname(appargs) */
08692    if ((s = strchr(appname, '('))) {
08693       char *e;
08694       *s++ = '\0';
08695       if ((e = strrchr(s, ')')))
08696          *e = '\0';
08697       else
08698          ast_log(LOG_WARNING, "Failed to find closing parenthesis\n");
08699    }
08700 
08701 
08702    if ((app = pbx_findapp(appname))) {
08703       return pbx_exec(chan, app, S_OR(s, ""));
08704    } else {
08705       ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
08706       return -1;
08707    }
08708 }

static int pbx_builtin_goto ( struct ast_channel chan,
void *  data 
) [static]

Goto

Definition at line 8911 of file pbx.c.

References ast_parseable_goto(), ast_verb, ast_channel::context, ast_channel::exten, and ast_channel::priority.

Referenced by pbx_builtin_gotoif(), and pbx_builtin_gotoiftime().

08912 {
08913    int res = ast_parseable_goto(chan, data);
08914    if (!res)
08915       ast_verb(3, "Goto (%s,%s,%d)\n", chan->context, chan->exten, chan->priority + 1);
08916    return res;
08917 }

static int pbx_builtin_gotoiftime ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8624 of file pbx.c.

References ast_build_timing(), ast_check_timing(), ast_debug, ast_destroy_timing(), ast_log(), ast_strlen_zero(), LOG_WARNING, pbx_builtin_goto(), and s.

08625 {
08626    char *s, *ts, *branch1, *branch2, *branch;
08627    struct ast_timing timing;
08628 
08629    if (ast_strlen_zero(data)) {
08630       ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n  <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n");
08631       return -1;
08632    }
08633 
08634    ts = s = ast_strdupa(data);
08635 
08636    /* Separate the Goto path */
08637    strsep(&ts, "?");
08638    branch1 = strsep(&ts,":");
08639    branch2 = strsep(&ts,"");
08640 
08641    /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
08642    if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
08643       branch = branch1;
08644    else
08645       branch = branch2;
08646    ast_destroy_timing(&timing);
08647 
08648    if (ast_strlen_zero(branch)) {
08649       ast_debug(1, "Not taking any branch\n");
08650       return 0;
08651    }
08652 
08653    return pbx_builtin_goto(chan, branch);
08654 }

static int pbx_builtin_hangup ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8594 of file pbx.c.

References AST_CAUSE_NORMAL_CLEARING, ast_log(), ast_str2cause(), ast_strlen_zero(), cause, ast_channel::hangupcause, and LOG_WARNING.

08595 {
08596    if (!ast_strlen_zero(data)) {
08597       int cause;
08598       char *endptr;
08599 
08600       if ((cause = ast_str2cause(data)) > -1) {
08601          chan->hangupcause = cause;
08602          return -1;
08603       }
08604 
08605       cause = strtol((const char *) data, &endptr, 10);
08606       if (cause != 0 || (data != endptr)) {
08607          chan->hangupcause = cause;
08608          return -1;
08609       }
08610 
08611       ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
08612    }
08613 
08614    if (!chan->hangupcause) {
08615       chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
08616    }
08617 
08618    return -1;
08619 }

static int pbx_builtin_proceeding ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8447 of file pbx.c.

References AST_CONTROL_PROCEEDING, and ast_indicate().

08448 {
08449    ast_indicate(chan, AST_CONTROL_PROCEEDING);
08450    return 0;
08451 }

static int pbx_builtin_progress ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8456 of file pbx.c.

References AST_CONTROL_PROGRESS, and ast_indicate().

08457 {
08458    ast_indicate(chan, AST_CONTROL_PROGRESS);
08459    return 0;
08460 }

static int pbx_builtin_resetcdr ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8566 of file pbx.c.

References ast_app_parse_options(), ast_cdr_reset(), ast_strlen_zero(), ast_channel::cdr, and resetcdr_opts.

08567 {
08568    char *args;
08569    struct ast_flags flags = { 0 };
08570 
08571    if (!ast_strlen_zero(data)) {
08572       args = ast_strdupa(data);
08573       ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
08574    }
08575 
08576    ast_cdr_reset(chan->cdr, &flags);
08577 
08578    return 0;
08579 }

static int pbx_builtin_ringing ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8465 of file pbx.c.

References AST_CONTROL_RINGING, and ast_indicate().

08466 {
08467    ast_indicate(chan, AST_CONTROL_RINGING);
08468    return 0;
08469 }

static int pbx_builtin_setamaflags ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8584 of file pbx.c.

References ast_cdr_setamaflags().

08585 {
08586    /* Copy the AMA Flags as specified */
08587    ast_cdr_setamaflags(chan, data ? data : "");
08588    return 0;
08589 }

static int pbx_builtin_wait ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8713 of file pbx.c.

References ast_safe_sleep(), and s.

08714 {
08715    double s;
08716    int ms;
08717 
08718    /* Wait for "n" seconds */
08719    if (data && (s = atof(data)) > 0.0) {
08720       ms = s * 1000.0;
08721       return ast_safe_sleep(chan, ms);
08722    }
08723    return 0;
08724 }

static int pbx_builtin_waitexten ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 8729 of file pbx.c.

References ast_channel::_softhangup, AST_APP_ARG, ast_app_parse_options(), AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_get_indication_tone(), ast_indicate(), ast_indicate_data(), ast_log(), ast_playtones_start(), ast_playtones_stop(), AST_SOFTHANGUP_TIMEOUT, AST_STANDARD_APP_ARGS, ast_strlen_zero(), ast_test_flag, ast_tone_zone_sound_unref(), ast_tonepair_start(), ast_verb, ast_waitfordigit(), ast_channel::cid, ast_callerid::cid_num, ast_channel::context, ast_tone_zone_sound::data, ast_channel::exten, LOG_WARNING, ast_channel::name, parse(), ast_channel::pbx, ast_channel::priority, ast_pbx::rtimeoutms, s, S_OR, set_ext_pri(), WAITEXTEN_DIALTONE, WAITEXTEN_MOH, waitexten_opts, and ast_channel::zone.

08730 {
08731    int ms, res;
08732    double s;
08733    struct ast_flags flags = {0};
08734    char *opts[1] = { NULL };
08735    char *parse;
08736    AST_DECLARE_APP_ARGS(args,
08737       AST_APP_ARG(timeout);
08738       AST_APP_ARG(options);
08739    );
08740 
08741    if (!ast_strlen_zero(data)) {
08742       parse = ast_strdupa(data);
08743       AST_STANDARD_APP_ARGS(args, parse);
08744    } else
08745       memset(&args, 0, sizeof(args));
08746 
08747    if (args.options)
08748       ast_app_parse_options(waitexten_opts, &flags, opts, args.options);
08749 
08750    if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
08751       ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n"); 
08752    } else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
08753       ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL), strlen(opts[0]));
08754    } else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
08755       struct ast_tone_zone_sound *ts = ast_get_indication_tone(chan->zone, "dial");
08756       if (ts) {
08757          ast_playtones_start(chan, 0, ts->data, 0);
08758          ts = ast_tone_zone_sound_unref(ts);
08759       } else {
08760          ast_tonepair_start(chan, 350, 440, 0, 0);
08761       }
08762    }
08763    /* Wait for "n" seconds */
08764    if (args.timeout && (s = atof(args.timeout)) > 0)
08765        ms = s * 1000.0;
08766    else if (chan->pbx)
08767       ms = chan->pbx->rtimeoutms;
08768    else
08769       ms = 10000;
08770 
08771    res = ast_waitfordigit(chan, ms);
08772    if (!res) {
08773       if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) {
08774          ast_verb(3, "Timeout on %s, continuing...\n", chan->name);
08775       } else if (chan->_softhangup == AST_SOFTHANGUP_TIMEOUT) {
08776          ast_verb(3, "Call timeout on %s, checking for 'T'\n", chan->name);
08777          res = -1;
08778       } else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) {
08779          ast_verb(3, "Timeout on %s, going to 't'\n", chan->name);
08780          set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
08781       } else {
08782          ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context);
08783          res = -1;
08784       }
08785    }
08786 
08787    if (ast_test_flag(&flags, WAITEXTEN_MOH))
08788       ast_indicate(chan, AST_CONTROL_UNHOLD);
08789    else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE))
08790       ast_playtones_stop(chan);
08791 
08792    return res;
08793 }


Generated by  doxygen 1.6.2