[asterisk-commits] rmudgett: trunk r365856 - in /trunk: ./ apps/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 8 21:35:34 CDT 2012


Author: rmudgett
Date: Tue May  8 21:35:29 2012
New Revision: 365856

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=365856
Log:
Keep answered FollowMe calls until call accepted or last step times out.

Modified:
    trunk/UPGRADE.txt
    trunk/apps/app_followme.c
    trunk/configs/followme.conf.sample

Modified: trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE.txt?view=diff&rev=365856&r1=365855&r2=365856
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Tue May  8 21:35:29 2012
@@ -78,6 +78,11 @@
 app_meetme:
   - The 'c' option (announce user count) will now work even if the 'q' (quiet)
     option is enabled.
+
+app_followme:
+ - Answered outgoing calls no longer get cut off when the next step is started.
+   You now have until the last step times out to decide if you want to accept
+   the call or not before being disconnected.
 
 SIP
 ===

Modified: trunk/apps/app_followme.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_followme.c?view=diff&rev=365856&r1=365855&r2=365856
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Tue May  8 21:35:29 2012
@@ -190,6 +190,8 @@
 	char dialarg[256];
 	/*! Collected digits to accept/decline the call. */
 	char yn[MAX_YN_STRING];
+	/*! TRUE if the outgoing call is answered. */
+	unsigned int answered:1;
 	/*! TRUE if connected line information is available. */
 	unsigned int pending_connected_update:1;
 	AST_LIST_ENTRY(findme_user) entry;
@@ -550,12 +552,14 @@
 	tmpuser->ochan = NULL;
 }
 
-static void clear_calling_tree(struct findme_user_listptr *findme_user_list) 
+static void clear_unanswered_calls(struct findme_user_listptr *findme_user_list) 
 {
 	struct findme_user *tmpuser;
 
 	AST_LIST_TRAVERSE(findme_user_list, tmpuser, entry) {
-		clear_caller(tmpuser);
+		if (!tmpuser->answered) {
+			clear_caller(tmpuser);
+		}
 	}
 }
 
@@ -704,8 +708,8 @@
 		totalwait -= tmpto;
 		wtd = to;
 		if (totalwait <= 0) {
-			ast_verb(3, "We've hit our timeout for this step. Drop everyone and move on to the next one. %ld\n", totalwait);
-			clear_calling_tree(findme_user_list);
+			ast_verb(3, "We've hit our timeout for this step. Dropping unanswered calls and starting the next step.\n");
+			clear_unanswered_calls(findme_user_list);
 			return NULL;
 		}
 		if (winner) {
@@ -743,6 +747,7 @@
 							break;
 						}
 						ast_verb(3, "%s answered %s\n", ast_channel_name(winner), ast_channel_name(caller));
+						tmpuser->answered = 1;
 						/* If call has been answered, then the eventual hangup is likely to be normal hangup */ 
 						ast_channel_hangupcause_set(winner, AST_CAUSE_NORMAL_CLEARING);
 						ast_channel_hangupcause_set(caller, AST_CAUSE_NORMAL_CLEARING);
@@ -956,6 +961,19 @@
 
 		ast_debug(2, "Number(s) %s timeout %ld\n", nm->number, nm->timeout);
 
+		/*
+		 * Put all active outgoing channels into autoservice.
+		 *
+		 * This needs to be done because ast_exists_extension() may put
+		 * the caller into autoservice.
+		 */
+		AST_LIST_TRAVERSE(&findme_user_list, tmpuser, entry) {
+			if (tmpuser->ochan) {
+				ast_autoservice_start(tmpuser->ochan);
+			}
+		}
+
+		/* Create all new outgoing calls */
 		ast_copy_string(num, nm->number, sizeof(num));
 		for (number = num; number; number = rest) {
 			struct ast_channel *outbound;
@@ -1009,12 +1027,15 @@
 
 			tmpuser->ochan = outbound;
 			tmpuser->state = 0;
-
+			AST_LIST_INSERT_TAIL(&new_user_list, tmpuser, entry);
+		}
+
+		/* Start all new outgoing calls */
+		AST_LIST_TRAVERSE_SAFE_BEGIN(&new_user_list, tmpuser, entry) {
 			ast_verb(3, "calling Local/%s\n", tmpuser->dialarg);
-			if (!ast_call(tmpuser->ochan, tmpuser->dialarg, 0)) {
-				AST_LIST_INSERT_TAIL(&new_user_list, tmpuser, entry);
-			} else {
+			if (ast_call(tmpuser->ochan, tmpuser->dialarg, 0)) {
 				ast_verb(3, "couldn't reach at this number.\n");
+				AST_LIST_REMOVE_CURRENT(entry);
 
 				/* Destroy this failed new outgoing call. */
 				ast_channel_lock(tmpuser->ochan);
@@ -1025,6 +1046,17 @@
 				destroy_calling_node(tmpuser);
 			}
 		}
+		AST_LIST_TRAVERSE_SAFE_END;
+
+		/* Take all active outgoing channels out of autoservice. */
+		AST_LIST_TRAVERSE_SAFE_BEGIN(&findme_user_list, tmpuser, entry) {
+			if (tmpuser->ochan && ast_autoservice_stop(tmpuser->ochan)) {
+				/* Existing outgoing call hungup. */
+				AST_LIST_REMOVE_CURRENT(entry);
+				destroy_calling_node(tmpuser);
+			}
+		}
+		AST_LIST_TRAVERSE_SAFE_END;
 
 		if (AST_LIST_EMPTY(&new_user_list)) {
 			/* No new channels remain at this order level.  If there were any at all. */
@@ -1036,6 +1068,14 @@
 
 		winner = wait_for_winner(&findme_user_list, nm, caller, tpargs);
 		if (!winner) {
+			/* Remove all dead outgoing nodes. */
+			AST_LIST_TRAVERSE_SAFE_BEGIN(&findme_user_list, tmpuser, entry) {
+				if (!tmpuser->ochan) {
+					AST_LIST_REMOVE_CURRENT(entry);
+					destroy_calling_node(tmpuser);
+				}
+			}
+			AST_LIST_TRAVERSE_SAFE_END;
 			continue;
 		}
 

Modified: trunk/configs/followme.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/followme.conf.sample?view=diff&rev=365856&r1=365855&r2=365856
==============================================================================
--- trunk/configs/followme.conf.sample (original)
+++ trunk/configs/followme.conf.sample Tue May  8 21:35:29 2012
@@ -40,17 +40,18 @@
 ; The context to dial the numbers from
 number=>01233456,25
 ; The a follow-me number to call. The format is:
-; number=> <number to call[&2nd #[&3rd #]]> [, <timeout value in seconds> [, <order in follow-me>] ]
+; number=> <number to call[&2nd #[&...]]>[,<timeout value in seconds>[,<order in follow-me>]]
 ; You can specify as many of these numbers as you like. They will be dialed in the
 ; order that you specify them in the config file OR as specified with the order field
 ; on the number prompt. As you can see from the example, forked dialing of multiple
 ; numbers in the same step is supported with this application if you'd like to dial
 ; multiple numbers in the same followme step.
-; It's also important to note that the timeout value is not the same
-; as the timeout value you would use in app_dial. This timeout value is the amount of
-; time allowed between the time the dialing step starts and the callee makes a choice
-; on whether to take the call or not. That being the case, you may want to account for
-; this time, and make this timeout longer than a timeout you might specify in app_dial.
+;
+; The timeout value is the amount of time allowed between the time the dialing step
+; starts and the callee answers.  The callee then has until the timeout of the last
+; step to make a choice on whether to take the call or not.  That being the case,
+; you may want to make the timeout on the last step longer to give enough time to
+; make the choice to accept or not.
 takecall=>1
 ; The keypress for the callee to take taking the current call. This can be
 ; a single digit or multiple digits. Default is the global default.




More information about the asterisk-commits mailing list