[asterisk-commits] rmudgett: trunk r404350 - in /trunk: ./ apps/ channels/ channels/h323/ channe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 19 10:52:49 CST 2013


Author: rmudgett
Date: Thu Dec 19 10:52:43 2013
New Revision: 404350

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404350
Log:
Voicemail: Remove mailbox identifier format (box at context) assumptions in the system.

This change is in preparation for external MWI support.

Removed code from the system for normal mailbox handling that appends
@default to the mailbox identifier if it does not have a context.  The
only exception is the legacy hasvoicemail users.conf option.  The legacy
option will only work for app_voicemail mailboxes.  The system cannot make
any assumptions about the format of the mailbox identifer used by
app_voicemail.

chan_sip and chan_dahdi/sig_pri had the most changes because they both
tried to interpret the mailbox identifier.  chan_sip just stored and
compared the two components.  chan_dahdi actually used the box
information.

The ISDN MWI support configuration options had to be reworked because
chan_dahdi was parsing the box at context format to get the box number.  As a
result the mwi_vm_boxes chan_dahdi.conf option was added and is documented
in the chan_dahdi.conf.sample file.

Review: https://reviewboard.asterisk.org/r/3072/
........

Merged revisions 404348 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/CHANGES
    trunk/UPGRADE-12.txt
    trunk/apps/app_voicemail.c
    trunk/channels/chan_dahdi.c
    trunk/channels/chan_dahdi.h
    trunk/channels/chan_h323.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_mgcp.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_skinny.c
    trunk/channels/chan_unistim.c
    trunk/channels/h323/chan_h323.h
    trunk/channels/sig_pri.c
    trunk/channels/sig_pri.h
    trunk/channels/sip/include/sip.h
    trunk/configs/chan_dahdi.conf.sample
    trunk/configs/iax.conf.sample
    trunk/configs/sip.conf.sample
    trunk/configs/skinny.conf.sample
    trunk/configs/voicemail.conf.sample
    trunk/funcs/func_vmcount.c
    trunk/include/asterisk/app.h
    trunk/main/app.c
    trunk/res/res_jabber.c
    trunk/res/res_xmpp.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Thu Dec 19 10:52:43 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404006,404027,404029,404042,404046,404048,404050,404099,404137,404184,404204,404237,404261,404263,404279,404292,404294,404306,404320,404332,404345
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404006,404027,404029,404042,404046,404048,404050,404099,404137,404184,404204,404237,404261,404263,404279,404292,404294,404306,404320,404332,404345,404348

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Dec 19 10:52:43 2013
@@ -403,6 +403,12 @@
 
 VoiceMail
 ------------------
+ * Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
+
  * The voicemail.conf configuration file now has an 'alias' configuration
    parameter for use with the Directory application. The voicemail realtime
    database table schema has also been updated with an 'alias' column.
@@ -886,6 +892,8 @@
  * Added the CLI command 'dahdi create channels'. A range of channels can be
    specified to be created, or the keyword 'new' can be used to add channels
    not yet created.
+
+ * Added mwi_vm_boxes that also must be configured for ISDN MWI to be enabled.
 
 chan_iax2
 ------------------
@@ -1032,6 +1040,14 @@
 ------------------
  * The SPEECH_ENGINE function now supports read operations. When read from, it
    will return the current value of the requested attribute.
+
+VMCOUNT:
+------------------
+ * Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
 
 
 Resources

Modified: trunk/UPGRADE-12.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE-12.txt?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/UPGRADE-12.txt (original)
+++ trunk/UPGRADE-12.txt Thu Dec 19 10:52:43 2013
@@ -181,6 +181,12 @@
  - This application is deprecated in favor of CHANNEL(amaflags).
 
 VoiceMail:
+ - Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
+
  - The voicemail.conf configuration file now has an 'alias' configuration
    parameter for use with the Directory application. The voicemail realtime
    database table schema has also been updated with an 'alias' column. Systems
@@ -207,6 +213,12 @@
  - The CLI command 'dahdi destroy channel' is now 'dahdi destroy channels'.
    A range of channels can be specified to be destroyed. Note that this command
    should only be used if you understand the risks it entails.
+
+ - The script specified by the chan_dahdi.conf mwimonitornotify option now gets
+   the exact configured mailbox name.  For app_voicemail mailboxes this is
+   mailbox at context.
+
+ - Added mwi_vm_boxes that also must be configured for ISDN MWI to be enabled.
 
 chan_local:
  - The /b option has been removed.
@@ -442,6 +454,13 @@
  - The 's' option has been removed, as LOCKED semantics no longer exist in the
    CDR engine.
 
+VMCOUNT:
+ - Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+   system as mailbox at context.  The rest of the system cannot add @default
+   to mailbox identifiers for app_voicemail that do not specify a context
+   any longer.  It is a mailbox identifier format that should only be
+   interpreted by app_voicemail.
+
 res_rtp_asterisk:
  - ICE/STUN/TURN support in res_rtp_asterisk has been made optional. To enable
    them, an Asterisk-specific version of PJSIP needs to be installed.

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Dec 19 10:52:43 2013
@@ -1111,6 +1111,34 @@
 static int vm_test_create_user(const char *context, const char *mailbox);
 #endif
 
+/*!
+ * \internal
+ * \brief Parse the given mailbox_id into mailbox and context.
+ * \since 12.0.0
+ *
+ * \param mailbox_id The mailbox at context string to separate.
+ * \param mailbox Where the mailbox part will start.
+ * \param context Where the context part will start.  ("default" if not present)
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int separate_mailbox(char *mailbox_id, char **mailbox, char **context)
+{
+	if (ast_strlen_zero(mailbox_id) || !mailbox || !context) {
+		return -1;
+	}
+	*context = mailbox_id;
+	*mailbox = strsep(context, "@");
+	if (ast_strlen_zero(*mailbox)) {
+		return -1;
+	}
+	if (ast_strlen_zero(*context)) {
+		*context = "default";
+	}
+	return 0;
+}
+
 struct ao2_container *inprocess_container;
 
 struct inprocess {
@@ -2502,15 +2530,22 @@
 
 /*!
  * \brief Gets the number of messages that exist in a mailbox folder.
- * \param context
- * \param mailbox
+ * \param mailbox_id
  * \param folder
  * 
  * This method is used when IMAP backend is used.
  * \return The number of messages in this mailbox folder (zero or more).
  */
-static int messagecount(const char *context, const char *mailbox, const char *folder)
-{
+static int messagecount(const char *mailbox_id, const char *folder)
+{
+	char *context;
+	char *mailbox;
+
+	if (ast_strlen_zero(mailbox_id)
+		|| separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
+		return 0;
+	}
+
 	if (ast_strlen_zero(folder) || !strcmp(folder, "INBOX")) {
 		return __messagecount(context, mailbox, "INBOX") + __messagecount(context, mailbox, "Urgent");
 	} else {
@@ -2533,8 +2568,11 @@
 	STRING str;
 	int ret; /* for better error checking */
 	char *imap_flags = NIL;
-	int msgcount = (messagecount(vmu->context, vmu->mailbox, "INBOX") + messagecount(vmu->context, vmu->mailbox, "Old"));
+	int msgcount;
 	int box = NEW_FOLDER;
+
+	snprintf(mailbox, sizeof(mailbox), "%s@%s", vmu->mailbox, vmu->context);
+	msgcount = messagecount(mailbox, "INBOX") + messagecount(mailbox, "Old");
 
 	/* Back out early if this is a greeting and we don't want to store greetings in IMAP */
 	if (msgnum < 0) {
@@ -5612,16 +5650,17 @@
 
 /*!
  * \brief Gets the number of messages that exist in a mailbox folder.
- * \param context
- * \param mailbox
+ * \param mailbox_id
  * \param folder
  * 
  * This method is used when ODBC backend is used.
  * \return The number of messages in this mailbox folder (zero or more).
  */
-static int messagecount(const char *context, const char *mailbox, const char *folder)
+static int messagecount(const char *mailbox_id, const char *folder)
 {
 	struct odbc_obj *obj = NULL;
+	char *context;
+	char *mailbox;
 	int nummsgs = 0;
 	int res;
 	SQLHSTMT stmt = NULL;
@@ -5630,7 +5669,8 @@
 	struct generic_prepare_struct gps = { .sql = sql, .argc = 0 };
 
 	/* If no mailbox, return immediately */
-	if (ast_strlen_zero(mailbox)) {
+	if (ast_strlen_zero(mailbox_id)
+		|| separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
 		return 0;
 	}
 
@@ -5681,16 +5721,16 @@
  * This invokes the messagecount(). Here we are interested in the presence of messages (> 0) only, not the actual count.
  * \return 1 if the folder has one or more messages. zero otherwise.
  */
-static int has_voicemail(const char *mailbox, const char *folder)
-{
-	char tmp[256], *tmp2 = tmp, *box, *context;
-	ast_copy_string(tmp, mailbox, sizeof(tmp));
-	while ((context = box = strsep(&tmp2, ",&"))) {
-		strsep(&context, "@");
-		if (ast_strlen_zero(context))
-			context = "default";
-		if (messagecount(context, box, folder))
+static int has_voicemail(const char *mailboxes, const char *folder)
+{
+	char *parse;
+	char *mailbox;
+
+	parse = ast_strdupa(mailboxes);
+	while ((mailbox = strsep(&parse, ",&"))) {
+		if (messagecount(mailbox, folder)) {
 			return 1;
+		}
 	}
 	return 0;
 }
@@ -5778,8 +5818,16 @@
 #endif
 #if !(defined(IMAP_STORAGE) || defined(ODBC_STORAGE))
 
-static int messagecount(const char *context, const char *mailbox, const char *folder)
-{
+static int messagecount(const char *mailbox_id, const char *folder)
+{
+	char *context;
+	char *mailbox;
+
+	if (ast_strlen_zero(mailbox_id)
+		|| separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
+		return 0;
+	}
+
 	return __has_voicemail(context, mailbox, folder, 0) + (folder && strcmp(folder, "INBOX") ? 0 : __has_voicemail(context, mailbox, "Urgent", 0));
 }
 
@@ -7742,13 +7790,11 @@
 
 static void queue_mwi_event(const char *channel_id, const char *box, int urgent, int new, int old)
 {
-	char *mailbox, *context;
-
-	/* Strip off @default */
-	context = mailbox = ast_strdupa(box);
-	strsep(&context, "@");
-	if (ast_strlen_zero(context)) {
-		context = "default";
+	char *mailbox;
+	char *context;
+
+	if (separate_mailbox(ast_strdupa(box), &mailbox, &context)) {
+		return;
 	}
 
 	ast_publish_mwi_state_channel(mailbox, context, new + urgent, old, channel_id);
@@ -11999,7 +12045,9 @@
 {
 	struct ast_vm_user svm;
 	struct ast_vm_user *vmu = NULL;
-	char *tmp, *mailbox, *context, *parse;
+	char *parse;
+	char *mailbox;
+	char *context;
 	int res = 0;
 
 	AST_DECLARE_APP_ARGS(arg,
@@ -12018,17 +12066,11 @@
 	parse = ast_strdupa(args);
 	AST_STANDARD_APP_ARGS(arg, parse);
 
-	if (ast_strlen_zero(arg.mailbox_context) || ast_strlen_zero(arg.attribute)) {
+	if (ast_strlen_zero(arg.mailbox_context)
+		|| ast_strlen_zero(arg.attribute)
+		|| separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
 		ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
 		return -1;
-	}
-
-	tmp = ast_strdupa(arg.mailbox_context);
-	mailbox = strsep(&tmp, "@");
-	context = strsep(&tmp, "");
-
-	if (ast_strlen_zero(context)) {
-		 context = "default";
 	}
 
 	vmu = find_user(&svm, context, mailbox);
@@ -12054,8 +12096,13 @@
 		} else if (!strncasecmp(arg.attribute, "tz", 2)) {
 			ast_copy_string(buf, vmu->zonetag, len);
 		} else if (!strncasecmp(arg.attribute, "count", 5)) {
+			char *mailbox_id;
+
+			mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
+			sprintf(mailbox_id, "%s@%s", mailbox, context);/* Safe */
+
 			/* If mbxfolder is empty messagecount will default to INBOX */
-			res = messagecount(context, mailbox, arg.folder);
+			res = messagecount(mailbox_id, arg.folder);
 			if (res < 0) {
 				ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
 				return -1;
@@ -12592,14 +12639,17 @@
 static void mwi_sub_event_cb(struct stasis_subscription_change *change)
 {
 	struct mwi_sub_task *mwist;
-	char *context = ast_strdupa(stasis_topic_name(change->topic));
+	char *context;
 	char *mailbox;
 
-	if ((mwist = ast_calloc(1, (sizeof(*mwist)))) == NULL) {
+	mwist = ast_calloc(1, (sizeof(*mwist)));
+	if (!mwist) {
 		return;
 	}
 
-	mailbox = strsep(&context, "@");
+	if (separate_mailbox(ast_strdupa(stasis_topic_name(change->topic)), &mailbox, &context)) {
+		return;
+	}
 
 	mwist->mailbox = ast_strdup(mailbox);
 	mwist->context = ast_strdup(context);
@@ -13668,26 +13718,20 @@
 static int vmsayname_exec(struct ast_channel *chan, const char *data)
 {
 	char *context;
-	char *args_copy;
+	char *mailbox;
 	int res;
 
-	if (ast_strlen_zero(data)) {
+	if (ast_strlen_zero(data)
+		|| separate_mailbox(ast_strdupa(data), &mailbox, &context)) {
 		ast_log(LOG_WARNING, "VMSayName requires argument mailbox at context\n");
 		return -1;
 	}
 
-	args_copy = ast_strdupa(data);
-	if ((context = strchr(args_copy, '@'))) {
-		*context++ = '\0';
-	} else {
-		context = "default";
-	}
-
-	if ((res = sayname(chan, args_copy, context)) < 0) {
-		ast_debug(3, "Greeting not found for '%s@%s', falling back to mailbox number.\n", args_copy, context);
+	if ((res = sayname(chan, mailbox, context)) < 0) {
+		ast_debug(3, "Greeting not found for '%s@%s', falling back to mailbox number.\n", mailbox, context);
 		res = ast_stream_and_wait(chan, "vm-extension", AST_DIGIT_ANY);
 		if (!res) {
-			res = ast_say_character_str(chan, args_copy, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
+			res = ast_say_character_str(chan, mailbox, AST_DIGIT_ANY, ast_channel_language(chan), AST_SAY_CASE_NONE);
 		}
 	}
 
@@ -13925,9 +13969,9 @@
 
 		new = old = urgent = 0;
 		for (j = 0; j < 3; j++) {
-			if (ast_app_messagecount(testcontext, testmailbox, folders[j]) != expected_results[i][9 + j]) {
+			if (ast_app_messagecount(testspec, folders[j]) != expected_results[i][9 + j]) {
 				ast_test_status_update(test, "messagecount(%s, %s) returned %d and we expected %d\n",
-					testspec, folders[j], ast_app_messagecount(testcontext, testmailbox, folders[j]), expected_results[i][9 + j]);
+					testspec, folders[j], ast_app_messagecount(testspec, folders[j]), expected_results[i][9 + j]);
 				res = AST_TEST_FAIL;
 			}
 		}

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Thu Dec 19 10:52:43 2013
@@ -3129,9 +3129,9 @@
 /*!
  * \brief Send MWI state change
  *
- * \arg mailbox_full This is the mailbox associated with the FXO line that the
+ * \param mailbox This is the mailbox associated with the FXO line that the
  *      MWI state has changed on.
- * \arg thereornot This argument should simply be set to 1 or 0, to indicate
+ * \param thereornot This argument should simply be set to 1 or 0, to indicate
  *      whether there are messages waiting or not.
  *
  *  \return nothing
@@ -3144,20 +3144,16 @@
  * 2) It runs the script specified by the mwimonitornotify option to allow
  *    some custom handling of the state change.
  */
-static void notify_message(char *mailbox_full, int thereornot)
+static void notify_message(char *mailbox, int thereornot)
 {
 	char s[sizeof(mwimonitornotify) + 80];
-	char *mailbox, *context;
-
-	/* Strip off @default */
-	context = mailbox = ast_strdupa(mailbox_full);
-	strsep(&context, "@");
-	if (ast_strlen_zero(context))
-		context = "default";
-
-	ast_publish_mwi_state(mailbox, context, thereornot, thereornot);
-
-	if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(mwimonitornotify)) {
+
+	if (ast_strlen_zero(mailbox)) {
+		return;
+	}
+
+	ast_publish_mwi_state(mailbox, NULL, thereornot, thereornot);
+	if (!ast_strlen_zero(mwimonitornotify)) {
 		snprintf(s, sizeof(s), "%s %s %d", mwimonitornotify, mailbox, thereornot);
 		ast_safe_system(s);
 	}
@@ -4835,19 +4831,9 @@
 static int has_voicemail(struct dahdi_pvt *p)
 {
 	int new_msgs;
-	char *mailbox, *context;
 	RAII_VAR(struct stasis_message *, mwi_message, NULL, ao2_cleanup);
-	struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
-
-	mailbox = context = ast_strdupa(p->mailbox);
-	strsep(&context, "@");
-	if (ast_strlen_zero(context)) {
-		context = "default";
-	}
-
-	ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-	mwi_message = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
-
+
+	mwi_message = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), p->mailbox);
 	if (mwi_message) {
 		struct ast_mwi_state *mwi_state = stasis_message_data(mwi_message);
 		new_msgs = mwi_state->new_msgs;
@@ -12172,6 +12158,9 @@
 						ast_copy_string(pris[span].pri.mwi_mailboxes,
 							conf->pri.pri.mwi_mailboxes,
 							sizeof(pris[span].pri.mwi_mailboxes));
+						ast_copy_string(pris[span].pri.mwi_vm_boxes,
+							conf->pri.pri.mwi_vm_boxes,
+							sizeof(pris[span].pri.mwi_vm_boxes));
 						ast_copy_string(pris[span].pri.mwi_vm_numbers,
 							conf->pri.pri.mwi_vm_numbers,
 							sizeof(pris[span].pri.mwi_vm_numbers));
@@ -12434,18 +12423,9 @@
 		tmp->cid_subaddr[0] = '\0';
 		ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox));
 		if (channel != CHAN_PSEUDO && !ast_strlen_zero(tmp->mailbox)) {
-			char *mailbox, *context;
-			struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
 			struct stasis_topic *mailbox_specific_topic;
 
-			mailbox = context = ast_strdupa(tmp->mailbox);
-			strsep(&context, "@");
-			if (ast_strlen_zero(context))
-				context = "default";
-
-			ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-
-			mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
+			mailbox_specific_topic = ast_mwi_topic(tmp->mailbox);
 			if (mailbox_specific_topic) {
 				tmp->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
 			}
@@ -16997,7 +16977,16 @@
 			ast_copy_string(confp->chan.description, v->value, sizeof(confp->chan.description));
 		} else if (!strcasecmp(v->name, "hasvoicemail")) {
 			if (ast_true(v->value) && ast_strlen_zero(confp->chan.mailbox)) {
-				ast_copy_string(confp->chan.mailbox, cat, sizeof(confp->chan.mailbox));
+				/*
+				 * hasvoicemail is a users.conf legacy voicemail enable method.
+				 * hasvoicemail is only going to work for app_voicemail mailboxes.
+				 */
+				if (strchr(cat, '@')) {
+					ast_copy_string(confp->chan.mailbox, cat, sizeof(confp->chan.mailbox));
+				} else {
+					snprintf(confp->chan.mailbox, sizeof(confp->chan.mailbox),
+						"%s at default", cat);
+				}
 			}
 		} else if (!strcasecmp(v->name, "adsi")) {
 			confp->chan.adsi = ast_true(v->value);
@@ -17685,6 +17674,9 @@
 			} else if (!strcasecmp(v->name, "mwi_mailboxes")) {
 				ast_copy_string(confp->pri.pri.mwi_mailboxes, v->value,
 					sizeof(confp->pri.pri.mwi_mailboxes));
+			} else if (!strcasecmp(v->name, "mwi_vm_boxes")) {
+				ast_copy_string(confp->pri.pri.mwi_vm_boxes, v->value,
+					sizeof(confp->pri.pri.mwi_vm_boxes));
 			} else if (!strcasecmp(v->name, "mwi_vm_numbers")) {
 				ast_copy_string(confp->pri.pri.mwi_vm_numbers, v->value,
 					sizeof(confp->pri.pri.mwi_vm_numbers));

Modified: trunk/channels/chan_dahdi.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.h?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_dahdi.h (original)
+++ trunk/channels/chan_dahdi.h Thu Dec 19 10:52:43 2013
@@ -38,6 +38,7 @@
 
 #include "asterisk/channel.h"
 #include "asterisk/dsp.h"
+#include "asterisk/app.h"
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
@@ -621,7 +622,7 @@
 	 * \brief Voice mailbox location.
 	 * \note Set from the "mailbox" string read in from chan_dahdi.conf
 	 */
-	char mailbox[AST_MAX_EXTENSION];
+	char mailbox[AST_MAX_MAILBOX_UNIQUEID];
 	/*! \brief Opaque event subscription parameters for message waiting indication support. */
 	struct stasis_subscription *mwi_event_sub;
 	/*! \brief Delayed dialing for E911.  Overlap digits for ISDN. */

Modified: trunk/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_h323.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Thu Dec 19 10:52:43 2013
@@ -1628,7 +1628,15 @@
 			ast_copy_string(peer->mailbox, v->value, sizeof(peer->mailbox));
 		} else if (!strcasecmp(v->name, "hasvoicemail")) {
 			if (ast_true(v->value) && ast_strlen_zero(peer->mailbox)) {
-				ast_copy_string(peer->mailbox, name, sizeof(peer->mailbox));
+				/*
+				 * hasvoicemail is a users.conf legacy voicemail enable method.
+				 * hasvoicemail is only going to work for app_voicemail mailboxes.
+				 */
+				if (strchr(name, '@')) {
+					ast_copy_string(peer->mailbox, name, sizeof(peer->mailbox));
+				} else {
+					snprintf(peer->mailbox, sizeof(peer->mailbox), "%s at default", name);
+				}
 			}
 		}
 	}

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Dec 19 10:52:43 2013
@@ -8927,19 +8927,9 @@
 		iax_ie_append_addr(&ied, IAX_IE_APPARENT_ADDR, &peer_addr);
 		if (!ast_strlen_zero(p->mailbox)) {
 			int new, old;
-			char *mailbox, *context;
 			RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-			struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
-
-			context = mailbox = ast_strdupa(p->mailbox);
-			strsep(&context, "@");
-			if (ast_strlen_zero(context)) {
-				context = "default";
-			}
-
-			ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-			msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
-
+
+			msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), p->mailbox);
 			if (msg) {
 				struct ast_mwi_state *mwi_state = stasis_message_data(msg);
 				new = mwi_state->new_msgs;
@@ -12553,7 +12543,15 @@
 				ast_string_field_set(peer, mailbox, v->value);
 			} else if (!strcasecmp(v->name, "hasvoicemail")) {
 				if (ast_true(v->value) && ast_strlen_zero(peer->mailbox)) {
-					ast_string_field_set(peer, mailbox, name);
+					/*
+					 * hasvoicemail is a users.conf legacy voicemail enable method.
+					 * hasvoicemail is only going to work for app_voicemail mailboxes.
+					 */
+					if (strchr(name, '@')) {
+						ast_string_field_set(peer, mailbox, name);
+					} else {
+						ast_string_field_build(peer, mailbox, "%s at default", name);
+					}
 				}
 			} else if (!strcasecmp(v->name, "mohinterpret")) {
 				ast_string_field_set(peer, mohinterpret, v->value);
@@ -12762,19 +12760,9 @@
 	}
 
 	if (!ast_strlen_zero(peer->mailbox)) {
-		char *mailbox, *context;
-		struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
 		struct stasis_topic *mailbox_specific_topic;
 
-		context = mailbox = ast_strdupa(peer->mailbox);
-		strsep(&context, "@");
-		if (ast_strlen_zero(context)) {
-			context = "default";
-		}
-
-		ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-
-		mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
+		mailbox_specific_topic = ast_mwi_topic(peer->mailbox);
 		if (mailbox_specific_topic) {
 			peer->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
 		}

Modified: trunk/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_mgcp.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Thu Dec 19 10:52:43 2013
@@ -202,7 +202,7 @@
 
 static char accountcode[AST_MAX_ACCOUNT_CODE] = "";
 
-static char mailbox[AST_MAX_EXTENSION];
+static char mailbox[AST_MAX_MAILBOX_UNIQUEID];
 
 static int amaflags = 0;
 
@@ -499,19 +499,8 @@
 {
 	int new_msgs;
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-	struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
-	char *mbox, *cntx;
-
-	cntx = mbox = ast_strdupa(p->mailbox);
-	strsep(&cntx, "@");
-	if (ast_strlen_zero(cntx)) {
-		cntx = "default";
-	}
-
-	ast_str_set(&uniqueid, 0, "%s@%s", mbox, cntx);
-
-	msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
-
+
+	msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), p->mailbox);
 	if (msg) {
 		struct ast_mwi_state *mwi_state = stasis_message_data(msg);
 		new_msgs = mwi_state->new_msgs;
@@ -3994,7 +3983,6 @@
 	struct mgcp_endpoint *e;
 	struct mgcp_subchannel *sub;
 	struct ast_variable *chanvars = NULL;
-	struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
 
 	/*char txident[80];*/
 	int i=0, y=0;
@@ -4138,7 +4126,15 @@
 			ast_copy_string(mailbox, v->value, sizeof(mailbox));
 		} else if (!strcasecmp(v->name, "hasvoicemail")) {
 			if (ast_true(v->value) && ast_strlen_zero(mailbox)) {
-				ast_copy_string(mailbox, gw->name, sizeof(mailbox));
+				/*
+				 * hasvoicemail is a users.conf legacy voicemail enable method.
+				 * hasvoicemail is only going to work for app_voicemail mailboxes.
+				 */
+				if (strchr(gw->name, '@')) {
+					ast_copy_string(mailbox, gw->name, sizeof(mailbox));
+				} else {
+					snprintf(mailbox, sizeof(mailbox), "%s at default", gw->name);
+				}
 			}
 		} else if (!strcasecmp(v->name, "adsi")) {
 			adsi = ast_true(v->value);
@@ -4190,18 +4186,9 @@
 				ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
 				ast_copy_string(e->parkinglot, parkinglot, sizeof(e->parkinglot));
 				if (!ast_strlen_zero(e->mailbox)) {
-					char *mbox, *cntx;
 					struct stasis_topic *mailbox_specific_topic;
 
-					cntx = mbox = ast_strdupa(e->mailbox);
-					strsep(&cntx, "@");
-					if (ast_strlen_zero(cntx)) {
-						cntx = "default";
-					}
-					ast_str_reset(uniqueid);
-					ast_str_set(&uniqueid, 0, "%s@%s", mbox, cntx);
-
-					mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
+					mailbox_specific_topic = ast_mwi_topic(e->mailbox);
 					if (mailbox_specific_topic) {
 						e->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
 					}

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Dec 19 10:52:43 2013
@@ -20362,10 +20362,8 @@
 	struct sip_mailbox *mailbox;
 
 	AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {
-		ast_str_append(mailbox_str, 0, "%s%s%s%s",
-			mailbox->mailbox,
-			ast_strlen_zero(mailbox->context) ? "" : "@",
-			S_OR(mailbox->context, ""),
+		ast_str_append(mailbox_str, 0, "%s%s",
+			mailbox->id,
 			AST_LIST_NEXT(mailbox, entry) ? "," : "");
 	}
 }
@@ -27445,16 +27443,12 @@
 static void add_peer_mwi_subs(struct sip_peer *peer)
 {
 	struct sip_mailbox *mailbox;
-	struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
 
 	AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {
 		struct stasis_topic *mailbox_specific_topic;
 		mailbox->event_sub = stasis_unsubscribe(mailbox->event_sub);
 
-		ast_str_reset(uniqueid);
-		ast_str_set(&uniqueid, 0, "%s@%s", mailbox->mailbox, S_OR(mailbox->context, "default"));
-
-		mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
+		mailbox_specific_topic = ast_mwi_topic(mailbox->id);
 		if (mailbox_specific_topic) {
 			ao2_ref(peer, +1);
 			mailbox->event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, peer);
@@ -28658,17 +28652,13 @@
 {
 	struct sip_mailbox *mailbox;
 	int in_cache;
-	struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
 
 	in_cache = 0;
 	AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {
 		RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 		struct ast_mwi_state *mwi_state;
 
-		ast_str_reset(uniqueid);
-		ast_str_set(&uniqueid, 0, "%s@%s", mailbox->mailbox, S_OR(mailbox->context, "default"));
-
-		msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
+		msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), mailbox->id);
 		if (!msg) {
 			continue;
 		}
@@ -30458,24 +30448,24 @@
 /*! \todo document this function */
 static void add_peer_mailboxes(struct sip_peer *peer, const char *value)
 {
-	char *next, *mbox, *context;
+	char *next;
+	char *mbox;
 
 	next = ast_strdupa(value);
 
-	while ((mbox = context = strsep(&next, ","))) {
+	while ((mbox = strsep(&next, ","))) {
 		struct sip_mailbox *mailbox;
 		int duplicate = 0;
+
 		/* remove leading/trailing whitespace from mailbox string */
 		mbox = ast_strip(mbox);
-		strsep(&context, "@");
-
 		if (ast_strlen_zero(mbox)) {
 			continue;
 		}
 
 		/* Check whether the mailbox is already in the list */
 		AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {
-			if (!strcmp(mailbox->mailbox, mbox) && !strcmp(S_OR(mailbox->context, ""), S_OR(context, ""))) {
+			if (!strcmp(mailbox->id, mbox)) {
 				duplicate = 1;
 				break;
 			}
@@ -30484,15 +30474,11 @@
 			continue;
 		}
 
-		if (!(mailbox = ast_calloc(1, sizeof(*mailbox) + strlen(mbox) + strlen(S_OR(context, ""))))) {
+		mailbox = ast_calloc(1, sizeof(*mailbox) + strlen(mbox));
+		if (!mailbox) {
 			continue;
 		}
-
-		if (!ast_strlen_zero(context)) {
-			mailbox->context = mailbox->mailbox + strlen(mbox) + 1;
-			strcpy(mailbox->context, context); /* SAFE */
-		}
-		strcpy(mailbox->mailbox, mbox); /* SAFE */
+		strcpy(mailbox->id, mbox); /* SAFE */
 
 		AST_LIST_INSERT_TAIL(&peer->mailboxes, mailbox, entry);
 	}
@@ -30839,7 +30825,18 @@
 				/* People expect that if 'hasvoicemail' is set, that the mailbox will
 				 * be also set, even if not explicitly specified. */
 				if (ast_true(v->value) && AST_LIST_EMPTY(&peer->mailboxes)) {
-					add_peer_mailboxes(peer, name);
+					/*
+					 * hasvoicemail is a users.conf legacy voicemail enable method.
+					 * hasvoicemail is only going to work for app_voicemail mailboxes.
+					 */
+					if (strchr(name, '@')) {
+						add_peer_mailboxes(peer, name);
+					} else {
+						char mailbox[AST_MAX_MAILBOX_UNIQUEID];
+
+						snprintf(mailbox, sizeof(mailbox), "%s at default", name);
+						add_peer_mailboxes(peer, mailbox);
+					}
 				}
 			} else if (!strcasecmp(v->name, "subscribemwi")) {
 				ast_set2_flag(&peer->flags[1], ast_true(v->value), SIP_PAGE2_SUBSCRIBEMWIONLY);
@@ -34339,8 +34336,7 @@
 			if (!data_peer_mailbox) {
 				continue;
 			}
-			ast_data_add_str(data_peer_mailbox, "mailbox", mailbox->mailbox);
-			ast_data_add_str(data_peer_mailbox, "context", mailbox->context);
+			ast_data_add_str(data_peer_mailbox, "id", mailbox->id);
 		}
 
 		/* amaflags */

Modified: trunk/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Thu Dec 19 10:52:43 2013
@@ -1429,7 +1429,7 @@
 	char call_forward_all[AST_MAX_EXTENSION];	\
 	char call_forward_busy[AST_MAX_EXTENSION];	\
 	char call_forward_noanswer[AST_MAX_EXTENSION];	\
-	char mailbox[AST_MAX_EXTENSION];		\
+	char mailbox[AST_MAX_MAILBOX_UNIQUEID];		\
 	char vmexten[AST_MAX_EXTENSION];		\
 	char regexten[AST_MAX_EXTENSION];		\
 	char regcontext[AST_MAX_CONTEXT];		\
@@ -8017,7 +8017,16 @@
 		} else if (!strcasecmp(v->name, "hasvoicemail")) {
 			if (type & (TYPE_LINE)) {
 				if (ast_true(v->value) && ast_strlen_zero(CLINE->mailbox)) {
-					ast_copy_string(CLINE->mailbox, CLINE->name, sizeof(CLINE->mailbox));
+					/*
+					 * hasvoicemail is a users.conf legacy voicemail enable method.
+					 * hasvoicemail is only going to work for app_voicemail mailboxes.
+					 */
+					if (strchr(CLINE->name, '@')) {
+						ast_copy_string(CLINE->mailbox, CLINE->name, sizeof(CLINE->mailbox));
+					} else {
+						snprintf(CLINE->mailbox, sizeof(CLINE->mailbox), "%s at default",
+							CLINE->name);
+					}
 				}
 				continue;
 			}
@@ -8297,20 +8306,11 @@
 	config_parse_variables(TYPE_LINE, l, v);
 
 	if (!ast_strlen_zero(l->mailbox)) {
-		char *cfg_mailbox, *cfg_context;
-		struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
 		struct stasis_topic *mailbox_specific_topic;
 
-		cfg_context = cfg_mailbox = ast_strdupa(l->mailbox);
-		ast_verb(3, "Setting mailbox '%s' on line %s\n", cfg_mailbox, l->name);
-		strsep(&cfg_context, "@");
-		if (ast_strlen_zero(cfg_context)) {
-			cfg_context = "default";
-		}
-
-		ast_str_set(&uniqueid, 0, "%s@%s", cfg_mailbox, cfg_context);
-
-		mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
+		ast_verb(3, "Setting mailbox '%s' on line %s\n", l->mailbox, l->name);
+
+		mailbox_specific_topic = ast_mwi_topic(l->mailbox);
 		if (mailbox_specific_topic) {
 			l->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, l);
 		}

Modified: trunk/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_unistim.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/chan_unistim.c (original)
+++ trunk/channels/chan_unistim.c Thu Dec 19 10:52:43 2013
@@ -5504,27 +5504,17 @@
 static int unistim_send_mwi_to_peer(struct unistim_line *peer, unsigned int tick)
 {
 	int new;
-	char *mailbox, *context;
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-	struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
-
-	context = mailbox = ast_strdupa(peer->mailbox);
-	strsep(&context, "@");
-	if (ast_strlen_zero(context)) {
-		context = "default";
-	}
-
-	ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-
-	msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
-
+
+	msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), peer->mailbox);
 	if (msg) {
 		struct ast_mwi_state *mwi_state = stasis_message_data(msg);
 		new = mwi_state->new_msgs;
 	} else { /* Fall back on checking the mailbox directly */
-		new = ast_app_has_voicemail(peer->mailbox, "INBOX");
-	}
-	ast_debug(3, "MWI Status for mailbox %s is %d, lastmsgsent:%d\n",mailbox,new,peer->parent->lastmsgssent);
+		new = ast_app_has_voicemail(peer->mailbox, NULL);
+	}
+	ast_debug(3, "MWI Status for mailbox %s is %d, lastmsgsent:%d\n",
+		peer->mailbox, new, peer->parent->lastmsgssent);
 	peer->parent->nextmsgcheck = tick + TIMER_MWI;
 
 	/* Return now if it's the same thing we told them last time */

Modified: trunk/channels/h323/chan_h323.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/h323/chan_h323.h?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/h323/chan_h323.h (original)
+++ trunk/channels/h323/chan_h323.h Thu Dec 19 10:52:43 2013
@@ -31,6 +31,7 @@
 
 #include <arpa/inet.h>
 #include "asterisk/format.h"
+#include "asterisk/app.h"
 
 /*
  * Enable support for sending/reception of tunnelled Q.SIG messages and
@@ -94,7 +95,7 @@
    All peers are registered to a GK if there is one */
 struct oh323_peer {
 	ASTOBJ_COMPONENTS(struct oh323_peer);
-	char mailbox[80];
+	char mailbox[AST_MAX_MAILBOX_UNIQUEID];
 	int delme;
 	struct sockaddr_in addr;
 	struct ast_ha *ha;

Modified: trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.c?view=diff&rev=404350&r1=404349&r2=404350
==============================================================================
--- trunk/channels/sig_pri.c (original)
+++ trunk/channels/sig_pri.c Thu Dec 19 10:52:43 2013
@@ -8847,25 +8847,25 @@
  *
  * \param pri PRI span control structure.
  * \param vm_number Voicemail controlling number (NULL if not present).
- * \param mbox_number Mailbox number
- * \param mbox_context Mailbox context
+ * \param vm_box Voicemail mailbox number
+ * \param mbox_id Mailbox id
  * \param num_messages Number of messages waiting.
  *
  * \return Nothing
  */
-static void sig_pri_send_mwi_indication(struct sig_pri_span *pri, const char *vm_number, const char *mbox_number, const char *mbox_context, int num_messages)
+static void sig_pri_send_mwi_indication(struct sig_pri_span *pri, const char *vm_number, const char *vm_box, const char *mbox_id, int num_messages)
 {
 	struct pri_party_id voicemail;
 	struct pri_party_id mailbox;
 
-	ast_debug(1, "Send MWI indication for %s@%s vm_number:%s num_messages:%d\n",
-		mbox_number, mbox_context, S_OR(vm_number, "<not-present>"), num_messages);
+	ast_debug(1, "Send MWI indication for %s(%s) vm_number:%s num_messages:%d\n",
+		vm_box, mbox_id, S_OR(vm_number, "<not-present>"), num_messages);
 
 	memset(&mailbox, 0, sizeof(mailbox));
 	mailbox.number.valid = 1;
 	mailbox.number.presentation = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
 	mailbox.number.plan = (PRI_TON_UNKNOWN << 4) | PRI_NPI_UNKNOWN;
-	ast_copy_string(mailbox.number.str, mbox_number, sizeof(mailbox.number.str));
+	ast_copy_string(mailbox.number.str, vm_box, sizeof(mailbox.number.str));
 
 	memset(&voicemail, 0, sizeof(voicemail));
 	voicemail.number.valid = 1;
@@ -8902,9 +8902,6 @@
 static void sig_pri_mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_message *msg)
 {
 	struct sig_pri_span *pri = userdata;
-	const char *mbox_context;
-	const char *mbox_number;
-	int num_messages;
 	int idx;
 	struct ast_mwi_state *mwi_state;
 
@@ -8913,27 +8910,17 @@
 	}
 
 	mwi_state = stasis_message_data(msg);
-
-	mbox_number = mwi_state->mailbox;
-	if (ast_strlen_zero(mbox_number)) {
-		return;
-	}
-	mbox_context = mwi_state->context;
-	if (ast_strlen_zero(mbox_context)) {
-		return;
-	}
-	num_messages = mwi_state->new_msgs;
 
 	for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {

[... 768 lines stripped ...]



More information about the asterisk-commits mailing list