[asterisk-commits] kmoore: branch kmoore/say_alpha_tweaks r397203 - in /team/kmoore/say_alpha_tw...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 20 20:58:03 CDT 2013


Author: kmoore
Date: Tue Aug 20 20:58:01 2013
New Revision: 397203

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397203
Log:
Commit initial patch and review modifications

Modified:
    team/kmoore/say_alpha_tweaks/apps/app_chanspy.c
    team/kmoore/say_alpha_tweaks/apps/app_directory.c
    team/kmoore/say_alpha_tweaks/apps/app_voicemail.c
    team/kmoore/say_alpha_tweaks/include/asterisk/say.h
    team/kmoore/say_alpha_tweaks/main/channel.c
    team/kmoore/say_alpha_tweaks/main/pbx.c
    team/kmoore/say_alpha_tweaks/main/say.c
    team/kmoore/say_alpha_tweaks/res/res_agi.c

Modified: team/kmoore/say_alpha_tweaks/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/apps/app_chanspy.c?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/apps/app_chanspy.c (original)
+++ team/kmoore/say_alpha_tweaks/apps/app_chanspy.c Tue Aug 20 20:58:01 2013
@@ -1048,7 +1048,7 @@
 								break;
 							}
 						} else {
-							res = ast_say_character_str(chan, peer_name, "", ast_channel_language(chan));
+							res = ast_say_character_str(chan, peer_name, "", ast_channel_language(chan), 0);
 						}
 					}
 					if (ptr && (num = atoi(ptr))) {

Modified: team/kmoore/say_alpha_tweaks/apps/app_directory.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/apps/app_directory.c?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/apps/app_directory.c (original)
+++ team/kmoore/say_alpha_tweaks/apps/app_directory.c Tue Aug 20 20:58:01 2013
@@ -281,13 +281,13 @@
 		/* If Option 'e' was specified, also read the extension number with the name */
 		if (ast_test_flag(flags, OPT_SAYEXTENSION)) {
 			ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
-			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan));
+			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), 0);
 		}
 	} else {
-		res = ast_say_character_str(chan, S_OR(name, ext), AST_DIGIT_ANY, ast_channel_language(chan));
+		res = ast_say_character_str(chan, S_OR(name, ext), AST_DIGIT_ANY, ast_channel_language(chan), 0);
 		if (!ast_strlen_zero(name) && ast_test_flag(flags, OPT_SAYEXTENSION)) {
 			ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
-			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan));
+			res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, ast_channel_language(chan), 0);
 		}
 	}
 

Modified: team/kmoore/say_alpha_tweaks/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/apps/app_voicemail.c?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/apps/app_voicemail.c (original)
+++ team/kmoore/say_alpha_tweaks/apps/app_voicemail.c Tue Aug 20 20:58:01 2013
@@ -13683,7 +13683,7 @@
 		ast_debug(3, "Greeting not found for '%s@%s', falling back to mailbox number.\n", args_copy, context);
 		res = ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
 		if (!res) {
-			res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan));
+			res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan), 0);
 		}
 	}
 

Modified: team/kmoore/say_alpha_tweaks/include/asterisk/say.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/include/asterisk/say.h?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/include/asterisk/say.h (original)
+++ team/kmoore/say_alpha_tweaks/include/asterisk/say.h Tue Aug 20 20:58:01 2013
@@ -152,9 +152,9 @@
  * function to pronounce character and phonetic strings
  */
 int ast_say_character_str(struct ast_channel *chan, const char *num,
-	const char *ints, const char *lang);
+	const char *ints, const char *lang, int casesensitive);
 
-SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
+SAY_EXTERN int (* ast_say_character_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int casesensitive, int audiofd, int ctrlfd) SAY_INIT(ast_say_character_str_full);
 
 int ast_say_phonetic_str(struct ast_channel *chan, const char *num,
 	const char *ints, const char *lang);

Modified: team/kmoore/say_alpha_tweaks/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/main/channel.c?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/main/channel.c (original)
+++ team/kmoore/say_alpha_tweaks/main/channel.c Tue Aug 20 20:58:01 2013
@@ -7792,9 +7792,9 @@
 }
 
 int ast_say_character_str(struct ast_channel *chan, const char *str,
-	const char *ints, const char *lang)
-{
-	return ast_say_character_str_full(chan, str, ints, lang, -1, -1);
+	const char *ints, const char *lang, int casesensitive)
+{
+	return ast_say_character_str_full(chan, str, ints, lang, casesensitive, -1, -1);
 }
 
 int ast_say_phonetic_str(struct ast_channel *chan, const char *str,

Modified: team/kmoore/say_alpha_tweaks/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/main/pbx.c?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/main/pbx.c (original)
+++ team/kmoore/say_alpha_tweaks/main/pbx.c Tue Aug 20 20:58:01 2013
@@ -489,10 +489,24 @@
 		</synopsis>
 		<syntax>
 			<parameter name="string" required="true" />
+			<parameter name="casetype">
+				<optionlist>
+					<option name="i">
+						<para>Case insensitive pronunciation.
+						(Ex: SayAlpha(aBc,i) - a b c).</para>
+					</option>
+					<option name="s">
+						<para>Case sensitive pronunciation.
+						(Ex: SayAlpha(aBc,s); - a uppercase b c).</para>
+					</option>
+				</optionlist>
+			</parameter>
 		</syntax>
 		<description>
 			<para>This application will play the sounds that correspond to the letters of the
-			given <replaceable>string</replaceable>.</para>
+			given <replaceable>string</replaceable>.  Optionally, a <replaceable>casetype</replaceable> may be
+			specified.  This will be used for case-insensitive or case-sensitive pronunciations.
+			No option given will default to normal operation of case insensitive.</para>
 		</description>
 		<see-also>
 			<ref type="application">SayDigits</ref>
@@ -779,6 +793,14 @@
 	AST_APP_OPTION('p', BACKGROUND_PLAYBACK),
 });
 
+#define SAYALPHA_CASE_INSENSITIVE		(1 << 0)
+#define SAYALPHA_CASE_SENSITIVE			(1 << 1)
+
+AST_APP_OPTIONS(sayalpha_opts, {
+	AST_APP_OPTION('i', SAYALPHA_CASE_INSENSITIVE),
+	AST_APP_OPTION('s', SAYALPHA_CASE_SENSITIVE),
+});
+
 #define WAITEXTEN_MOH		(1 << 0)
 #define WAITEXTEN_DIALTONE	(1 << 1)
 
@@ -11263,9 +11285,33 @@
 static int pbx_builtin_saycharacters(struct ast_channel *chan, const char *data)
 {
 	int res = 0;
-
-	if (data)
-		res = ast_say_character_str(chan, data, "", ast_channel_language(chan));
+	int casesensitive = 0;
+	char *parse;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(characters);
+		AST_APP_ARG(options);
+	);
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_WARNING, "SayAlpha requires an argument (characters)\n");
+		return 0;
+	}
+
+	parse = ast_strdupa(data);
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (args.options) {
+		if (strcasecmp(args.options, "i") && strcasecmp(args.options, "s")) {
+			ast_log(LOG_WARNING, "SayAlpha case sensitive option is either 'i' or 's'\n");
+			return 0;
+		}
+		if (!strcasecmp(args.options, "s")) {
+			casesensitive = 1;
+		}
+	}
+
+	res = ast_say_character_str(chan, args.characters, "", ast_channel_language(chan), casesensitive);
+
 	return res;
 }
 

Modified: team/kmoore/say_alpha_tweaks/main/say.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/main/say.c?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/main/say.c (original)
+++ team/kmoore/say_alpha_tweaks/main/say.c Tue Aug 20 20:58:01 2013
@@ -61,13 +61,14 @@
 static int wait_file(struct ast_channel *chan, const char *ints, const char *file, const char *lang);
 
 
-static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int audiofd, int ctrlfd)
+static int say_character_str_full(struct ast_channel *chan, const char *str, const char *ints, const char *lang, int casesensitive, int audiofd, int ctrlfd)
 {
 	const char *fn;
 	char fnbuf[10], asciibuf[20] = "letters/ascii";
 	char ltr;
 	int num = 0;
 	int res = 0;
+	int upper = 0;
 
 	while (str[num] && !res) {
 		fn = NULL;
@@ -121,9 +122,18 @@
 			break;
 		default:
 			ltr = str[num];
-			if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A';		/* file names are all lower-case */
-			strcpy(fnbuf, "letters/X");
-			fnbuf[8] = ltr;
+			if ('A' <= ltr && ltr <= 'Z') {
+				ltr += 'a' - 'A';		/* file names are all lower-case */
+				if (casesensitive) {
+					upper = !upper;
+				}
+			}
+			if (upper) {
+				strcpy(fnbuf, "uppercase");
+			} else {
+				strcpy(fnbuf, "letters/X");
+				fnbuf[8] = ltr;
+			}
 			fn = fnbuf;
 		}
 		if ((fn && ast_fileexists(fn, NULL, lang) > 0) ||
@@ -136,6 +146,9 @@
 					res = ast_waitstream(chan, ints);
 			}
 			ast_stopstream(chan);
+		}
+		if (upper) {
+			continue;
 		}
 		num++;
 	}

Modified: team/kmoore/say_alpha_tweaks/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/say_alpha_tweaks/res/res_agi.c?view=diff&rev=397203&r1=397202&r2=397203
==============================================================================
--- team/kmoore/say_alpha_tweaks/res/res_agi.c (original)
+++ team/kmoore/say_alpha_tweaks/res/res_agi.c Tue Aug 20 20:58:01 2013
@@ -2313,11 +2313,19 @@
 static int handle_sayalpha(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
 {
 	int res;
-
-	if (argc != 4)
-		return RESULT_SHOWUSAGE;
-
-	res = ast_say_character_str_full(chan, argv[2], argv[3], ast_channel_language(chan), agi->audio, agi->ctrl);
+	int casesensitive = 0;
+
+	if (argc < 4 || argc > 5) {
+		return RESULT_SHOWUSAGE;
+	}
+
+	if (argc > 4) {
+		if (strcasecmp(argv[4], "i") && strcasecmp(argv[4], "s")) {
+			return RESULT_SHOWUSAGE;
+		}
+		casesensitive = (!strcasecmp(argv[4], "s") ? 1 : 0);
+	}
+	res = ast_say_character_str_full(chan, argv[2], argv[3], ast_channel_language(chan), casesensitive, agi->audio, agi->ctrl);
 	if (res == 1) /* New command */
 		return RESULT_SUCCESS;
 	ast_agi_send(agi->fd, chan, "200 result=%d\n", res);




More information about the asterisk-commits mailing list