aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-08-05 22:02:33 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-08-05 22:02:33 +0000
commit78a64af8adb18ccc112dd19c95f6b1f47113b844 (patch)
tree1f31fac0b1c9393e3eeb939b6f4fb1ab168263cb
parent50bda21fc4c4ee0ca143dd1c00c89e4eef684120 (diff)
Allow directory to be searched by first name (bug #2208)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3580 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapps/app_directory.c36
-rwxr-xr-xsounds.txt2
-rwxr-xr-xsounds/dir-intro-fn.gsmbin0 -> 17424 bytes
3 files changed, 27 insertions, 11 deletions
diff --git a/apps/app_directory.c b/apps/app_directory.c
index 1e2fe1869..6d417444e 100755
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -32,13 +32,15 @@ static char *app = "Directory";
static char *synopsis = "Provide directory of voicemail extensions";
static char *descrip =
-" Directory(vm-context[|dial-context]): Presents the user with a directory\n"
+" Directory(vm-context[|dial-context[|options]]): Presents the user with a directory\n"
"of extensions from which they may select by name. The list of names \n"
"and extensions is discovered from voicemail.conf. The vm-context argument\n"
"is required, and specifies the context of voicemail.conf to use. The\n"
"dial-context is the context to use for dialing the users, and defaults to\n"
-"the vm-context if unspecified. Returns 0 unless the user hangs up. It also\n"
-"sets up the channel on exit to enter the extension the user selected.\n";
+"the vm-context if unspecified. The 'f' option causes the directory to match\n"
+"based on the first name in voicemail.conf instead of the last name.\n"
+"Returns 0 unless the user hangs up. It also sets up the channel on exit\n"
+"to enter the extension the user selected.\n";
/* For simplicity, I'm keeping the format compatible with the voicemail config,
but i'm open to suggestions for isolating it */
@@ -208,7 +210,7 @@ static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dia
return(res);
}
-static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit)
+static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit, int last)
{
/* Read in the first three digits.. "digit" is the first digit, already read */
char ext[NUMDIGITS + 1];
@@ -225,7 +227,6 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
"(context in which to interpret extensions)\n");
return -1;
}
-
memset(ext, 0, sizeof(ext));
ext[0] = digit;
res = 0;
@@ -245,7 +246,7 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
if (pos) {
strncpy(name, pos, sizeof(name) - 1);
/* Grab the last name */
- if (strrchr(pos, ' '))
+ if (last && strrchr(pos,' '))
pos = strrchr(pos, ' ') + 1;
conv = convert(pos);
if (conv) {
@@ -312,7 +313,9 @@ static int directory_exec(struct ast_channel *chan, void *data)
int res = 0;
struct localuser *u;
struct ast_config *cfg;
- char *context, *dialcontext, *dirintro;
+ int last = 1;
+ char *context, *dialcontext, *dirintro, *options;
+
if (!data) {
ast_log(LOG_WARNING, "directory requires an argument (context[,dialcontext])\n");
return -1;
@@ -329,13 +332,24 @@ top:
if (dialcontext) {
*dialcontext = '\0';
dialcontext++;
- } else
+ options = strchr(dialcontext, '|');
+ if (options) {
+ *options = '\0';
+ options++;
+ if (strchr(options, 'f'))
+ last = 0;
+ }
+ } else
dialcontext = context;
dirintro = ast_variable_retrieve(cfg, context, "directoryintro");
if (!dirintro || ast_strlen_zero(dirintro))
dirintro = ast_variable_retrieve(cfg, "general", "directoryintro");
- if (!dirintro || ast_strlen_zero(dirintro))
- dirintro = "dir-intro";
+ if (!dirintro || ast_strlen_zero(dirintro)) {
+ if (last)
+ dirintro = "dir-intro";
+ else
+ dirintro = "dir-intro-fn";
+ }
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
if (!res)
@@ -346,7 +360,7 @@ top:
if (!res)
res = ast_waitfordigit(chan, 5000);
if (res > 0) {
- res = do_directory(chan, cfg, context, dialcontext, res);
+ res = do_directory(chan, cfg, context, dialcontext, res, last);
if (res > 0) {
res = ast_waitstream(chan, AST_DIGIT_ANY);
ast_stopstream(chan);
diff --git a/sounds.txt b/sounds.txt
index 92ea6e6c2..0d8e2a4da 100755
--- a/sounds.txt
+++ b/sounds.txt
@@ -64,6 +64,8 @@
%dir-intro.gsm%Welcome to the Asterisk directory. Please enter the first three letters of your parties last name using your touch tone keypad. Use the 7 key for Q and the 9 key for Z.
+%dir-intro-fn.gsm%Welcome to the Asterisk directory. Please enter the first three letters of your parties first name using your touch tone keypad. Use the 7 key for Q and the 9 key for Z.
+
%dir-nomatch.gsm%No directory entries match your search.
%dir-nomore.gsm%There are no more compatible entries in the directory.
diff --git a/sounds/dir-intro-fn.gsm b/sounds/dir-intro-fn.gsm
new file mode 100755
index 000000000..c399ee5ff
--- /dev/null
+++ b/sounds/dir-intro-fn.gsm
Binary files differ