Fix a problem that I had introduced into MWI handling. I had ignored
authorRussell Bryant <russell@russellbryant.com>
Thu, 9 Aug 2007 17:07:36 +0000 (17:07 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 9 Aug 2007 17:07:36 +0000 (17:07 +0000)
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

apps/app_voicemail.c
channels/chan_iax2.c
channels/chan_mgcp.c
channels/chan_sip.c
channels/chan_zap.c
include/asterisk/event_defs.h

index ae2fa2f..aba3347 100644 (file)
@@ -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);
 }
 
index 5137d2a..30c79e4 100644 (file)
@@ -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);
        }
 
index 198c964..f5e38dd 100644 (file)
@@ -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);
                                        }
index 8800a60..ab875b1 100644 (file)
@@ -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
index 1426f45..4152f0e 100644 (file)
@@ -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);
                }
index 2627bae..9aadaeb 100644 (file)
@@ -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,
 };
 
 /*!