Thu Oct 11 06:49:58 2012

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 11431 of file chan_iax2.c.

References iax2_trunk_peer::addr, ast_inet_ntoa(), ast_log(), ast_strdupa, 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().

11432 {
11433    int res;
11434    char *sdata;
11435    char *opts;
11436    int force =0;
11437    unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
11438    if (ast_strlen_zero(data))
11439       data = "default";
11440    sdata = ast_strdupa(data);
11441    opts = strchr(sdata, '|');
11442    if (opts)
11443       *opts='\0';
11444 
11445    if (chan->tech != &iax2_tech) {
11446       ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
11447       return -1;
11448    } 
11449    if (!callno || !iaxs[callno] || !iaxs[callno]->addr.sin_addr.s_addr) {
11450       ast_log(LOG_NOTICE, "Can't provision something with no IP?\n");
11451       return -1;
11452    }
11453    res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
11454    ast_verb(3, "Provisioned IAXY at '%s' with '%s'= %d\n",
11455       ast_inet_ntoa(iaxs[callno]->addr.sin_addr),
11456       sdata, res);
11457    return res;
11458 }

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

Definition at line 8573 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_strdupa, ast_strlen_zero(), and parse().

08574 {
08575    int delay = 0;
08576    int answer_cdr = 1;
08577    char *parse;
08578    AST_DECLARE_APP_ARGS(args,
08579       AST_APP_ARG(delay);
08580       AST_APP_ARG(answer_cdr);
08581    );
08582 
08583    if (ast_strlen_zero(data)) {
08584       return __ast_answer(chan, 0, 1);
08585    }
08586 
08587    parse = ast_strdupa(data);
08588 
08589    AST_STANDARD_APP_ARGS(args, parse);
08590 
08591    if (!ast_strlen_zero(args.delay) && (chan->_state != AST_STATE_UP))
08592       delay = atoi(data);
08593 
08594    if (delay < 0) {
08595       delay = 0;
08596    }
08597 
08598    if (!ast_strlen_zero(args.answer_cdr) && !strcasecmp(args.answer_cdr, "nocdr")) {
08599       answer_cdr = 0;
08600    }
08601 
08602    return __ast_answer(chan, delay, answer_cdr);
08603 }

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

Definition at line 8867 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_strdupa, 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(), ast_channel::priority, and strsep().

08868 {
08869    int res = 0;
08870    int mres = 0;
08871    struct ast_flags flags = {0};
08872    char *parse, exten[2] = "";
08873    AST_DECLARE_APP_ARGS(args,
08874       AST_APP_ARG(filename);
08875       AST_APP_ARG(options);
08876       AST_APP_ARG(lang);
08877       AST_APP_ARG(context);
08878    );
08879 
08880    if (ast_strlen_zero(data)) {
08881       ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
08882       return -1;
08883    }
08884 
08885    parse = ast_strdupa(data);
08886 
08887    AST_STANDARD_APP_ARGS(args, parse);
08888 
08889    if (ast_strlen_zero(args.lang))
08890       args.lang = (char *)chan->language; /* XXX this is const */
08891 
08892    if (ast_strlen_zero(args.context)) {
08893       const char *context;
08894       ast_channel_lock(chan);
08895       if ((context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"))) {
08896          args.context = ast_strdupa(context);
08897       } else {
08898          args.context = chan->context;
08899       }
08900       ast_channel_unlock(chan);
08901    }
08902 
08903    if (args.options) {
08904       if (!strcasecmp(args.options, "skip"))
08905          flags.flags = BACKGROUND_SKIP;
08906       else if (!strcasecmp(args.options, "noanswer"))
08907          flags.flags = BACKGROUND_NOANSWER;
08908       else
08909          ast_app_parse_options(background_opts, &flags, NULL, args.options);
08910    }
08911 
08912    /* Answer if need be */
08913    if (chan->_state != AST_STATE_UP) {
08914       if (ast_test_flag(&flags, BACKGROUND_SKIP)) {
08915          goto done;
08916       } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
08917          res = ast_answer(chan);
08918       }
08919    }
08920 
08921    if (!res) {
08922       char *back = args.filename;
08923       char *front;
08924 
08925       ast_stopstream(chan);      /* Stop anything playing */
08926       /* Stream the list of files */
08927       while (!res && (front = strsep(&back, "&")) ) {
08928          if ( (res = ast_streamfile(chan, front, args.lang)) ) {
08929             ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data);
08930             res = 0;
08931             mres = 1;
08932             break;
08933          }
08934          if (ast_test_flag(&flags, BACKGROUND_PLAYBACK)) {
08935             res = ast_waitstream(chan, "");
08936          } else if (ast_test_flag(&flags, BACKGROUND_MATCHEXTEN)) {
08937             res = ast_waitstream_exten(chan, args.context);
08938          } else {
08939             res = ast_waitstream(chan, AST_DIGIT_ANY);
08940          }
08941          ast_stopstream(chan);
08942       }
08943    }
08944 
08945    /*
08946     * If the single digit DTMF is an extension in the specified context, then
08947     * go there and signal no DTMF.  Otherwise, we should exit with that DTMF.
08948     * If we're in Macro, we'll exit and seek that DTMF as the beginning of an
08949     * extension in the Macro's calling context.  If we're not in Macro, then
08950     * we'll simply seek that extension in the calling context.  Previously,
08951     * someone complained about the behavior as it related to the interior of a
08952     * Gosub routine, and the fix (#14011) inadvertently broke FreePBX
08953     * (#14940).  This change should fix both of these situations, but with the
08954     * possible incompatibility that if a single digit extension does not exist
08955     * (but a longer extension COULD have matched), it would have previously
08956     * gone immediately to the "i" extension, but will now need to wait for a
08957     * timeout.
08958     *
08959     * Later, we had to add a flag to disable this workaround, because AGI
08960     * users can EXEC Background and reasonably expect that the DTMF code will
08961     * be returned (see #16434).
08962     */
08963    if (!ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS) &&
08964          (exten[0] = res) &&
08965          ast_canmatch_extension(chan, args.context, exten, 1, chan->cid.cid_num) &&
08966          !ast_matchmore_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
08967       snprintf(chan->exten, sizeof(chan->exten), "%c", res);
08968       ast_copy_string(chan->context, args.context, sizeof(chan->context));
08969       chan->priority = 0;
08970       res = 0;
08971    }
08972 done:
08973    pbx_builtin_setvar_helper(chan, "BACKGROUNDSTATUS", mres ? "FAILED" : "SUCCESS");
08974    return res;
08975 }

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

Definition at line 8543 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().

08544 {
08545    ast_indicate(chan, AST_CONTROL_BUSY);
08546    /* Don't change state of an UP channel, just indicate
08547       busy in audio */
08548    if (chan->_state != AST_STATE_UP) {
08549       ast_setstate(chan, AST_STATE_BUSY);
08550       ast_cdr_busy(chan->cdr);
08551    }
08552    wait_for_hangup(chan, data);
08553    return -1;
08554 }

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

Definition at line 8559 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().

08560 {
08561    ast_indicate(chan, AST_CONTROL_CONGESTION);
08562    /* Don't change state of an UP channel, just indicate
08563       congestion in audio */
08564    if (chan->_state != AST_STATE_UP)
08565       ast_setstate(chan, AST_STATE_BUSY);
08566    wait_for_hangup(chan, data);
08567    return -1;
08568 }

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

Definition at line 8728 of file pbx.c.

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

08729 {
08730    char *s, *appname;
08731    struct ast_timing timing;
08732    struct ast_app *app;
08733    static const char *usage = "ExecIfTime requires an argument:\n  <time range>,<days of week>,<days of month>,<months>[,<timezone>]?<appname>[(<appargs>)]";
08734 
08735    if (ast_strlen_zero(data)) {
08736       ast_log(LOG_WARNING, "%s\n", usage);
08737       return -1;
08738    }
08739 
08740    appname = ast_strdupa(data);
08741 
08742    s = strsep(&appname, "?"); /* Separate the timerange and application name/data */
08743    if (!appname) {   /* missing application */
08744       ast_log(LOG_WARNING, "%s\n", usage);
08745       return -1;
08746    }
08747 
08748    if (!ast_build_timing(&timing, s)) {
08749       ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage);
08750       ast_destroy_timing(&timing);
08751       return -1;
08752    }
08753 
08754    if (!ast_check_timing(&timing))  { /* outside the valid time window, just return */
08755       ast_destroy_timing(&timing);
08756       return 0;
08757    }
08758    ast_destroy_timing(&timing);
08759 
08760    /* now split appname(appargs) */
08761    if ((s = strchr(appname, '('))) {
08762       char *e;
08763       *s++ = '\0';
08764       if ((e = strrchr(s, ')')))
08765          *e = '\0';
08766       else
08767          ast_log(LOG_WARNING, "Failed to find closing parenthesis\n");
08768    }
08769 
08770 
08771    if ((app = pbx_findapp(appname))) {
08772       return pbx_exec(chan, app, S_OR(s, ""));
08773    } else {
08774       ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
08775       return -1;
08776    }
08777 }

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

Goto

Definition at line 8980 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().

08981 {
08982    int res = ast_parseable_goto(chan, data);
08983    if (!res)
08984       ast_verb(3, "Goto (%s,%s,%d)\n", chan->context, chan->exten, chan->priority + 1);
08985    return res;
08986 }

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

Definition at line 8693 of file pbx.c.

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

08694 {
08695    char *s, *ts, *branch1, *branch2, *branch;
08696    struct ast_timing timing;
08697 
08698    if (ast_strlen_zero(data)) {
08699       ast_log(LOG_WARNING, "GotoIfTime requires an argument:\n  <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n");
08700       return -1;
08701    }
08702 
08703    ts = s = ast_strdupa(data);
08704 
08705    /* Separate the Goto path */
08706    strsep(&ts, "?");
08707    branch1 = strsep(&ts,":");
08708    branch2 = strsep(&ts,"");
08709 
08710    /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
08711    if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
08712       branch = branch1;
08713    else
08714       branch = branch2;
08715    ast_destroy_timing(&timing);
08716 
08717    if (ast_strlen_zero(branch)) {
08718       ast_debug(1, "Not taking any branch\n");
08719       return 0;
08720    }
08721 
08722    return pbx_builtin_goto(chan, branch);
08723 }

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

Definition at line 8663 of file pbx.c.

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

08664 {
08665    if (!ast_strlen_zero(data)) {
08666       int cause;
08667       char *endptr;
08668 
08669       if ((cause = ast_str2cause(data)) > -1) {
08670          chan->hangupcause = cause;
08671          return -1;
08672       }
08673 
08674       cause = strtol((const char *) data, &endptr, 10);
08675       if (cause != 0 || (data != endptr)) {
08676          chan->hangupcause = cause;
08677          return -1;
08678       }
08679 
08680       ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
08681    }
08682 
08683    if (!chan->hangupcause) {
08684       chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
08685    }
08686 
08687    return -1;
08688 }

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

Definition at line 8516 of file pbx.c.

References AST_CONTROL_PROCEEDING, and ast_indicate().

08517 {
08518    ast_indicate(chan, AST_CONTROL_PROCEEDING);
08519    return 0;
08520 }

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

Definition at line 8525 of file pbx.c.

References AST_CONTROL_PROGRESS, and ast_indicate().

08526 {
08527    ast_indicate(chan, AST_CONTROL_PROGRESS);
08528    return 0;
08529 }

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

Definition at line 8635 of file pbx.c.

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

08636 {
08637    char *args;
08638    struct ast_flags flags = { 0 };
08639 
08640    if (!ast_strlen_zero(data)) {
08641       args = ast_strdupa(data);
08642       ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
08643    }
08644 
08645    ast_cdr_reset(chan->cdr, &flags);
08646 
08647    return 0;
08648 }

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

Definition at line 8534 of file pbx.c.

References AST_CONTROL_RINGING, and ast_indicate().

08535 {
08536    ast_indicate(chan, AST_CONTROL_RINGING);
08537    return 0;
08538 }

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

Definition at line 8653 of file pbx.c.

References ast_cdr_setamaflags().

08654 {
08655    /* Copy the AMA Flags as specified */
08656    ast_cdr_setamaflags(chan, data ? data : "");
08657    return 0;
08658 }

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

Definition at line 8782 of file pbx.c.

References ast_safe_sleep(), and s.

08783 {
08784    double s;
08785    int ms;
08786 
08787    /* Wait for "n" seconds */
08788    if (data && (s = atof(data)) > 0.0) {
08789       ms = s * 1000.0;
08790       return ast_safe_sleep(chan, ms);
08791    }
08792    return 0;
08793 }

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

Definition at line 8798 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_strdupa, 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.

08799 {
08800    int ms, res;
08801    double s;
08802    struct ast_flags flags = {0};
08803    char *opts[1] = { NULL };
08804    char *parse;
08805    AST_DECLARE_APP_ARGS(args,
08806       AST_APP_ARG(timeout);
08807       AST_APP_ARG(options);
08808    );
08809 
08810    if (!ast_strlen_zero(data)) {
08811       parse = ast_strdupa(data);
08812       AST_STANDARD_APP_ARGS(args, parse);
08813    } else
08814       memset(&args, 0, sizeof(args));
08815 
08816    if (args.options)
08817       ast_app_parse_options(waitexten_opts, &flags, opts, args.options);
08818 
08819    if (ast_test_flag(&flags, WAITEXTEN_MOH) && !opts[0] ) {
08820       ast_log(LOG_WARNING, "The 'm' option has been specified for WaitExten without a class.\n"); 
08821    } else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
08822       ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL), strlen(opts[0]));
08823    } else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
08824       struct ast_tone_zone_sound *ts = ast_get_indication_tone(chan->zone, "dial");
08825       if (ts) {
08826          ast_playtones_start(chan, 0, ts->data, 0);
08827          ts = ast_tone_zone_sound_unref(ts);
08828       } else {
08829          ast_tonepair_start(chan, 350, 440, 0, 0);
08830       }
08831    }
08832    /* Wait for "n" seconds */
08833    if (args.timeout && (s = atof(args.timeout)) > 0)
08834        ms = s * 1000.0;
08835    else if (chan->pbx)
08836       ms = chan->pbx->rtimeoutms;
08837    else
08838       ms = 10000;
08839 
08840    res = ast_waitfordigit(chan, ms);
08841    if (!res) {
08842       if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->cid.cid_num)) {
08843          ast_verb(3, "Timeout on %s, continuing...\n", chan->name);
08844       } else if (chan->_softhangup & AST_SOFTHANGUP_TIMEOUT) {
08845          ast_verb(3, "Call timeout on %s, checking for 'T'\n", chan->name);
08846          res = -1;
08847       } else if (ast_exists_extension(chan, chan->context, "t", 1, chan->cid.cid_num)) {
08848          ast_verb(3, "Timeout on %s, going to 't'\n", chan->name);
08849          set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
08850       } else {
08851          ast_log(LOG_WARNING, "Timeout but no rule 't' in context '%s'\n", chan->context);
08852          res = -1;
08853       }
08854    }
08855 
08856    if (ast_test_flag(&flags, WAITEXTEN_MOH))
08857       ast_indicate(chan, AST_CONTROL_UNHOLD);
08858    else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE))
08859       ast_playtones_stop(chan);
08860 
08861    return res;
08862 }


Generated on Thu Oct 11 06:49:58 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6