[Asterisk-Users] Re: [Asterisk-Users]: External access to voicemail

Brian Buhrow buhrow at lothlorien.nfbcal.org
Thu Apr 8 21:17:24 MST 2004


	Hello steve.  Here is a patch I wrote for app_voicemail.c which does
exactly as you describe.  When the outgoing message is playing, if the
listener hits the "*" key, they're prompted for a mailbox and password,
whereupon they can check their voicemail as if they were using the internal
phone.  I found no other way of doing this.
	If you patch your app_voicemail.c, I have V1.44 from CVS as of
12/11/2003, with this diff file, and recompile the app_voicemail.so module
and install it in /usr/lib/asterisk/modules and then, from the command line
of Asterisk, do:
unload app_voicemail.so
load app_voicemail.so
you should have the new feature, all without having to stop and restart
asterisk.
Good luck, and let me know if it works for you.
-Brian

--- app_voicemail.c.fcs	Thu Dec 11 12:55:25 2003
+++ app_voicemail.c	Sat Feb 28 16:21:15 2004
@@ -1083,7 +1083,7 @@
 	char prefile[256]="";
 	char fmt[80];
 	char *context;
-	char *ecodes = "#";
+	char *ecodes = "*#";
 	char *stringp;
 	time_t start;
 	time_t end;
@@ -1117,12 +1117,12 @@
 		if (mkdir(dir, 0700) && (errno != EEXIST))
 			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
 		if (ast_exists_extension(chan, strlen(chan->macrocontext) ? chan->macrocontext : chan->context, "o", 1, chan->callerid))
-			ecodes = "#0";
+			ecodes = "*#0";
 		/* Play the beginning intro if desired */
 		if (strlen(prefile)) {
 			if (ast_fileexists(prefile, NULL, NULL) > 0) {
 				if (ast_streamfile(chan, prefile, chan->language) > -1) 
-				    res = ast_waitstream(chan, "#0");
+				    res = ast_waitstream(chan, "*#0");
 			} else {
 				ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
 				res = invent_message(chan, vmu->context, ext, busy, ecodes);
@@ -1138,6 +1138,10 @@
 			silent = 1;
 			res = 0;
 		}
+		if (res == '*') { /*break out to main vm*/
+			free_user(vmu);
+			return(100);
+		}
 		if (!res && !silent) {
 			res = ast_streamfile(chan, INTRO, chan->language);
 			if (!res)
@@ -1156,6 +1160,10 @@
 			free_user(vmu);
 			return 0;
 		}
+		if (res == '*') { /*break out to main vm*/
+			free_user(vmu);
+			return(100);
+		}
 		if (res >= 0) {
 			/* Unless we're *really* silent, try to send the beep */
 			res = ast_streamfile(chan, "beep", chan->language);
@@ -2678,6 +2686,9 @@
 	}
 	res = leave_voicemail(chan, ext, silent, busy, unavail);
 	LOCAL_USER_REMOVE(u);
+	if (res == 100) { /*The user requested vm main*/
+		res = vm_execmain(chan, NULL);
+	}
 	return res;
 }
 



More information about the asterisk-users mailing list