summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES16
-rw-r--r--UPGRADE-12.txt19
-rw-r--r--apps/app_voicemail.c146
-rw-r--r--channels/chan_dahdi.c60
-rw-r--r--channels/chan_dahdi.h3
-rw-r--r--channels/chan_h323.c10
-rw-r--r--channels/chan_iax2.c34
-rw-r--r--channels/chan_mgcp.c37
-rw-r--r--channels/chan_sip.c54
-rw-r--r--channels/chan_skinny.c26
-rw-r--r--channels/chan_unistim.c18
-rw-r--r--channels/h323/chan_h323.h3
-rw-r--r--channels/sig_pri.c119
-rw-r--r--channels/sig_pri.h32
-rw-r--r--channels/sip/include/sip.h5
-rw-r--r--configs/chan_dahdi.conf.sample44
-rw-r--r--configs/iax.conf.sample1
-rw-r--r--configs/sip.conf.sample6
-rw-r--r--configs/skinny.conf.sample1
-rw-r--r--configs/voicemail.conf.sample9
-rw-r--r--funcs/func_vmcount.c21
-rw-r--r--include/asterisk/app.h38
-rw-r--r--main/app.c15
-rw-r--r--res/res_jabber.c24
-rw-r--r--res/res_xmpp.c24
25 files changed, 400 insertions, 365 deletions
diff --git a/CHANGES b/CHANGES
index ada66405a..aa414bfaf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -403,6 +403,12 @@ UserEvent
VoiceMail
------------------
+ * Mailboxes defined by app_voicemail MUST be referenced by the rest of the
+ system as mailbox@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.
@@ -887,6 +893,8 @@ chan_dahdi
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
------------------
* IPv6 support has been added. We are now able to bind to and
@@ -1033,6 +1041,14 @@ SPEECH_ENGINE
* 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@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
------------------
diff --git a/UPGRADE-12.txt b/UPGRADE-12.txt
index e65cedc21..360e28d93 100644
--- a/UPGRADE-12.txt
+++ b/UPGRADE-12.txt
@@ -181,6 +181,12 @@ SetAMAFlags
- 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@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
@@ -208,6 +214,12 @@ chan_dahdi:
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@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 @@ CDR: (function)
- 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@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.
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 36692981b..05b0cfb09 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1111,6 +1111,34 @@ static int vm_test_destroy_user(const char *context, const char *mailbox);
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@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 @@ static int imap_check_limits(struct ast_channel *chan, struct vm_state *vms, str
/*!
* \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,9 +2568,12 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char
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) {
if(!imapgreetings) {
@@ -5612,16 +5650,17 @@ static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *
/*!
* \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 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
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 @@ yuck:
* 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)
+static int has_voicemail(const char *mailboxes, 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))
+ char *parse;
+ char *mailbox;
+
+ parse = ast_strdupa(mailboxes);
+ while ((mailbox = strsep(&parse, ",&"))) {
+ if (messagecount(mailbox, folder)) {
return 1;
+ }
}
return 0;
}
@@ -5778,8 +5818,16 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i
#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 int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
static void queue_mwi_event(const char *channel_id, const char *box, int urgent, int new, int old)
{
- char *mailbox, *context;
+ char *mailbox;
+ char *context;
- /* Strip off @default */
- context = mailbox = ast_strdupa(box);
- strsep(&context, "@");
- if (ast_strlen_zero(context)) {
- context = "default";
+ 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 @@ static int acf_vm_info(struct ast_channel *chan, const char *cmd, char *args, ch
{
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,19 +12066,13 @@ static int acf_vm_info(struct ast_channel *chan, const char *cmd, char *args, ch
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);
if (!strncasecmp(arg.attribute, "exists", 5)) {
@@ -12054,8 +12096,13 @@ static int acf_vm_info(struct ast_channel *chan, const char *cmd, char *args, ch
} 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_unsub_event_cb(struct stasis_subscription_change *change)
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 write_password_to_file(const char *secretfn, const char *password) {
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@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 @@ AST_TEST_DEFINE(test_voicemail_msgcount)
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;
}
}
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index e4f1c0c85..d4e2a8238 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -3129,9 +3129,9 @@ struct sig_ss7_callback sig_ss7_callbacks =
/*!
* \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 @@ struct sig_ss7_callback sig_ss7_callbacks =
* 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)) {
+ return;
+ }
- if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(mwimonitornotify)) {
+ 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 send_cwcidspill(struct dahdi_pvt *p)
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 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
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 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
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 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
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@default", cat);
+ }
}
} else if (!strcasecmp(v->name, "adsi")) {
confp->chan.adsi = ast_true(v->value);
@@ -17685,6 +17674,9 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
} 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));
diff --git a/channels/chan_dahdi.h b/channels/chan_dahdi.h
index 91c961910..d302bd7f7 100644
--- a/channels/chan_dahdi.h
+++ b/channels/chan_dahdi.h
@@ -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 @@ struct dahdi_pvt {
* \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. */
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 1c9bb2ad0..013e49e55 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -1628,7 +1628,15 @@ static struct oh323_peer *build_peer(const char *name, struct ast_variable *v, s
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@default", name);
+ }
}
}
}
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 447860bd1..dcbd210dc 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -8927,19 +8927,9 @@ static int update_registry(struct ast_sockaddr *addr, int callno, char *devtype,
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 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st
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@default", name);
+ }
}
} else if (!strcasecmp(v->name, "mohinterpret")) {
ast_string_field_set(peer, mohinterpret, v->value);
@@ -12762,19 +12760,9 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st
}
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);
}
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index aaed68fea..e250a9220 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -202,7 +202,7 @@ static int directmedia = DIRECTMEDIA;
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 @@ static int has_voicemail(struct mgcp_endpoint *p)
{
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 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
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 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
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@default", gw->name);
+ }
}
} else if (!strcasecmp(v->name, "adsi")) {
adsi = ast_true(v->value);
@@ -4190,18 +4186,9 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
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);
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 0fde84e2d..8b458ae5f 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -20362,10 +20362,8 @@ static void peer_mailboxes_to_str(struct ast_str **mailbox_str, struct sip_peer
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 int handle_request_publish(struct sip_pvt *p, struct sip_request *req, st
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 @@ static int get_cached_mwi(struct sip_peer *peer, int *new, int *old)
{
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 @@ static struct sip_peer *temp_peer(const char *name)
/*! \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 @@ static void add_peer_mailboxes(struct sip_peer *peer, const char *value)
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 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
/* 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@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 @@ static int peers_data_provider_get(const struct ast_data_search *search,
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 */
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index e54108c3b..c78a04782 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -1429,7 +1429,7 @@ struct skinny_subchannel {
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 @@ static void config_parse_variables(int type, void *item, struct ast_variable *vp
} 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@default",
+ CLINE->name);
+ }
}
continue;
}
@@ -8297,20 +8306,11 @@ static struct skinny_line *config_line(const char *lname, struct ast_variable *v
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);
+ ast_verb(3, "Setting mailbox '%s' on line %s\n", l->mailbox, l->name);
- mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
+ 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);
}
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index bc79f5ee0..2f4b9c6a7 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -5504,27 +5504,17 @@ static int unistim_sendtext(struct ast_channel *ast, const char *text)
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");
+ new = ast_app_has_voicemail(peer->mailbox, NULL);
}
- ast_debug(3, "MWI Status for mailbox %s is %d, lastmsgsent:%d\n",mailbox,new,peer->parent->lastmsgssent);
+ 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 */
diff --git a/channels/h323/chan_h323.h b/channels/h323/chan_h323.h
index ddabb669a..3787ad60d 100644
--- a/channels/h323/chan_h323.h
+++ b/channels/h323/chan_h323.h
@@ -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 @@ struct oh323_user {
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;
diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index 48c8c33d7..369a0b952 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -8847,25 +8847,25 @@ void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast)
*
* \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_send_mwi_indication(struct sig_pri_span *pri, const char *vm
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;
@@ -8914,26 +8911,16 @@ static void sig_pri_mwi_event_cb(void *userdata, struct stasis_subscription *sub
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) {
if (!pri->mbox[idx].sub) {
/* Mailbox slot is empty */
continue;
}
- if (!strcmp(pri->mbox[idx].number, mbox_number)
- && !strcmp(pri->mbox[idx].context, mbox_context)) {
+
+ if (!strcmp(pri->mbox[idx].uniqueid, mwi_state->uniqueid)) {
/* Found the mailbox. */
- sig_pri_send_mwi_indication(pri, pri->mbox[idx].vm_number, mbox_number,
- mbox_context, num_messages);
+ sig_pri_send_mwi_indication(pri, pri->mbox[idx].vm_number,
+ pri->mbox[idx].vm_box, pri->mbox[idx].uniqueid, mwi_state->new_msgs);
break;
}
}
@@ -8953,7 +8940,6 @@ static void sig_pri_mwi_event_cb(void *userdata, struct stasis_subscription *sub
static void sig_pri_mwi_cache_update(struct sig_pri_span *pri)
{
int idx;
- struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
struct ast_mwi_state *mwi_state;
for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
@@ -8963,18 +8949,16 @@ static void sig_pri_mwi_cache_update(struct sig_pri_span *pri)
continue;
}
- ast_str_reset(uniqueid);
- ast_str_set(&uniqueid, 0, "%s@%s", pri->mbox[idx].number, pri->mbox[idx].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(),
+ pri->mbox[idx].uniqueid);
if (!msg) {
/* No cached event for this mailbox. */
continue;
}
mwi_state = stasis_message_data(msg);
- sig_pri_send_mwi_indication(pri, pri->mbox[idx].vm_number, pri->mbox[idx].number,
- pri->mbox[idx].context, mwi_state->new_msgs);
+ sig_pri_send_mwi_indication(pri, pri->mbox[idx].vm_number, pri->mbox[idx].vm_box,
+ pri->mbox[idx].uniqueid, mwi_state->new_msgs);
}
}
#endif /* defined(HAVE_PRI_MWI) */
@@ -9059,8 +9043,6 @@ int sig_pri_start_pri(struct sig_pri_span *pri)
#if defined(HAVE_PRI_MWI)
char *saveptr;
char *prev_vm_number;
- struct ast_str *mwi_description = ast_str_alloca(64);
- struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
#endif /* defined(HAVE_PRI_MWI) */
#if defined(HAVE_PRI_MWI)
@@ -9100,58 +9082,61 @@ int sig_pri_start_pri(struct sig_pri_span *pri)
}
/*
+ * Split the mwi_vm_boxes configuration string into the mbox[].vm_box:
+ * vm_box{,vm_box}
+ */
+ saveptr = pri->mwi_vm_boxes;
+ for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {
+ char *vm_box;
+
+ vm_box = strsep(&saveptr, ",");
+ if (vm_box) {
+ vm_box = ast_strip(vm_box);
+ if (ast_strlen_zero(vm_box)) {
+ vm_box = NULL;
+ }
+ }
+ pri->mbox[i].vm_box = vm_box;
+ }
+
+ /*
* Split the mwi_mailboxes configuration string into the mbox[]:
- * mailbox_number[@context]{,mailbox_number[@context]}
+ * vm_mailbox{,vm_mailbox}
*/
saveptr = pri->mwi_mailboxes;
for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {
- char *mbox_number;
- char *mbox_context;
+ char *mbox_id;
struct stasis_topic *mailbox_specific_topic;
- mbox_number = strsep(&saveptr, ",");
- if (!mbox_number) {
- /* No more defined mailboxes. */
- break;
- }
- /* Split the mailbox_number and context */
- mbox_context = strchr(mbox_number, '@');
- if (mbox_context) {
- *mbox_context++ = '\0';
- mbox_context = ast_strip(mbox_context);
+ mbox_id = strsep(&saveptr, ",");
+ if (mbox_id) {
+ mbox_id = ast_strip(mbox_id);
+ if (ast_strlen_zero(mbox_id)) {
+ mbox_id = NULL;
+ }
}
- mbox_number = ast_strip(mbox_number);
- if (ast_strlen_zero(mbox_number)) {
- /* There is no mailbox number. Skip it. */
+ pri->mbox[i].uniqueid = mbox_id;
+ if (!pri->mbox[i].vm_box || !mbox_id) {
+ /* The mailbox position is disabled. */
+ ast_debug(1, "%s span %d MWI position %d disabled. vm_box:%s mbox_id:%s.\n",
+ sig_pri_cc_type_name, pri->span, i,
+ pri->mbox[i].vm_box ?: "<missing>",
+ mbox_id ?: "<missing>");
continue;
}
- if (ast_strlen_zero(mbox_context)) {
- /* There was no context so use the default. */
- mbox_context = "default";
- }
-
- /* Fill the mbox[] element. */
- pri->mbox[i].number = mbox_number;
- pri->mbox[i].context = mbox_context;
-
- ast_str_reset(uniqueid);
- ast_str_set(&uniqueid, 0, "%s@%s", mbox_number, mbox_context);
-
- ast_str_set(&mwi_description, -1, "%s span %d[%d] MWI mailbox %s@%s",
- sig_pri_cc_type_name, pri->span, i, mbox_number, mbox_context);
- mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
+ mailbox_specific_topic = ast_mwi_topic(mbox_id);
if (mailbox_specific_topic) {
pri->mbox[i].sub = stasis_subscribe(mailbox_specific_topic, sig_pri_mwi_event_cb, pri);
}
if (!pri->mbox[i].sub) {
- ast_log(LOG_ERROR, "%s span %d could not subscribe to MWI events for %s@%s.",
- sig_pri_cc_type_name, pri->span, mbox_number, mbox_context);
+ ast_log(LOG_ERROR, "%s span %d could not subscribe to MWI events for %s(%s).\n",
+ sig_pri_cc_type_name, pri->span, pri->mbox[i].vm_box, mbox_id);
}
#if defined(HAVE_PRI_MWI_V2)
if (ast_strlen_zero(pri->mbox[i].vm_number)) {
- ast_log(LOG_WARNING, "%s span %d MWI voicemail number for %s@%s is empty.\n",
- sig_pri_cc_type_name, pri->span, mbox_number, mbox_context);
+ ast_log(LOG_WARNING, "%s span %d MWI voicemail number for %s(%s) is empty.\n",
+ sig_pri_cc_type_name, pri->span, pri->mbox[i].vm_box, mbox_id);
}
#endif /* defined(HAVE_PRI_MWI_V2) */
}
diff --git a/channels/sig_pri.h b/channels/sig_pri.h
index a46bca637..09fa92073 100644
--- a/channels/sig_pri.h
+++ b/channels/sig_pri.h
@@ -388,7 +388,7 @@ struct sig_pri_chan {
/*! Typical maximum length of mwi mailbox context */
#define SIG_PRI_MAX_MWI_CONTEXT_LEN 10
/*!
- * \brief Maximum mwi_vm_numbers string length.
+ * \brief Maximum mwi_vm_numbers and mwi_vm_boxes string length.
* \details
* max_length = #mailboxes * (vm_number + ',')
* The last ',' is a null terminator instead.
@@ -396,13 +396,20 @@ struct sig_pri_chan {
#define SIG_PRI_MAX_MWI_VM_NUMBER_STR (SIG_PRI_MAX_MWI_MAILBOXES \
* (SIG_PRI_MAX_MWI_VM_NUMBER_LEN + 1))
/*!
+ * \brief Maximum length of vm_mailbox string.
+ * \details
+ * max_length = vm_box + '@' + context.
+ */
+#define SIG_PRI_MAX_MWI_VM_MAILBOX (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN \
+ + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN)
+/*!
* \brief Maximum mwi_mailboxs string length.
* \details
- * max_length = #mailboxes * (mbox_number + '@' + context + ',')
+ * max_length = #mailboxes * (vm_mailbox + ',')
* The last ',' is a null terminator instead.
*/
#define SIG_PRI_MAX_MWI_MAILBOX_STR (SIG_PRI_MAX_MWI_MAILBOXES \
- * (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN + 1))
+ * (SIG_PRI_MAX_MWI_VM_MAILBOX + 1))
struct sig_pri_mbox {
/*!
@@ -410,11 +417,11 @@ struct sig_pri_mbox {
* \note NULL if mailbox not configured.
*/
struct stasis_subscription *sub;
- /*! \brief Mailbox number */
- const char *number;
- /*! \brief Mailbox context. */
- const char *context;
- /*! \brief Voicemail controlling number. */
+ /*! \brief Mailbox uniqueid. */
+ const char *uniqueid;
+ /*! \brief Mailbox number sent to span. */
+ const char *vm_box;
+ /*! \brief Voicemail access controlling number sent to span. */
const char *vm_number;
};
#endif /* defined(HAVE_PRI_MWI) */
@@ -506,11 +513,18 @@ struct sig_pri_span {
/*!
* \brief Comma separated list of mailboxes to indicate MWI.
* \note Empty if disabled.
- * \note Format: mailbox_number[@context]{,mailbox_number[@context]}
+ * \note Format: vm_mailbox{,vm_mailbox}
* \note String is split apart when span is started.
*/
char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
/*!
+ * \brief Comma separated list of mailbox numbers sent over ISDN span for MWI.
+ * \note Empty if disabled.
+ * \note Format: vm_box{,vm_box}
+ * \note String is split apart when span is started.
+ */
+ char mwi_vm_boxes[SIG_PRI_MAX_MWI_VM_NUMBER_STR];
+ /*!
* \brief Comma separated list of voicemail access controlling numbers for MWI.
* \note Format: vm_number{,vm_number}
* \note String is split apart when span is started.
diff --git a/channels/sip/include/sip.h b/channels/sip/include/sip.h
index 524d4e32d..0b88dae43 100644
--- a/channels/sip/include/sip.h
+++ b/channels/sip/include/sip.h
@@ -1232,7 +1232,7 @@ struct sip_pkt {
/*!
* \brief A peer's mailbox
*
- * We could use STRINGFIELDS here, but for only two strings, it seems like
+ * We could use STRINGFIELDS here, but for only one string, its
* too much effort ...
*/
struct sip_mailbox {
@@ -1240,8 +1240,7 @@ struct sip_mailbox {
struct stasis_subscription *event_sub;
AST_LIST_ENTRY(sip_mailbox) entry;
unsigned int delme:1;
- char *context;
- char mailbox[2];
+ char id[1];
};
/*! \brief Structure for SIP peer data, we place calls to peers if registered or fixed IP address (host)
diff --git a/configs/chan_dahdi.conf.sample b/configs/chan_dahdi.conf.sample
index 7eb270b9a..51dedcad8 100644
--- a/configs/chan_dahdi.conf.sample
+++ b/configs/chan_dahdi.conf.sample
@@ -617,8 +617,11 @@ usecallerid=yes
;
; This option is used in conjunction with mwimonitor. This will get executed
; when incoming MWI state changes. The script is passed 2 arguments. The
-; first is the corresponding mailbox, and the second is 1 or 0, indicating if
-; there are messages waiting or not.
+; first is the corresponding configured mailbox, and the second is 1 or 0,
+; indicating if there are messages waiting or not.
+; Note: app_voicemail mailboxes are in the form of mailbox@context.
+;
+; /usr/local/bin/dahdinotify.sh 501@mailboxes 1
;
;mwimonitornotify=/usr/local/bin/dahdinotify.sh
;
@@ -654,11 +657,24 @@ callwaiting=yes
; Configure the ISDN span to indicate MWI for the list of mailboxes.
; You can give a comma separated list of up to 8 mailboxes per span.
; An empty list disables MWI.
+;
; The default is an empty list.
-;mwi_mailboxes=mailbox_number[@context]{,mailbox_number[@context]}
+;mwi_mailboxes=vm-mailbox{,vm-mailbox}
+; vm-mailbox = Internal voicemail mailbox identifier.
+; Note: app_voicemail mailboxes must be in the form of mailbox@context.
+;mwi_mailboxes=501@mailboxes,502@mailboxes
+
+; Configure the ISDN mailbox number sent over the span for MWI mailboxes.
+; The position of the number in the list corresponds to the position in
+; mwi_mailboxes. If either position in mwi_mailboxes or mwi_vm_boxes is
+; empty then that position is disabled.
;
-; Configure the ISDN span voicemail numbers for MWI mailboxes. What number
-; to call for a user to retrieve voicemail messages.
+; The default is an empty list.
+;mwi_vm_boxes=mailbox_number{,mailbox_number}
+;mwi_vm_boxes=501,502
+
+; Configure the ISDN span voicemail controlling numbers for MWI mailboxes.
+; What number to call for a user to retrieve voicemail messages.
;
; You can give a comma separated list of numbers. The position of the number
; corresponds to the position in mwi_mailboxes. If a position is empty then
@@ -667,7 +683,7 @@ callwaiting=yes
; For example:
; mwi_vm_numbers=700,,800,,900
; is equivalent to:
-; mwi_vm_numbers=700,700,800,800,900
+; mwi_vm_numbers=700,700,800,800,900,900,900,900
;
; The default is no number.
;mwi_vm_numbers=
@@ -737,19 +753,11 @@ cancallforward=yes
;
callreturn=yes
;
-; Stutter dialtone support: If a mailbox is specified without a voicemail
-; context, then when voicemail is received in a mailbox in the default
-; voicemail context in voicemail.conf, taking the phone off hook will cause a
-; stutter dialtone instead of a normal one.
-;
-; If a mailbox is specified *with* a voicemail context, the same will result
-; if voicemail received in mailbox in the specified voicemail context.
-;
-; for default voicemail context, the example below is fine:
-;
-;mailbox=1234
+; Stutter dialtone support: If voicemail is received in the mailbox then
+; taking the phone off hook will cause a stutter dialtone instead of a
+; normal one.
;
-; for any other voicemail context, the following will produce the stutter tone:
+; Note: app_voicemail mailboxes must be in the form of mailbox@context.
;
;mailbox=1234@context
;
diff --git a/configs/iax.conf.sample b/configs/iax.conf.sample
index b74adc4b0..a9841f0da 100644
--- a/configs/iax.conf.sample
+++ b/configs/iax.conf.sample
@@ -623,6 +623,7 @@ description=Demo System At Digium ; Description of this peer, as listed by
;[dynamichost]
;host=dynamic
;secret=mysecret
+; Note: app_voicemail mailboxes must be in the form of mailbox@context.
;mailbox=1234 ; Notify about mailbox 1234
;inkeys=key1:key2
;peercontext=local ; Default context to request for calls to peer
diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample
index 31db6de92..fa3965260 100644
--- a/configs/sip.conf.sample
+++ b/configs/sip.conf.sample
@@ -803,7 +803,8 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
;mwi => 1234:password:authuser@myauthprovider.com/1234
;mwi => 1234:password:authuser@myauthportprovider.com:6969/1234
;
-; MWI received will be stored in the 1234 mailbox of the SIP_Remote context. It can be used by other phones by following the below:
+; MWI received will be stored in the 1234 mailbox of the SIP_Remote context.
+; It can be used by other phones by following the below:
; mailbox=1234@SIP_Remote
;----------------------------------------- NAT SUPPORT ------------------------
;
@@ -1231,6 +1232,7 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; videosupport
; maxcallbitrate
; rfc2833compensate
+; Note: app_voicemail mailboxes must be in the form of mailbox@context.
; mailbox
; session-timers
; session-expires
@@ -1450,7 +1452,7 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
;host=dynamic ; This peer register with us
;dtmfmode=inband ; Choices are inband, rfc2833, or info
;defaultip=192.168.0.59 ; IP used until peer registers
-;mailbox=1234@context,2345 ; Mailbox(-es) for message waiting indicator
+;mailbox=1234@context,2345@context ; Mailbox(-es) for message waiting indicator
;subscribemwi=yes ; Only send notifications if this phone
; subscribes for mailbox notification
;vmexten=voicemail ; dialplan extension to reach mailbox
diff --git a/configs/skinny.conf.sample b/configs/skinny.conf.sample
index 60dc87305..be88dc230 100644
--- a/configs/skinny.conf.sample
+++ b/configs/skinny.conf.sample
@@ -108,6 +108,7 @@ keepalive=120
;[100]
;nat=yes
;callerid="Customer Support" <810-234-1212>
+; Note: app_voicemail mailboxes must be in the form of mailbox@context.
;mailbox=100
;vmexten=8500 ; Device level voicemailmain pilot number
;regexten=100
diff --git a/configs/voicemail.conf.sample b/configs/voicemail.conf.sample
index b776fd60d..974e0225d 100644
--- a/configs/voicemail.conf.sample
+++ b/configs/voicemail.conf.sample
@@ -2,12 +2,20 @@
; Voicemail Configuration
;
+; ********* NOTICE ************************************************************
;
; NOTE: Asterisk has to edit this file to change a user's password. This does
; not currently work with the "#include <file>" directive for Asterisk
; configuration files, nor when using realtime static configuration.
; Do not use them with this configuration file.
;
+; NOTE: Mailboxes defined by app_voicemail MUST be referenced by the rest
+; of the system as mailbox@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.
+;
+; ********* NOTICE ************************************************************
[general]
; Formats for writing Voicemail. Note that when using IMAP storage for
@@ -410,6 +418,7 @@ european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM
[default]
+; Note: The rest of the system must reference mailboxes defined here as mailbox@default.
1234 => 4242,Example Mailbox,root@localhost
;4200 => 9855,Mark Spencer,markster@linux-support.net,mypager@digium.com,attach=no|serveremail=myaddy@digium.com|tz=central|maxmsg=10
diff --git a/funcs/func_vmcount.c b/funcs/func_vmcount.c
index c4d80d499..6c98e72f6 100644
--- a/funcs/func_vmcount.c
+++ b/funcs/func_vmcount.c
@@ -49,27 +49,21 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
Count the voicemails in a specified mailbox.
</synopsis>
<syntax>
- <parameter name="vmbox" required="true" argsep="@">
- <argument name="vmbox" required="true" />
- <argument name="context" required="false">
- <para>If not specified, defaults to <literal>default</literal>.</para>
- </argument>
- </parameter>
+ <parameter name="vmbox" required="true" />
<parameter name="folder" required="false">
<para>If not specified, defaults to <literal>INBOX</literal></para>
</parameter>
</syntax>
<description>
<para>Count the number of voicemails in a specified mailbox, you could also specify
- the <replaceable>context</replaceable> and the mailbox <replaceable>folder</replaceable>.</para>
- <para>Example: <literal>exten => s,1,Set(foo=${VMCOUNT(125)})</literal></para>
+ the mailbox <replaceable>folder</replaceable>.</para>
+ <para>Example: <literal>exten => s,1,Set(foo=${VMCOUNT(125@default)})</literal></para>
</description>
</function>
***/
static int acf_vmcount_exec(struct ast_channel *chan, const char *cmd, char *argsstr, char *buf, size_t len)
{
- char *context;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(vmbox);
AST_APP_ARG(folder);
@@ -82,18 +76,15 @@ static int acf_vmcount_exec(struct ast_channel *chan, const char *cmd, char *arg
AST_STANDARD_APP_ARGS(args, argsstr);
- if (strchr(args.vmbox, '@')) {
- context = args.vmbox;
- args.vmbox = strsep(&context, "@");
- } else {
- context = "default";
+ if (ast_strlen_zero(args.vmbox)) {
+ return -1;
}
if (ast_strlen_zero(args.folder)) {
args.folder = "INBOX";
}
- snprintf(buf, len, "%d", ast_app_messagecount(context, args.vmbox, args.folder));
+ snprintf(buf, len, "%d", ast_app_messagecount(args.vmbox, args.folder));
return 0;
}
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 623f0884e..a998ed86d 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -382,16 +382,14 @@ typedef int (ast_inboxcount2_fn)(const char *mailboxes, int *urgentmsgs, int *ne
/*!
* \brief Gets the number of messages that exist in a mailbox folder.
*
- * \param context The context part of user@context. Uses 'default' if not provided.
- * \param user The user part of user@context.
+ * \param mailbox_id The mailbox name.
* \param folder The folder to look in. Default is INBOX if not provided.
*
- * \note If requesting INBOX then the returned count is INBOX +
- * Urgent.
+ * \note If requesting INBOX then the returned count is INBOX + Urgent.
*
- * \return The number of messages in this mailbox folder (zero or more).
+ * \return The number of messages in the mailbox folder (zero or more).
*/
-typedef int (ast_messagecount_fn)(const char *context, const char *user, const char *folder);
+typedef int (ast_messagecount_fn)(const char *mailbox_id, const char *folder);
/*!
* \brief Play a recorded user name for the mailbox.
@@ -569,7 +567,7 @@ struct ast_vm_functions {
/*!
* \brief Determine if a voicemail provider is registered.
- * \since 13.0.0
+ * \since 12.0.0
*
* \retval 0 if no privider registered.
* \retval 1 if a privider is registered.
@@ -666,14 +664,16 @@ int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, in
int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *context);
/*!
- * \brief Check number of messages in a given context, mailbox, and folder
- * \since 1.4
- * \param[in] context Mailbox context
- * \param[in] mailbox Mailbox number
- * \param[in] folder Mailbox folder
- * \return Number of messages in the given context, mailbox, and folder. If folder is NULL, folder "INBOX" is assumed. If folder is "INBOX", includes number of messages in the "Urgent" folder.
+ * \brief Get the number of messages in a given mailbox folder
+ *
+ * \param[in] mailbox_id Mailbox name
+ * \param[in] folder The folder to look in. Default is INBOX if not provided.
+ *
+ * \note If requesting INBOX then the returned count is INBOX + Urgent.
+ *
+ * \return The number of messages in the mailbox folder (zero or more).
*/
-int ast_app_messagecount(const char *context, const char *mailbox, const char *folder);
+int ast_app_messagecount(const char *mailbox_id, const char *folder);
/*!
* \brief Return name of folder, given an id
@@ -1342,7 +1342,7 @@ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen def
* \since 12
* \brief Publish a MWI state update via stasis
* \param[in] mailbox The number identifying this mailbox
- * \param[in] context The context this mailbox resides in
+ * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
* \param[in] new_msgs The number of new messages in this mailbox
* \param[in] old_msgs The number of old messages in this mailbox
* \retval 0 Success
@@ -1356,7 +1356,7 @@ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen def
* \since 12
* \brief Publish a MWI state update associated with some channel
* \param[in] mailbox The number identifying this mailbox
- * \param[in] context The context this mailbox resides in
+ * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
* \param[in] new_msgs The number of new messages in this mailbox
* \param[in] old_msgs The number of old messages in this mailbox
* \param[in] channel_id A unique identifier for a channel associated with this
@@ -1372,7 +1372,7 @@ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen def
* \since 12
* \brief Publish a MWI state update via stasis with all parameters
* \param[in] mailbox The number identifying this mailbox
- * \param[in] context The context this mailbox resides in
+ * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
* \param[in] new_msgs The number of new messages in this mailbox
* \param[in] old_msgs The number of old messages in this mailbox
* \param[in] channel_id A unique identifier for a channel associated with this
@@ -1399,9 +1399,7 @@ int ast_publish_mwi_state_full(
*/
struct ast_mwi_state {
AST_DECLARE_STRING_FIELDS(
- AST_STRING_FIELD(uniqueid); /*!< Unique identifier for this mailbox/context */
- AST_STRING_FIELD(mailbox); /*!< Mailbox for this event */
- AST_STRING_FIELD(context); /*!< Context that this mailbox belongs to */
+ AST_STRING_FIELD(uniqueid); /*!< Unique identifier for this mailbox */
);
int new_msgs; /*!< The current number of new messages for this mailbox */
int old_msgs; /*!< The current number of old messages for this mailbox */
diff --git a/main/app.c b/main/app.c
index 579984dab..6e1a176c6 100644
--- a/main/app.c
+++ b/main/app.c
@@ -587,11 +587,11 @@ int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *c
return res;
}
-int ast_app_messagecount(const char *context, const char *mailbox, const char *folder)
+int ast_app_messagecount(const char *mailbox_id, const char *folder)
{
int res = 0;
- VM_API_CALL(res, messagecount, (context, mailbox, folder));
+ VM_API_CALL(res, messagecount, (mailbox_id, folder));
return res;
}
@@ -2800,10 +2800,8 @@ struct stasis_topic *ast_mwi_topic(const char *uniqueid)
struct ast_mwi_state *ast_mwi_create(const char *mailbox, const char *context)
{
RAII_VAR(struct ast_mwi_state *, mwi_state, NULL, ao2_cleanup);
- struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
ast_assert(!ast_strlen_zero(mailbox));
- ast_assert(!ast_strlen_zero(context));
mwi_state = ao2_alloc(sizeof(*mwi_state), mwi_state_dtor);
if (!mwi_state) {
@@ -2813,10 +2811,11 @@ struct ast_mwi_state *ast_mwi_create(const char *mailbox, const char *context)
if (ast_string_field_init(mwi_state, 256)) {
return NULL;
}
- ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
- ast_string_field_set(mwi_state, uniqueid, ast_str_buffer(uniqueid));
- ast_string_field_set(mwi_state, mailbox, mailbox);
- ast_string_field_set(mwi_state, context, context);
+ if (!ast_strlen_zero(context)) {
+ ast_string_field_build(mwi_state, uniqueid, "%s@%s", mailbox, context);
+ } else {
+ ast_string_field_set(mwi_state, uniqueid, mailbox);
+ }
ao2_ref(mwi_state, +1);
return mwi_state;
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 798ff4b5a..41dd70c02 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -370,7 +370,7 @@ static int aji_delete_node_list(void *data, ikspak* pak);
static void aji_pubsub_purge_nodes(struct aji_client *client,
const char* collection_name);
static void aji_publish_mwi(struct aji_client *client, const char *mailbox,
- const char *context, const char *oldmsgs, const char *newmsgs);
+ const char *oldmsgs, const char *newmsgs);
static void aji_devstate_cb(void *data, struct stasis_subscription *sub, struct stasis_message *msg);
static void aji_mwi_cb(void *data, struct stasis_subscription *sub, struct stasis_message *msg);
static iks* aji_build_publish_skeleton(struct aji_client *client, const char *node,
@@ -3237,8 +3237,6 @@ int ast_aji_disconnect(struct aji_client *client)
*/
static void aji_mwi_cb(void *data, struct stasis_subscription *sub, struct stasis_message *msg)
{
- const char *mailbox;
- const char *context;
char oldmsgs[10];
char newmsgs[10];
struct aji_client *client = data;
@@ -3255,13 +3253,9 @@ static void aji_mwi_cb(void *data, struct stasis_subscription *sub, struct stasi
return;
}
- mailbox = mwi_state->mailbox;
- context = mwi_state->context;
- snprintf(oldmsgs, sizeof(oldmsgs), "%d",
- mwi_state->old_msgs);
- snprintf(newmsgs, sizeof(newmsgs), "%d",
- mwi_state->new_msgs);
- aji_publish_mwi(client, mailbox, context, oldmsgs, newmsgs);
+ snprintf(oldmsgs, sizeof(oldmsgs), "%d", mwi_state->old_msgs);
+ snprintf(newmsgs, sizeof(newmsgs), "%d", mwi_state->new_msgs);
+ aji_publish_mwi(client, mwi_state->uniqueid, oldmsgs, newmsgs);
}
/*!
* \brief Callback function for device state events
@@ -3514,20 +3508,18 @@ static void aji_publish_device_state(struct aji_client *client, const char *devi
/*!
* \brief Publish MWI to a PubSub node
* \param client the configured XMPP client we use to connect to a XMPP server
- * \param mailbox The mailbox
- * \param context The context
+ * \param mailbox The mailbox identifier
* \param oldmsgs Old messages
* \param newmsgs New messages
* \return void
*/
static void aji_publish_mwi(struct aji_client *client, const char *mailbox,
- const char *context, const char *oldmsgs, const char *newmsgs)
+ const char *oldmsgs, const char *newmsgs)
{
- char full_mailbox[AST_MAX_EXTENSION+AST_MAX_CONTEXT];
char eid_str[20];
iks *mailbox_node, *request;
- snprintf(full_mailbox, sizeof(full_mailbox), "%s@%s", mailbox, context);
- request = aji_build_publish_skeleton(client, full_mailbox, "message_waiting", 1);
+
+ request = aji_build_publish_skeleton(client, mailbox, "message_waiting", 1);
ast_eid_to_str(eid_str, sizeof(eid_str), &ast_eid_default);
mailbox_node = iks_insert(request, "mailbox");
iks_insert_attrib(mailbox_node, "xmlns", "http://asterisk.org");
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index 34392fd5d..c067fdec4 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -1245,21 +1245,20 @@ static void xmpp_pubsub_create_leaf(struct ast_xmpp_client *client, const char *
/*!
* \brief Publish MWI to a PubSub node
* \param client the configured XMPP client we use to connect to a XMPP server
- * \param mailbox The Mailbox
- * \param context The Context
+ * \param mailbox The mailbox identifier
* \param oldmsgs Old messages
* \param newmsgs New Messages
* \return void
*/
static void xmpp_pubsub_publish_mwi(struct ast_xmpp_client *client, const char *mailbox,
- const char *context, const char *oldmsgs, const char *newmsgs)
+ const char *oldmsgs, const char *newmsgs)
{
- char full_mailbox[AST_MAX_EXTENSION+AST_MAX_CONTEXT], eid_str[20];
+ char eid_str[20];
iks *mailbox_node, *request;
- snprintf(full_mailbox, sizeof(full_mailbox), "%s@%s", mailbox, context);
-
- if (!(request = xmpp_pubsub_build_publish_skeleton(client, full_mailbox, "message_waiting", AST_DEVSTATE_CACHABLE))) {
+ request = xmpp_pubsub_build_publish_skeleton(client, mailbox, "message_waiting",
+ AST_DEVSTATE_CACHABLE);
+ if (!request) {
return;
}
@@ -1321,7 +1320,6 @@ static void xmpp_pubsub_publish_device_state(struct ast_xmpp_client *client, con
static void xmpp_pubsub_mwi_cb(void *data, struct stasis_subscription *sub, struct stasis_message *msg)
{
struct ast_xmpp_client *client = data;
- const char *mailbox, *context;
char oldmsgs[10], newmsgs[10];
struct ast_mwi_state *mwi_state;
@@ -1336,13 +1334,9 @@ static void xmpp_pubsub_mwi_cb(void *data, struct stasis_subscription *sub, stru
return;
}
- mailbox = mwi_state->mailbox;
- context = mwi_state->context;
- snprintf(oldmsgs, sizeof(oldmsgs), "%d",
- mwi_state->old_msgs);
- snprintf(newmsgs, sizeof(newmsgs), "%d",
- mwi_state->new_msgs);
- xmpp_pubsub_publish_mwi(client, mailbox, context, oldmsgs, newmsgs);
+ snprintf(oldmsgs, sizeof(oldmsgs), "%d", mwi_state->old_msgs);
+ snprintf(newmsgs, sizeof(newmsgs), "%d", mwi_state->new_msgs);
+ xmpp_pubsub_publish_mwi(client, mwi_state->uniqueid, oldmsgs, newmsgs);
}
/*!