[Asterisk-code-review] app_directory: Add a 'skip call' option. (asterisk[18])

George Joseph asteriskteam at digium.com
Mon Feb 27 13:41:05 CST 2023


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19798 )

Change subject: app_directory: Add a 'skip call' option.
......................................................................

app_directory: Add a 'skip call' option.

Adds 's' option to skip calling the extension and instead set the
extension as DIRECTORY_EXTEN channel variable.

ASTERISK-30405

Change-Id: Ib9d9db1ba5b7524594c640461b4aa8f752db8299
---
M apps/app_directory.c
A doc/CHANGES-staging/app_directory_skip_call.txt
2 files changed, 33 insertions(+), 1 deletion(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit
  Michael Bradeen: Looks good to me, but someone else must approve




diff --git a/apps/app_directory.c b/apps/app_directory.c
index 847710b..40f7896 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -107,6 +107,10 @@
 						<para>Load the specified config file instead of voicemail.conf</para>
 						<argument name="filename" required="true" />
 					</option>
+					<option name="s">
+						<para>Skip calling the extension, instead set it in the <variable>DIRECTORY_EXTEN</variable>
+						channel variable.</para>
+					</option>
 				</optionlist>
 				<note><para>Only one of the <replaceable>f</replaceable>, <replaceable>l</replaceable>, or <replaceable>b</replaceable>
 				options may be specified. <emphasis>If more than one is specified</emphasis>, then Directory will act as
@@ -123,7 +127,7 @@
 			received and the extension to jump to exists:</para>
 			<para><literal>0</literal> - Jump to the 'o' extension, if it exists.</para>
 			<para><literal>*</literal> - Jump to the 'a' extension, if it exists.</para>
-			<para>This application will set the following channel variable before completion:</para>
+			<para>This application will set the following channel variables before completion:</para>
 			<variablelist>
 				<variable name="DIRECTORY_RESULT">
 					<para>Reason Directory application exited.</para>
@@ -135,6 +139,10 @@
 					<value name="USEREXIT">User exited with '#' during selection</value>
 					<value name="FAILED">The application failed</value>
 				</variable>
+				<variable name="DIRECTORY_EXTEN">
+					<para>If the skip calling option is set this will be set to the selected extension
+					provided one is selected.</para>
+				</variable>
 			</variablelist>
 		</description>
 	</application>
@@ -158,6 +166,7 @@
 	OPT_NOANSWER =        (1 << 6),
 	OPT_ALIAS =           (1 << 7),
 	OPT_CONFIG_FILE =     (1 << 8),
+	OPT_SKIP =            (1 << 9),
 };
 
 enum {
@@ -190,6 +199,7 @@
 	AST_APP_OPTION('n', OPT_NOANSWER),
 	AST_APP_OPTION('a', OPT_ALIAS),
 	AST_APP_OPTION_ARG('c', OPT_CONFIG_FILE, OPT_ARG_FILENAME),
+	AST_APP_OPTION('s', OPT_SKIP),
 });
 
 static int compare(const char *text, const char *template)
@@ -325,6 +335,9 @@
 	if (ast_test_flag(flags, OPT_FROMVOICEMAIL)) {
 		/* We still want to set the exten though */
 		ast_channel_exten_set(chan, item->exten);
+	} else if (ast_test_flag(flags, OPT_SKIP)) {
+		/* Skip calling the extension, only set it in the channel variable. */
+		pbx_builtin_setvar_helper(chan, "DIRECTORY_EXTEN", item->exten);
 	} else if (ast_goto_if_exists(chan, S_OR(dialcontext, item->context), item->exten, 1)) {
 		ast_log(LOG_WARNING,
 			"Can't find extension '%s' in context '%s'.  "
diff --git a/doc/CHANGES-staging/app_directory_skip_call.txt b/doc/CHANGES-staging/app_directory_skip_call.txt
new file mode 100644
index 0000000..83687fe
--- /dev/null
+++ b/doc/CHANGES-staging/app_directory_skip_call.txt
@@ -0,0 +1,5 @@
+Subject: app_directory
+
+A new option 's' has been added to the Directory() application that
+will skip calling the extension and instead set the extension as
+DIRECTORY_EXTEN channel variable.

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19798
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: Ib9d9db1ba5b7524594c640461b4aa8f752db8299
Gerrit-Change-Number: 19798
Gerrit-PatchSet: 6
Gerrit-Owner: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Michael Bradeen <mbradeen at sangoma.com>
Gerrit-Reviewer: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230227/2bf9bfb0/attachment-0001.html>


More information about the asterisk-code-review mailing list