[asterisk-dev] [asterisk-users] Calling Directory app from AGI
Mike Diehl
mdiehl at diehlnet.com
Tue Feb 15 11:34:54 CST 2011
"Bob Beers" <bob.beers at gmail.com> wrote:
> On Tue, Feb 15, 2011 at 3:08 AM, Mike Diehl <mdiehl at diehlnet.com> wrote:
>> Comments?
>>
>> # diff app_directory.c app_directory.c.orig
>
> Hi Mike,
>
> Could you repost your diff? Using
>
> # diff -pub app_directory.c.orig app_directory.c
>
> will make it much easier to comprehend.
Thank you for taking a moment to look at my code. This is the first
contribution I've made to the Asterisk project, so I'm still trying to
figure out how things get done.
Here's the patch:
# diff -pub app_directory.c.orig app_directory.c
--- app_directory.c.orig 2011-02-14 22:46:02.000000000 -0700
+++ app_directory.c 2011-02-15 00:50:29.000000000 -0700
@@ -95,6 +95,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revisi
receiver to their ear while
entering DTMF.</para>
<argument name="n"
required="true" />
</option>
+ <option name="s">
+ Do not connect call.
Instead set ${DIR_EXTEN} to the selected extension.</para>
+ </option>
</optionlist>
<note>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
@@ -129,6 +132,7 @@ enum {
OPT_LISTBYLASTNAME = (1 << 4),
OPT_LISTBYEITHER = OPT_LISTBYFIRSTNAME | OPT_LISTBYLASTNAME,
OPT_PAUSE = (1 << 5),
+ OPT_SET = (1 << 6),
} directory_option_flags;
enum {
@@ -136,8 +140,9 @@ enum {
OPT_ARG_LASTNAME = 1,
OPT_ARG_EITHER = 2,
OPT_ARG_PAUSE = 3,
+ OPT_ARG_SET = 4,
/* This *must* be the last value in this enum! */
- OPT_ARG_ARRAY_SIZE = 4,
+ OPT_ARG_ARRAY_SIZE = 5,
};
struct directory_item {
@@ -154,6 +159,7 @@ AST_APP_OPTIONS(directory_app_options, {
AST_APP_OPTION_ARG('l', OPT_LISTBYLASTNAME, OPT_ARG_LASTNAME),
AST_APP_OPTION_ARG('b', OPT_LISTBYEITHER, OPT_ARG_EITHER),
AST_APP_OPTION_ARG('p', OPT_PAUSE, OPT_ARG_PAUSE),
+ AST_APP_OPTION_ARG('s', OPT_SET, OPT_ARG_SET),
AST_APP_OPTION('e', OPT_SAYEXTENSION),
AST_APP_OPTION('v', OPT_FROMVOICEMAIL),
AST_APP_OPTION('m', OPT_SELECTFROMMENU),
@@ -707,7 +713,6 @@ static int do_directory(struct ast_chann
goto exit;
}
-
/* Create plain array of pointers to items (for sorting) */
sorted = ast_calloc(count, sizeof(*sorted));
@@ -726,6 +731,14 @@ static int do_directory(struct ast_chann
}
}
+ if (count == 1) {
+ pbx_builtin_setvar_helper(chan, "DIR_EXTEN",
sorted[0]->exten);
+ ast_log(LOG_WARNING, "User entered %s, which matched %s
(%s).\n",
+ ext, sorted[0]->exten, sorted[0]->name);
+
+ return 1;
+ }
+
if (ast_test_flag(flags, OPT_SELECTFROMMENU)) {
/* Offer multiple entries at the same time */
res = select_item_menu(chan, sorted, count, dialcontext,
flags, opts);
--
Take care and have fun,
Mike Diehl.
More information about the asterisk-dev
mailing list