--- asterisk-orig/apps/app_queue.c 2005-12-21 13:03:10.000000000 -0500 +++ asterisk/apps/app_queue.c 2005-12-21 13:14:47.000000000 -0500 @@ -113,6 +113,8 @@ #define DEFAULT_TIMEOUT 15 #define RECHECK 1 /* Recheck every second to see we we're at the top yet */ +#define MAX_PERIODIC_ANNOUNCEMENTS 5 /* The maximum periodic announcements we can have */ + #define RES_OKAY 0 /* Action completed */ #define RES_EXISTS (-1) /* Entry already exists */ #define RES_OUTOFMEMORY (-2) /* Out of memory */ @@ -281,6 +283,7 @@ int prio; /*!< Our priority */ int last_pos_said; /*!< Last position we told the user */ time_t last_periodic_announce_time; /*!< The last time we played a periodic anouncement */ + int last_periodic_announce_sound; /* The last periodic announcement we made */ time_t last_pos; /*!< Last time we told the user their position */ int opos; /*!< Where we started in the queue */ int handled; /*!< Whether our call was handled */ @@ -344,7 +347,7 @@ char sound_seconds[80]; /*!< Sound file: "seconds." (def. queue-seconds) */ char sound_thanks[80]; /*!< Sound file: "Thank you for your patience." (def. queue-thankyou) */ char sound_reporthold[80]; /*!< Sound file: "Hold time" (def. queue-reporthold) */ - char sound_periodicannounce[80];/*!< Sound file: Custom announce, no default */ + char sound_periodicannounce[MAX_PERIODIC_ANNOUNCEMENTS][80];/* Sound file: Custom announce, no default */ int count; /*!< How many entries */ int maxlen; /*!< Max number of entries */ @@ -559,6 +562,7 @@ static void init_queue(struct ast_call_queue *q) { + int i; q->dead = 0; q->retry = DEFAULT_RETRY; q->timeout = -1; @@ -581,7 +585,10 @@ ast_copy_string(q->sound_thanks, "queue-thankyou", sizeof(q->sound_thanks)); ast_copy_string(q->sound_lessthan, "queue-less-than", sizeof(q->sound_lessthan)); ast_copy_string(q->sound_reporthold, "queue-reporthold", sizeof(q->sound_reporthold)); - ast_copy_string(q->sound_periodicannounce, "queue-periodic-announce", sizeof(q->sound_periodicannounce)); + ast_copy_string(q->sound_periodicannounce[0], "queue-periodic-announce", sizeof(q->sound_periodicannounce[0])); + for (i=1;isound_periodicannounce[i], "", sizeof(q->sound_periodicannounce[i])); + } } static void clear_queue(struct ast_call_queue *q) @@ -602,6 +609,9 @@ extra fields in the tables. */ static void queue_set_param(struct ast_call_queue *q, const char *param, const char *val, int linenum, int failunknown) { + int i = 0; + char *c, *lastc; + char buff[80]; if (!strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) { ast_copy_string(q->moh, val, sizeof(q->moh)); } else if (!strcasecmp(param, "announce")) { @@ -657,7 +667,22 @@ else q->announceholdtime = 0; } else if (!strcasecmp(param, "periodic-announce")) { - ast_copy_string(q->sound_periodicannounce, val, sizeof(q->sound_periodicannounce)); + if (strchr(val,'|')) { + lastc = (char *)val; + while ((c = strchr(lastc,'|'))) { + if (i > MAX_PERIODIC_ANNOUNCEMENTS) { break; } + strncpy(buff, lastc, abs(lastc - c)); + buff[abs(lastc - c)] = '\0'; + ast_copy_string(q->sound_periodicannounce[i], buff, sizeof(q->sound_periodicannounce[i])); + lastc = (c + 1); + i++; + } + if (strlen(lastc)) { + ast_copy_string(q->sound_periodicannounce[i], lastc, sizeof(q->sound_periodicannounce[i])); + } + }else{ + ast_copy_string(q->sound_periodicannounce[i], val, sizeof(q->sound_periodicannounce[i])); + } } else if (!strcasecmp(param, "periodic-announce-frequency")) { q->periodicannouncefrequency = atoi(val); } else if (!strcasecmp(param, "retry")) { @@ -1564,8 +1589,14 @@ if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Playing periodic announcement\n"); + /* Check to make sure we have a sound file. If not, reset to the first sound file */ + if (qe->last_periodic_announce_sound >= MAX_PERIODIC_ANNOUNCEMENTS || + !strlen(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound])) { + qe->last_periodic_announce_sound = 0; + } + /* play the announcement */ - res = background_file(qe, qe->chan, qe->parent->sound_periodicannounce); + 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); @@ -1573,6 +1604,9 @@ /* update last_periodic_announce_time */ qe->last_periodic_announce_time = now; + /* Update the current periodic announcement to the next announcement */ + qe->last_periodic_announce_sound++; + return res; } @@ -2911,6 +2945,7 @@ qe.last_pos_said = 0; qe.last_pos = 0; qe.last_periodic_announce_time = time(NULL); + qe.last_periodic_announce_sound = 0; if (!join_queue(queuename, &qe, &reason)) { ast_queue_log(queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s", url ? url : "", chan->cid.cid_num ? chan->cid.cid_num : "");