aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-19 05:47:21 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-19 05:47:21 +0000
commit5363b1ca880afeb9b5acf01aa59d41cb3dff669f (patch)
treeee8536c9ff101bc6aeec4f3dbb77025719d74f4f
parent675d834dc930bef980382075d5faefd7adb93198 (diff)
Add option to use directory for forward/compose (bug #2025)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4294 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapps/app_voicemail.c95
-rwxr-xr-xconfigs/voicemail.conf.sample2
-rwxr-xr-xsounds.txt2
-rwxr-xr-xsounds/vm-forward.gsmbin0 -> 7260 bytes
4 files changed, 92 insertions, 7 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 5e6ea023c..4035f4569 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -290,11 +290,11 @@ static char pagerfromstring[100];
static char emailtitle[100];
static char charset[32] = "ISO-8859-1";
+static int directory_forward;
static char adsifdn[4] = "\x00\x00\x00\x0F";
static char adsisec[4] = "\x9B\xDB\xF7\xAC";
static int adsiver = 1;
-
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
@@ -2218,7 +2218,7 @@ static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu,
static int forward_message(struct ast_channel *chan, char *context, char *dir, int curmsg, struct ast_vm_user *sender, char *fmt,int flag)
{
- char username[70];
+ char username[70]="";
char sys[256];
char todir[256];
int todircount=0;
@@ -2234,12 +2234,88 @@ static int forward_message(struct ast_channel *chan, char *context, char *dir, i
char *stringp, *s;
int saved_messages = 0, found = 0;
int valid_extensions = 0;
+
while (!res && !valid_extensions) {
- res = ast_streamfile(chan, "vm-extension", chan->language); /* "extension" */
- if (res)
- break;
- if ((res = ast_readstring(chan, username, sizeof(username) - 1, 2000, 10000, "#") < 0))
- break;
+
+ int use_directory = 0;
+ if( directory_forward ) {
+ int done = 0;
+ int retries = 0;
+ cmd=0;
+ while((cmd >= 0) && !done ){
+ if (cmd)
+ retries = 0;
+ switch (cmd) {
+ case '1':
+ use_directory = 0;
+ done = 1;
+ break;
+ case '2':
+ use_directory = 1;
+ done=1;
+ break;
+ case '*':
+ cmd = 't';
+ done = 1;
+ break;
+ default:
+ /* Press 1 to enter an extension press 2 to use the directory */
+ cmd = ast_play_and_wait(chan,"vm-forward");
+ if (!cmd)
+ cmd = ast_waitfordigit(chan,3000);
+ if (!cmd)
+ retries++;
+ if (retries > 3)
+ {
+ cmd = 't';
+ done = 1;
+ }
+
+ }
+ }
+ if( cmd<0 || cmd=='t' )
+ break;
+ }
+
+ if( use_directory ) {
+ /* use app_directory */
+
+ char old_context[sizeof(chan->context)];
+ char old_exten[sizeof(chan->exten)];
+ int old_priority;
+ struct ast_app* app;
+
+
+ app = pbx_findapp("Directory");
+ if (app) {
+ /* make mackup copies */
+ memcpy(old_context, chan->context, sizeof(chan->context));
+ memcpy(old_exten, chan->exten, sizeof(chan->exten));
+ old_priority = chan->priority;
+
+ /* call the the Directory, changes the channel */
+ res = pbx_exec(chan, app, ((context)?context:chan->context), 1);
+
+ strncpy(username, chan->exten, sizeof(username)-1);
+
+ /* restore the old context, exten, and priority */
+ memcpy(chan->context, old_context, sizeof(chan->context));
+ memcpy(chan->exten, old_exten, sizeof(chan->exten));
+ chan->priority = old_priority;
+
+ } else {
+ ast_log(LOG_WARNING, "Could not find the Directory application, disabling directory_forward\n");
+ directory_forward = 0;
+ }
+ } else {
+ /* Ask for an extension */
+ res = ast_streamfile(chan, "vm-extension", chan->language); /* "extension" */
+ if (res)
+ break;
+ if ((res = ast_readstring(chan, username, sizeof(username) - 1, 2000, 10000, "#") < 0))
+ break;
+ }
+
/* start all over if no username */
if (ast_strlen_zero(username))
continue;
@@ -4150,6 +4226,7 @@ static int load_config(void)
char *astsaydurationinfo;
char *astsaydurationminfo;
char *silencestr;
+ char *astdirfwd;
char *thresholdstr;
char *fmt;
char *astemail;
@@ -4382,6 +4459,10 @@ static int load_config(void)
exitcontext[0] = '\0';
}
+ directory_forward = 0;
+ if (!(astdirfwd = ast_variable_retrieve(cfg, "general", "usedirectory")))
+ astdirfwd = "no";
+ directory_forward = ast_true(astdirfwd);
cat = ast_category_browse(cfg, NULL);
while (cat) {
diff --git a/configs/voicemail.conf.sample b/configs/voicemail.conf.sample
index 2713a79ed..8503a8817 100755
--- a/configs/voicemail.conf.sample
+++ b/configs/voicemail.conf.sample
@@ -46,6 +46,8 @@ maxlogins=3
;pbxskip=yes
; Change the From: string
;fromstring=The Asterisk PBX
+; Permit finding entries for forward/compose from the directory
+;usedirectory=yes
;
;Change the From: string for pager messages
;pagerfromstring=The Asterisk PBX
diff --git a/sounds.txt b/sounds.txt
index b6fcb7781..ff4adba4c 100755
--- a/sounds.txt
+++ b/sounds.txt
@@ -98,6 +98,8 @@
%transfer.gsm%Please hold while I try that extension.
+%vm-forward.gsm%Press 1 to enter an extension, press 2 to use the directory
+
%vm-Cust1.gsm%folder 5
%vm-Cust2.gsm%folder 6
diff --git a/sounds/vm-forward.gsm b/sounds/vm-forward.gsm
new file mode 100755
index 000000000..af5367eb6
--- /dev/null
+++ b/sounds/vm-forward.gsm
Binary files differ