mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Allow directory to be searched by first name (bug #2208)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -32,13 +32,15 @@ static char *app = "Directory";
|
|||||||
|
|
||||||
static char *synopsis = "Provide directory of voicemail extensions";
|
static char *synopsis = "Provide directory of voicemail extensions";
|
||||||
static char *descrip =
|
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"
|
"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"
|
"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"
|
"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"
|
"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"
|
"the vm-context if unspecified. The 'f' option causes the directory to match\n"
|
||||||
"sets up the channel on exit to enter the extension the user selected.\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,
|
/* For simplicity, I'm keeping the format compatible with the voicemail config,
|
||||||
but i'm open to suggestions for isolating it */
|
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);
|
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 */
|
/* Read in the first three digits.. "digit" is the first digit, already read */
|
||||||
char ext[NUMDIGITS + 1];
|
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");
|
"(context in which to interpret extensions)\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(ext, 0, sizeof(ext));
|
memset(ext, 0, sizeof(ext));
|
||||||
ext[0] = digit;
|
ext[0] = digit;
|
||||||
res = 0;
|
res = 0;
|
||||||
@@ -245,7 +246,7 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
|
|||||||
if (pos) {
|
if (pos) {
|
||||||
strncpy(name, pos, sizeof(name) - 1);
|
strncpy(name, pos, sizeof(name) - 1);
|
||||||
/* Grab the last name */
|
/* Grab the last name */
|
||||||
if (strrchr(pos, ' '))
|
if (last && strrchr(pos,' '))
|
||||||
pos = strrchr(pos, ' ') + 1;
|
pos = strrchr(pos, ' ') + 1;
|
||||||
conv = convert(pos);
|
conv = convert(pos);
|
||||||
if (conv) {
|
if (conv) {
|
||||||
@@ -312,7 +313,9 @@ static int directory_exec(struct ast_channel *chan, void *data)
|
|||||||
int res = 0;
|
int res = 0;
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
char *context, *dialcontext, *dirintro;
|
int last = 1;
|
||||||
|
char *context, *dialcontext, *dirintro, *options;
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
ast_log(LOG_WARNING, "directory requires an argument (context[,dialcontext])\n");
|
ast_log(LOG_WARNING, "directory requires an argument (context[,dialcontext])\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -329,13 +332,24 @@ top:
|
|||||||
if (dialcontext) {
|
if (dialcontext) {
|
||||||
*dialcontext = '\0';
|
*dialcontext = '\0';
|
||||||
dialcontext++;
|
dialcontext++;
|
||||||
} else
|
options = strchr(dialcontext, '|');
|
||||||
|
if (options) {
|
||||||
|
*options = '\0';
|
||||||
|
options++;
|
||||||
|
if (strchr(options, 'f'))
|
||||||
|
last = 0;
|
||||||
|
}
|
||||||
|
} else
|
||||||
dialcontext = context;
|
dialcontext = context;
|
||||||
dirintro = ast_variable_retrieve(cfg, context, "directoryintro");
|
dirintro = ast_variable_retrieve(cfg, context, "directoryintro");
|
||||||
if (!dirintro || ast_strlen_zero(dirintro))
|
if (!dirintro || ast_strlen_zero(dirintro))
|
||||||
dirintro = ast_variable_retrieve(cfg, "general", "directoryintro");
|
dirintro = ast_variable_retrieve(cfg, "general", "directoryintro");
|
||||||
if (!dirintro || ast_strlen_zero(dirintro))
|
if (!dirintro || ast_strlen_zero(dirintro)) {
|
||||||
dirintro = "dir-intro";
|
if (last)
|
||||||
|
dirintro = "dir-intro";
|
||||||
|
else
|
||||||
|
dirintro = "dir-intro-fn";
|
||||||
|
}
|
||||||
if (chan->_state != AST_STATE_UP)
|
if (chan->_state != AST_STATE_UP)
|
||||||
res = ast_answer(chan);
|
res = ast_answer(chan);
|
||||||
if (!res)
|
if (!res)
|
||||||
@@ -346,7 +360,7 @@ top:
|
|||||||
if (!res)
|
if (!res)
|
||||||
res = ast_waitfordigit(chan, 5000);
|
res = ast_waitfordigit(chan, 5000);
|
||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
res = do_directory(chan, cfg, context, dialcontext, res);
|
res = do_directory(chan, cfg, context, dialcontext, res, last);
|
||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
res = ast_waitstream(chan, AST_DIGIT_ANY);
|
res = ast_waitstream(chan, AST_DIGIT_ANY);
|
||||||
ast_stopstream(chan);
|
ast_stopstream(chan);
|
||||||
|
@@ -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.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-nomatch.gsm%No directory entries match your search.
|
||||||
|
|
||||||
%dir-nomore.gsm%There are no more compatible entries in the directory.
|
%dir-nomore.gsm%There are no more compatible entries in the directory.
|
||||||
|
BIN
sounds/dir-intro-fn.gsm
Executable file
BIN
sounds/dir-intro-fn.gsm
Executable file
Binary file not shown.
Reference in New Issue
Block a user