--- apps/app_directory.c.orig 2005-11-29 13:24:39.000000000 -0500 +++ apps/app_directory.c 2006-03-29 09:39:13.000000000 -0500 @@ -62,6 +62,8 @@ " extension that the user has selected, or when jumping to the\n" " 'o' or 'a' extension.\n\n" " Options:\n" +" e - In addition to the name, also read the extension number to the\n" +" caller before presenting dialing options.\n" " f - Allow the caller to enter the first name of a user in the directory\n" " instead of using the last name.\n"; @@ -151,7 +153,7 @@ * '1' for selected entry from directory * '*' for skipped entry from directory */ -static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dialcontext, char *ext, char *name) { +static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dialcontext, char *ext, char *name, int readext) { int res = 0; int loop = 3; char fn[256]; @@ -171,15 +173,38 @@ res = ast_waitstream(chan, AST_DIGIT_ANY); } ast_stopstream(chan); + /* If Option 'e' was specified, also read the extension number with the name */ + if (readext) { + res = ast_streamfile(chan, "vm-extension", chan->language); + if (!res) { + res = ast_waitstream(chan, AST_DIGIT_ANY); + } + res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, chan->language); + } } else if (ast_fileexists(fn2, NULL, chan->language) > 0) { res = ast_streamfile(chan, fn2, chan->language); if (!res) { res = ast_waitstream(chan, AST_DIGIT_ANY); } ast_stopstream(chan); + /* If Option 'e' was specified, also read the extension number with the name */ + if (readext) { + res = ast_streamfile(chan, "vm-extension", chan->language); + if (!res) { + res = ast_waitstream(chan, AST_DIGIT_ANY); + } + res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, chan->language); + } } else { res = ast_say_character_str(chan, !ast_strlen_zero(name) ? name : ext, AST_DIGIT_ANY, chan->language); + if (!ast_strlen_zero(name) && readext) { + res = ast_streamfile(chan, "vm-extension", chan->language); + if (!res) { + res = ast_waitstream(chan, AST_DIGIT_ANY); + } + res = ast_say_character_str(chan, ext, AST_DIGIT_ANY, chan->language); + } } while (loop) { @@ -288,7 +313,7 @@ return cfg; } -static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit, int last) +static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit, int last, int readext) { /* Read in the first three digits.. "digit" is the first digit, already read */ char ext[NUMDIGITS + 1]; @@ -367,7 +392,7 @@ if (v) { /* We have a match -- play a greeting if they have it */ - res = play_mailbox_owner(chan, context, dialcontext, v->name, name); + res = play_mailbox_owner(chan, context, dialcontext, v->name, name, readext); switch (res) { case -1: /* user pressed '1' but extension does not exist, or @@ -414,6 +439,7 @@ struct localuser *u; struct ast_config *cfg; int last = 1; + int readext = 0; char *context, *dialcontext, *dirintro, *options; if (ast_strlen_zero(data)) { @@ -434,6 +460,8 @@ options++; if (strchr(options, 'f')) last = 0; + if (strchr(options, 'e')) + readext = 1; } } else dialcontext = context; @@ -466,7 +494,7 @@ if (!res) res = ast_waitfordigit(chan, 5000); if (res > 0) { - res = do_directory(chan, cfg, context, dialcontext, res, last); + res = do_directory(chan, cfg, context, dialcontext, res, last, readext); if (res > 0) { res = ast_waitstream(chan, AST_DIGIT_ANY); ast_stopstream(chan);