[svn-commits] rmudgett: branch rmudgett/parking r331573 - /team/rmudgett/parking/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 10 20:00:48 CDT 2011


Author: rmudgett
Date: Wed Aug 10 20:00:45 2011
New Revision: 331573

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=331573
Log:
* Address ASTERISK-15729 by juggling the return codes returned when DTMF
atxfer, DTMF blind transfer, and DTMF one-touch-parking are invoked by the
originating channel.

* Fix when pbx-parkingfailed is played that the other channel is put in
autoservice if it exists.

Modified:
    team/rmudgett/parking/main/features.c

Modified: team/rmudgett/parking/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/parking/main/features.c?view=diff&rev=331573&r1=331572&r2=331573
==============================================================================
--- team/rmudgett/parking/main/features.c (original)
+++ team/rmudgett/parking/main/features.c Wed Aug 10 20:00:45 2011
@@ -757,6 +757,7 @@
 static struct ast_parkinglot *create_parkinglot(const char *name);
 static struct ast_parkinglot *copy_parkinglot(const char *name, const struct ast_parkinglot *parkinglot);
 static int parkinglot_activate(struct ast_parkinglot *parkinglot);
+static int play_message_on_chan(struct ast_channel *play_to, struct ast_channel *other, const char *msg, const char *audiofile);
 
 /*!
  * \internal
@@ -1286,7 +1287,6 @@
 		}
 
 		/* free parking extension linear search: O(n^2) */
-		//parking_space = -1;
 		for (i = start; ; i++) {
 			/* If we are past the end, wrap around to the first parking slot*/
 			if (i == parkinglot->cfg.parking_stop + 1) {
@@ -1525,6 +1525,13 @@
 /*!
  * \param rchan the real channel to be parked
  * \param peer the channel to have the parking read to.
+ * \param timeout is a timeout in milliseconds
+ * \param extout is a parameter to an int that will hold the parked location, or NULL if you want.
+ * \param play_announcement TRUE if to play which parking space call parked in to peer.
+ * \param args Optional additional parking options when parking a call.
+ *
+ * \retval 0 on success.
+ * \retval -1 on failure.
  */
 static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout, int play_announcement, struct ast_park_call_args *args)
 {
@@ -1542,20 +1549,28 @@
 		rchan->context, rchan->linkedid, rchan->amaflags, "Parked/%s", rchan->name);
 	if (!chan) {
 		ast_log(LOG_WARNING, "Unable to create parked channel\n");
-		if (peer) {
+		if (peer == rchan) {
+			/* Only have one channel to worry about. */
 			ast_stream_and_wait(peer, "pbx-parkingfailed", "");
-		}
-		return AST_FEATURE_RETURN_PARKFAILED;
+		} else if (peer) {
+			/* Have two different channels to worry about. */
+			play_message_on_chan(peer, rchan, "failure message", "pbx-parkingfailed");
+		}
+		return -1;
 	}
 
 	args->pu = park_space_reserve(rchan, peer, args);
 	if (!args->pu) {
 		chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
 		ast_hangup(chan);
-		if (peer) {
+		if (peer == rchan) {
+			/* Only have one channel to worry about. */
 			ast_stream_and_wait(peer, "pbx-parkingfailed", "");
-		}
-		return AST_FEATURE_RETURN_PARKFAILED;
+		} else if (peer) {
+			/* Have two different channels to worry about. */
+			play_message_on_chan(peer, rchan, "failure message", "pbx-parkingfailed");
+		}
+		return -1;
 	}
 
 	/* Make formats okay */
@@ -1590,10 +1605,19 @@
 
 int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout)
 {
-	return masq_park_call(rchan, peer, timeout, extout, 0, NULL) ? -1 : 0;
-}
-
-/* Park call via masqueraded channel and announce parking spot on peer channel. */
+	return masq_park_call(rchan, peer, timeout, extout, 0, NULL);
+}
+
+/*!
+ * \brief Park call via masqueraded channel and announce parking spot on peer channel.
+ *
+ * \param rchan the real channel to be parked
+ * \param peer the channel to have the parking read to.
+ * \param args Optional additional parking options when parking a call.
+ *
+ * \retval 0 on success.
+ * \retval -1 on failure.
+ */
 static int masq_park_call_announce(struct ast_channel *rchan, struct ast_channel *peer, struct ast_park_call_args *args)
 {
 	return masq_park_call(rchan, peer, 0, NULL, 1, args);
@@ -1616,9 +1640,9 @@
  *
  * \note Assumes park_me is on hold and in autoservice.
  *
- * \retval 0 on success.
+ * \retval -1 on successful park.
  * \retval -1 on park_me hangup.
- * \retval AST_FEATURE_RETURN_PARKFAILED on error.
+ * \retval AST_FEATURE_RETURN_SUCCESS on error to keep the bridge connected.
  */
 static int xfer_park_call_helper(struct ast_channel *park_me, struct ast_channel *parker, struct ast_exten *park_exten)
 {
@@ -1636,13 +1660,7 @@
 	parse = ast_strdupa(app_data);
 	AST_STANDARD_APP_ARGS(app_args, parse);
 
-	res = finishup(park_me);
-	if (res) {
-		/* Parkee hungup on us. */
-		return res;
-	}
-
-	/* Park the call */
+	/* Find the parking lot */
 	if (!ast_strlen_zero(app_args.pl_name)) {
 		pl_name = app_args.pl_name;
 	} else {
@@ -1656,17 +1674,26 @@
 		if (!args.parkinglot && parkeddynamic) {
 			args.parkinglot = create_dynamic_parkinglot(pl_name, park_me);
 		}
-
-	}
+	}
+
 	if (args.parkinglot) {
+		/* Park the call */
+		res = finishup(park_me);
+		if (res) {
+			/* park_me hungup on us. */
+			parkinglot_unref(args.parkinglot);
+			return -1;
+		}
 		res = masq_park_call_announce(park_me, parker, &args);
 		parkinglot_unref(args.parkinglot);
 	} else {
 		/* Parking failed because parking lot does not exist. */
-		res = AST_FEATURE_RETURN_PARKFAILED;
-	}
-
-	return res;
+		ast_stream_and_wait(parker, "pbx-parkingfailed", "");
+		finishup(park_me);
+		res = -1;
+	}
+
+	return res ? AST_FEATURE_RETURN_SUCCESS : -1;
 }
 
 /*!
@@ -1687,23 +1714,23 @@
 	}
 }
 
-/*! 
+/*!
  * \brief support routing for one touch call parking
  * \param chan channel parking call
  * \param peer channel to be parked
  * \param config unsed
  * \param code unused
  * \param sense feature options
- *
- * \param data
- * Setup channel, set return exten,priority to 's,1'
- * answer chan, sleep chan, park call
+ * \param data unused
+ *
+ * \retval -1 on successful park.
+ * \retval -1 on chan hangup.
+ * \retval AST_FEATURE_RETURN_SUCCESS on error to keep the bridge connected.
  */
 static int builtin_parkcall(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, const char *code, int sense, void *data)
 {
 	struct ast_channel *parker;
 	struct ast_channel *parkee;
-	int res;
 
 	/*
 	 * We used to set chan's exten and priority to "s" and 1 here,
@@ -1716,6 +1743,10 @@
 
 	/* Answer if call is not up */
 	if (chan->_state != AST_STATE_UP) {
+		/*
+		 * XXX Why are we doing this?  Both of the channels should be up
+		 * since you cannot do DTMF features unless you are bridged.
+		 */
 		if (ast_answer(chan)) {
 			return -1;
 		}
@@ -1728,10 +1759,8 @@
 
 	/* one direction used to call park_call.... */
 	set_peers(&parker, &parkee, peer, chan, sense);
-	res = masq_park_call_announce(parkee, parker, NULL);
-	/* PBX should hangup zombie channel if a masquerade actually occurred (res=0) */
-
-	return res;
+	return masq_park_call_announce(parkee, parker, NULL)
+		? AST_FEATURE_RETURN_SUCCESS : -1;
 }
 
 /*!
@@ -4758,6 +4787,7 @@
 		parkinglot_unref(args.parkinglot);
 	} else {
 		/* Parking failed because the parking lot does not exist. */
+		ast_stream_and_wait(chan, "pbx-parkingfailed", "");
 		res = -1;
 	}
 	if (res) {




More information about the svn-commits mailing list