[asterisk-commits] trunk r29972 - in /trunk: ./ apps/app_queue.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed May 24 09:54:10 MST 2006


Author: kpfleming
Date: Wed May 24 11:54:10 2006
New Revision: 29972

URL: http://svn.digium.com/view/asterisk?rev=29972&view=rev
Log:
Merged revisions 29971 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r29971 | kpfleming | 2006-05-24 11:52:08 -0500 (Wed, 24 May 2006) | 2 lines

fix various bugs related to exiting from queue via keypress and moh handling (issue #6776, different fix)

........

Modified:
    trunk/   (props changed)
    trunk/apps/app_queue.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=29972&r1=29971&r2=29972&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Wed May 24 11:54:10 2006
@@ -1213,13 +1213,16 @@
 		ast_verbose(VERBOSE_PREFIX_3 "Told %s in %s their queue position (which was %d)\n",
 			    qe->chan->name, qe->parent->name, qe->pos);
 	res = play_file(qe->chan, qe->parent->sound_thanks);
+	if (res && !valid_exit(qe, res))
+		res = 0;
 
  playout:
 	/* Set our last_pos indicators */
  	qe->last_pos = now;
 	qe->last_pos_said = qe->pos;
+
 	/* Don't restart music on hold if we're about to exit the caller from the queue */
-	if (res)
+	if (!res)
 		ast_moh_start(qe->chan, qe->moh);
 
 	return res;
@@ -1585,7 +1588,7 @@
 	if (!res) {
 		/* Wait for a keypress */
 		res = ast_waitstream(chan, AST_DIGIT_ANY);
-		if (res <= 0 || !valid_exit(qe, res))
+		if (res < 0 || !valid_exit(qe, res))
 			res = 0;
 
 		/* Stop playback */
@@ -1628,8 +1631,9 @@
 	/* play the announcement */
 	res = background_file(qe, qe->chan, qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]);
 
-	/* Resume Music on Hold */
-	ast_moh_start(qe->chan, qe->moh);
+	/* Resume Music on Hold if the caller is going to stay in the queue */
+	if (!res)
+		ast_moh_start(qe->chan, qe->moh);
 
 	/* update last_periodic_announce_time */
 	qe->last_periodic_announce_time = now;
@@ -1993,18 +1997,17 @@
 		}
 
 		/* Make a position announcement, if enabled */
-		if (qe->parent->announcefrequency && !ringing)
-			res = say_position(qe);
-		if (res)
+		if (qe->parent->announcefrequency && !ringing &&
+		    (res = say_position(qe)))
 			break;
 
 		/* Make a periodic announcement, if enabled */
-		if (qe->parent->periodicannouncefrequency && !ringing)
-			res = say_periodic_announcement(qe);
+		if (qe->parent->periodicannouncefrequency && !ringing &&
+		    (res = say_periodic_announcement(qe)))
+			break;
 
 		/* Wait a second before checking again */
-		if (!res) res = ast_waitfordigit(qe->chan, RECHECK * 1000);
-		if (res)
+		if ((res = ast_waitfordigit(qe->chan, RECHECK * 1000)))
 			break;
 	}
 	return res;
@@ -2301,7 +2304,7 @@
 		if (res < 0) {
 			ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "SYSCOMPAT", "%s", "");
 			ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", qe->chan->name, peer->name);
-		record_abandoned(qe);
+			record_abandoned(qe);
 			ast_hangup(peer);
 			return -1;
 		}
@@ -2459,13 +2462,10 @@
 					      (long)(time(NULL) - callstart));
 		}
 
-		if(bridge != AST_PBX_NO_HANGUP_PEER)
+		if (bridge != AST_PBX_NO_HANGUP_PEER)
 			ast_hangup(peer);
 		update_queue(qe->parent, member);
-		if (bridge == 0) 
-			res = 1; /* JDG: bridge successfully, leave app_queue */
-		else 
-			res = bridge; /* bridge error, stay in the queue */
+		res = bridge ? 0 : -1;
 	}
 out:
 	hangupcalls(outgoing, NULL);
@@ -3142,9 +3142,8 @@
 
 				if (makeannouncement) {
 					/* Make a position announcement, if enabled */
-					if (qe.parent->announcefrequency && !ringing)
-						res = say_position(&qe);
-					if (res) {
+					if (qe.parent->announcefrequency && !ringing &&
+					    (res = say_position(&qe))) {
 						 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
 						break;
 					}
@@ -3153,10 +3152,8 @@
 				makeannouncement = 1;
 
 				/* Make a periodic announcement, if enabled */
-				if (qe.parent->periodicannouncefrequency && !ringing)
-					res = say_periodic_announcement(&qe);
-
-				if (res && valid_exit(&qe, res)) {
+				if (qe.parent->periodicannouncefrequency && !ringing &&
+				    (res = say_periodic_announcement(&qe))) {
 					ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%c|%d", res, qe.pos);
 					break;
 				}
@@ -3170,8 +3167,9 @@
 							record_abandoned(&qe);
 							ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long)time(NULL) - qe.start);
 						}
-					} else if (res > 0)
+					} else if (valid_exit(&qe, res)) {
 						 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
+					}
 					break;
 				}
 
@@ -3234,7 +3232,7 @@
 				if (!is_our_turn(&qe)) {
 					if (option_debug)
 						ast_log(LOG_DEBUG, "Darn priorities, going back in queue (%s)!\n",
-								qe.chan->name);
+							qe.chan->name);
 					goto check_turns;
 				}
 			}



More information about the asterisk-commits mailing list