[asterisk-commits] file: branch file/usecnt-cleanup r54710 - in /team/file/usecnt-cleanup: ./ ap...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Feb 15 16:46:02 MST 2007


Author: file
Date: Thu Feb 15 17:46:01 2007
New Revision: 54710

URL: http://svn.digium.com/view/asterisk?view=rev&rev=54710
Log:
Merged revisions 54528,54534,54552,54574-54575,54598-54599,54624,54654,54686 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r54528 | file | 2007-02-14 20:52:10 -0500 (Wed, 14 Feb 2007) | 2 lines

Clean up app_milliwatt code.

................
r54534 | file | 2007-02-14 21:02:30 -0500 (Wed, 14 Feb 2007) | 2 lines

Few more code clean ups.

................
r54552 | file | 2007-02-14 21:11:34 -0500 (Wed, 14 Feb 2007) | 2 lines

Clean up the I/O context handler.

................
r54574 | oej | 2007-02-15 07:10:55 -0500 (Thu, 15 Feb 2007) | 3 lines

Issue #7443 - amdtech - Optionally SIP registrations in another 
realtime family. 

................
r54575 | oej | 2007-02-15 07:12:51 -0500 (Thu, 15 Feb 2007) | 2 lines

Update CHANGES

................
r54598 | oej | 2007-02-15 10:52:35 -0500 (Thu, 15 Feb 2007) | 2 lines

Add callgroup and pickupgroup to SIPPEER function. (thanks ramon)

................
r54599 | oej | 2007-02-15 10:53:26 -0500 (Thu, 15 Feb 2007) | 2 lines

...and don't forget to update CHANGES

................
r54624 | file | 2007-02-15 11:24:13 -0500 (Thu, 15 Feb 2007) | 18 lines

Merged revisions 54623 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r54623 | file | 2007-02-15 11:19:39 -0500 (Thu, 15 Feb 2007) | 10 lines

Merged revisions 54622 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r54622 | file | 2007-02-15 11:14:40 -0500 (Thu, 15 Feb 2007) | 2 lines

Use a separate variable to indicate execution should continue instead of the return value. (issue #8842 reported by pluto70)

........

................

................
r54654 | oej | 2007-02-15 12:13:29 -0500 (Thu, 15 Feb 2007) | 2 lines

Make file's new comment doxygenified

................
r54686 | oej | 2007-02-15 15:29:37 -0500 (Thu, 15 Feb 2007) | 5 lines

- add some notes, asking for help
- insert a few ast_strlen_zero
- Doxygen additions
- A few more spaces

................

Modified:
    team/file/usecnt-cleanup/   (props changed)
    team/file/usecnt-cleanup/CHANGES
    team/file/usecnt-cleanup/apps/app_dial.c
    team/file/usecnt-cleanup/apps/app_exec.c
    team/file/usecnt-cleanup/apps/app_flash.c
    team/file/usecnt-cleanup/apps/app_image.c
    team/file/usecnt-cleanup/apps/app_milliwatt.c
    team/file/usecnt-cleanup/apps/app_voicemail.c
    team/file/usecnt-cleanup/channels/chan_sip.c
    team/file/usecnt-cleanup/configs/extconfig.conf.sample
    team/file/usecnt-cleanup/doc/realtime.txt
    team/file/usecnt-cleanup/main/io.c

Propchange: team/file/usecnt-cleanup/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/file/usecnt-cleanup/
            ('branch-1.2-merged' removed)

Propchange: team/file/usecnt-cleanup/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/file/usecnt-cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Feb 15 17:46:01 2007
@@ -1,1 +1,1 @@
-/trunk:1-54499
+/trunk:1-54709

Modified: team/file/usecnt-cleanup/CHANGES
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/CHANGES?view=diff&rev=54710&r1=54709&r2=54710
==============================================================================
--- team/file/usecnt-cleanup/CHANGES (original)
+++ team/file/usecnt-cleanup/CHANGES Thu Feb 15 17:46:01 2007
@@ -95,3 +95,8 @@
     being removed is now also removed.
   * A new option "busy-level" for setting a level of calls where asterisk reports
     a device as busy, to separate it from call-limit
+  * A new realtime family called "sipregs" is now supported to store SIP registration
+    data. If this family is defined, "sippeers" will be used for configuration and
+    "sipregs" for registrations. If it's not defined, "sippeers" will be used for
+    registration data, as before.
+  * The SIPPEER function have new options for port address, call and pickup groups

Modified: team/file/usecnt-cleanup/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/apps/app_dial.c?view=diff&rev=54710&r1=54709&r2=54710
==============================================================================
--- team/file/usecnt-cleanup/apps/app_dial.c (original)
+++ team/file/usecnt-cleanup/apps/app_dial.c Thu Feb 15 17:46:01 2007
@@ -1167,7 +1167,7 @@
 	return 1;	/* success */
 }
 
-static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags *peerflags)
+static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags *peerflags, int *continue_exec)
 {
 	int res = -1;	/* default: error */
 	char *rest, *cur;	/* scan the list of destinations */
@@ -1264,6 +1264,9 @@
 			goto out;
 		res = -1;	/* reset default */
 	}
+
+	if (continue_exec)
+		*continue_exec = 0;
 
 	/* If a channel group has been specified, get it for use when we create peer channels */
 	outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
@@ -1530,7 +1533,9 @@
 			peer->priority++;
 			ast_pbx_start(peer);
 			hanguptree(outgoing, NULL);
-			res = 1;
+			if (continue_exec)
+				*continue_exec = 1;
+			res = 0;
 			goto done;
 		}
 
@@ -1704,12 +1709,10 @@
 static int dial_exec(struct ast_channel *chan, void *data)
 {
 	struct ast_flags peerflags;
-	int res = 0;
 
 	memset(&peerflags, 0, sizeof(peerflags));
-	res = dial_exec_full(chan, data, &peerflags);
-
-	return (res >= 0 ? 0 : -1);
+
+	return dial_exec_full(chan, data, &peerflags, NULL);
 }
 
 static int retrydial_exec(struct ast_channel *chan, void *data)
@@ -1762,14 +1765,16 @@
 
 	res = 0;
 	while (loops) {
+		int continue_exec;
+
 		chan->data = "Retrying";
 		if (ast_test_flag(chan, AST_FLAG_MOH))
 			ast_moh_stop(chan);
 
-		res = dial_exec_full(chan, dialdata, &peerflags);
-		if (res == 1) {
+		res = dial_exec_full(chan, dialdata, &peerflags, &continue_exec);
+		if (continue_exec)
 			break;
-		} else if (res == 0) {
+		if (res == 0) {
 			if (ast_test_flag(&peerflags, OPT_DTMF_EXIT)) {
 				if (!(res = ast_streamfile(chan, announce, chan->language)))
 					res = ast_waitstream(chan, AST_DIGIT_ANY);
@@ -1807,7 +1812,6 @@
 
 	if (ast_test_flag(chan, AST_FLAG_MOH))
 		ast_moh_stop(chan);
-
  done:
 	return res;
 }

Modified: team/file/usecnt-cleanup/apps/app_exec.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/apps/app_exec.c?view=diff&rev=54710&r1=54709&r2=54710
==============================================================================
--- team/file/usecnt-cleanup/apps/app_exec.c (original)
+++ team/file/usecnt-cleanup/apps/app_exec.c Thu Feb 15 17:46:01 2007
@@ -94,26 +94,27 @@
 	char *s, *appname, *endargs, args[MAXRESULT] = "";
 	struct ast_app *app;
 
-	/* Check and parse arguments */
-	if (data) {
-		s = ast_strdupa(data);
-		appname = strsep(&s, "(");
-		if (s) {
-			endargs = strrchr(s, ')');
-			if (endargs)
-				*endargs = '\0';
-			pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
-		}
-		if (appname) {
-			app = pbx_findapp(appname);
-			if (app) {
-				res = pbx_exec(chan, app, args);
-			} else {
-				ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
-				res = -1;
-			}
+	if (ast_strlen_zero(data))
+		return 0;
+	
+	s = ast_strdupa(data);
+	appname = strsep(&s, "(");
+	if (s) {
+		endargs = strrchr(s, ')');
+		if (endargs)
+			*endargs = '\0';
+		pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+	}
+	if (appname) {
+		app = pbx_findapp(appname);
+		if (app) {
+			res = pbx_exec(chan, app, args);
+		} else {
+			ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
+			res = -1;
 		}
 	}
+
 	return res;
 }
 
@@ -123,27 +124,28 @@
 	char *s, *appname, *endargs, args[MAXRESULT] = "";
 	struct ast_app *app;
 
-	/* Check and parse arguments */
-	if (data) {
-		s = ast_strdupa(data);
-		appname = strsep(&s, "(");
-		if (s) {
-			endargs = strrchr(s, ')');
-			if (endargs)
-				*endargs = '\0';
-			pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
-		}
-		if (appname) {
-			app = pbx_findapp(appname);
-			if (app) {
-				res = pbx_exec(chan, app, args);
-				pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
-			} else {
-				ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
-				pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
-			}
+	if (ast_strlen_zero(data))
+		return 0;
+
+	s = ast_strdupa(data);
+	appname = strsep(&s, "(");
+	if (s) {
+		endargs = strrchr(s, ')');
+		if (endargs)
+			*endargs = '\0';
+		pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+	}
+	if (appname) {
+		app = pbx_findapp(appname);
+		if (app) {
+			res = pbx_exec(chan, app, args);
+			pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
+		} else {
+			ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
+			pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
 		}
 	}
+
 	return 0;
 }
 

Modified: team/file/usecnt-cleanup/apps/app_flash.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/apps/app_flash.c?view=diff&rev=54710&r1=54709&r2=54710
==============================================================================
--- team/file/usecnt-cleanup/apps/app_flash.c (original)
+++ team/file/usecnt-cleanup/apps/app_flash.c Thu Feb 15 17:46:01 2007
@@ -74,29 +74,34 @@
 	int res = -1;
 	int x;
 	struct zt_params ztp;
-	if (!strcasecmp(chan->tech->type, "Zap")) {
-		memset(&ztp, 0, sizeof(ztp));
-		res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
-		if (!res) {
-			if (ztp.sigtype & __ZT_SIG_FXS) {
-				x = ZT_FLASH;
-				res = ioctl(chan->fds[0], ZT_HOOK, &x);
-				if (!res || (errno == EINPROGRESS)) {
-					if (res) {
-						/* Wait for the event to finish */
-						zt_wait_event(chan->fds[0]);
-					}
-					res = ast_safe_sleep(chan, 1000);
-					if (option_verbose > 2)
-						ast_verbose(VERBOSE_PREFIX_3 "Flashed channel %s\n", chan->name);
-				} else
-					ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
+
+	if (strcasecmp(chan->tech->type, "Zap")) {
+		ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
+		return -1;
+	}
+	
+	memset(&ztp, 0, sizeof(ztp));
+	res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
+	if (!res) {
+		if (ztp.sigtype & __ZT_SIG_FXS) {
+			x = ZT_FLASH;
+			res = ioctl(chan->fds[0], ZT_HOOK, &x);
+			if (!res || (errno == EINPROGRESS)) {
+				if (res) {
+					/* Wait for the event to finish */
+					zt_wait_event(chan->fds[0]);
+				}
+				res = ast_safe_sleep(chan, 1000);
+				if (option_verbose > 2)
+					ast_verbose(VERBOSE_PREFIX_3 "Flashed channel %s\n", chan->name);
 			} else
-				ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
+				ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
 		} else
-			ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
+			ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
 	} else
-		ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
+		ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
+
+
 	return res;
 }
 

Modified: team/file/usecnt-cleanup/apps/app_image.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/apps/app_image.c?view=diff&rev=54710&r1=54709&r2=54710
==============================================================================
--- team/file/usecnt-cleanup/apps/app_image.c (original)
+++ team/file/usecnt-cleanup/apps/app_image.c Thu Feb 15 17:46:01 2007
@@ -92,9 +92,7 @@
 		return 0;
 	}
 
-	res = ast_send_image(chan, args.filename);
-	
-	if (!res)
+	if (!(res = ast_send_image(chan, args.filename)))
 		pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
 		
 	return res;

Modified: team/file/usecnt-cleanup/apps/app_milliwatt.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/apps/app_milliwatt.c?view=diff&rev=54710&r1=54709&r2=54710
==============================================================================
--- team/file/usecnt-cleanup/apps/app_milliwatt.c (original)
+++ team/file/usecnt-cleanup/apps/app_milliwatt.c Thu Feb 15 17:46:01 2007
@@ -50,7 +50,6 @@
 static char *descrip = 
 "Milliwatt(): Generate a Constant 1000Hz tone at 0dbm (mu-law)\n";
 
-
 static char digital_milliwatt[] = {0x1e,0x0b,0x0b,0x1e,0x9e,0x8b,0x8b,0x9e} ;
 
 static void *milliwatt_alloc(struct ast_channel *chan, void *params)
@@ -82,7 +81,6 @@
 	* a multiple of samples, given by number of samples times bytes per
 	* sample. In the case of ulaw, len = samples. for signed linear
 	* len = 2 * samples */
-
 	if (samples > maxsamples) {
 		ast_log(LOG_WARNING, "Only doing %d samples (%d requested)\n", maxsamples, samples);
 		samples = maxsamples;
@@ -90,17 +88,18 @@
 	len = samples * sizeof (buf[0]);
 	wf.datalen = len;
 	wf.samples = samples;
+
 	/* create a buffer containing the digital milliwatt pattern */
-	for(i = 0; i < len; i++)
-	{
+	for (i = 0; i < len; i++) {
 		buf[AST_FRIENDLY_OFFSET + i] = digital_milliwatt[(*indexp)++];
 		*indexp &= 7;
 	}
-	if (ast_write(chan,&wf) < 0)
-	{
+
+	if (ast_write(chan,&wf) < 0) {
 		ast_log(LOG_WARNING,"Failed to write frame to '%s': %s\n",chan->name,strerror(errno));
 		return -1;
 	}
+
 	return 0;
 }
 
@@ -109,23 +108,27 @@
 	alloc: milliwatt_alloc,
 	release: milliwatt_release,
 	generate: milliwatt_generate,
-} ;
+};
 
 static int milliwatt_exec(struct ast_channel *chan, void *data)
 {
+
 	ast_set_write_format(chan, AST_FORMAT_ULAW);
 	ast_set_read_format(chan, AST_FORMAT_ULAW);
+
+
 	if (chan->_state != AST_STATE_UP)
-	{
 		ast_answer(chan);
-	}
-	if (ast_activate_generator(chan,&milliwattgen,"milliwatt") < 0)
-	{
+
+	if (ast_activate_generator(chan,&milliwattgen,"milliwatt") < 0) {
 		ast_log(LOG_WARNING,"Failed to activate generator on '%s'\n",chan->name);
 		return -1;
 	}
+
 	while(!ast_safe_sleep(chan, 10000));
+
 	ast_deactivate_generator(chan);
+
 	return -1;
 }
 

Modified: team/file/usecnt-cleanup/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/apps/app_voicemail.c?view=diff&rev=54710&r1=54709&r2=54710
==============================================================================
--- team/file/usecnt-cleanup/apps/app_voicemail.c (original)
+++ team/file/usecnt-cleanup/apps/app_voicemail.c Thu Feb 15 17:46:01 2007
@@ -24,8 +24,16 @@
  * 
  * \par See also
  * \arg \ref Config_vm
+ * \note For information about voicemail IMAP storage, read doc/imapstorage.txt
  * \ingroup applications
- * \note This module requires res_adsi to load.
+ * \note This module requires res_adsi to load. This needs to be optional
+ * during compilation.
+ *
+ *
+ *
+ * \note  This file is now almost impossible to work with, due to all #ifdefs.
+ *        Feels like the database code before realtime. Someone - please come up
+ *        with a plan to clean this up.
  */
 
 /*** MODULEINFO
@@ -64,6 +72,7 @@
 #include <sys/mman.h>
 #include <time.h>
 #include <dirent.h>
+
 #ifdef IMAP_STORAGE
 #include <ctype.h>
 #include <signal.h>
@@ -72,6 +81,7 @@
 #include "imap4r1.h"
 #include "linkage.h"
 #endif
+
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
@@ -90,6 +100,7 @@
 #include "asterisk/utils.h"
 #include "asterisk/stringfields.h"
 #include "asterisk/smdi.h"
+
 #ifdef ODBC_STORAGE
 #include "asterisk/res_odbc.h"
 #endif
@@ -109,10 +120,10 @@
 struct vm_state;
 struct ast_vm_user;
 
-static int init_mailstream (struct vm_state *vms, int box);
-static void write_file (char *filename, char *buffer, unsigned long len);
-/*static void status (MAILSTREAM *stream); */ /* No need for this. */
-static void display_body (BODY *body, char *pfx, long i);
+/* Forward declarations for IMAP */
+static int init_mailstream(struct vm_state *vms, int box);
+static void write_file char *filename, char *buffer, unsigned long len);
+static void display_body(BODY *body, char *pfx, long i);
 static char *get_header_by_tag(char *header, char *tag, char *buf, size_t len);
 static void vm_imap_delete(int msgnum, struct vm_state *vms);
 static char *get_user_by_mailbox(char *mailbox, char *buf, size_t len);
@@ -130,12 +141,16 @@
 static void mm_parsequota (MAILSTREAM *stream, unsigned char *msg, QUOTALIST *pquota);
 static void imap_mailbox_name(char *spec, struct vm_state *vms, int box, int target);
 static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms);
-static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box);
+
+
+
 struct vmstate {
 	struct vm_state *vms;
 	AST_LIST_ENTRY(vmstate) list;
 };
+
 static AST_LIST_HEAD_STATIC(vmstates, vmstate);
+
 #endif
 
 #define SMDI_MWI_WAIT_TIMEOUT 1000 /* 1 second */
@@ -316,13 +331,14 @@
 	int maxmsg;                      /*!< Maximum number of msgs per folder for this mailbox */
 	int maxsecs;                     /*!< Maximum number of seconds per message for this mailbox */
 #ifdef IMAP_STORAGE
-	char imapuser[80];	/* IMAP server login */
-	char imappassword[80];	/* IMAP server password if authpassword not defined */
+	char imapuser[80];               /*!< IMAP server login */
+	char imappassword[80];           /*!< IMAP server password if authpassword not defined */
 #endif
-	double volgain;		/*!< Volume gain for voicemails sent via email */
+	double volgain;		         /*!< Volume gain for voicemails sent via email */
 	AST_LIST_ENTRY(ast_vm_user) list;
 };
 
+/*! Voicemail time zones */
 struct vm_zone {
 	AST_LIST_ENTRY(vm_zone) list;
 	char name[80];
@@ -330,6 +346,7 @@
 	char msg_format[512];
 };
 
+/*! Voicemail mailbox state */
 struct vm_state {
 	char curbox[80];
 	char username[80];
@@ -346,30 +363,18 @@
 	int starting;
 	int repeats;
 #ifdef IMAP_STORAGE
-	int updated; /* decremented on each mail check until 1 -allows delay */
+	int updated;                         /*!< decremented on each mail check until 1 -allows delay */
 	long msgArray[256];
 	MAILSTREAM *mailstream;
 	int vmArrayIndex;
-	char imapuser[80]; /* IMAP server login */
+	char imapuser[80];                   /*!< IMAP server login */
 	int interactive;
 	unsigned int quota_limit;
 	unsigned int quota_usage;
 	struct vm_state *persist_vms;
 #endif
 };
-static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain);
-static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
-static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime,
-			char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir,
-			signed char record_gain, struct vm_state *vms);
-static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain);
-static int vm_play_folder_name(struct ast_channel *chan, char *mbox);
-static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname);
-static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap);
-#if !(defined(ODBC_STORAGE) || defined(IMAP_STORAGE))
-static int __has_voicemail(const char *context, const char *mailbox, const char *folder, int shortcircuit);
-#endif
-static void apply_options(struct ast_vm_user *vmu, const char *options);
+
 
 #ifdef ODBC_STORAGE
 static char odbc_database[80];
@@ -422,77 +427,74 @@
 
 static char *addesc = "Comedian Mail";
 
-static char *synopsis_vm =
-"Leave a Voicemail message";
+static char *synopsis_vm = "Leave a Voicemail message";
 
 static char *descrip_vm =
-"  VoiceMail(mailbox[@context][&mailbox[@context]][...][|options]): This\n"
-"application allows the calling party to leave a message for the specified\n"
-"list of mailboxes. When multiple mailboxes are specified, the greeting will\n"
-"be taken from the first mailbox specified. Dialplan execution will stop if the\n"
-"specified mailbox does not exist.\n"
-"  The Voicemail application will exit if any of the following DTMF digits are\n"
-"received:\n"
-"    0 - Jump to the 'o' extension in the current dialplan context.\n"
-"    * - Jump to the 'a' extension in the current dialplan context.\n"
-"  This application will set the following channel variable upon completion:\n"
-"    VMSTATUS - This indicates the status of the execution of the VoiceMail\n"
-"               application. The possible values are:\n"
-"               SUCCESS | USEREXIT | FAILED\n\n"
-"  Options:\n"
-"    b    - Play the 'busy' greeting to the calling party.\n"
-"    g(#) - Use the specified amount of gain when recording the voicemail\n"
-"           message. The units are whole-number decibels (dB).\n"
-"    s    - Skip the playback of instructions for leaving a message to the\n"
-"           calling party.\n"
-"    u    - Play the 'unavailble greeting.\n"
-"    j    - Jump to priority n+101 if the mailbox is not found or some other\n"
-"           error occurs.\n";
-
-static char *synopsis_vmain =
-"Check Voicemail messages";
+	"  VoiceMail(mailbox[@context][&mailbox[@context]][...][|options]): This\n"
+	"application allows the calling party to leave a message for the specified\n"
+	"list of mailboxes. When multiple mailboxes are specified, the greeting will\n"
+	"be taken from the first mailbox specified. Dialplan execution will stop if the\n"
+	"specified mailbox does not exist.\n"
+	"  The Voicemail application will exit if any of the following DTMF digits are\n"
+	"received:\n"
+	"    0 - Jump to the 'o' extension in the current dialplan context.\n"
+	"    * - Jump to the 'a' extension in the current dialplan context.\n"
+	"  This application will set the following channel variable upon completion:\n"
+	"    VMSTATUS - This indicates the status of the execution of the VoiceMail\n"
+	"               application. The possible values are:\n"
+	"               SUCCESS | USEREXIT | FAILED\n\n"
+	"  Options:\n"
+	"    b    - Play the 'busy' greeting to the calling party.\n"
+	"    g(#) - Use the specified amount of gain when recording the voicemail\n"
+	"           message. The units are whole-number decibels (dB).\n"
+	"    s    - Skip the playback of instructions for leaving a message to the\n"
+	"           calling party.\n"
+	"    u    - Play the 'unavailble greeting.\n"
+	"    j    - Jump to priority n+101 if the mailbox is not found or some other\n"
+	"           error occurs.\n";
+
+static char *synopsis_vmain = "Check Voicemail messages";
 
 static char *descrip_vmain =
-"  VoiceMailMain([mailbox][@context][|options]): This application allows the\n"
-"calling party to check voicemail messages. A specific mailbox, and optional\n"
-"corresponding context, may be specified. If a mailbox is not provided, the\n"
-"calling party will be prompted to enter one. If a context is not specified,\n"
-"the 'default' context will be used.\n\n"
-"  Options:\n"
-"    p    - Consider the mailbox parameter as a prefix to the mailbox that\n"
-"           is entered by the caller.\n"
-"    g(#) - Use the specified amount of gain when recording a voicemail\n"
-"           message. The units are whole-number decibels (dB).\n"
-"    s    - Skip checking the passcode for the mailbox.\n"
-"    a(#) - Skip folder prompt and go directly to folder specified.\n"
-"           Defaults to INBOX\n";
+	"  VoiceMailMain([mailbox][@context][|options]): This application allows the\n"
+	"calling party to check voicemail messages. A specific mailbox, and optional\n"
+	"corresponding context, may be specified. If a mailbox is not provided, the\n"
+	"calling party will be prompted to enter one. If a context is not specified,\n"
+	"the 'default' context will be used.\n\n"
+	"  Options:\n"
+	"    p    - Consider the mailbox parameter as a prefix to the mailbox that\n"
+	"           is entered by the caller.\n"
+	"    g(#) - Use the specified amount of gain when recording a voicemail\n"
+	"           message. The units are whole-number decibels (dB).\n"
+	"    s    - Skip checking the passcode for the mailbox.\n"
+	"    a(#) - Skip folder prompt and go directly to folder specified.\n"
+	"           Defaults to INBOX\n";
 
 static char *synopsis_vm_box_exists =
 "Check to see if Voicemail mailbox exists";
 
 static char *descrip_vm_box_exists =
-"  MailboxExists(mailbox[@context][|options]): Check to see if the specified\n"
-"mailbox exists. If no voicemail context is specified, the 'default' context\n"
-"will be used.\n"
-"  This application will set the following channel variable upon completion:\n"
-"    VMBOXEXISTSSTATUS - This will contain the status of the execution of the\n"
-"                        MailboxExists application. Possible values include:\n"
-"                        SUCCESS | FAILED\n\n"
-"  Options:\n"
-"    j - Jump to priority n+101 if the mailbox is found.\n";
-
-static char *synopsis_vmauthenticate =
-"Authenticate with Voicemail passwords";
+	"  MailboxExists(mailbox[@context][|options]): Check to see if the specified\n"
+	"mailbox exists. If no voicemail context is specified, the 'default' context\n"
+	"will be used.\n"
+	"  This application will set the following channel variable upon completion:\n"
+	"    VMBOXEXISTSSTATUS - This will contain the status of the execution of the\n"
+	"                        MailboxExists application. Possible values include:\n"
+	"                        SUCCESS | FAILED\n\n"
+	"  Options:\n"
+	"    j - Jump to priority n+101 if the mailbox is found.\n";
+
+static char *synopsis_vmauthenticate = "Authenticate with Voicemail passwords";
 
 static char *descrip_vmauthenticate =
-"  VMAuthenticate([mailbox][@context][|options]): This application behaves the\n"
-"same way as the Authenticate application, but the passwords are taken from\n"
-"voicemail.conf.\n"
-"  If the mailbox is specified, only that mailbox's password will be considered\n"
-"valid. If the mailbox is not specified, the channel variable AUTH_MAILBOX will\n"
-"be set with the authenticated mailbox.\n\n"
-"  Options:\n"
-"    s - Skip playing the initial prompts.\n";
+	"  VMAuthenticate([mailbox][@context][|options]): This application behaves the\n"
+	"same way as the Authenticate application, but the passwords are taken from\n"
+	"voicemail.conf.\n"
+	"  If the mailbox is specified, only that mailbox's password will be considered\n"
+	"valid. If the mailbox is not specified, the channel variable AUTH_MAILBOX will\n"
+	"be set with the authenticated mailbox.\n\n"
+	"  Options:\n"
+	"    s - Skip playing the initial prompts.\n";
 
 /* Leave a message */
 static char *app = "VoiceMail";
@@ -551,6 +553,24 @@
 static unsigned char adsisec[4] = "\x9B\xDB\xF7\xAC";
 static int adsiver = 1;
 static char emaildateformat[32] = "%A, %B %d, %Y at %r";
+
+/* Forward declarations - generic */
+static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box);
+static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain);
+static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
+static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime,
+			char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir,
+			signed char record_gain, struct vm_state *vms);
+static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain);
+static int vm_play_folder_name(struct ast_channel *chan, char *mbox);
+static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname);
+static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap);
+static void apply_options(struct ast_vm_user *vmu, const char *options);
+
+#if !(defined(ODBC_STORAGE) || defined(IMAP_STORAGE))
+static int __has_voicemail(const char *context, const char *mailbox, const char *folder, int shortcircuit);
+#endif
+
 
 
 static void populate_defaults(struct ast_vm_user *vmu)
@@ -798,8 +818,7 @@
 	if ((cfg = ast_config_load_with_comments(VOICEMAIL_CONFIG))) {
 		while ((category = ast_category_browse(cfg, category))) {
 			if (!strcasecmp(category, vmu->context)) {
-				tmp = ast_variable_retrieve(cfg, category, vmu->mailbox);
-				if (!tmp) {
+				if (!(tmp = ast_variable_retrieve(cfg, category, vmu->mailbox))) {
 					ast_log(LOG_WARNING, "We could not find the mailbox.\n");
 					break;
 				}
@@ -944,7 +963,8 @@
 	return 1;
 }
 
-/* only return failure if ast_lock_path returns 'timeout',
+/*! \brief Lock file path
+    only return failure if ast_lock_path returns 'timeout',
    not if the path does not exist or any other reason
 */
 static int vm_lock_path(const char *path)
@@ -1615,7 +1635,8 @@
 	copy(frompath2, topath2);
 }
 #endif
-/*
+
+/*! \brief
  * A negative return value indicates an error.
  * \note Should always be called with a lock already set on dir.
  */
@@ -1696,14 +1717,14 @@
 
 static int ochar(struct baseio *bio, int c, FILE *so)
 {
-	if (bio->linelength>=BASELINELEN) {
-		if (fputs(eol,so)==EOF)
+	if (bio->linelength >= BASELINELEN) {
+		if (fputs(eol,so) == EOF)
 			return -1;
 
 		bio->linelength= 0;
 	}
 
-	if (putc(((unsigned char)c),so)==EOF)
+	if (putc(((unsigned char)c),so) == EOF)
 		return -1;
 
 	bio->linelength++;
@@ -1726,24 +1747,24 @@
 		return -1;
 	}
 
-	for (i= 0;i<9;i++) {
+	for (i= 0; i<9; i++) {
 		dtable[i]= 'A'+i;
 		dtable[i+9]= 'J'+i;
 		dtable[26+i]= 'a'+i;
 		dtable[26+i+9]= 'j'+i;
 	}
-	for (i= 0;i<8;i++) {
+	for (i= 0; i<8; i++) {
 		dtable[i+18]= 'S'+i;
 		dtable[26+i+18]= 's'+i;
 	}
-	for (i= 0;i<10;i++) {
+	for (i= 0; i<10; i++) {
 		dtable[52+i]= '0'+i;
 	}
 	dtable[62]= '+';
 	dtable[63]= '/';
 
 	while (!hiteof){
-		unsigned char igroup[3],ogroup[4];
+		unsigned char igroup[3], ogroup[4];
 		int c,n;
 
 		igroup[0]= igroup[1]= igroup[2]= 0;
@@ -1759,8 +1780,8 @@
 
 		if (n> 0) {
 			ogroup[0]= dtable[igroup[0]>>2];
-			ogroup[1]= dtable[((igroup[0]&3)<<4)|(igroup[1]>>4)];
-			ogroup[2]= dtable[((igroup[1]&0xF)<<2)|(igroup[2]>>6)];
+			ogroup[1]= dtable[((igroup[0]&3)<<4) | (igroup[1]>>4)];
+			ogroup[2]= dtable[((igroup[1]&0xF)<<2) | (igroup[2]>>6)];
 			ogroup[3]= dtable[igroup[2]&0x3F];
 
 			if (n<3) {
@@ -1775,7 +1796,7 @@
 		}
 	}
 
-	if (fputs(eol,so)==EOF)
+	if (fputs(eol,so) == EOF)
 		return 0;
 
 	fclose(fi);
@@ -1816,7 +1837,8 @@
 	*ptr = '\0';
 	return to;
 }
-/*
+
+/*! \brief
  * fill in *tm for current time according to the proper timezone, if any.
  * Return tm so it can be used as a function argument.
  */
@@ -1839,7 +1861,7 @@
 	return tm;
 }
 
-/* same as mkstemp, but return a FILE * */
+/*! \brief same as mkstemp, but return a FILE * */
 static FILE *vm_mkftemp(char *template)
 {
 	FILE *p = NULL;
@@ -1870,9 +1892,8 @@
 	gethostname(host, sizeof(host)-1);
 	if (strchr(srcemail, '@'))
 		ast_copy_string(who, srcemail, sizeof(who));
-	else {
+	else 
 		snprintf(who, sizeof(who), "%s@%s", srcemail, host);
-	}
 	snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
 	strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm));
 	fprintf(p, "Date: %s\r\n", date);
@@ -1880,7 +1901,7 @@
 	/* Set date format for voicemail mail */
 	strftime(date, sizeof(date), emaildateformat, &tm);
 
-	if (*fromstring) {
+	if (!ast_strlen_zero(fromstring)) {
 		struct ast_channel *ast;
 		if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
 			char *passdata;
@@ -1902,11 +1923,11 @@
 	len_passdata = strlen(vmu->fullname) * 2 + 3;
 	passdata2 = alloca(len_passdata);
 	fprintf(p, "To: %s <%s>\r\n", quote(vmu->fullname, passdata2, len_passdata), vmu->email);
-	if (emailsubject) {
+	if (!ast_strlen_zero(emailsubject)) {
 		struct ast_channel *ast;
 		if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
 			char *passdata;
-			int vmlen = strlen(emailsubject)*3 + 200;
+			int vmlen = strlen(emailsubject) * 3 + 200;
 			if ((passdata = alloca(vmlen))) {
 				memset(passdata, 0, vmlen);
 				prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
@@ -1917,7 +1938,7 @@
 			ast_channel_free(ast);
 		} else
 			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
-	} else	if (*emailtitle) {
+	} else	if (!ast_strlen_zero(emailtitle)) {
 		fprintf(p, emailtitle, msgnum + 1, mailbox) ;
 		fprintf(p,"\r\n") ;
 	} else if (ast_test_flag((&globalflags), VM_PBXSKIP))
@@ -2019,6 +2040,7 @@
 		unlink(newtmp);
 	}
 }
+
 static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category)
 {
 	FILE *p=NULL;
@@ -2063,73 +2085,77 @@
 	if ((p = vm_mkftemp(tmp)) == NULL) {
 		ast_log(LOG_WARNING, "Unable to launch '%s' (can't create temporary file)\n", mailcmd);
 		return -1;
+	}
+	gethostname(host, sizeof(host)-1);
+	if (strchr(srcemail, '@'))
+		ast_copy_string(who, srcemail, sizeof(who));
+	else 
+		snprintf(who, sizeof(who), "%s@%s", srcemail, host);
+	snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
+	strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm));
+	fprintf(p, "Date: %s\n", date);
+
+	if (*pagerfromstring) {
+		struct ast_channel *ast;
+		if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
+			char *passdata;
+			int vmlen = strlen(fromstring)*3 + 200;
+			if ((passdata = alloca(vmlen))) {
+				memset(passdata, 0, vmlen);
+				prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
+				pbx_substitute_variables_helper(ast, pagerfromstring, passdata, vmlen);
+				fprintf(p, "From: %s <%s>\n", passdata, who);
+			} else 
+				ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
+			ast_channel_free(ast);
+		} else 
+			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
+	} else
+		fprintf(p, "From: Asterisk PBX <%s>\n", who);
+	fprintf(p, "To: %s\n", pager);
+	if (pagersubject) {
+		struct ast_channel *ast;
+		if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
+			char *passdata;
+			int vmlen = strlen(pagersubject) * 3 + 200;
+			if ((passdata = alloca(vmlen))) {
+				memset(passdata, 0, vmlen);
+				prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
+				pbx_substitute_variables_helper(ast, pagersubject, passdata, vmlen);
+				fprintf(p, "Subject: %s\n\n", passdata);
+			} else
+				ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
+			ast_channel_free(ast);
+		} else
+			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
+	} else
+		fprintf(p, "Subject: New VM\n\n");
+
+	strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
+	if (pagerbody) {
+		struct ast_channel *ast;
+		if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
+			char *passdata;
+			int vmlen = strlen(pagerbody)*3 + 200;
+			if ((passdata = alloca(vmlen))) {
+				memset(passdata, 0, vmlen);
+				prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
+				pbx_substitute_variables_helper(ast, pagerbody, passdata, vmlen);
+				fprintf(p, "%s\n", passdata);
+			} else
+				ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
+			ast_channel_free(ast);
+		} else
+			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
 	} else {
-		gethostname(host, sizeof(host)-1);
-		if (strchr(srcemail, '@'))
-			ast_copy_string(who, srcemail, sizeof(who));
-		else {
-			snprintf(who, sizeof(who), "%s@%s", srcemail, host);
-		}
-		snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
-		strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm));
-		fprintf(p, "Date: %s\n", date);
-
-		if (*pagerfromstring) {
-			struct ast_channel *ast;
-			if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
-				char *passdata;
-				int vmlen = strlen(fromstring)*3 + 200;
-				if ((passdata = alloca(vmlen))) {
-					memset(passdata, 0, vmlen);
-					prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
-					pbx_substitute_variables_helper(ast, pagerfromstring, passdata, vmlen);
-					fprintf(p, "From: %s <%s>\n", passdata, who);
-				} else 
-					ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
-				ast_channel_free(ast);
-			} else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
-		} else
-			fprintf(p, "From: Asterisk PBX <%s>\n", who);
-		fprintf(p, "To: %s\n", pager);
-		if (pagersubject) {
-			struct ast_channel *ast;
-			if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
-				char *passdata;
-				int vmlen = strlen(pagersubject) * 3 + 200;
-				if ((passdata = alloca(vmlen))) {
-					memset(passdata, 0, vmlen);
-					prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
-					pbx_substitute_variables_helper(ast, pagersubject, passdata, vmlen);
-					fprintf(p, "Subject: %s\n\n", passdata);
-				} else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
-				ast_channel_free(ast);
-			} else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
-		} else
-			fprintf(p, "Subject: New VM\n\n");
-		strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
-		if (pagerbody) {
-			struct ast_channel *ast;
-			if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, 0))) {
-				char *passdata;
-				int vmlen = strlen(pagerbody)*3 + 200;
-				if ((passdata = alloca(vmlen))) {
-					memset(passdata, 0, vmlen);
-					prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category);
-					pbx_substitute_variables_helper(ast, pagerbody, passdata, vmlen);
-					fprintf(p, "%s\n", passdata);
-				} else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
-			ast_channel_free(ast);
-			} else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
-		} else {
-			fprintf(p, "New %s long msg in box %s\n"
-					"from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date);
-		}
-		fclose(p);
-		snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
-		ast_safe_system(tmp2);
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
-	}
+		fprintf(p, "New %s long msg in box %s\n"
+				"from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date);
+	}
+	fclose(p);
+	snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);

[... 497 lines stripped ...]


More information about the asterisk-commits mailing list