[svn-commits] jrose: trunk r347866 - in /trunk: ./ apps/ include/asterisk/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 9 14:27:12 CST 2011


Author: jrose
Date: Fri Dec  9 14:27:03 2011
New Revision: 347866

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=347866
Log:
Remove autojump extensions from SayUnixTime, make an option to perform automatic jumps.

When a caller sends DTMF while the SayUnixTime application is saying the time, The call
would jump to the next extension much like it does during Background(). This patch adds
option 'j' to SayUnixTime which when used employs the old behavior. Also, this patch
allows arguments to sayunixtime to not be used as empty strings in the case of something
like 'sayunixtime(,,,j)' or 'sayunixtime(,,pattern).

(closes issue ASTERISK-16675)
Reported by: jlpedrosa
Patches:
	patch_SayUnixTime_noJump.patch uploaded by jlpedrosa (license 5959)
Review: https://reviewboard.asterisk.org/r/956/

Modified:
    trunk/CHANGES
    trunk/apps/app_sayunixtime.c
    trunk/include/asterisk/file.h

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=347866&r1=347865&r2=347866
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Fri Dec  9 14:27:03 2011
@@ -44,6 +44,15 @@
 -------------
  * Added queue options autopausebusy and autopauseunavail for automatically
    pausing a queue member when their device reports busy or congestion.
+
+Applications
+------------
+ * Added 'j' option to SayUnixTime. SayUnixTime no longer auto jumps to extension
+   when receiving DTMF.  Use the 'j' option to enable extension jumping. Also
+   changed arguments to SayUnixTime so that every option is truly optional even
+   when using multiple options (so that j option could be used without having to
+   manually specify timezone and format) There are other beneftis eg. format can
+   now be used without specifying time zone as well.
 
 CDR postgresql driver changes
 -----------------------------

Modified: trunk/apps/app_sayunixtime.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_sayunixtime.c?view=diff&rev=347866&r1=347865&r2=347866
==============================================================================
--- trunk/apps/app_sayunixtime.c (original)
+++ trunk/apps/app_sayunixtime.c Fri Dec  9 14:27:03 2011
@@ -46,15 +46,22 @@
 			Says a specified time in a custom format.
 		</synopsis>
 		<syntax>
-			<parameter name="unixtime">
+			<parameter name="unixtime" required="false">
 				<para>time, in seconds since Jan 1, 1970.  May be negative. Defaults to now.</para>
 			</parameter>
-			<parameter name="timezone">
+			<parameter name="timezone" required="false" >
 				<para>timezone, see <directory>/usr/share/zoneinfo</directory> for a list. Defaults to machine default.</para>
 			</parameter>
-			<parameter name="format">
+			<parameter name="format" required="false" >
 				<para>a format the time is to be said in.  See <filename>voicemail.conf</filename>.
 				Defaults to <literal>ABdY "digits/at" IMp</literal></para>
+			</parameter>
+			<parameter name="options" required="false">
+				 <optionlist>
+					<option name="j">
+						<para>Allow the calling user to dial digits to jump to that extension.</para>
+					</option>
+				</optionlist>
 			</parameter>
 		</syntax>
 		<description>
@@ -90,6 +97,20 @@
 
  ***/
 
+enum {
+	OPT_JUMP =          (1 << 0),
+};
+
+enum {
+	OPT_ARG_JUMP = 0,
+	/* note: this entry _MUST_ be the last one in the enum */
+	OPT_ARG_ARRAY_SIZE,
+};
+
+AST_APP_OPTIONS(sayunixtime_exec_options, BEGIN_OPTIONS
+	AST_APP_OPTION_ARG('j', OPT_JUMP, OPT_ARG_JUMP),
+END_OPTIONS );
+
 static char *app_sayunixtime = "SayUnixTime";
 static char *app_datetime = "DateTime";
 
@@ -99,26 +120,42 @@
 		AST_APP_ARG(timeval);
 		AST_APP_ARG(timezone);
 		AST_APP_ARG(format);
+		AST_APP_ARG(options);
 	);
 	char *parse;
 	int res = 0;
 	time_t unixtime;
-	
-	if (!data)
+	/* New default behavior is do not jump on key pressed */
+	const char * haltondigits = AST_DIGIT_NONE;
+	struct ast_flags64 opts = { 0, };
+	char *opt_args[OPT_ARG_ARRAY_SIZE];
+
+	if (!data) {
 		return 0;
+	}
 
 	parse = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, parse);
 
-	ast_get_time_t(args.timeval, &unixtime, time(NULL), NULL);
+	/* check if we had the 'j' jump flag in option list */
+	if (!ast_strlen_zero(args.options))	{
+		ast_app_parse_options64(sayunixtime_exec_options, &opts, opt_args, args.options);
+		if (ast_test_flag64(&opts, OPT_JUMP)){
+			haltondigits = AST_DIGIT_ANY;
+		}
+	}
 
-	if (chan->_state != AST_STATE_UP)
+	ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL);
+
+	if (chan->_state != AST_STATE_UP) {
 		res = ast_answer(chan);
+	}
 
-	if (!res)
-		res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY,
-					       chan->language, args.format, args.timezone);
+	if (!res) {
+		res = ast_say_date_with_format(chan, unixtime, haltondigits,
+					       chan->language, ast_strlen_zero(args.format) ? NULL : args.format, ast_strlen_zero(args.timezone) ? NULL : args.timezone);
+	}
 
 	return res;
 }

Modified: trunk/include/asterisk/file.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/file.h?view=diff&rev=347866&r1=347865&r2=347866
==============================================================================
--- trunk/include/asterisk/file.h (original)
+++ trunk/include/asterisk/file.h Fri Dec  9 14:27:03 2011
@@ -44,6 +44,7 @@
 #define AST_MAX_FORMATS 10
 
 /*! Convenient for waiting */
+#define AST_DIGIT_NONE ""
 #define AST_DIGIT_ANY "0123456789#*ABCD"
 #define AST_DIGIT_ANYNUM "0123456789"
 




More information about the svn-commits mailing list