[asterisk-commits] russell: trunk r47408 - in /trunk: apps/
include/asterisk/ main/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Nov 9 20:59:48 MST 2006
Author: russell
Date: Thu Nov 9 21:59:48 2006
New Revision: 47408
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47408
Log:
Add the ability to specify multiple prompts to the Read() dialplan application,
similar to Background() and Playback().
(issue #7897, jsmith, with some modifications)
Modified:
trunk/apps/app_read.c
trunk/include/asterisk/app.h
trunk/main/app.c
Modified: trunk/apps/app_read.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_read.c?view=diff&rev=47408&r1=47407&r2=47408
==============================================================================
--- trunk/apps/app_read.c (original)
+++ trunk/apps/app_read.c Thu Nov 9 21:59:48 2006
@@ -62,10 +62,10 @@
static char *synopsis = "Read a variable";
static char *descrip =
-" Read(variable[|filename][|maxdigits][|option][|attempts][|timeout])\n\n"
+" Read(variable[|filename[&filename2...]][|maxdigits][|option][|attempts][|timeout])\n\n"
"Reads a #-terminated string of digits a certain number of times from the\n"
"user in to the given variable.\n"
-" filename -- file to play before reading digits or tone with option i\n"
+" filename -- file(s) to play before reading digits or tone with option i\n"
" maxdigits -- maximum acceptable number of digits. Stops reading after\n"
" maxdigits have been entered (without requiring the user to\n"
" press the '#' key).\n"
Modified: trunk/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/app.h?view=diff&rev=47408&r1=47407&r2=47408
==============================================================================
--- trunk/include/asterisk/app.h (original)
+++ trunk/include/asterisk/app.h Thu Nov 9 21:59:48 2006
@@ -84,7 +84,9 @@
/*! \brief Plays a stream and gets DTMF data from a channel
* \param c Which channel one is interacting with
- * \param prompt File to pass to ast_streamfile (the one that you wish to play)
+ * \param prompt File to pass to ast_streamfile (the one that you wish to play).
+ * It is also valid for this to be multiple files concatenated by "&".
+ * For example, "file1&file2&file3".
* \param s The location where the DTMF data will be stored
* \param maxlen Max Length of the data
* \param timeout Timeout length waiting for data(in milliseconds). Set to 0 for standard timeout(six seconds), or -1 for no time out.
@@ -94,7 +96,7 @@
* is pressed during playback, it will immediately break out of the message and continue
* execution of your code.
*/
-int ast_app_getdata(struct ast_channel *c, char *prompt, char *s, int maxlen, int timeout);
+int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout);
/*! \brief Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other full functions */
int ast_app_getdata_full(struct ast_channel *c, char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd);
Modified: trunk/main/app.c
URL: http://svn.digium.com/view/asterisk/trunk/main/app.c?view=diff&rev=47408&r1=47407&r2=47408
==============================================================================
--- trunk/main/app.c (original)
+++ trunk/main/app.c Thu Nov 9 21:59:48 2006
@@ -105,25 +105,45 @@
* \param maxlen How many digits to read (maximum)
* \param timeout set timeout to 0 for "standard" timeouts. Set timeout to -1 for
* "ludicrous time" (essentially never times out) */
-int ast_app_getdata(struct ast_channel *c, char *prompt, char *s, int maxlen, int timeout)
-{
- int res,to,fto;
+int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
+{
+ int res = 0, to, fto;
+ char *front, *filename;
+
/* XXX Merge with full version? XXX */
+
if (maxlen)
s[0] = '\0';
- if (prompt) {
- res = ast_streamfile(c, prompt, c->language);
- if (res < 0)
+
+ if (ast_strlen_zero(prompt))
+ return -1;
+
+ filename = ast_strdupa(prompt);
+ while ((front = strsep(&filename, "&"))) {
+ res = ast_streamfile(c, front, c->language);
+ if (res)
+ continue;
+ if (ast_strlen_zero(filename)) {
+ /* set timeouts for the last prompt */
+ fto = c->pbx ? c->pbx->rtimeout * 1000 : 6000;
+ to = c->pbx ? c->pbx->dtimeout * 1000 : 2000;
+
+ if (timeout > 0)
+ fto = to = timeout;
+ if (timeout < 0)
+ fto = to = 1000000000;
+ } else {
+ /* there is more than one prompt, so
+ get rid of the long timeout between
+ prompts, and make it 50ms */
+ fto = 50;
+ to = c->pbx ? c->pbx->dtimeout * 1000 : 2000;
+ }
+ res = ast_readstring(c, s, maxlen, to, fto, "#");
+ if (!ast_strlen_zero(s))
return res;
}
- fto = c->pbx ? c->pbx->rtimeout * 1000 : 6000;
- to = c->pbx ? c->pbx->dtimeout * 1000 : 2000;
-
- if (timeout > 0)
- fto = to = timeout;
- if (timeout < 0)
- fto = to = 1000000000;
- res = ast_readstring(c, s, maxlen, to, fto, "#");
+
return res;
}
More information about the asterisk-commits
mailing list