diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_celgenuserevent.c | 98 | ||||
-rw-r--r-- | apps/app_chanisavail.c | 2 | ||||
-rw-r--r-- | apps/app_confbridge.c | 2 | ||||
-rw-r--r-- | apps/app_dial.c | 12 | ||||
-rw-r--r-- | apps/app_directed_pickup.c | 2 | ||||
-rw-r--r-- | apps/app_followme.c | 2 | ||||
-rw-r--r-- | apps/app_meetme.c | 4 | ||||
-rw-r--r-- | apps/app_minivm.c | 6 | ||||
-rw-r--r-- | apps/app_parkandannounce.c | 2 | ||||
-rw-r--r-- | apps/app_queue.c | 11 | ||||
-rw-r--r-- | apps/app_voicemail.c | 16 |
11 files changed, 133 insertions, 24 deletions
diff --git a/apps/app_celgenuserevent.c b/apps/app_celgenuserevent.c new file mode 100644 index 000000000..da1c246ef --- /dev/null +++ b/apps/app_celgenuserevent.c @@ -0,0 +1,98 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2008, Digium, Inc + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * + * \brief Generate User-Defined CEL event + * + * \author Steve Murphy + * + * \ingroup applications + */ + +#include "asterisk.h" + +ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + +#include "asterisk/module.h" +#include "asterisk/app.h" +#include "asterisk/channel.h" +#include "asterisk/cel.h" + +/*** DOCUMENTATION + <application name="CELGenUserEvent" language="en_US"> + <synopsis> + Generates a CEL User Defined Event. + </synopsis> + <syntax> + <parameter name="event-name" required="true"> + <argument name="event-name" required="true"> + </argument> + </parameter> + </syntax> + <description> + <para>A CEL event will be immediately generated by this channel, with the supplied name for a type.</para> + </description> + </application> + ***/ + +static char *app = "CELGenUserEvent"; + +static int celgenuserevent_exec(struct ast_channel *chan, const char *data) +{ + int res = 0; + char *parse; + AST_DECLARE_APP_ARGS(args, + AST_APP_ARG(event); + AST_APP_ARG(extra); + ); + + if (ast_strlen_zero(data)) { + return 0; + } + + parse = ast_strdupa(data); + AST_STANDARD_APP_ARGS(args, parse); + + ast_cel_report_event(chan, AST_CEL_USER_DEFINED, args.event, args.extra, NULL); + return res; +} + +static int unload_module(void) +{ + int res; + + res = ast_unregister_application(app); + + ast_module_user_hangup_all(); + + return res; +} + +static int load_module(void) +{ + int res = ast_register_application_xml(app, celgenuserevent_exec); + if (res) { + return AST_MODULE_LOAD_DECLINE; + } else { + return AST_MODULE_LOAD_SUCCESS; + } +} + +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined CEL event", + .load = load_module, + .unload = unload_module, + ); diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c index b1c426af5..c1b33b938 100644 --- a/apps/app_chanisavail.c +++ b/apps/app_chanisavail.c @@ -159,7 +159,7 @@ static int chanavail_exec(struct ast_channel *chan, const char *data) snprintf(trychan, sizeof(trychan), "%s/%s",cur,number); status = inuse = ast_device_state(trychan); } - if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) { + if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, chan, number, &status))) { ast_str_append(&tmp_availchan, 0, "%s%s", ast_str_strlen(tmp_availchan) ? "&" : "", tempchan->name); snprintf(tmp, sizeof(tmp), "%s/%s", tech, number); diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c index bb68f365a..446cc097f 100644 --- a/apps/app_confbridge.c +++ b/apps/app_confbridge.c @@ -559,7 +559,7 @@ static int play_sound_file(struct conference_bridge *conference_bridge, const ch if (!(conference_bridge->playback_chan)) { int cause; - if (!(conference_bridge->playback_chan = ast_request("Bridge", AST_FORMAT_SLINEAR, "", &cause))) { + if (!(conference_bridge->playback_chan = ast_request("Bridge", AST_FORMAT_SLINEAR, NULL, "", &cause))) { ast_mutex_unlock(&conference_bridge->playback_lock); return -1; } diff --git a/apps/app_dial.c b/apps/app_dial.c index a9522652b..92d16576b 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -61,6 +61,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/stringfields.h" #include "asterisk/global_datastores.h" #include "asterisk/dsp.h" +#include "asterisk/cel.h" /*** DOCUMENTATION <application name="Dial" language="en_US"> @@ -756,6 +757,9 @@ static void do_forward(struct chanlist *o, stuff = tmpchan; tech = "Local"; } + + ast_cel_report_event(in, AST_CEL_FORWARD, NULL, c->call_forward, NULL); + /* Before processing channel, go ahead and check for forwarding */ ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, c->name); /* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */ @@ -765,7 +769,7 @@ static void do_forward(struct chanlist *o, cause = AST_CAUSE_BUSY; } else { /* Setup parameters */ - c = o->chan = ast_request(tech, in->nativeformats, stuff, &cause); + c = o->chan = ast_request(tech, in->nativeformats, in, stuff, &cause); if (c) { if (single) ast_channel_make_compatible(o->chan, in); @@ -1872,7 +1876,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast AST_LIST_UNLOCK(dialed_interfaces); } - tc = ast_request(tech, chan->nativeformats, numsubst, &cause); + tc = ast_request(tech, chan->nativeformats, chan, numsubst, &cause); if (!tc) { /* 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", @@ -1921,7 +1925,9 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast tc->cid.cid_tns = chan->cid.cid_tns; - ast_string_field_set(tc, accountcode, chan->accountcode); + if (!ast_strlen_zero(chan->accountcode)) { + ast_string_field_set(tc, peeraccount, chan->accountcode); + } tc->cdrflags = chan->cdrflags; if (ast_strlen_zero(tc->musicclass)) ast_string_field_set(tc, musicclass, chan->musicclass); diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c index 69015a090..9301395c8 100644 --- a/apps/app_directed_pickup.c +++ b/apps/app_directed_pickup.c @@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/features.h" #include "asterisk/callerid.h" +#include "asterisk/cel.h" #define PICKUPMARK "PICKUPMARK" @@ -95,6 +96,7 @@ static int pickup_do(struct ast_channel *chan, struct ast_channel *target) struct ast_party_connected_line connected_caller; ast_debug(1, "Call pickup on '%s' by '%s'\n", target->name, chan->name); + ast_cel_report_event(target, AST_CEL_PICKUP, NULL, NULL, chan); connected_caller = target->connected; connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; diff --git a/apps/app_followme.c b/apps/app_followme.c index 504ff7c76..67648331b 100644 --- a/apps/app_followme.c +++ b/apps/app_followme.c @@ -831,7 +831,7 @@ static void findmeexec(struct fm_args *tpargs) return; } - outbound = ast_request("Local", ast_best_codec(caller->nativeformats), dialarg, &dg); + outbound = ast_request("Local", ast_best_codec(caller->nativeformats), caller, dialarg, &dg); if (outbound) { ast_set_callerid(outbound, caller->cid.cid_num, caller->cid.cid_name, caller->cid.cid_num); ast_channel_inherit_variables(tpargs->chan, outbound); diff --git a/apps/app_meetme.c b/apps/app_meetme.c index bfb61a399..23abe82b2 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -1176,7 +1176,7 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin cnf->dahdiconf = dahdic.confno; /* Setup a new channel for playback of audio files */ - cnf->chan = ast_request("DAHDI", AST_FORMAT_SLINEAR, "pseudo", NULL); + cnf->chan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL); if (cnf->chan) { ast_set_read_format(cnf->chan, AST_FORMAT_SLINEAR); ast_set_write_format(cnf->chan, AST_FORMAT_SLINEAR); @@ -2202,7 +2202,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c } ast_mutex_lock(&conf->recordthreadlock); - if ((conf->recordthread == AST_PTHREADT_NULL) && (confflags & CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, "pseudo", NULL)))) { + if ((conf->recordthread == AST_PTHREADT_NULL) && (confflags & CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL)))) { ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR); ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR); dahdic.chan = 0; diff --git a/apps/app_minivm.c b/apps/app_minivm.c index ac48aa50f..c4e786698 100644 --- a/apps/app_minivm.c +++ b/apps/app_minivm.c @@ -1299,8 +1299,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu return -1; } /* Allocate channel used for chanvar substitution */ - ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "%s", ""); - + ast = ast_dummy_channel_alloc(); snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60); @@ -1461,9 +1460,8 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu ast_safe_system(tmp2); ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : ""); ast_debug(3, "Actual command used: %s\n", tmp2); - if (ast) { + if (ast) ast = ast_channel_release(ast); - } ast_free(str1); ast_free(str2); return 0; diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c index d8858b64e..4ae525101 100644 --- a/apps/app_parkandannounce.c +++ b/apps/app_parkandannounce.c @@ -145,7 +145,7 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data) snprintf(buf, sizeof(buf), "%d", lot); oh.parent_channel = chan; oh.vars = ast_variable_new("_PARKEDAT", buf, ""); - dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, args.dial, 30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh); + dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, chan, args.dial, 30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh); if (dchan) { if (dchan->_state == AST_STATE_UP) { diff --git a/apps/app_queue.c b/apps/app_queue.c index bebe543b8..aa3564a87 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -95,6 +95,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/global_datastores.h" #include "asterisk/taskprocessor.h" #include "asterisk/callerid.h" +#include "asterisk/cel.h" /*! * \par Please read before modifying this file. @@ -2656,7 +2657,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies location = ""; /* Request the peer */ - tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status); + tmp->chan = ast_request(tech, qe->chan->nativeformats, qe->chan, location, &status); if (!tmp->chan) { /* If we can't, just go on to the next call */ if (qe->chan->cdr) ast_cdr_busy(qe->chan->cdr); @@ -3138,10 +3139,13 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte stuff = tmpchan; tech = "Local"; } + + ast_cel_report_event(in, AST_CEL_FORWARD, NULL, o->chan->call_forward, NULL); + /* Before processing channel, go ahead and check for forwarding */ ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", inchan_name, tech, stuff, ochan_name); /* Setup parameters */ - o->chan = ast_request(tech, in->nativeformats, stuff, &status); + o->chan = ast_request(tech, in->nativeformats, in, stuff, &status); if (!o->chan) { ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s'\n", tech, stuff); o->stillgoing = 0; @@ -7483,7 +7487,8 @@ static int load_module(void) ast_log(LOG_WARNING, "devicestate taskprocessor reference failed - devicestate notifications will not occur\n"); } - if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, NULL, AST_EVENT_IE_END))) { + /* in the following subscribe call, do I use DEVICE_STATE, or DEVICE_STATE_CHANGE? */ + if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, "AppQueue Device state", NULL, AST_EVENT_IE_END))) { res = -1; } diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 51b78e254..b058ab182 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -4105,7 +4105,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in if (!ast_strlen_zero(fromstring)) { struct ast_channel *ast; - if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { + if ((ast = ast_dummy_channel_alloc())) { char *ptr; prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, enc_cidnum, enc_cidname, dur, date, category, flag); ast_str_substitute_variables(&str1, 0, ast, fromstring); @@ -4151,7 +4151,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in if (!ast_strlen_zero(emailsubject) || !ast_strlen_zero(vmu->emailsubject)) { char *e_subj = !ast_strlen_zero(vmu->emailsubject) ? vmu->emailsubject : emailsubject; struct ast_channel *ast; - if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { + if ((ast = ast_dummy_channel_alloc())) { prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag); ast_str_substitute_variables(&str1, 0, ast, e_subj); if (check_mime(ast_str_buffer(str1))) { @@ -4234,7 +4234,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in if (emailbody || vmu->emailbody) { char* e_body = vmu->emailbody ? vmu->emailbody : emailbody; struct ast_channel *ast; - if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { + if ((ast = ast_dummy_channel_alloc())) { prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag); ast_str_substitute_variables(&str1, 0, ast, e_body); fprintf(p, "%s" ENDL, ast_str_buffer(str1)); @@ -4434,7 +4434,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char if (!ast_strlen_zero(pagerfromstring)) { struct ast_channel *ast; - if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { + if ((ast = ast_dummy_channel_alloc())) { char *ptr; prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, enc_cidnum, enc_cidname, dur, date, category, flag); ast_str_substitute_variables(&str1, 0, ast, pagerfromstring); @@ -4479,7 +4479,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char if (!ast_strlen_zero(pagersubject)) { struct ast_channel *ast; - if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { + if ((ast = ast_dummy_channel_alloc())) { prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag); ast_str_substitute_variables(&str1, 0, ast, pagersubject); if (check_mime(ast_str_buffer(str1))) { @@ -4512,7 +4512,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char ast_strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm); if (pagerbody) { struct ast_channel *ast; - if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { + if ((ast = ast_dummy_channel_alloc())) { prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag); ast_str_substitute_variables(&str1, 0, ast, pagerbody); fprintf(p, "%s" ENDL, ast_str_buffer(str1)); @@ -10254,11 +10254,11 @@ static void mwi_sub_event_cb(const struct ast_event *event, void *userdata) static void start_poll_thread(void) { - mwi_sub_sub = ast_event_subscribe(AST_EVENT_SUB, mwi_sub_event_cb, NULL, + mwi_sub_sub = ast_event_subscribe(AST_EVENT_SUB, mwi_sub_event_cb, "Voicemail MWI subscription", NULL, AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI, AST_EVENT_IE_END); - mwi_unsub_sub = ast_event_subscribe(AST_EVENT_UNSUB, mwi_unsub_event_cb, NULL, + mwi_unsub_sub = ast_event_subscribe(AST_EVENT_UNSUB, mwi_unsub_event_cb, "Voicemail MWI subscription", NULL, AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI, AST_EVENT_IE_END); |