summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-08-09 17:07:36 +0000
committerRussell Bryant <russell@russellbryant.com>2007-08-09 17:07:36 +0000
commit9d1acad76b611cc2400d00da0b60fd75d07d6263 (patch)
tree39e19a7ab54bc20ed756d9df396b5c0916c5c1ff
parenteb649f932b46a10f8ec26107462183ad12759691 (diff)
Fix a problem that I had introduced into MWI handling. I had ignored
the mailbox context. Now, all related MWI event dealings pay attention to the context as well. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@78747 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--apps/app_voicemail.c11
-rw-r--r--channels/chan_iax2.c17
-rw-r--r--channels/chan_mgcp.c17
-rw-r--r--channels/chan_sip.c24
-rw-r--r--channels/chan_zap.c17
-rw-r--r--include/asterisk/event_defs.h6
6 files changed, 79 insertions, 13 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index ae2fa2f94..aba334717 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3997,15 +3997,17 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
static void queue_mwi_event(const char *mbox, int new, int old)
{
struct ast_event *event;
- char *mailbox;
+ char *mailbox, *context;
/* Strip off @default */
- mailbox = ast_strdupa(mbox);
- if (strstr(mailbox, "@default"))
- mailbox = strsep(&mailbox, "@");
+ context = mailbox = ast_strdupa(mbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
if (!(event = ast_event_new(AST_EVENT_MWI,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, new,
AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old,
AST_EVENT_IE_END))) {
@@ -4014,6 +4016,7 @@ static void queue_mwi_event(const char *mbox, int new, int old)
ast_event_queue_and_cache(event,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR,
AST_EVENT_IE_END);
}
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 5137d2af1..30c79e47c 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -6054,9 +6054,16 @@ static int update_registry(const char *name, struct sockaddr_in *sin, int callno
if (!ast_strlen_zero(p->mailbox)) {
struct ast_event *event;
int new, old;
+ char *mailbox, *context;
+
+ context = mailbox = ast_strdupa(p->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, p->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
@@ -9315,8 +9322,14 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st
ast_free_ha(oldha);
if (!ast_strlen_zero(peer->mailbox)) {
+ char *mailbox, *context;
+ mailbox = ast_strdupa(peer->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, NULL,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_END);
}
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 198c964ad..f5e38ddf1 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -468,9 +468,16 @@ static int has_voicemail(struct mgcp_endpoint *p)
{
int new_msgs;
struct ast_event *event;
+ char *mailbox, *context;
+
+ context = mailbox = ast_strdupa(p->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, p->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
@@ -3692,8 +3699,14 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_copy_string(e->musicclass, musicclass, sizeof(e->musicclass));
ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
if (!ast_strlen_zero(e->mailbox)) {
+ char *mailbox, *context;
+ context = mailbox = ast_strdupa(e->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
e->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, NULL,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, e->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 8800a60ba..ab875b1a9 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -15756,8 +15756,14 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
p->subscribed = MWI_NOTIFICATION;
if (ast_test_flag(&authpeer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY)) {
+ char *mailbox, *context;
+ context = mailbox = ast_strdupa(authpeer->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
authpeer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, authpeer,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, authpeer->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_END);
}
if (authpeer->mwipvt && authpeer->mwipvt != p) /* Destroy old PVT if this is a new one */
@@ -16244,9 +16250,15 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer, const struct ast_event *e
return 0;
if (!event) {
+ char *mailbox, *context = NULL;
/* Check the event cache for the mailbox info */
+ context = mailbox = ast_strdupa(peer->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
event = cache_event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
@@ -17488,8 +17500,14 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
* subscribe to it now. */
if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY) &&
!ast_strlen_zero(peer->mailbox)) {
+ char *mailbox, *context;
+ context = mailbox = ast_strdupa(peer->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, peer,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_END);
/* Send MWI from the event cache only. This is so we can send initial
* MWI if app_voicemail got loaded before chan_sip. If it is the other
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 1426f456a..4152f0e19 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -1850,9 +1850,16 @@ static int has_voicemail(struct zt_pvt *p)
{
int new_msgs;
struct ast_event *event;
+ char *mailbox, *context;
+
+ mailbox = context = ast_strdupa(p->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, p->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
@@ -7850,8 +7857,14 @@ static struct zt_pvt *mkintf(int channel, struct zt_chan_conf conf, struct zt_pr
ast_copy_string(tmp->cid_name, conf.chan.cid_name, sizeof(tmp->cid_name));
ast_copy_string(tmp->mailbox, conf.chan.mailbox, sizeof(tmp->mailbox));
if (!ast_strlen_zero(tmp->mailbox)) {
+ char *mailbox, *context;
+ mailbox = context = ast_strdupa(tmp->mailbox);
+ strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = "default";
tmp->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, NULL,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, tmp->mailbox,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
}
diff --git a/include/asterisk/event_defs.h b/include/asterisk/event_defs.h
index 2627bae8d..9aadaebf6 100644
--- a/include/asterisk/event_defs.h
+++ b/include/asterisk/event_defs.h
@@ -103,6 +103,12 @@ enum ast_event_ie_type {
* this IE is a part of.
*/
AST_EVENT_IE_STATE = 0x08,
+ /*!
+ * \brief Context IE
+ * Used by AST_EVENT_MWI
+ * Payload type: str
+ */
+ AST_EVENT_IE_CONTEXT = 0x09,
};
/*!