summaryrefslogtreecommitdiff
path: root/channels/chan_mgcp.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2013-12-19 16:52:43 +0000
committerRichard Mudgett <rmudgett@digium.com>2013-12-19 16:52:43 +0000
commite4803bbd9eba2705615e2495de0ed0c35051dd45 (patch)
treefe8787ab22e2c694e93c4ec2757e3d8ca4c681dc /channels/chan_mgcp.c
parent2882c5f9f1f1c81a5a2bae35825d81070bb10164 (diff)
Voicemail: Remove mailbox identifier format (box@context) assumptions in the system.
This change is in preparation for external MWI support. Removed code from the system for normal mailbox handling that appends @default to the mailbox identifier if it does not have a context. The only exception is the legacy hasvoicemail users.conf option. The legacy option will only work for app_voicemail mailboxes. The system cannot make any assumptions about the format of the mailbox identifer used by app_voicemail. chan_sip and chan_dahdi/sig_pri had the most changes because they both tried to interpret the mailbox identifier. chan_sip just stored and compared the two components. chan_dahdi actually used the box information. The ISDN MWI support configuration options had to be reworked because chan_dahdi was parsing the box@context format to get the box number. As a result the mwi_vm_boxes chan_dahdi.conf option was added and is documented in the chan_dahdi.conf.sample file. Review: https://reviewboard.asterisk.org/r/3072/ ........ Merged revisions 404348 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_mgcp.c')
-rw-r--r--channels/chan_mgcp.c37
1 files changed, 12 insertions, 25 deletions
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);
}