aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_agi.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-04-11 03:23:54 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-04-11 03:23:54 +0000
commit2c123568dff2fa858b0d31c9dfd19389940b354d (patch)
tree20eedc69059250f6783d5b46278c9df5ed258f72 /res/res_agi.c
parent6a44809129d614a218a460de119482266cb7f8fc (diff)
Add datetime to AGI (bug #3984)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5446 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_agi.c')
-rwxr-xr-xres/res_agi.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 3930d67e9..7c7f6e3d9 100755
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -649,6 +649,43 @@ static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, char *ar
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 @@ static char usage_saytime[] =
" 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 @@ static agi_command commands[MAX_COMMANDS] = {
{ { "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 },