From aabff54c4bfb687714df72119a0241af6a14edf4 Mon Sep 17 00:00:00 2001
From: Matthew Nicholson <mnicholson@digium.com>
Date: Mon, 9 Nov 2009 16:28:31 +0000
Subject: [PATCH] Add the 'relative-periodic-announce' option to app_queue to
 allow for calculating the time of announcments from the end of the previous
 announcment rather than from the beginning.

(closes issue #15260)
Reported by: tonils


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228947 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 CHANGES                    | 3 +++
 apps/app_queue.c           | 8 +++++++-
 configs/queues.conf.sample | 6 ++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/CHANGES b/CHANGES
index cba56f900e..ab41474e03 100644
--- a/CHANGES
+++ b/CHANGES
@@ -158,6 +158,9 @@ Queue changes
   * A new option, 'I' has been added to both app_queue and app_dial.
     By setting this option, Asterisk will not update the caller with
     connected line changes or redirecting party changes when they occur.
+  * A 'relative-peroidic-announce' option has been added to queues.conf.  When
+    enabled, this option will cause periodic announce times to be calculated
+    from the end of announcements rather than from the beginning.
 
 mISDN channel driver (chan_misdn) changes
 ----------------------------------------
diff --git a/apps/app_queue.c b/apps/app_queue.c
index bdbb91560f..c0b32ff90c 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -930,6 +930,7 @@ struct call_queue {
 	unsigned int maskmemberstatus:1;
 	unsigned int realtime:1;
 	unsigned int found:1;
+	unsigned int relativeperiodicannounce:1;
 	enum empty_conditions joinempty;
 	enum empty_conditions leavewhenempty;
 	int announcepositionlimit;          /*!< How many positions we announce? */
@@ -1720,6 +1721,8 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
 		}
 	} else if (!strcasecmp(param, "periodic-announce-frequency")) {
 		q->periodicannouncefrequency = atoi(val);
+	} else if (!strcasecmp(param, "relative-periodic-announce")) {
+		q->relativeperiodicannounce = ast_true(val);
 	} else if (!strcasecmp(param, "random-periodic-announce")) {
 		q->randomperiodicannounce = ast_true(val);
 	} else if (!strcasecmp(param, "retry")) {
@@ -3029,7 +3032,10 @@ static int say_periodic_announcement(struct queue_ent *qe, int ringing)
 	}
 
 	/* update last_periodic_announce_time */
-	qe->last_periodic_announce_time = now;
+	if (qe->parent->relativeperiodicannounce)
+		time(&qe->last_periodic_announce_time);
+	else
+		qe->last_periodic_announce_time = now;
 
 	/* Update the current periodic announcement to the next announcement */
 	if (!qe->parent->randomperiodicannounce) {
diff --git a/configs/queues.conf.sample b/configs/queues.conf.sample
index 6752bbffd6..56ebeed417 100644
--- a/configs/queues.conf.sample
+++ b/configs/queues.conf.sample
@@ -254,6 +254,12 @@ shared_lastcall=no
 ;
 ;random-periodic-announce=no
 ;
+; If set to yes, the periodic announcment frequency will be timed from the end
+; of each announcment rather than from the start of each announcment.  This
+; defaults to off.
+;
+;relative-periodic-announce=yes
+;
 ; Should we include estimated hold time in position announcements?
 ; Either yes, no, or only once.
 ; Hold time will be announced as the estimated time.
-- 
GitLab