Make holdtime announcement say "less than 2 minutes" instead of "1 minutes" (bug...
authorMark Spencer <markster@digium.com>
Sat, 25 Sep 2004 14:22:27 +0000 (14:22 +0000)
committerMark Spencer <markster@digium.com>
Sat, 25 Sep 2004 14:22:27 +0000 (14:22 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3834 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_queue.c
res/res_agi.c
sounds.txt
sounds/queue-less-than.gsm [new file with mode: 0755]

index a2f2ae5..542ede2 100755 (executable)
@@ -208,6 +208,7 @@ struct ast_call_queue {
        char sound_calls[80];           /* Sound file: "calls waiting to speak to a representative." (def. queue-callswaiting)*/
        char sound_holdtime[80];        /* Sound file: "The current estimated total holdtime is" (def. queue-holdtime) */
        char sound_minutes[80];         /* Sound file: "minutes." (def. queue-minutes) */
+       char sound_lessthan[80];        /* Sound file: "less-than" (def. queue-lessthan) */
        char sound_seconds[80];         /* Sound file: "seconds." (def. queue-seconds) */
        char sound_thanks[80];          /* Sound file: "Thank you for your patience." (def. queue-thankyou) */
 
@@ -434,7 +435,11 @@ static int say_position(struct queue_ent *qe)
        if ((avgholdmins+avgholdsecs) > 0 && (qe->parent->announceholdtime) && (!(qe->parent->announceholdtime==1 && qe->last_pos)) ) {
                res += play_file(qe->chan, qe->parent->sound_holdtime);
                if(avgholdmins>0) {
-                       res += ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, (char*) NULL);
+                       if (avgholdmins < 2) {
+                               res += play_file(qe->chan, qe->parent->sound_lessthan);
+                               res += ast_say_number(qe->chan, 2, AST_DIGIT_ANY, qe->chan->language, (char *)NULL);
+                       } else 
+                               res += ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, (char*) NULL);
                        res += play_file(qe->chan, qe->parent->sound_minutes);
                }
                if(avgholdsecs>0) {
@@ -1776,6 +1781,7 @@ static void reload_queues(void)
                                strncpy(q->sound_minutes, "queue-minutes", sizeof(q->sound_minutes) - 1);
                                strncpy(q->sound_seconds, "queue-seconds", sizeof(q->sound_seconds) - 1);
                                strncpy(q->sound_thanks, "queue-thankyou", sizeof(q->sound_thanks) - 1);
+                               strncpy(q->sound_lessthan, "queue-lessthan", sizeof(q->sound_lessthan) - 1);
                                prev = q->members;
                                if (prev) {
                                        /* find the end of any dynamic members */
@@ -1836,6 +1842,8 @@ static void reload_queues(void)
                                                strncpy(q->sound_minutes, var->value, sizeof(q->sound_minutes) - 1);
                                        } else if (!strcasecmp(var->name, "queue-seconds")) {
                                                strncpy(q->sound_seconds, var->value, sizeof(q->sound_seconds) - 1);
+                                       } else if (!strcasecmp(var->name, "queue-lessthan")) {
+                                               strncpy(q->sound_lessthan, var->value, sizeof(q->sound_lessthan) - 1);
                                        } else if (!strcasecmp(var->name, "queue-thankyou")) {
                                                strncpy(q->sound_thanks, var->value, sizeof(q->sound_thanks) - 1);
                                        } else if (!strcasecmp(var->name, "announce-frequency")) {
index 2a58a5b..b504708 100755 (executable)
@@ -38,6 +38,7 @@
 #include <asterisk/app.h>
 #include <asterisk/dsp.h>
 #include <asterisk/musiconhold.h>
+#include <asterisk/manager.h>
 #include <asterisk/utils.h>
 #include <asterisk/lock.h>
 #include <asterisk/agi.h>
@@ -48,7 +49,7 @@
 #define MAX_COMMANDS 128
 
 /* Recycle some stuff from the CLI interface */
-#define fdprintf ast_cli
+#define fdprintf agi_debug_cli
 
 static char *tdesc = "Asterisk Gateway Interface (AGI)";
 
@@ -74,6 +75,8 @@ static char *descrip =
 "on file descriptor 3\n\n"
 "Use the CLI command 'show agi' to list available agi commands\n";
 
+static int agidebug = 0;
+
 STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
@@ -86,6 +89,25 @@ LOCAL_USER_DECL;
 
 #define AGI_PORT 4573
 
+static void agi_debug_cli(int fd, char *fmt, ...)
+{
+       char *stuff;
+       int res = 0;
+
+       va_list ap;
+       va_start(ap, fmt);
+       res = vasprintf(&stuff, fmt, ap);
+       va_end(ap);
+       if (res == -1) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+       } else {
+               if (agidebug)
+                       ast_verbose("AGI Tx >> %s", stuff);
+               ast_carefulwrite(fd, stuff, strlen(stuff), 100);
+               free(stuff);
+       }
+}
+
 static int launch_netscript(char *agiurl, char *argv[], int *fds, int *efd, int *opid)
 {
        int s;
@@ -961,6 +983,38 @@ static int handle_dbdeltree(struct ast_channel *chan, AGI *agi, int argc, char *
        return RESULT_SUCCESS;
 }
 
+static char debug_usage[] = 
+"Usage: agi debug\n"
+"       Enables dumping of AGI transactions for debugging purposes\n";
+
+static char no_debug_usage[] = 
+"Usage: agi no debug\n"
+"       Disables dumping of AGI transactions for debugging purposes\n";
+
+static int agi_do_debug(int fd, int argc, char *argv[])
+{
+       if (argc != 2)
+               return RESULT_SHOWUSAGE;
+       agidebug = 1;
+       ast_cli(fd, "AGI Debugging Enabled\n");
+       return RESULT_SUCCESS;
+}
+
+static int agi_no_debug(int fd, int argc, char *argv[])
+{
+       if (argc != 3)
+               return RESULT_SHOWUSAGE;
+       agidebug = 0;
+       ast_cli(fd, "AGI Debugging Disabled\n");
+       return RESULT_SUCCESS;
+}
+
+static struct ast_cli_entry  cli_debug =
+       { { "agi", "debug", NULL }, agi_do_debug, "Enable AGI debugging", debug_usage };
+
+static struct ast_cli_entry  cli_no_debug =
+       { { "agi", "no", "debug", NULL }, agi_no_debug, "Disable AGI debugging", no_debug_usage };
+
 static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, char *argv[])
 {
        fdprintf(agi->fd, "200 result=0\n");
@@ -1469,7 +1523,8 @@ static int run_agi(struct ast_channel *chan, char *request, AGI *agi, int pid, i
                          /* get rid of trailing newline, if any */
                        if (*buf && buf[strlen(buf) - 1] == '\n')
                                buf[strlen(buf) - 1] = 0;
-
+                       if (agidebug)
+                               ast_verbose("AGI Rx << %s\n", buf);
                        returnstatus |= agi_handle_command(chan, agi, buf);
                        /* If the handle_command returns -1, we need to stop */
                        if ((returnstatus < 0) || (returnstatus == AST_PBX_KEEPALIVE)) {
@@ -1672,6 +1727,8 @@ int unload_module(void)
        STANDARD_HANGUP_LOCALUSERS;
        ast_cli_unregister(&showagi);
        ast_cli_unregister(&dumpagihtml);
+       ast_cli_unregister(&cli_debug);
+       ast_cli_unregister(&cli_no_debug);
        ast_unregister_application(eapp);
        ast_unregister_application(deadapp);
        return ast_unregister_application(app);
@@ -1681,6 +1738,8 @@ int load_module(void)
 {
        ast_cli_register(&showagi);
        ast_cli_register(&dumpagihtml);
+       ast_cli_register(&cli_debug);
+       ast_cli_register(&cli_no_debug);
        ast_register_application(deadapp, deadagi_exec, deadsynopsis, descrip);
        ast_register_application(eapp, eagi_exec, esynopsis, descrip);
        return ast_register_application(app, agi_exec, synopsis, descrip);
index c988e1c..5797920 100755 (executable)
 %conf-unlockednow.gsm%The conference is now unlocked
 
 %vm-leavemsg.gsm% Press 5 to send a voicemail message
+
+%queue-less-than.gsm%less than
diff --git a/sounds/queue-less-than.gsm b/sounds/queue-less-than.gsm
new file mode 100755 (executable)
index 0000000..38875ed
Binary files /dev/null and b/sounds/queue-less-than.gsm differ