[asterisk-commits] rmudgett: trunk r365829 - /trunk/apps/app_followme.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 8 20:59:18 CDT 2012


Author: rmudgett
Date: Tue May  8 20:59:14 2012
New Revision: 365829

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365829
Log:
Put winning FollowMe outgoing call on hold if the caller put it on hold.

The FollowMe caller call leg is usually answered and listening to MOH.
The caller could put the call on hold while FollowMe is looking for a
winner.  The winning outgoing call is now immediately placed on hold if
the caller has put the call on hold before the winning call was selected.

Modified:
    trunk/apps/app_followme.c

Modified: trunk/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_followme.c?view=diff&rev=365829&r1=365828&r2=365829
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Tue May  8 20:59:14 2012
@@ -163,6 +163,10 @@
 	unsigned int pending_in_connected_update:1;
 	/*! TRUE if connected line information from outbound call is available. */
 	unsigned int pending_out_connected_update:1;
+	/*! TRUE if caller has a pending hold request for the winning call. */
+	unsigned int pending_hold:1;
+	/*! Music On Hold Class suggested by caller hold for winning call. */
+	char suggested_moh[MAX_MUSICCLASS];
 	char context[AST_MAX_CONTEXT];
 	char namerecloc[PATH_MAX];
 	char takecall[MAX_YN_STRING];	/*!< Digit mapping to take a call */
@@ -792,9 +796,37 @@
 						break;
 					case AST_CONTROL_HOLD:
 						ast_verb(3, "%s placed call on hold\n", ast_channel_name(winner));
+						if (!tmpuser) {
+							/* Caller placed outgoing calls on hold. */
+							tpargs->pending_hold = 1;
+							if (f->data.ptr) {
+								ast_copy_string(tpargs->suggested_moh, f->data.ptr,
+									sizeof(tpargs->suggested_moh));
+							} else {
+								tpargs->suggested_moh[0] = '\0';
+							}
+						} else {
+							/*
+							 * Outgoing call placed caller on hold.
+							 *
+							 * Ignore because the outgoing call should not be able to place
+							 * the caller on hold until after they are bridged.
+							 */
+						}
 						break;
 					case AST_CONTROL_UNHOLD:
 						ast_verb(3, "%s removed call from hold\n", ast_channel_name(winner));
+						if (!tmpuser) {
+							/* Caller removed outgoing calls from hold. */
+							tpargs->pending_hold = 0;
+						} else {
+							/*
+							 * Outgoing call removed caller from hold.
+							 *
+							 * Ignore because the outgoing call should not be able to place
+							 * the caller on hold until after they are bridged.
+							 */
+						}
 						break;
 					case AST_CONTROL_OFFHOOK:
 					case AST_CONTROL_FLASH:
@@ -948,12 +980,12 @@
 				snprintf(tmpuser->dialarg, sizeof(tmpuser->dialarg), "%s%s",
 					number,
 					ast_test_flag(&tpargs->followmeflags, FOLLOWMEFLAG_DISABLEOPTIMIZATION)
-						? "/n" : "");
+						? "/n" : "/m");
 			} else {
 				snprintf(tmpuser->dialarg, sizeof(tmpuser->dialarg), "%s@%s%s",
 					number, tpargs->context,
 					ast_test_flag(&tpargs->followmeflags, FOLLOWMEFLAG_DISABLEOPTIMIZATION)
-						? "/n" : "");
+						? "/n" : "/m");
 			}
 
 			outbound = ast_request("Local", ast_channel_nativeformats(caller), caller,
@@ -1323,6 +1355,16 @@
 			}
 		}
 
+		/* Put winner on hold if caller requested. */
+		if (targs->pending_hold) {
+			if (ast_strlen_zero(targs->suggested_moh)) {
+				ast_indicate_data(outbound, AST_CONTROL_HOLD, NULL, 0);
+			} else {
+				ast_indicate_data(outbound, AST_CONTROL_HOLD,
+					targs->suggested_moh, strlen(targs->suggested_moh) + 1);
+			}
+		}
+
 		res = ast_bridge_call(caller, outbound, &config);
 		ast_hangup(outbound);
 	}




More information about the asterisk-commits mailing list