[asterisk-commits] rmudgett: branch rmudgett/parking r330821 - /team/rmudgett/parking/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 3 12:44:21 CDT 2011


Author: rmudgett
Date: Wed Aug  3 12:44:18 2011
New Revision: 330821

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=330821
Log:
Undo parked call entertainment of either RINGING or HOLD when call unparked.

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=330821&r1=330820&r2=330821
==============================================================================
--- team/rmudgett/parking/main/features.c (original)
+++ team/rmudgett/parking/main/features.c Wed Aug  3 12:44:18 2011
@@ -439,6 +439,8 @@
 	char exten[AST_MAX_EXTENSION];
 	int priority;
 	int parkingtime;                            /*!< Maximum length in parking lot before return */
+	/*! Method to entertain the caller when parked: AST_CONTROL_RINGING, AST_CONTROL_HOLD, or 0(none) */
+	enum ast_control_frame_type hold_method;
 	unsigned int notquiteyet:1;
 	unsigned int options_specified:1;
 	char peername[1024];
@@ -1222,12 +1224,13 @@
 
 	pu->chan = chan;
 
-/* BUGBUG should make note if call put on hold or did ringing to undo it later. */
 	/* Put the parked channel on hold if we have two different channels */
 	if (chan != peer) {
 		if (ast_test_flag(args, AST_PARK_OPT_RINGING)) {
+			pu->hold_method = AST_CONTROL_RINGING;
 			ast_indicate(pu->chan, AST_CONTROL_RINGING);
 		} else {
+			pu->hold_method = AST_CONTROL_HOLD;
 			ast_indicate_data(pu->chan, AST_CONTROL_HOLD, 
 				S_OR(pu->parkinglot->cfg.mohclass, NULL),
 				!ast_strlen_zero(pu->parkinglot->cfg.mohclass) ? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0);
@@ -1366,6 +1369,7 @@
 	}
 	if (peer == chan) { /* pu->notquiteyet = 1 */
 		/* Wake up parking thread if we're really done */
+		pu->hold_method = AST_CONTROL_HOLD;
 		ast_indicate_data(pu->chan, AST_CONTROL_HOLD, 
 			S_OR(pu->parkinglot->cfg.mohclass, NULL),
 			!ast_strlen_zero(pu->parkinglot->cfg.mohclass) ? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0);
@@ -4140,12 +4144,21 @@
 
 	tms = ast_tvdiff_ms(ast_tvnow(), pu->start);
 	if (tms > pu->parkingtime) {
-/* BUGBUG stop MOH or RINGING depending on what was last sent */
 		/*
 		 * Call has been parked too long.
-		 * Stop music on hold
+		 * Stop entertaining the caller.
 		 */
-		ast_indicate(pu->chan, AST_CONTROL_UNHOLD);
+		switch (pu->hold_method) {
+		case AST_CONTROL_HOLD:
+			ast_indicate(pu->chan, AST_CONTROL_UNHOLD);
+			break;
+		case AST_CONTROL_RINGING:
+			ast_indicate(pu->chan, -1);
+			break;
+		default:
+			break;
+		}
+		pu->hold_method = 0;
 
 		/* Get chan, exten from derived kludge */
 		if (pu->peername[0]) {
@@ -4294,11 +4307,12 @@
 			} else {
 				/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
 				ast_frfree(f);
-				if (pu->moh_trys < 3 && !chan->generatordata) {
+				if (pu->hold_method == AST_CONTROL_HOLD
+					&& pu->moh_trys < 3
+					&& !chan->generatordata) {
 					ast_debug(1,
 						"MOH on parked call stopped by outside source.  Restarting on channel %s.\n",
 						chan->name);
-/* BUGBUG update last request of ring or hold to peer. */
 					ast_indicate_data(chan, AST_CONTROL_HOLD,
 						S_OR(pu->parkinglot->cfg.mohclass, NULL),
 						(!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
@@ -4606,6 +4620,19 @@
 			S_COR(pu->chan->connected.id.name.valid, pu->chan->connected.id.name.str, "<unknown>")
 			);
 
+		/* Stop entertaining the caller. */
+		switch (pu->hold_method) {
+		case AST_CONTROL_HOLD:
+			ast_indicate(pu->chan, AST_CONTROL_UNHOLD);
+			break;
+		case AST_CONTROL_RINGING:
+			ast_indicate(pu->chan, -1);
+			break;
+		default:
+			break;
+		}
+		pu->hold_method = 0;
+
 		parkinglot_unref(pu->parkinglot);
 		ast_free(pu);
 	}
@@ -4621,9 +4648,6 @@
 	if (peer) {
 		struct ast_datastore *features_datastore;
 		struct ast_dial_features *dialfeatures = NULL;
-
-/* BUGBUG we should unhold or stop ringing as configured. */
-		ast_indicate(peer, AST_CONTROL_UNHOLD);
 
 		/* Play a courtesy to the source(s) configured to prefix the bridge connecting */
 		if (!ast_strlen_zero(courtesytone)) {




More information about the asterisk-commits mailing list