[asterisk-commits] jpeeler: branch 1.4 r122208 - in /branches/1.4: apps/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 12 10:46:09 CDT 2008
Author: jpeeler
Date: Thu Jun 12 10:46:08 2008
New Revision: 122208
URL: http://svn.digium.com/view/asterisk?view=rev&rev=122208
Log:
(closes issue #12193)
Reported by: davidw
Patch by: Corydon76, modified by me to work properly with ParkAndAnnounce app
Modified:
branches/1.4/apps/app_parkandannounce.c
branches/1.4/res/res_features.c
Modified: branches/1.4/apps/app_parkandannounce.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_parkandannounce.c?view=diff&rev=122208&r1=122207&r2=122208
==============================================================================
--- branches/1.4/apps/app_parkandannounce.c (original)
+++ branches/1.4/apps/app_parkandannounce.c Thu Jun 12 10:46:08 2008
@@ -76,14 +76,13 @@
static int parkandannounce_exec(struct ast_channel *chan, void *data)
{
- int res=0;
char *return_context;
int lot, timeout = 0, dres;
char *working, *context, *exten, *priority, *dial, *dialtech, *dialstr;
char *template, *tpl_working, *tpl_current;
char *tmp[100];
char buf[13];
- int looptemp=0,i=0;
+ int looptemp = 0,i = 0, res = 0;
char *s;
struct ast_channel *dchan;
@@ -101,7 +100,7 @@
s = ast_strdupa(data);
- template=strsep(&s,"|");
+ template = strsep(&s,"|");
if(! template) {
ast_log(LOG_WARNING, "PARK: An announce template must be defined\n");
ast_module_user_remove(u);
@@ -112,14 +111,14 @@
timeout = atoi(strsep(&s, "|"));
timeout *= 1000;
}
- dial=strsep(&s, "|");
+ dial = strsep(&s, "|");
if(!dial) {
ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or Zap/g1/5551212\n");
ast_module_user_remove(u);
return -1;
} else {
- dialtech=strsep(&dial, "/");
- dialstr=dial;
+ dialtech = strsep(&dial, "/");
+ dialstr = dial;
ast_verbose( VERBOSE_PREFIX_3 "Dial Tech,String: (%s,%s)\n", dialtech,dialstr);
}
@@ -170,9 +169,10 @@
/* we are using masq_park here to protect * from touching the channel once we park it. If the channel comes out of timeout
before we are done announcing and the channel is messed with, Kablooeee. So we use Masq to prevent this. */
- ast_masq_park_call(chan, NULL, timeout, &lot);
-
- res=-1;
+ res = ast_masq_park_call(chan, NULL, timeout, &lot);
+ if (res == -1) {
+ goto finish;
+ }
ast_verbose( VERBOSE_PREFIX_3 "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, return_context);
@@ -209,15 +209,15 @@
ast_verbose(VERBOSE_PREFIX_4 "Announce Template:%s\n", template);
tpl_working = template;
- tpl_current=strsep(&tpl_working, ":");
+ tpl_current = strsep(&tpl_working, ":");
while(tpl_current && looptemp < ARRAY_LEN(tmp)) {
tmp[looptemp]=tpl_current;
looptemp++;
- tpl_current=strsep(&tpl_working,":");
- }
-
- for(i=0; i<looptemp; i++) {
+ tpl_current = strsep(&tpl_working,":");
+ }
+
+ for(i = 0; i < looptemp; i++) {
ast_verbose(VERBOSE_PREFIX_4 "Announce:%s\n", tmp[i]);
if(!strcmp(tmp[i], "PARKED")) {
ast_say_digits(dchan, lot, "", dchan->language);
@@ -234,9 +234,9 @@
ast_stopstream(dchan);
ast_hangup(dchan);
-
+
+finish:
ast_module_user_remove(u);
-
return res;
}
Modified: branches/1.4/res/res_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/res_features.c?view=diff&rev=122208&r1=122207&r2=122208
==============================================================================
--- branches/1.4/res/res_features.c (original)
+++ branches/1.4/res/res_features.c Thu Jun 12 10:46:08 2008
@@ -326,14 +326,26 @@
/* Check for channel variable PARKINGEXTEN */
parkingexten = pbx_builtin_getvar_helper(chan, "PARKINGEXTEN");
if (!ast_strlen_zero(parkingexten)) {
- if (ast_exists_extension(NULL, parking_con, parkingexten, 1, NULL)) {
+ /*!\note The API forces us to specify a numeric parking slot, even
+ * though the architecture would tend to support non-numeric extensions
+ * (as are possible with SIP, for example). Hence, we enforce that
+ * limitation here. If extout was not numeric, we could permit
+ * arbitrary non-numeric extensions.
+ */
+ if (sscanf(parkingexten, "%d", &x) != 1 || x < 0) {
+ ast_log(LOG_WARNING, "PARKINGEXTEN does not indicate a valid parking slot: '%s'.\n", parkingexten);
+ ast_mutex_unlock(&parking_lock);
+ free(pu);
+ return 1; /* Continue execution if possible */
+ }
+ snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", x);
+
+ if (ast_exists_extension(NULL, parking_con, pu->parkingexten, 1, NULL)) {
ast_mutex_unlock(&parking_lock);
free(pu);
ast_log(LOG_WARNING, "Requested parking extension already exists: %s@%s\n", parkingexten, parking_con);
return 1; /* Continue execution if possible */
}
- ast_copy_string(pu->parkingexten, parkingexten, sizeof(pu->parkingexten));
- x = atoi(parkingexten);
} else {
/* Select parking space within range */
parking_range = parking_stop - parking_start+1;
@@ -358,6 +370,7 @@
/* Set pointer for next parking */
if (parkfindnext)
parking_offset = x - parking_start + 1;
+ snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", x);
}
chan->appl = "Parked Call";
@@ -398,8 +411,6 @@
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Parked %s on %d@%s. Will timeout back to extension [%s] %s, %d in %d seconds\n", pu->chan->name, pu->parkingnum, parking_con, pu->context, pu->exten, pu->priority, (pu->parkingtime/1000));
- if (pu->parkingnum != -1)
- snprintf(pu->parkingexten, sizeof(pu->parkingexten), "%d", x);
manager_event(EVENT_FLAG_CALL, "ParkedCall",
"Exten: %s\r\n"
"Channel: %s\r\n"
@@ -424,7 +435,7 @@
if (!con) /* Still no context? Bad */
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
/* Tell the peer channel the number of the parking space */
- if (peer && ((pu->parkingnum != -1 && ast_strlen_zero(orig_chan_name)) || !strcasecmp(peer->name, orig_chan_name))) { /* Only say number if it's a number and the channel hasn't been masqueraded away */
+ if (peer && (ast_strlen_zero(orig_chan_name) || !strcasecmp(peer->name, orig_chan_name))) { /* Only say number if it's a number and the channel hasn't been masqueraded away */
/* Make sure we don't start saying digits to the channel being parked */
ast_set_flag(peer, AST_FLAG_MASQ_NOSTREAM);
ast_say_digits(peer, pu->parkingnum, "", peer->language);
@@ -458,6 +469,7 @@
struct ast_channel *chan;
struct ast_frame *f;
char *orig_chan_name = NULL;
+ int park_status;
/* Make a new, fake channel that we'll use to masquerade in the real one */
if (!(chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, rchan->accountcode, rchan->exten, rchan->context, rchan->amaflags, "Parked/%s",rchan->name))) {
@@ -480,7 +492,12 @@
orig_chan_name = ast_strdupa(chan->name);
- park_call_full(chan, peer, timeout, extout, orig_chan_name);
+ park_status = park_call_full(chan, peer, timeout, extout, orig_chan_name);
+ if (park_status == 1) {
+ /* would be nice to play: "invalid parking extension" */
+ ast_hangup(chan);
+ return -1;
+ }
return 0;
}
More information about the asterisk-commits
mailing list