[Asterisk-cvs] asterisk/res res_agi.c,1.31,1.32
markster at lists.digium.com
markster at lists.digium.com
Sun Apr 10 22:31:56 CDT 2005
Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv25442/res
Modified Files:
res_agi.c
Log Message:
Add datetime to AGI (bug #3984)
Index: res_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_agi.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- res_agi.c 30 Mar 2005 07:00:49 -0000 1.31
+++ res_agi.c 11 Apr 2005 03:23:54 -0000 1.32
@@ -649,6 +649,43 @@
return RESULT_FAILURE;
}
+static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+{
+ int res=0;
+ long unixtime;
+ char *format, *zone=NULL;
+
+ if (argc < 4)
+ return RESULT_SHOWUSAGE;
+
+ if (argc > 4) {
+ format = argv[4];
+ } else {
+ if (!strcasecmp(chan->language, "de")) {
+ format = "A dBY HMS";
+ } else {
+ format = "ABdY 'digits/at' IMp";
+ }
+ }
+
+ if (argc > 5 && !ast_strlen_zero(argv[5]))
+ zone = argv[5];
+
+ if (sscanf(argv[2], "%ld", &unixtime) != 1)
+ return RESULT_SHOWUSAGE;
+
+ res = ast_say_date_with_format(chan, (time_t) unixtime, argv[3], chan->language, format, zone);
+ 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_sayphonetic(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
{
int res;
@@ -1389,6 +1426,17 @@
" 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_saydatetime[] =
+" Usage: SAY DATETIME <time> <escape digits> [format] [timezone]\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). [format] is the format\n"
+" the time should be said in. See voicemail.conf (defaults to \"ABdY\n"
+" 'digits/at' IMp\"). Acceptable values for [timezone] can be found in\n"
+" /usr/share/zoneinfo. Defaults to machine default. 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_sayphonetic[] =
" Usage: SAY PHONETIC <string> <escape digits>\n"
" Say a given character string with phonetics, returning early if any of the\n"
@@ -1457,6 +1505,7 @@
{ { "say", "phonetic", NULL }, handle_sayphonetic, "Says a given character string with phonetics", usage_sayphonetic },
{ { "say", "date", NULL }, handle_saydate, "Says a given date", usage_saydate },
{ { "say", "time", NULL }, handle_saytime, "Says a given time", usage_saytime },
+ { { "say", "datetime", NULL }, handle_saydatetime, "Says a given time as specfied by the format given", usage_saydatetime },
{ { "send", "image", NULL }, handle_sendimage, "Sends images to channels supporting it", usage_sendimage },
{ { "send", "text", NULL }, handle_sendtext, "Sends text to channels supporting it", usage_sendtext },
{ { "set", "autohangup", NULL }, handle_autohangup, "Autohangup channel in some time", usage_autohangup },
More information about the svn-commits
mailing list