[asterisk-commits] jpeeler: branch jpeeler/feature14882 r280299 - in /team/jpeeler/feature14882:...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 28 16:26:00 CDT 2010


Author: jpeeler
Date: Wed Jul 28 16:25:54 2010
New Revision: 280299

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=280299
Log:
Update channel drivers for new parking extension possibilities. Also, make the
code actually work for the parking scenarios I've tested so far.

Modified:
    team/jpeeler/feature14882/channels/chan_dahdi.c
    team/jpeeler/feature14882/channels/chan_iax2.c
    team/jpeeler/feature14882/channels/chan_mgcp.c
    team/jpeeler/feature14882/channels/chan_sip.c
    team/jpeeler/feature14882/channels/sig_analog.c
    team/jpeeler/feature14882/include/asterisk/features.h
    team/jpeeler/feature14882/main/features.c

Modified: team/jpeeler/feature14882/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_dahdi.c?view=diff&rev=280299&r1=280298&r2=280299
==============================================================================
--- team/jpeeler/feature14882/channels/chan_dahdi.c (original)
+++ team/jpeeler/feature14882/channels/chan_dahdi.c Wed Jul 28 16:25:54 2010
@@ -9738,7 +9738,7 @@
 				tone_zone_play_tone(p->subs[idx].dfd, -1);
 			else
 				tone_zone_play_tone(p->subs[idx].dfd, DAHDI_TONE_DIALTONE);
-			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && strcmp(exten, ast_parking_ext())) {
+			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten)) {
 				if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
 					if (getforward) {
 						/* Record this as the forwarding extension */
@@ -9874,7 +9874,7 @@
 				getforward = 0;
 				memset(exten, 0, sizeof(exten));
 				len = 0;
-			} else if ((p->transfer || p->canpark) && !strcmp(exten, ast_parking_ext()) &&
+			} else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten) &&
 						p->subs[SUB_THREEWAY].owner &&
 						ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
 				/* This is a three way call, the main call being a real channel,

Modified: team/jpeeler/feature14882/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_iax2.c?view=diff&rev=280299&r1=280298&r2=280299
==============================================================================
--- team/jpeeler/feature14882/channels/chan_iax2.c (original)
+++ team/jpeeler/feature14882/channels/chan_iax2.c Wed Jul 28 16:25:54 2010
@@ -9050,7 +9050,7 @@
 	memset(&ied1, 0, sizeof(ied1));
 	mm = ast_matchmore_extension(NULL, context, callednum, 1, callerid);
 	/* Must be started */
-	if (!strcmp(callednum, ast_parking_ext()) || ast_exists_extension(NULL, context, callednum, 1, callerid)) {
+	if (ast_parking_ext_valid(callednum) || ast_exists_extension(NULL, context, callednum, 1, callerid)) {
 		dpstatus = IAX_DPSTATUS_EXISTS;
 	} else if (ast_canmatch_extension(NULL, context, callednum, 1, callerid)) {
 		dpstatus = IAX_DPSTATUS_CANEXIST;
@@ -10541,7 +10541,7 @@
 					}
 
 					pbx_builtin_setvar_helper(bridged_chan, "BLINDTRANSFER", iaxs[fr->callno]->owner->name);
-					if (!strcmp(ies.called_number, ast_parking_ext())) {
+					if (ast_parking_ext_valid(ies.called_number)) {
 						struct ast_channel *saved_channel = iaxs[fr->callno]->owner;
 						ast_mutex_unlock(&iaxsl[fr->callno]);
 						if (iax_park(bridged_chan, saved_channel)) {

Modified: team/jpeeler/feature14882/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_mgcp.c?view=diff&rev=280299&r1=280298&r2=280299
==============================================================================
--- team/jpeeler/feature14882/channels/chan_mgcp.c (original)
+++ team/jpeeler/feature14882/channels/chan_mgcp.c Wed Jul 28 16:25:54 2010
@@ -3107,7 +3107,7 @@
 			getforward = 0;
 			memset(p->dtmf_buf, 0, sizeof(p->dtmf_buf));
 			len = 0;
-		} else if (!strcmp(p->dtmf_buf, ast_parking_ext()) &&
+		} else if (ast_parking_ext_valid(p->dtmf_buf) &&
 			sub->next->owner && ast_bridged_channel(sub->next->owner)) {
 			/* This is a three way call, the main call being a real channel,
 			   and we're parking the first call. */

Modified: team/jpeeler/feature14882/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/chan_sip.c?view=diff&rev=280299&r1=280298&r2=280299
==============================================================================
--- team/jpeeler/feature14882/channels/chan_sip.c (original)
+++ team/jpeeler/feature14882/channels/chan_sip.c Wed Jul 28 16:25:54 2010
@@ -21905,7 +21905,7 @@
 
 
 	/* Parking a call */
-	if (p->refer->localtransfer && !strcmp(p->refer->refer_to, ast_parking_ext())) {
+	if (p->refer->localtransfer && ast_parking_ext_valid(p->refer->refer_to)) {
 		/* Must release c's lock now, because it will not longer be accessible after the transfer! */
 		*nounlock = 1;
 		ast_channel_unlock(current.chan1);

Modified: team/jpeeler/feature14882/channels/sig_analog.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/channels/sig_analog.c?view=diff&rev=280299&r1=280298&r2=280299
==============================================================================
--- team/jpeeler/feature14882/channels/sig_analog.c (original)
+++ team/jpeeler/feature14882/channels/sig_analog.c Wed Jul 28 16:25:54 2010
@@ -1930,7 +1930,7 @@
 			} else {
 				analog_play_tone(p, index, ANALOG_TONE_DIALTONE);
 			}
-			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && strcmp(exten, ast_parking_ext())) {
+			if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && !ast_parking_ext_valid(exten)) {
 				if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
 					if (getforward) {
 						/* Record this as the forwarding extension */
@@ -2081,7 +2081,7 @@
 				getforward = 0;
 				memset(exten, 0, sizeof(exten));
 				len = 0;
-			} else if ((p->transfer || p->canpark) && !strcmp(exten, ast_parking_ext()) &&
+			} else if ((p->transfer || p->canpark) && ast_parking_ext_valid(exten) &&
 						p->subs[ANALOG_SUB_THREEWAY].owner &&
 						ast_bridged_channel(p->subs[ANALOG_SUB_THREEWAY].owner)) {
 				/* This is a three way call, the main call being a real channel,

Modified: team/jpeeler/feature14882/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/include/asterisk/features.h?view=diff&rev=280299&r1=280298&r2=280299
==============================================================================
--- team/jpeeler/feature14882/include/asterisk/features.h (original)
+++ team/jpeeler/feature14882/include/asterisk/features.h Wed Jul 28 16:25:54 2010
@@ -106,10 +106,11 @@
 int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *host, int timeout, int *extout);
 
 /*! 
- * \brief Determine system parking extension
- * \returns the call parking extension for drivers that provide special call parking help 
+ * \brief Determine if parking extension exists
+ * \retval 0 if extension does not exist
+ * \retval 1 if extension does exist
 */
-const char *ast_parking_ext(void);
+int ast_parking_ext_valid(const char *exten);
 
 /*! \brief Determine system call pickup extension */
 const char *ast_pickup_ext(void);

Modified: team/jpeeler/feature14882/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/feature14882/main/features.c?view=diff&rev=280299&r1=280298&r2=280299
==============================================================================
--- team/jpeeler/feature14882/main/features.c (original)
+++ team/jpeeler/feature14882/main/features.c Wed Jul 28 16:25:54 2010
@@ -444,9 +444,28 @@
 static struct ast_parkinglot *create_parkinglot(const char *name);
 static struct ast_parkinglot *copy_parkinglot(const char *name, const struct ast_parkinglot *parkinglot);
 
-const char *ast_parking_ext(void)
-{
-	return parking_ext;
+static int find_parkinglot_by_exten_cb(void *obj, void *args, int flags)
+{
+	struct ast_parkinglot *parkinglot = obj;
+	const char *parkext = args;
+
+	if (!strcmp(parkinglot->parkext, parkext)) {
+		return CMP_MATCH | CMP_STOP;
+	}
+
+	return 0;
+}
+
+int ast_parking_ext_valid(const char *exten)
+{
+	struct ast_parkinglot *curlot;
+	curlot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, &exten);
+	if (curlot) {
+		ao2_ref(curlot, -1);
+		return 1;
+	}
+
+	return 0;
 }
 
 const char *ast_pickup_ext(void)
@@ -1031,7 +1050,7 @@
 	}
 
 	if ((args->pu = park_space_reserve(peer, rchan, args, parkinglot)) == NULL) { /* create parkinglot */
-		if (peer){ /* if error */
+		if (peer) { /* if error */
 			ast_stream_and_wait(peer, "beeperr", "");
 		}
 		return AST_FEATURE_RETURN_PARKFAILED;
@@ -1089,7 +1108,7 @@
 
 static int masq_park_call_announce_args(struct ast_channel *rchan, struct ast_channel *peer, struct ast_park_call_args *args, struct ast_parkinglot *parkinglot)
 {
-	return masq_park_call(rchan, peer, 0, NULL, 1, args, NULL);
+	return masq_park_call(rchan, peer, 0, NULL, 1, args, parkinglot);
 }
 
 static int masq_park_call_announce(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout, struct ast_parkinglot *parkinglot)
@@ -1231,7 +1250,7 @@
 	}
 	pbx_builtin_setvar_helper(test_channel1, "PARKINGLOT", unique_parkinglot);
 	pbx_builtin_setvar_helper(test_channel1, "PARKINGDYNPOS", parkinglot_range);
-	if (masq_park_call(test_channel1, NULL, 0, NULL, 0, &args) == AST_FEATURE_RETURN_PARKFAILED) {
+	if (masq_park_call(test_channel1, NULL, 0, NULL, 0, &args, NULL) == AST_FEATURE_RETURN_PARKFAILED) {
 		goto exit_features_test;
 	}
 	/* hangup zombie channel */
@@ -1800,7 +1819,6 @@
 	struct ast_party_connected_line connected_line;
 	struct ast_datastore *features_datastore;
 	struct ast_dial_features *dialfeatures = NULL;
-	struct ao2_iterator iter;
 	struct ast_parkinglot *parkinglot;
 
 	ast_debug(1, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
@@ -1850,14 +1868,11 @@
 	/* if there are more possible parkingextensions to choose from, you need to figure out the proper parkinglot
 	 * and pass it to builtin_parkcall */
 
-	iter = ao2_iterator_init(parkinglots, 0);
-	while ((parkinglot = ao2_iterator_next(&iter))) { /* look for all parkinglots */
-		if (!strcmp(xferto, parkinglot->parkext)) {
-			finishup(transferee);
-			data = (void *)parkinglot;
-			return builtin_parkcall(chan, peer, config, code, sense, data);
-		}
-		ao2_ref(parkinglot, -1);
+	parkinglot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, &xferto);
+	if (parkinglot) {
+		finishup(transferee);
+		/* unrefed in park_space_reserve */
+		return builtin_parkcall(chan, peer, config, code, sense, parkinglot);
 	}
 
 	l = strlen(xferto);
@@ -3922,6 +3937,7 @@
 	char *orig_chan_name = ast_strdupa(chan->name);
 	char orig_exten[AST_MAX_EXTENSION];
 	int orig_priority = chan->priority;
+	struct ast_parkinglot *parkinglot;
 
 	/* Data is unused at the moment but could contain a parking
 	   lot context eventually */
@@ -3985,7 +4001,8 @@
 		ast_app_parse_options(park_call_options, &flags, NULL, app_args.options);
 		args.flags = flags.flags;
 
-		res = masq_park_call_announce_args(chan, chan, &args, NULL);
+		parkinglot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, &orig_exten);
+		res = masq_park_call_announce_args(chan, chan, &args, parkinglot);
 		/* Continue on in the dialplan */
 		if (res == 1) {
 			ast_copy_string(chan->exten, orig_exten, sizeof(chan->exten));




More information about the asterisk-commits mailing list