[asterisk-commits] russell: trunk r78747 - in /trunk: apps/ channels/ include/asterisk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 9 12:07:36 CDT 2007
Author: russell
Date: Thu Aug 9 12:07:36 2007
New Revision: 78747
URL: http://svn.digium.com/view/asterisk?view=rev&rev=78747
Log:
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.
Modified:
trunk/apps/app_voicemail.c
trunk/channels/chan_iax2.c
trunk/channels/chan_mgcp.c
trunk/channels/chan_sip.c
trunk/channels/chan_zap.c
trunk/include/asterisk/event_defs.h
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=78747&r1=78746&r2=78747
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Aug 9 12:07:36 2007
@@ -3997,15 +3997,17 @@
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 @@
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);
}
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=78747&r1=78746&r2=78747
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Aug 9 12:07:36 2007
@@ -6054,9 +6054,16 @@
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 @@
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);
}
Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?view=diff&rev=78747&r1=78746&r2=78747
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Thu Aug 9 12:07:36 2007
@@ -468,9 +468,16 @@
{
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 @@
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);
}
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=78747&r1=78746&r2=78747
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Aug 9 12:07:36 2007
@@ -15756,8 +15756,14 @@
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 @@
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 @@
* 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
Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?view=diff&rev=78747&r1=78746&r2=78747
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Thu Aug 9 12:07:36 2007
@@ -1850,9 +1850,16 @@
{
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 @@
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);
}
Modified: trunk/include/asterisk/event_defs.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/event_defs.h?view=diff&rev=78747&r1=78746&r2=78747
==============================================================================
--- trunk/include/asterisk/event_defs.h (original)
+++ trunk/include/asterisk/event_defs.h Thu Aug 9 12:07:36 2007
@@ -103,6 +103,12 @@
* 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,
};
/*!
More information about the asterisk-commits
mailing list