[asterisk-commits] rmudgett: branch rmudgett/external_mwi r403688 - in /team/rmudgett/external_m...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 11 15:14:10 CST 2013
Author: rmudgett
Date: Wed Dec 11 15:14:04 2013
New Revision: 403688
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403688
Log:
Initial elimination of the user at context mailbox format leaking out of app_voicemail.
* Made core not depend upon user at context mailbox format.
* Made channel drivers not depend upon user at context mailbox format. The
channel drivers just use the given mailbox string as is.
* The chan_dahdi.conf mwi_mailboxes format now associates the internal
mailbox name with a mailbox number to send out on the span.
* The chan_dahdi.conf mwimonitornotify shell script is now passed the
internal mailbox name instead of just the user part of user at context
format.
* Made channel drivers not append @default to a mailbox that does not have
a context. The exception to this is the users.conf hasvoicemail option.
The option is legacy and could only work with app_voicemail anyway. The
mailbox option overrides the hasvoicemail option anyway.
* Made the external MWI code not deal with context at all.
Modified:
team/rmudgett/external_mwi/UPGRADE.txt
team/rmudgett/external_mwi/channels/chan_dahdi.c
team/rmudgett/external_mwi/channels/chan_h323.c
team/rmudgett/external_mwi/channels/chan_iax2.c
team/rmudgett/external_mwi/channels/chan_mgcp.c
team/rmudgett/external_mwi/channels/chan_sip.c
team/rmudgett/external_mwi/channels/chan_skinny.c
team/rmudgett/external_mwi/channels/chan_unistim.c
team/rmudgett/external_mwi/channels/sig_pri.c
team/rmudgett/external_mwi/channels/sig_pri.h
team/rmudgett/external_mwi/channels/sip/include/sip.h
team/rmudgett/external_mwi/configs/chan_dahdi.conf.sample
team/rmudgett/external_mwi/configs/iax.conf.sample
team/rmudgett/external_mwi/configs/sip.conf.sample
team/rmudgett/external_mwi/configs/skinny.conf.sample
team/rmudgett/external_mwi/configs/voicemail.conf.sample
team/rmudgett/external_mwi/funcs/func_vmcount.c
team/rmudgett/external_mwi/include/asterisk/app.h
team/rmudgett/external_mwi/include/asterisk/res_mwi_external.h
team/rmudgett/external_mwi/main/app.c
team/rmudgett/external_mwi/res/res_jabber.c
team/rmudgett/external_mwi/res/res_mwi_external.c
team/rmudgett/external_mwi/res/res_mwi_external_ami.c
team/rmudgett/external_mwi/res/res_xmpp.c
Modified: team/rmudgett/external_mwi/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/UPGRADE.txt?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/UPGRADE.txt (original)
+++ team/rmudgett/external_mwi/UPGRADE.txt Wed Dec 11 15:14:04 2013
@@ -21,6 +21,10 @@
=== UPGRADE-12.txt -- Upgrade info for 11 to 12
===========================================================
+VoiceMail:
+ - Mailboxes defined by app_voicemail must be referenced by the rest of the
+ system as mailbox at context. app_voicemail no longer assumes @default for
+ mailbox identifiers that do not specify a context.
===========================================================
Modified: team/rmudgett/external_mwi/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_dahdi.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_dahdi.c (original)
+++ team/rmudgett/external_mwi/channels/chan_dahdi.c Wed Dec 11 15:14:04 2013
@@ -3127,9 +3127,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
@@ -3142,20 +3142,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);
}
@@ -4833,19 +4829,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;
@@ -12426,18 +12412,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);
}
@@ -16989,7 +16966,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);
Modified: team/rmudgett/external_mwi/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_h323.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_h323.c (original)
+++ team/rmudgett/external_mwi/channels/chan_h323.c Wed Dec 11 15:14:04 2013
@@ -1627,7 +1627,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: team/rmudgett/external_mwi/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_iax2.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_iax2.c (original)
+++ team/rmudgett/external_mwi/channels/chan_iax2.c Wed Dec 11 15:14:04 2013
@@ -8925,19 +8925,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;
@@ -12549,7 +12539,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);
@@ -12758,19 +12756,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: team/rmudgett/external_mwi/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_mgcp.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_mgcp.c (original)
+++ team/rmudgett/external_mwi/channels/chan_mgcp.c Wed Dec 11 15:14:04 2013
@@ -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;
@@ -3991,7 +3980,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;
@@ -4135,7 +4123,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);
@@ -4187,18 +4183,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: team/rmudgett/external_mwi/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_sip.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_sip.c (original)
+++ team/rmudgett/external_mwi/channels/chan_sip.c Wed Dec 11 15:14:04 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[80];
+
+ 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);
@@ -34348,8 +34345,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: team/rmudgett/external_mwi/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_skinny.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_skinny.c (original)
+++ team/rmudgett/external_mwi/channels/chan_skinny.c Wed Dec 11 15:14:04 2013
@@ -7979,7 +7979,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;
}
@@ -8259,20 +8268,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: team/rmudgett/external_mwi/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/chan_unistim.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/chan_unistim.c (original)
+++ team/rmudgett/external_mwi/channels/chan_unistim.c Wed Dec 11 15:14:04 2013
@@ -5502,27 +5502,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: team/rmudgett/external_mwi/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/sig_pri.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/sig_pri.c (original)
+++ team/rmudgett/external_mwi/channels/sig_pri.c Wed Dec 11 15:14:04 2013
@@ -8845,19 +8845,19 @@
*
* \param pri PRI span control structure.
* \param vm_number Voicemail controlling number (NULL if not present).
+ * \param mbox_id Mailbox id
* \param mbox_number Mailbox number
- * \param mbox_context Mailbox context
* \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 *mbox_id, const char *mbox_number, 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",
+ mbox_id, mbox_number, S_OR(vm_number, "<not-present>"), num_messages);
memset(&mailbox, 0, sizeof(mailbox));
mailbox.number.valid = 1;
@@ -8900,9 +8900,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;
@@ -8911,27 +8908,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) {
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].uniqueid, pri->mbox[idx].number, mwi_state->new_msgs);
break;
}
}
@@ -8951,7 +8938,6 @@
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) {
@@ -8961,18 +8947,16 @@
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].uniqueid, pri->mbox[idx].number, mwi_state->new_msgs);
}
}
#endif /* defined(HAVE_PRI_MWI) */
@@ -9057,8 +9041,6 @@
#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)
@@ -9099,57 +9081,55 @@
/*
* Split the mwi_mailboxes configuration string into the mbox[]:
- * mailbox_number[@context]{,mailbox_number[@context]}
+ * mailbox_number/mailbox_id{,mailbox_number/mailbox_id}
*/
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) {
+ mbox_id = strsep(&saveptr, ",");
+ if (!mbox_id) {
/* No more defined mailboxes. */
break;
}
+ mbox_id = ast_strip(mbox_id);
+
/* Split the mailbox_number and context */
- mbox_context = strchr(mbox_number, '@');
- if (mbox_context) {
- *mbox_context++ = '\0';
- mbox_context = ast_strip(mbox_context);
- }
+ mbox_number = strsep(&mbox_id, "/");
+ if (!mbox_id) {
+ /* There is no mailbox id. Skip it. */
+ ast_log(LOG_WARNING, "%s span %d invalid MWI mailbox reference '%s'.",
+ sig_pri_cc_type_name, pri->span, mbox_number);
+ continue;
+ }
+
mbox_number = ast_strip(mbox_number);
- if (ast_strlen_zero(mbox_number)) {
- /* There is no mailbox number. Skip it. */
+ mbox_id = ast_strip(mbox_id);
+ if (ast_strlen_zero(mbox_number) || ast_strlen_zero(mbox_id)) {
+ /* There is no mailbox id or number. Skip it. */
+ ast_log(LOG_WARNING, "%s span %d invalid MWI mailbox reference '%s/%s'.",
+ sig_pri_cc_type_name, pri->span, mbox_number, mbox_id);
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));
+ pri->mbox[i].uniqueid = mbox_id;
+
+ 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).",
+ sig_pri_cc_type_name, pri->span, mbox_number, 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, mbox_number, mbox_id);
}
#endif /* defined(HAVE_PRI_MWI_V2) */
}
Modified: team/rmudgett/external_mwi/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/sig_pri.h?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/sig_pri.h (original)
+++ team/rmudgett/external_mwi/channels/sig_pri.h Wed Dec 11 15:14:04 2013
@@ -396,13 +396,20 @@
#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 * (box + '/' + 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_MBOX_NUMBER_LEN + 1 + SIG_PRI_MAX_MWI_VM_MAILBOX + 1))
struct sig_pri_mbox {
/*!
@@ -410,10 +417,10 @@
* \note NULL if mailbox not configured.
*/
struct stasis_subscription *sub;
- /*! \brief Mailbox number */
+ /*! \brief Mailbox number sent to span. */
const char *number;
- /*! \brief Mailbox context. */
- const char *context;
+ /*! \brief Mailbox uniqueid. */
+ const char *uniqueid;
/*! \brief Voicemail controlling number. */
const char *vm_number;
};
@@ -506,7 +513,7 @@
/*!
* \brief Comma separated list of mailboxes to indicate MWI.
* \note Empty if disabled.
- * \note Format: mailbox_number[@context]{,mailbox_number[@context]}
+ * \note Format: box/vm-box at context{,box/vm-box at context}
* \note String is split apart when span is started.
*/
char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
Modified: team/rmudgett/external_mwi/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/channels/sip/include/sip.h?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/channels/sip/include/sip.h (original)
+++ team/rmudgett/external_mwi/channels/sip/include/sip.h Wed Dec 11 15:14:04 2013
@@ -1232,7 +1232,7 @@
/*!
* \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 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)
Modified: team/rmudgett/external_mwi/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/configs/chan_dahdi.conf.sample?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/configs/chan_dahdi.conf.sample (original)
+++ team/rmudgett/external_mwi/configs/chan_dahdi.conf.sample Wed Dec 11 15:14:04 2013
@@ -617,8 +617,11 @@
;
; 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 at context.
+;
+; /usr/local/bin/dahdinotify.sh 501 at mailboxes 1
;
;mwimonitornotify=/usr/local/bin/dahdinotify.sh
;
@@ -655,8 +658,15 @@
; 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=mailbox_association{,mailbox_association}
+; A mailbox_association is of the form:
+; mailbox_association=box/vm-mailbox
+; box = ISDN mailbox number sent over the span.
+; vm-mailbox = Internal voicemail mailbox identifier (app_voicemail mailbox at context)
+; Note: app_voicemail mailboxes must be in the form of mailbox at context.
+;mwi_mailboxes=501/501 at mailboxes,502/502 at mailboxes
+
; Configure the ISDN span voicemail numbers for MWI mailboxes. What number
; to call for a user to retrieve voicemail messages.
;
@@ -737,19 +747,11 @@
;
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
-;
-; for any other voicemail context, the following will produce the stutter tone:
+; 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.
+;
+; Note: app_voicemail mailboxes must be in the form of mailbox at context.
;
;mailbox=1234 at context
;
Modified: team/rmudgett/external_mwi/configs/iax.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/configs/iax.conf.sample?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/configs/iax.conf.sample (original)
+++ team/rmudgett/external_mwi/configs/iax.conf.sample Wed Dec 11 15:14:04 2013
@@ -623,6 +623,7 @@
;[dynamichost]
;host=dynamic
;secret=mysecret
+; Note: app_voicemail mailboxes must be in the form of mailbox at context.
;mailbox=1234 ; Notify about mailbox 1234
;inkeys=key1:key2
;peercontext=local ; Default context to request for calls to peer
Modified: team/rmudgett/external_mwi/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/configs/sip.conf.sample?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/configs/sip.conf.sample (original)
+++ team/rmudgett/external_mwi/configs/sip.conf.sample Wed Dec 11 15:14:04 2013
@@ -803,7 +803,8 @@
;mwi => 1234:password:authuser at myauthprovider.com/1234
;mwi => 1234:password:authuser at 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 at SIP_Remote
;----------------------------------------- NAT SUPPORT ------------------------
;
@@ -1231,6 +1232,7 @@
; videosupport
; maxcallbitrate
; rfc2833compensate
+; Note: app_voicemail mailboxes must be in the form of mailbox at context.
; mailbox
; session-timers
; session-expires
@@ -1450,7 +1452,7 @@
;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 at context,2345 ; Mailbox(-es) for message waiting indicator
+;mailbox=1234 at context,2345 at 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
Modified: team/rmudgett/external_mwi/configs/skinny.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/configs/skinny.conf.sample?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/configs/skinny.conf.sample (original)
+++ team/rmudgett/external_mwi/configs/skinny.conf.sample Wed Dec 11 15:14:04 2013
@@ -108,6 +108,7 @@
;[100]
;nat=yes
;callerid="Customer Support" <810-234-1212>
+; Note: app_voicemail mailboxes must be in the form of mailbox at context.
;mailbox=100
;vmexten=8500 ; Device level voicemailmain pilot number
;regexten=100
Modified: team/rmudgett/external_mwi/configs/voicemail.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/configs/voicemail.conf.sample?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/configs/voicemail.conf.sample (original)
+++ team/rmudgett/external_mwi/configs/voicemail.conf.sample Wed Dec 11 15:14:04 2013
@@ -227,6 +227,10 @@
; received, to the given mailbox. If pager is specified, a message will be
; sent there as well. If the password is prefixed by '-', then it is
; considered to be unchangeable.
+;
+; Note: The rest of the system identifies voicemail mailboxes as mailbox at context.
+; Voicemail will no longer assume @default for a mailbox identifier presented by
+; another module to voicemail without the @context part.
;
; Advanced options example is extension 4069
; NOTE: All options can be expressed globally in the general section, and
@@ -410,6 +414,7 @@
[default]
+; Note: The rest of the system must reference mailboxes defined here as mailbox at default.
1234 => 4242,Example Mailbox,root at localhost
;4200 => 9855,Mark Spencer,markster at linux-support.net,mypager at digium.com,attach=no|serveremail=myaddy at digium.com|tz=central|maxmsg=10
Modified: team/rmudgett/external_mwi/funcs/func_vmcount.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/external_mwi/funcs/func_vmcount.c?view=diff&rev=403688&r1=403687&r2=403688
==============================================================================
--- team/rmudgett/external_mwi/funcs/func_vmcount.c (original)
+++ team/rmudgett/external_mwi/funcs/func_vmcount.c Wed Dec 11 15:14:04 2013
@@ -93,6 +93,7 @@
args.folder = "INBOX";
}
+/* BUGBUG likely need to fix this to just pass a mailbox string and separate user and context */
snprintf(buf, len, "%d", ast_app_messagecount(context, args.vmbox, args.folder));
return 0;
Modified: team/rmudgett/external_mwi/include/asterisk/app.h
[... 777 lines stripped ...]
More information about the asterisk-commits
mailing list