[asterisk-commits] kmoore: branch kmoore/stasis-device_state r383285 - in /team/kmoore/stasis-de...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Mar 16 10:50:13 CDT 2013
Author: kmoore
Date: Sat Mar 16 10:50:09 2013
New Revision: 383285
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383285
Log:
Multiple revisions 383283-383284
........
r383283 | file | 2013-03-16 10:40:31 -0500 (Sat, 16 Mar 2013) | 7 lines
Add support for using XMPP buddy state via device state.
This change allows you to use XMPP buddy state in places where device state
can be used be used, such as dialplan hints. If at least one resource is
available the buddy is considered available. Now your phone can reflect
their IM status too!
........
r383284 | kmoore | 2013-03-16 10:45:58 -0500 (Sat, 16 Mar 2013) | 11 lines
Transition MWI to Stasis-core
Remove MWI's dependency on the event system by moving it to
Stasis-core. This also introduces forwarding topic pools in Stasis-core
which aggregate many dynamically allocated topics into a single primary
topic.
Review: https://reviewboard.asterisk.org/r/2368/
(closes issue ASTERISK-21097)
Patch-by: Kinsey Moore
........
Merged revisions 383283-383284 from http://svn.asterisk.org/svn/asterisk/trunk
Modified:
team/kmoore/stasis-device_state/ (props changed)
team/kmoore/stasis-device_state/CHANGES
team/kmoore/stasis-device_state/apps/app_minivm.c
team/kmoore/stasis-device_state/apps/app_voicemail.c
team/kmoore/stasis-device_state/channels/chan_dahdi.c
team/kmoore/stasis-device_state/channels/chan_iax2.c
team/kmoore/stasis-device_state/channels/chan_mgcp.c
team/kmoore/stasis-device_state/channels/chan_sip.c
team/kmoore/stasis-device_state/channels/chan_skinny.c
team/kmoore/stasis-device_state/channels/chan_unistim.c
team/kmoore/stasis-device_state/channels/sig_pri.c
team/kmoore/stasis-device_state/channels/sig_pri.h
team/kmoore/stasis-device_state/channels/sip/include/sip.h
team/kmoore/stasis-device_state/include/asterisk/app.h
team/kmoore/stasis-device_state/include/asterisk/stasis.h
team/kmoore/stasis-device_state/include/asterisk/xmpp.h
team/kmoore/stasis-device_state/main/app.c
team/kmoore/stasis-device_state/main/asterisk.c
team/kmoore/stasis-device_state/main/channel.c
team/kmoore/stasis-device_state/main/stasis.c
team/kmoore/stasis-device_state/res/res_jabber.c
team/kmoore/stasis-device_state/res/res_xmpp.c
Propchange: team/kmoore/stasis-device_state/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Mar 16 10:50:09 2013
@@ -1,1 +1,1 @@
-/trunk:1-383272
+/trunk:1-383284
Modified: team/kmoore/stasis-device_state/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/CHANGES?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/CHANGES (original)
+++ team/kmoore/stasis-device_state/CHANGES Sat Mar 16 10:50:09 2013
@@ -116,6 +116,14 @@
* ICE/STUN/TURN support in res_rtp_asterisk has been made optional. To enable
them, an Asterisk-specific version of pjproject needs to be installed.
Tarballs are available from https://github.com/asterisk/pjproject/tags/.
+
+XMPP
+------------------
+ * Device state for XMPP buddies is now available using the following format:
+ XMPP/<client name>/<buddy address>
+ If any resource is available the device state is considered to be not in use.
+ If no resources exist or all are unavailable the device state is considered
+ to be unavailable.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 10 to Asterisk 11 --------------------
Modified: team/kmoore/stasis-device_state/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/apps/app_minivm.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/apps/app_minivm.c (original)
+++ team/kmoore/stasis-device_state/apps/app_minivm.c Sat Mar 16 10:50:09 2013
@@ -2013,7 +2013,6 @@
* \brief Queue a message waiting event */
static void queue_mwi_event(const char *mbx, const char *ctx, int urgent, int new, int old)
{
- struct ast_event *event;
char *mailbox, *context;
mailbox = ast_strdupa(mbx);
@@ -2022,16 +2021,7 @@
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+urgent),
- AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old,
- AST_EVENT_IE_END))) {
- return;
- }
-
- ast_event_queue_and_cache(event);
+ stasis_publish_mwi_state(mailbox, context, new + urgent, old);
}
/*!\internal
Modified: team/kmoore/stasis-device_state/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/apps/app_voicemail.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/apps/app_voicemail.c (original)
+++ team/kmoore/stasis-device_state/apps/app_voicemail.c Sat Mar 16 10:50:09 2013
@@ -974,10 +974,8 @@
static pthread_t poll_thread = AST_PTHREADT_NULL;
static unsigned char poll_thread_run;
-/*! Subscription to ... MWI event subscriptions */
-static struct ast_event_sub *mwi_sub_sub;
-/*! Subscription to ... MWI event un-subscriptions */
-static struct ast_event_sub *mwi_unsub_sub;
+/*! Subscription to MWI event subscription changes */
+static struct stasis_subscription *mwi_sub_sub;
/*!
* \brief An MWI subscription
@@ -991,15 +989,23 @@
int old_urgent;
int old_new;
int old_old;
- uint32_t uniqueid;
+ char *uniqueid;
char mailbox[1];
};
struct mwi_sub_task {
const char *mailbox;
const char *context;
- uint32_t uniqueid;
+ const char *uniqueid;
};
+
+static void mwi_sub_task_dtor(struct mwi_sub_task *mwist)
+{
+ ast_free((void *) mwist->mailbox);
+ ast_free((void *) mwist->context);
+ ast_free((void *) mwist->uniqueid);
+ ast_free(mwist);
+}
static struct ast_taskprocessor *mwi_subscription_tps;
@@ -7721,25 +7727,16 @@
static void queue_mwi_event(const char *box, int urgent, int new, int old)
{
- struct ast_event *event;
char *mailbox, *context;
/* Strip off @default */
context = mailbox = ast_strdupa(box);
strsep(&context, "@");
- if (ast_strlen_zero(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+urgent),
- AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old,
- AST_EVENT_IE_END))) {
- return;
- }
-
- ast_event_queue_and_cache(event);
+ }
+
+ stasis_publish_mwi_state(mailbox, context, new + urgent, old);
}
/*!
@@ -12533,28 +12530,28 @@
static void mwi_sub_destroy(struct mwi_sub *mwi_sub)
{
+ ast_free(mwi_sub->uniqueid);
ast_free(mwi_sub);
}
static int handle_unsubscribe(void *datap)
{
struct mwi_sub *mwi_sub;
- uint32_t *uniqueid = datap;
-
+ char *uniqueid = datap;
+
AST_RWLIST_WRLOCK(&mwi_subs);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&mwi_subs, mwi_sub, entry) {
- if (mwi_sub->uniqueid == *uniqueid) {
+ if (!strcmp(mwi_sub->uniqueid, uniqueid)) {
AST_LIST_REMOVE_CURRENT(entry);
- break;
+ /* Don't break here since a duplicate uniqueid
+ * may have been added as a result of a cache dump. */
+ mwi_sub_destroy(mwi_sub);
}
}
AST_RWLIST_TRAVERSE_SAFE_END
AST_RWLIST_UNLOCK(&mwi_subs);
- if (mwi_sub)
- mwi_sub_destroy(mwi_sub);
-
- ast_free(uniqueid);
+ ast_free(uniqueid);
return 0;
}
@@ -12574,7 +12571,7 @@
if (!(mwi_sub = ast_calloc(1, len)))
return -1;
- mwi_sub->uniqueid = p->uniqueid;
+ mwi_sub->uniqueid = ast_strdup(p->uniqueid);
if (!ast_strlen_zero(p->mailbox))
strcpy(mwi_sub->mailbox, p->mailbox);
@@ -12586,75 +12583,85 @@
AST_RWLIST_WRLOCK(&mwi_subs);
AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry);
AST_RWLIST_UNLOCK(&mwi_subs);
- ast_free((void *) p->mailbox);
- ast_free((void *) p->context);
- ast_free(p);
+ mwi_sub_task_dtor(p);
poll_subscribed_mailbox(mwi_sub);
return 0;
}
-static void mwi_unsub_event_cb(const struct ast_event *event, void *userdata)
-{
- uint32_t u, *uniqueid = ast_calloc(1, sizeof(*uniqueid));
+static void mwi_unsub_event_cb(struct stasis_subscription_change *change)
+{
+ char *uniqueid = ast_strdup(change->uniqueid);
if (!uniqueid) {
ast_log(LOG_ERROR, "Unable to allocate memory for uniqueid\n");
return;
}
- if (ast_event_get_type(event) != AST_EVENT_UNSUB) {
- ast_free(uniqueid);
- return;
- }
-
- if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI) {
- ast_free(uniqueid);
- return;
- }
-
- u = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
- *uniqueid = u;
if (ast_taskprocessor_push(mwi_subscription_tps, handle_unsubscribe, uniqueid) < 0) {
ast_free(uniqueid);
}
}
-static void mwi_sub_event_cb(const struct ast_event *event, void *userdata)
+static void mwi_sub_event_cb(struct stasis_subscription_change *change)
{
struct mwi_sub_task *mwist;
-
- if (ast_event_get_type(event) != AST_EVENT_SUB)
+ char *context = ast_strdupa(stasis_topic_name(change->topic));
+ char *mailbox;
+
+ if ((mwist = ast_calloc(1, (sizeof(*mwist)))) == NULL) {
return;
-
- if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI)
+ }
+
+ mailbox = strsep(&context, "@");
+
+ mwist->mailbox = ast_strdup(mailbox);
+ mwist->context = ast_strdup(context);
+ mwist->uniqueid = ast_strdup(change->uniqueid);
+
+ if (ast_taskprocessor_push(mwi_subscription_tps, handle_subscribe, mwist) < 0) {
+ mwi_sub_task_dtor(mwist);
+ }
+}
+
+static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
+{
+ struct stasis_subscription_change *change;
+ /* Only looking for subscription change notices here */
+ if (stasis_message_type(msg) != stasis_subscription_change()) {
return;
-
- if ((mwist = ast_calloc(1, (sizeof(*mwist)))) == NULL) {
- ast_log(LOG_ERROR, "could not allocate a mwi_sub_task\n");
+ }
+
+ change = stasis_message_data(msg);
+ if (change->topic == stasis_mwi_topic_all()) {
return;
}
- mwist->mailbox = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX));
- mwist->context = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT));
- mwist->uniqueid = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
-
- if (ast_taskprocessor_push(mwi_subscription_tps, handle_subscribe, mwist) < 0) {
- ast_free(mwist);
- }
+
+ if (!strcmp(change->description, "Subscribe")) {
+ mwi_sub_event_cb(change);
+ } else if (!strcmp(change->description, "Unsubscribe")) {
+ mwi_unsub_event_cb(change);
+ }
+}
+
+static int dump_cache(void *obj, void *arg, int flags)
+{
+ struct stasis_message *msg = obj;
+ mwi_event_cb(NULL, NULL, NULL, msg);
+ return 0;
}
static void start_poll_thread(void)
{
int errcode;
- mwi_sub_sub = ast_event_subscribe(AST_EVENT_SUB, mwi_sub_event_cb, "Voicemail MWI subscription", NULL,
- AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI,
- AST_EVENT_IE_END);
-
- mwi_unsub_sub = ast_event_subscribe(AST_EVENT_UNSUB, mwi_unsub_event_cb, "Voicemail MWI subscription", NULL,
- AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI,
- AST_EVENT_IE_END);
-
- if (mwi_sub_sub)
- ast_event_report_subs(mwi_sub_sub);
+ mwi_sub_sub = stasis_subscribe(stasis_mwi_topic_all(), mwi_event_cb, NULL);
+
+ if (mwi_sub_sub) {
+ struct ao2_container *cached = stasis_cache_dump(stasis_mwi_topic_cached(), stasis_subscription_change());
+ if (cached) {
+ ao2_callback(cached, OBJ_MULTIPLE | OBJ_NODATA, dump_cache, NULL);
+ }
+ ao2_cleanup(cached);
+ }
poll_thread_run = 1;
@@ -12668,13 +12675,7 @@
poll_thread_run = 0;
if (mwi_sub_sub) {
- ast_event_unsubscribe(mwi_sub_sub);
- mwi_sub_sub = NULL;
- }
-
- if (mwi_unsub_sub) {
- ast_event_unsubscribe(mwi_unsub_sub);
- mwi_unsub_sub = NULL;
+ mwi_sub_sub = stasis_unsubscribe(mwi_sub_sub);
}
ast_mutex_lock(&poll_lock);
Modified: team/kmoore/stasis-device_state/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/channels/chan_dahdi.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/channels/chan_dahdi.c (original)
+++ team/kmoore/stasis-device_state/channels/chan_dahdi.c Sat Mar 16 10:50:09 2013
@@ -502,7 +502,7 @@
static int dahdi_sendtext(struct ast_channel *c, const char *text);
-static void mwi_event_cb(const struct ast_event *event, void *userdata)
+static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
{
/* This module does not handle MWI in an event-based manner. However, it
* subscribes to MWI for each mailbox that is configured so that the core
@@ -1215,7 +1215,7 @@
*/
char mailbox[AST_MAX_EXTENSION];
/*! \brief Opaque event subscription parameters for message waiting indication support. */
- struct ast_event_sub *mwi_event_sub;
+ struct stasis_subscription *mwi_event_sub;
/*! \brief Delayed dialing for E911. Overlap digits for ISDN. */
char dialdest[256];
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
@@ -3753,7 +3753,6 @@
static void notify_message(char *mailbox_full, int thereornot)
{
char s[sizeof(mwimonitornotify) + 80];
- struct ast_event *event;
char *mailbox, *context;
/* Strip off @default */
@@ -3762,16 +3761,7 @@
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, thereornot,
- AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, thereornot,
- AST_EVENT_IE_END))) {
- return;
- }
-
- ast_event_queue_and_cache(event);
+ stasis_publish_mwi_state(mailbox, context, thereornot, thereornot);
if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(mwimonitornotify)) {
snprintf(s, sizeof(s), "%s %s %d", mwimonitornotify, mailbox, thereornot);
@@ -5413,24 +5403,25 @@
static int has_voicemail(struct dahdi_pvt *p)
{
int new_msgs;
- struct ast_event *event;
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))
+ if (ast_strlen_zero(context)) {
context = "default";
-
- event = ast_event_get_cached(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_END);
-
- if (event) {
- new_msgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- ast_event_destroy(event);
- } else
+ }
+
+ ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
+ mwi_message = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_message(), ast_str_buffer(uniqueid));
+
+ if (mwi_message) {
+ struct stasis_mwi_state *mwi_state = stasis_message_data(mwi_message);
+ new_msgs = mwi_state->new_msgs;
+ } else {
new_msgs = ast_app_has_voicemail(p->mailbox, NULL);
+ }
return new_msgs;
}
@@ -5965,10 +5956,12 @@
}
}
ast_free(p->cidspill);
- if (p->use_smdi)
+ if (p->use_smdi) {
ast_smdi_interface_unref(p->smdi_iface);
- if (p->mwi_event_sub)
- ast_event_unsubscribe(p->mwi_event_sub);
+ }
+ if (p->mwi_event_sub) {
+ p->mwi_event_sub = stasis_unsubscribe(p->mwi_event_sub);
+ }
if (p->vars) {
ast_variables_destroy(p->vars);
}
@@ -5981,8 +5974,9 @@
ast_mutex_destroy(&p->lock);
dahdi_close_sub(p, SUB_REAL);
- if (p->owner)
+ if (p->owner) {
ast_channel_tech_pvt_set(p->owner, NULL);
+ }
ast_free(p);
}
@@ -13226,15 +13220,20 @@
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";
- tmp->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, "Dahdi MWI subscription", NULL,
- 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);
+
+ ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
+
+ mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+ if (mailbox_specific_topic) {
+ tmp->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
+ }
}
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
tmp->mwisend_setting = conf->chan.mwisend_setting;
Modified: team/kmoore/stasis-device_state/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/channels/chan_iax2.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/channels/chan_iax2.c (original)
+++ team/kmoore/stasis-device_state/channels/chan_iax2.c Sat Mar 16 10:50:09 2013
@@ -533,7 +533,7 @@
int expire; /*!< Schedule entry for expiry */
int expiry; /*!< How soon to expire */
- iax2_format capability; /*!< Capability */
+ iax2_format capability; /*!< Capability */
/* Qualification */
int callno; /*!< Call number of POKE request */
@@ -545,12 +545,12 @@
int pokefreqnotok; /*!< How often to check when the host has been determined to be down */
int historicms; /*!< How long recent average responses took */
int smoothing; /*!< Sample over how many units to determine historic ms */
- uint16_t maxcallno; /*!< Max call number limit for this peer. Set on registration */
-
- struct ast_event_sub *mwi_event_sub;
+ uint16_t maxcallno; /*!< Max call number limit for this peer. Set on registration */
+
+ struct stasis_subscription *mwi_event_sub; /*!< This subscription lets pollmailboxes know which mailboxes need to be polled */
struct ast_acl_list *acl;
- enum calltoken_peer_enum calltoken_required; /*!< Is calltoken validation required or not, can be YES, NO, or AUTO */
+ enum calltoken_peer_enum calltoken_required; /*!< Is calltoken validation required or not, can be YES, NO, or AUTO */
};
#define IAX2_TRUNK_PREFACE (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr))
@@ -1316,7 +1316,7 @@
}
}
-static void mwi_event_cb(const struct ast_event *event, void *userdata)
+static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
{
/* The MWI subscriptions exist just so the core knows we care about those
* mailboxes. However, we just grab the events out of the cache when it
@@ -8743,23 +8743,24 @@
iax_ie_append_short(&ied, IAX_IE_REFRESH, p->expiry);
iax_ie_append_addr(&ied, IAX_IE_APPARENT_ADDR, &peer_addr);
if (!ast_strlen_zero(p->mailbox)) {
- struct ast_event *event;
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))
+ if (ast_strlen_zero(context)) {
context = "default";
-
- event = ast_event_get_cached(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_END);
- if (event) {
- new = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- old = ast_event_get_ie_uint(event, AST_EVENT_IE_OLDMSGS);
- ast_event_destroy(event);
+ }
+
+ ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
+ msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_message(), ast_str_buffer(uniqueid));
+
+ if (msg) {
+ struct stasis_mwi_state *mwi_state = stasis_message_data(msg);
+ new = mwi_state->new_msgs;
+ old = mwi_state->old_msgs;
} else { /* Fall back on checking the mailbox directly */
ast_app_inboxcount(p->mailbox, &new, &old);
}
@@ -12392,8 +12393,9 @@
if (peer->dnsmgr)
ast_dnsmgr_release(peer->dnsmgr);
- if (peer->mwi_event_sub)
- ast_event_unsubscribe(peer->mwi_event_sub);
+ if (peer->mwi_event_sub) {
+ peer->mwi_event_sub = stasis_unsubscribe(peer->mwi_event_sub);
+ }
ast_string_field_free_memory(peer);
}
@@ -12667,14 +12669,21 @@
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))
+ if (ast_strlen_zero(context)) {
context = "default";
- peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, "IAX MWI subscription", NULL,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
- AST_EVENT_IE_END);
+ }
+
+ ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
+
+ mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+ if (mailbox_specific_topic) {
+ peer->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
+ }
}
if (subscribe_acl_change) {
Modified: team/kmoore/stasis-device_state/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/channels/chan_mgcp.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/channels/chan_mgcp.c (original)
+++ team/kmoore/stasis-device_state/channels/chan_mgcp.c Sat Mar 16 10:50:09 2013
@@ -82,6 +82,7 @@
#include "asterisk/event.h"
#include "asterisk/chanvars.h"
#include "asterisk/pktccops.h"
+#include "asterisk/stasis.h"
/*
* Define to work around buggy dlink MGCP phone firmware which
@@ -342,7 +343,7 @@
char curtone[80]; /*!< Current tone */
char mailbox[AST_MAX_EXTENSION];
char parkinglot[AST_MAX_CONTEXT]; /*!< Parkinglot */
- struct ast_event_sub *mwi_event_sub;
+ struct stasis_subscription *mwi_event_sub;
ast_group_t callgroup;
ast_group_t pickupgroup;
int callwaiting;
@@ -483,7 +484,7 @@
.func_channel_read = acf_channel_read,
};
-static void mwi_event_cb(const struct ast_event *event, void *userdata)
+static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
{
/* This module does not handle MWI in an event-based manner. However, it
* subscribes to MWI for each mailbox that is configured so that the core
@@ -494,24 +495,26 @@
static int has_voicemail(struct mgcp_endpoint *p)
{
int new_msgs;
- struct ast_event *event;
+ 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))
+ if (ast_strlen_zero(cntx)) {
cntx = "default";
-
- event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, cntx,
- AST_EVENT_IE_END);
-
- if (event) {
- new_msgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- ast_event_destroy(event);
- } else
+ }
+
+ ast_str_set(&uniqueid, 0, "%s@%s", mbox, cntx);
+
+ msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state(), ast_str_buffer(uniqueid));
+
+ if (msg) {
+ struct stasis_mwi_state *mwi_state = stasis_message_data(msg);
+ new_msgs = mwi_state->new_msgs;
+ } else {
new_msgs = ast_app_has_voicemail(p->mailbox, NULL);
+ }
return new_msgs;
}
@@ -3972,6 +3975,7 @@
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;
@@ -4168,16 +4172,20 @@
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";
}
- e->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, "MGCP MWI subscription", NULL,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, cntx,
- AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
- AST_EVENT_IE_END);
+ ast_str_reset(uniqueid);
+ ast_str_set(&uniqueid, 0, "%s@%s", mbox, cntx);
+
+ maibox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+ if (mailbox_specific_topic) {
+ e->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
+ }
}
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random());
e->msgstate = -1;
@@ -4516,8 +4524,9 @@
ast_free(s);
}
- if (e->mwi_event_sub)
- ast_event_unsubscribe(e->mwi_event_sub);
+ if (e->mwi_event_sub) {
+ e->mwi_event_sub = stasis_unsubscribe(e->mwi_event_sub);
+ }
if (e->chanvars) {
ast_variables_destroy(e->chanvars);
Modified: team/kmoore/stasis-device_state/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/channels/chan_sip.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/channels/chan_sip.c (original)
+++ team/kmoore/stasis-device_state/channels/chan_sip.c Sat Mar 16 10:50:09 2013
@@ -294,6 +294,7 @@
#include "sip/include/dialplan_functions.h"
#include "sip/include/security_events.h"
#include "asterisk/sip_api.h"
+#include "asterisk/app.h"
/*** DOCUMENTATION
<application name="SIPDtmfMode" language="en_US">
@@ -1275,7 +1276,7 @@
static int sip_poke_peer(struct sip_peer *peer, int force);
static void sip_poke_all_peers(void);
static void sip_peer_hold(struct sip_pvt *p, int hold);
-static void mwi_event_cb(const struct ast_event *, void *);
+static void mwi_event_cb(void *, struct stasis_subscription *, struct stasis_topic *, struct stasis_message *);
static void network_change_event_cb(const struct ast_event *, void *);
static void acl_change_event_cb(const struct ast_event *event, void *userdata);
static void sip_keepalive_all_peers(void);
@@ -5225,8 +5226,9 @@
/*! Destroy mailbox subscriptions */
static void destroy_mailbox(struct sip_mailbox *mailbox)
{
- if (mailbox->event_sub)
- ast_event_unsubscribe(mailbox->event_sub);
+ if (mailbox->event_sub) {
+ mailbox->event_sub = stasis_unsubscribe(mailbox->event_sub);
+ }
ast_free(mailbox);
}
@@ -16644,11 +16646,16 @@
}
/*! \brief Receive MWI events that we have subscribed to */
-static void mwi_event_cb(const struct ast_event *event, void *userdata)
+static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
{
struct sip_peer *peer = userdata;
-
- sip_send_mwi_to_peer(peer, 0);
+ if (stasis_subscription_final_message(sub, msg)) {
+ ao2_cleanup(peer);
+ return;
+ }
+ if (stasis_mwi_state_message() == stasis_message_type(msg)) {
+ sip_send_mwi_to_peer(peer, 0);
+ }
}
static void network_change_event_subscribe(void)
@@ -24787,16 +24794,9 @@
if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(c)) {
char *old = strsep(&c, " ");
char *new = strsep(&old, "/");
- struct ast_event *event;
-
- 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, "SIP_Remote",
- AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(new),
- AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(old),
- AST_EVENT_IE_END))) {
- ast_event_queue_and_cache(event);
- }
+
+ stasis_publish_mwi_state(mailbox, "SIP_Remote", atoi(new), atoi(old));
+
transmit_response(p, "200 OK", req);
} else {
transmit_response(p, "489 Bad event", req);
@@ -27617,16 +27617,20 @@
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) {
- if (mailbox->event_sub) {
- ast_event_unsubscribe(mailbox->event_sub);
- }
-
- mailbox->event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, "SIP mbox event", peer,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox->mailbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, S_OR(mailbox->context, "default"),
- AST_EVENT_IE_END);
+ 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 = stasis_mwi_topic(ast_str_buffer(uniqueid));
+ if (mailbox_specific_topic) {
+ ao2_ref(peer, +1);
+ mailbox->event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, peer);
+ }
}
}
@@ -28832,19 +28836,24 @@
{
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) {
- struct ast_event *event;
- event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox->mailbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, S_OR(mailbox->context, "default"),
- AST_EVENT_IE_END);
- if (!event)
+ RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+ struct stasis_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(stasis_mwi_topic_cached(), stasis_mwi_state_message(), ast_str_buffer(uniqueid));
+ if (!msg) {
continue;
- *new += ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- *old += ast_event_get_ie_uint(event, AST_EVENT_IE_OLDMSGS);
- ast_event_destroy(event);
+ }
+
+ mwi_state = stasis_message_data(msg);
+ *new += mwi_state->new_msgs;
+ *old += mwi_state->old_msgs;
in_cache = 1;
}
Modified: team/kmoore/stasis-device_state/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/channels/chan_skinny.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/channels/chan_skinny.c (original)
+++ team/kmoore/stasis-device_state/channels/chan_skinny.c Sat Mar 16 10:50:09 2013
@@ -1442,7 +1442,7 @@
SKINNY_LINE_OPTIONS
ast_mutex_t lock;
struct skinny_container *container;
- struct ast_event_sub *mwi_event_sub; /* Event based MWI */
+ struct stasis_subscription *mwi_event_sub; /* Event based MWI */
struct skinny_subchannel *activesub;
AST_LIST_HEAD(, skinny_subchannel) sub;
AST_LIST_HEAD(, skinny_subline) sublines;
@@ -1611,7 +1611,7 @@
static int skinny_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static int skinny_senddigit_begin(struct ast_channel *ast, char digit);
static int skinny_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration);
-static void mwi_event_cb(const struct ast_event *event, void *userdata);
+static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg);
static int skinny_dialer_cb(const void *data);
static int skinny_reload(void);
@@ -2261,7 +2261,7 @@
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: Skinny\r\nPeer: Skinny/%s@%s\r\nPeerStatus: Registered\r\n", l->name, d->name);
register_exten(l);
/* initialize MWI on line and device */
- mwi_event_cb(0, l);
+ mwi_event_cb(l, NULL, NULL, NULL);
AST_LIST_TRAVERSE(&l->sublines, subline, list) {
ast_extension_state_add(subline->context, subline->exten, skinny_extensionstate_cb, subline->container);
}
@@ -3507,7 +3507,7 @@
send_callinfo(sub);
}
-static void mwi_event_cb(const struct ast_event *event, void *userdata)
+static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
{
struct skinny_line *l = userdata;
struct skinny_device *d = l->device;
@@ -3518,8 +3518,9 @@
return;
}
- if (event) {
- l->newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
+ if (msg && stasis_mwi_state_message() == stasis_message_type(msg)) {
+ struct stasis_mwi_state *mwi_state = stasis_message_data(msg);
+ l->newmsgs = mwi_state->new_msgs;
}
if (l->newmsgs) {
@@ -8250,16 +8251,22 @@
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";
- l->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, "skinny MWI subsciption", l,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, cfg_mailbox,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, cfg_context,
- AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
- AST_EVENT_IE_END);
+ if (ast_strlen_zero(cfg_context)) {
+ cfg_context = "default";
+ }
+
+ ast_str_set(&uniqueid, 0, "%s@%s", cfg_mailbox, cfg_context);
+
+ mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+ if (mailbox_specific_topic) {
+ l->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, l);
+ }
}
if (!ast_strlen_zero(vmexten) && ast_strlen_zero(l->vmexten)) {
@@ -8694,8 +8701,9 @@
}
ast_mutex_unlock(&sub->lock);
}
- if (l->mwi_event_sub)
- ast_event_unsubscribe(l->mwi_event_sub);
+ if (l->mwi_event_sub) {
+ l->mwi_event_sub = stasis_unsubscribe(l->mwi_event_sub);
+ }
ast_mutex_unlock(&l->lock);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: Skinny\r\nPeer: Skinny/%s@%s\r\nPeerStatus: Unregistered\r\n", l->name, d->name);
unregister_exten(l);
Modified: team/kmoore/stasis-device_state/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/channels/chan_unistim.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/channels/chan_unistim.c (original)
+++ team/kmoore/stasis-device_state/channels/chan_unistim.c Sat Mar 16 10:50:09 2013
@@ -5500,23 +5500,24 @@
/*--- unistim_send_mwi_to_peer: Send message waiting indication ---*/
static int unistim_send_mwi_to_peer(struct unistim_line *peer, unsigned int tick)
{
- struct ast_event *event;
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";
}
- event = ast_event_get_cached(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_END);
-
- if (event) {
- new = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- ast_event_destroy(event);
+
+ ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
+
+ msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_message(), ast_str_buffer(uniqueid));
+
+ if (msg) {
+ struct stasis_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");
}
Modified: team/kmoore/stasis-device_state/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-device_state/channels/sig_pri.c?view=diff&rev=383285&r1=383284&r2=383285
==============================================================================
--- team/kmoore/stasis-device_state/channels/sig_pri.c (original)
+++ team/kmoore/stasis-device_state/channels/sig_pri.c Sat Mar 16 10:50:09 2013
@@ -8752,23 +8752,30 @@
*
* \return Nothing
*/
-static void sig_pri_mwi_event_cb(const struct ast_event *event, void *userdata)
+static void sig_pri_mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg)
{
struct sig_pri_span *pri = userdata;
const char *mbox_context;
const char *mbox_number;
int num_messages;
int idx;
-
- mbox_number = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
+ struct stasis_mwi_state *mwi_state;
+
+ if (stasis_mwi_state_message() != stasis_message_type(msg)) {
+ return;
+ }
+
+ mwi_state = stasis_message_data(msg);
+
+ mbox_number = mwi_state->mailbox;
if (ast_strlen_zero(mbox_number)) {
return;
}
- mbox_context = ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT);
+ mbox_context = mwi_state->context;
if (ast_strlen_zero(mbox_context)) {
return;
}
- num_messages = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
+ num_messages = mwi_state->new_msgs;
for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
if (!pri->mbox[idx].sub) {
@@ -8799,27 +8806,28 @@
static void sig_pri_mwi_cache_update(struct sig_pri_span *pri)
{
int idx;
- int num_messages;
- struct ast_event *event;
+ struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
+ struct stasis_mwi_state *mwi_state;
for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
+ RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
if (!pri->mbox[idx].sub) {
/* Mailbox slot is empty */
continue;
}
- event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, pri->mbox[idx].number,
- AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, pri->mbox[idx].context,
- AST_EVENT_IE_END);
- if (!event) {
+ ast_str_reset(uniqueid);
+ ast_str_set(&uniqueid, 0, "%s@%s", pri->mbox[idx].number, pri->mbox[idx].context);
+
+ msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_message(), ast_str_buffer(uniqueid));
+ if (!msg) {
/* No cached event for this mailbox. */
continue;
}
- num_messages = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
+
+ 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, num_messages);
- ast_event_destroy(event);
+ pri->mbox[idx].context, mwi_state->new_msgs);
}
}
#endif /* defined(HAVE_PRI_MWI) */
@@ -8841,7 +8849,7 @@
#if defined(HAVE_PRI_MWI)
for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
[... 784 lines stripped ...]
More information about the asterisk-commits
mailing list