Add 'SAY TIME' to AGI. (bug #269)
authorJames Golovich <james@gnuinter.net>
Fri, 27 Feb 2004 08:30:30 +0000 (08:30 +0000)
committerJames Golovich <james@gnuinter.net>
Fri, 27 Feb 2004 08:30:30 +0000 (08:30 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2269 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_agi.c

index 2be4987..68570c8 100755 (executable)
@@ -396,6 +396,24 @@ static int handle_saydigits(struct ast_channel *chan, AGI *agi, int argc, char *
                return RESULT_FAILURE;
 }
 
                return RESULT_FAILURE;
 }
 
+static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+{
+       int res;
+       int num;
+       if (argc != 4)
+               return RESULT_SHOWUSAGE;
+       if (sscanf(argv[2], "%i", &num) != 1)
+               return RESULT_SHOWUSAGE;
+       res = ast_say_time(chan, num, argv[3], chan->language);
+       if (res == 1)
+               return RESULT_SUCCESS;
+       fdprintf(agi->fd, "200 result=%d\n", res);
+       if (res >= 0)
+               return RESULT_SUCCESS;
+       else
+               return RESULT_FAILURE;
+}
+
 static int handle_getdata(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
 {
        int res;
 static int handle_getdata(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
 {
        int res;
@@ -993,6 +1011,14 @@ static char usage_saydigits[] =
 " being pressed, or the ASCII numerical value of the digit if one was pressed or\n"
 " -1 on error/hangup.\n";
 
 " being pressed, or the ASCII numerical value of the digit if one was pressed or\n"
 " -1 on error/hangup.\n";
 
+static char usage_saytime[] =
+" Usage: SAY TIME <time> <escape digits>\n"
+"        Say a given time, returning early if any of the given DTMF digits are\n"
+" received on the channel.  <time> is number of seconds elapsed since 00:00:00\n"
+" on January 1, 1970, Coordinated Universal Time (UTC).  Returns 0 if playback\n"
+" completes without a digit being pressed, or the ASCII numerical value of the\n"
+" digit if one was pressed or -1 on error/hangup.\n";
+
 static char usage_getdata[] =
 " Usage: GET DATA <file to be streamed> [timeout] [max digits]\n"
 "       Stream the given file, and recieve DTMF data. Returns the digits recieved\n"
 static char usage_getdata[] =
 " Usage: GET DATA <file to be streamed> [timeout] [max digits]\n"
 "       Stream the given file, and recieve DTMF data. Returns the digits recieved\n"
@@ -1042,6 +1068,7 @@ static agi_command commands[] = {
        { { "send", "image", NULL }, handle_sendimage, "Sends images to channels supporting it", usage_sendimage },
        { { "say", "digits", NULL }, handle_saydigits, "Says a given digit string", usage_saydigits },
        { { "say", "number", NULL }, handle_saynumber, "Says a given number", usage_saynumber },
        { { "send", "image", NULL }, handle_sendimage, "Sends images to channels supporting it", usage_sendimage },
        { { "say", "digits", NULL }, handle_saydigits, "Says a given digit string", usage_saydigits },
        { { "say", "number", NULL }, handle_saynumber, "Says a given number", usage_saynumber },
+       { { "say", "time", NULL }, handle_saytime, "Says a given time", usage_saytime },
        { { "get", "data", NULL }, handle_getdata, "Gets data on a channel", usage_getdata },
        { { "set", "context", NULL }, handle_setcontext, "Sets channel context", usage_setcontext },
        { { "set", "extension", NULL }, handle_setextension, "Changes channel extension", usage_setextension },
        { { "get", "data", NULL }, handle_getdata, "Gets data on a channel", usage_getdata },
        { { "set", "context", NULL }, handle_setcontext, "Sets channel context", usage_setcontext },
        { { "set", "extension", NULL }, handle_setextension, "Changes channel extension", usage_setextension },