Adding new configuration options to app_queue. This adds two new values
authorMark Michelson <mmichelson@digium.com>
Wed, 30 Apr 2008 19:30:41 +0000 (19:30 +0000)
committerMark Michelson <mmichelson@digium.com>
Wed, 30 Apr 2008 19:30:41 +0000 (19:30 +0000)
to announce-position, "limit" and "more," as well as a new option,
announce-position-limit. For more information on the use of these options,
see CHANGES or configs/queues.conf.sample.

(closes issue #10991)
Reported by: slavon
Patches:
      app_q.diff uploaded by slavon (license 288)
Tested by: slavon, putnopvut

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114906 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
apps/app_queue.c
configs/queues.conf.sample

diff --git a/CHANGES b/CHANGES
index 1071176..1c1fa07 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -417,6 +417,12 @@ Queue changes
   * New configuration option: randomperiodicannounce. If a list of periodic announcements is
     specified by the periodic-announce option, then one will be chosen randomly when it is time
        to play a periodic announcment
+  * New configuration options: announce-position now takes two more values in addition to "yes" and
+    "no." Two new options, "limit" and "more," are allowed. These are tied to another option,
+       announce-position-limit. By setting announce-position to "limit" callers will only have their
+       position announced if their position is less than what is specified by announce-position-limit.
+       If announce-position is set to "more" then callers beyond the position specified by announce-position-limit
+       will be told that their are more than announce-position-limit callers waiting.
 
 MeetMe Changes
 --------------
index 1624529..ad87ad5 100644 (file)
@@ -407,6 +407,11 @@ struct penalty_rule {
        AST_LIST_ENTRY(penalty_rule) list;  /*!< Next penalty_rule */
 };
 
+#define ANNOUNCEPOSITION_YES 1 /*!< We announce position */
+#define ANNOUNCEPOSITION_NO 2 /*!< We don't announce position */
+#define ANNOUNCEPOSITION_MORE_THAN 3 /*!< We say "Currently there are more than <limit>" */
+#define ANNOUNCEPOSITION_LIMIT 4 /*!< We not announce position more than <limit> */
+
 struct call_queue {
        AST_DECLARE_STRING_FIELDS(
                /*! Queue name */
@@ -429,6 +434,10 @@ struct call_queue {
                AST_STRING_FIELD(sound_thereare);
                /*! Sound file: "calls waiting to speak to a representative." (def. queue-callswaiting) */
                AST_STRING_FIELD(sound_calls);
+               /*! Sound file: "Currently there are more than" (def. queue-quantity1) */
+               AST_STRING_FIELD(queue_quantity1);
+               /*! Sound file: "callers waiting to speak with a representative" (def. queue-quantity2) */
+               AST_STRING_FIELD(queue_quantity2);
                /*! Sound file: "The current estimated total holdtime is" (def. queue-holdtime) */
                AST_STRING_FIELD(sound_holdtime);
                /*! Sound file: "minutes." (def. queue-minutes) */
@@ -458,11 +467,12 @@ struct call_queue {
        unsigned int wrapped:1;
        unsigned int timeoutrestart:1;
        unsigned int announceholdtime:2;
-       unsigned int announceposition:1;
+       unsigned int announceposition:3;
        int strategy:4;
        unsigned int maskmemberstatus:1;
        unsigned int realtime:1;
        unsigned int found:1;
+       int announcepositionlimit;          /*!< How many positions we announce? */
        int announcefrequency;              /*!< How often to announce their position */
        int minannouncefrequency;           /*!< The minimum number of seconds between position announcements (def. 15) */
        int periodicannouncefrequency;      /*!< How often to play periodic announcement */
@@ -926,8 +936,9 @@ static void init_queue(struct call_queue *q)
        q->maxlen = 0;
        q->announcefrequency = 0;
        q->minannouncefrequency = DEFAULT_MIN_ANNOUNCE_FREQUENCY;
-       q->announceholdtime = 0;
        q->announceholdtime = 1;
+       q->announcepositionlimit = 10; /* Default 10 positions */
+       q->announceposition = ANNOUNCEPOSITION_YES; /* Default yes */
        q->roundingseconds = 0; /* Default - don't announce seconds */
        q->servicelevel = 0;
        q->ringinuse = 1;
@@ -962,6 +973,8 @@ static void init_queue(struct call_queue *q)
        ast_string_field_set(q, sound_next, "queue-youarenext");
        ast_string_field_set(q, sound_thereare, "queue-thereare");
        ast_string_field_set(q, sound_calls, "queue-callswaiting");
+       ast_string_field_set(q, queue_quantity1, "queue-quantity1");
+       ast_string_field_set(q, queue_quantity2, "queue-quantity2");
        ast_string_field_set(q, sound_holdtime, "queue-holdtime");
        ast_string_field_set(q, sound_minutes, "queue-minutes");
        ast_string_field_set(q, sound_minute, "queue-minute");
@@ -1195,6 +1208,10 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
                ast_string_field_set(q, sound_thereare, val);
        } else if (!strcasecmp(param, "queue-callswaiting")) {
                ast_string_field_set(q, sound_calls, val);
+       } else if (!strcasecmp(param, "queue-quantity1")) {
+               ast_string_field_set(q, queue_quantity1, val);
+       } else if (!strcasecmp(param, "queue-quantity2")) {
+               ast_string_field_set(q, queue_quantity2, val);
        } else if (!strcasecmp(param, "queue-holdtime")) {
                ast_string_field_set(q, sound_holdtime, val);
        } else if (!strcasecmp(param, "queue-minutes")) {
@@ -1237,7 +1254,16 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
                else
                        q->announceholdtime = 0;
        } else if (!strcasecmp(param, "announce-position")) {
-               q->announceposition = ast_true(val);
+               if (!strcasecmp(val, "limit"))
+                       q->announceposition = ANNOUNCEPOSITION_LIMIT;
+               else if (!strcasecmp(val, "more"))
+                       q->announceposition = ANNOUNCEPOSITION_MORE_THAN;
+               else if (ast_true(val))
+                       q->announceposition = ANNOUNCEPOSITION_YES;
+               else
+                       q->announceposition = ANNOUNCEPOSITION_NO;
+       } else if (!strcasecmp(param, "announce-position-limit")) {
+               q->announcepositionlimit = atoi(val);
        } else if (!strcasecmp(param, "periodic-announce")) {
                if (strchr(val, ',')) {
                        char *s, *buf = ast_strdupa(val);
@@ -1802,7 +1828,7 @@ static int valid_exit(struct queue_ent *qe, char digit)
 
 static int say_position(struct queue_ent *qe, int ringing)
 {
-       int res = 0, avgholdmins, avgholdsecs;
+       int res = 0, avgholdmins, avgholdsecs, announceposition = 0;
        time_t now;
 
        /* Let minannouncefrequency seconds pass between the start of each position announcement */
@@ -1819,7 +1845,15 @@ static int say_position(struct queue_ent *qe, int ringing)
        } else {
                ast_moh_stop(qe->chan);
        }
-       if (qe->parent->announceposition) {
+
+       if (qe->parent->announceposition == ANNOUNCEPOSITION_YES ||
+               qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN ||
+               (qe->parent->announceposition == ANNOUNCEPOSITION_LIMIT &&
+               qe->pos <= qe->parent->announcepositionlimit))
+                       announceposition = 1;
+
+
+       if (announceposition == 1) {
                /* Say we're next, if we are */
                if (qe->pos == 1) {
                        res = play_file(qe->chan, qe->parent->sound_next);
@@ -1828,15 +1862,33 @@ static int say_position(struct queue_ent *qe, int ringing)
                        else
                                goto posout;
                } else {
-                       res = play_file(qe->chan, qe->parent->sound_thereare);
-                       if (res)
-                               goto playout;
-                       res = ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language, NULL); /* Needs gender */
-                       if (res)
-                               goto playout;
-                       res = play_file(qe->chan, qe->parent->sound_calls);
-                       if (res)
-                               goto playout;
+                       if (qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN && qe->pos > qe->parent->announcepositionlimit){
+                               /* More than Case*/
+                               res = play_file(qe->chan, qe->parent->queue_quantity1);
+                               if (res)
+                                       goto playout;
+                               res = ast_say_number(qe->chan, qe->parent->announcepositionlimit, AST_DIGIT_ANY, qe->chan->language, NULL); /* Needs gender */
+                               if (res)
+                                       goto playout;
+                       } else {
+                               /* Normal Case */
+                               res = play_file(qe->chan, qe->parent->sound_thereare);
+                               if (res)
+                                       goto playout;
+                               res = ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language, NULL); /* Needs gender */
+                               if (res)
+                                       goto playout;
+                       }
+                       if (qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN && qe->pos > qe->parent->announcepositionlimit){
+                               /* More than Case*/
+                               res = play_file(qe->chan, qe->parent->queue_quantity2);
+                               if (res)
+                                       goto playout;
+                       } else {
+                               res = play_file(qe->chan, qe->parent->sound_calls);
+                               if (res)
+                                       goto playout;
+                       }
                }
        }
        /* Round hold time to nearest minute */
@@ -1888,12 +1940,13 @@ static int say_position(struct queue_ent *qe, int ringing)
        }
 
 posout:
-       if (qe->parent->announceposition) {
-               ast_verb(3, "Told %s in %s their queue position (which was %d)\n",
-                       qe->chan->name, qe->parent->name, qe->pos);
+       if (announceposition == 1){
+               if (qe->parent->announceposition) {
+                       ast_verb(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);
        }
-       res = play_file(qe->chan, qe->parent->sound_thanks);
-
 playout:
        if ((res > 0 && !valid_exit(qe, res)) || res < 0)
                res = 0;
index 0b171f6..3d826ce 100644 (file)
@@ -221,11 +221,23 @@ shared_lastcall=no
 ;announce-holdtime = yes|no|once
 ;
 ; Queue position announce?
-; Either yes or no. If turned off, only the holdtime will be announced (as
-; configured in announce-holdtime)
+; Valid values are "yes," "no," "limit," or "more." If set to "no," then the caller's position will
+; never be announced. If "yes," then the caller's position in the queue will be announced
+; to the caller. If set to "more," then if the number of callers is more than the number
+; specified by the announce-position-limit option, then the caller will hear that there
+; are more than that many callers waiting (i.e. if a caller number 6 is in a queue with the
+; announce-position-limit set to 5, then that caller will hear that there are more than 5
+; callers waiting). If set to "limit," then only callers within the limit specified by announce-position-limit
+; will have their position announced.
 ;
 ;announce-position = yes
 ;
+; If you have specified "limit" or "more" for the announce-position option, then the following
+; value is what is used to determine what announcement to play to waiting callers. If you have
+; set the announce-position option to anything else, then this will have no bearing on queue operation
+;
+;announce-position-limit = 5
+;
 ; What's the rounding time for the seconds?
 ; If this is non-zero, then we announce the seconds as well as the minutes
 ; rounded to this value.