ao2_cleanup(p->smdi_iface);
}
if (p->mwi_event_sub) {
- p->mwi_event_sub = stasis_unsubscribe(p->mwi_event_sub);
+ p->mwi_event_sub = ast_mwi_unsubscribe(p->mwi_event_sub);
}
if (p->vars) {
ast_variables_destroy(p->vars);
tmp->cid_subaddr[0] = '\0';
ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox));
if (channel != CHAN_PSEUDO && !ast_strlen_zero(tmp->mailbox)) {
- struct stasis_topic *mailbox_specific_topic;
-
- mailbox_specific_topic = ast_mwi_topic(tmp->mailbox);
- if (mailbox_specific_topic) {
- /* 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
- * knows that we care about it. Then, chan_dahdi will get the MWI from the
- * event cache instead of checking the mailbox directly. */
- tmp->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, stasis_subscription_cb_noop, NULL);
- stasis_subscription_accept_message_type(tmp->mwi_event_sub, ast_mwi_state_type());
- stasis_subscription_set_filter(tmp->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
- }
+ /* 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
+ * knows that we care about it. Then, chan_dahdi will get the MWI from the
+ * event cache instead of checking the mailbox directly. */
+ tmp->mwi_event_sub = ast_mwi_subscribe_pool(tmp->mailbox, stasis_subscription_cb_noop, NULL);
}
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
tmp->mwisend_setting = conf->chan.mwisend_setting;
*/
char mailbox[AST_MAX_MAILBOX_UNIQUEID];
/*! \brief Opaque event subscription parameters for message waiting indication support. */
- struct stasis_subscription *mwi_event_sub;
+ struct ast_mwi_subscriber *mwi_event_sub;
/*! \brief Delayed dialing for E911. Overlap digits for ISDN. */
char dialdest[256];
#ifdef HAVE_DAHDI_LINEREVERSE_VMWI
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 stasis_subscription *mwi_event_sub; /*!< This subscription lets pollmailboxes know which mailboxes need to be polled */
+ struct ast_mwi_subscriber *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 */
if (peer->dnsmgr)
ast_dnsmgr_release(peer->dnsmgr);
- peer->mwi_event_sub = stasis_unsubscribe(peer->mwi_event_sub);
+ if (peer->mwi_event_sub) {
+ peer->mwi_event_sub = ast_mwi_unsubscribe(peer->mwi_event_sub);
+ }
ast_string_field_free_memory(peer);
}
if (!ast_strlen_zero(peer->mailbox) && !peer->mwi_event_sub) {
- struct stasis_topic *mailbox_specific_topic;
-
- mailbox_specific_topic = ast_mwi_topic(peer->mailbox);
- if (mailbox_specific_topic) {
- /* 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
- * is time to send MWI, since it is only sent with a REGACK. */
- peer->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, stasis_subscription_cb_noop, NULL);
- stasis_subscription_accept_message_type(peer->mwi_event_sub, ast_mwi_state_type());
- stasis_subscription_set_filter(peer->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
- }
+ /* 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
+ * is time to send MWI, since it is only sent with a REGACK. */
+ peer->mwi_event_sub = ast_mwi_subscribe_pool(peer->mailbox, stasis_subscription_cb_noop, NULL);
}
if (subscribe_acl_change) {
char curtone[80]; /*!< Current tone */
char mailbox[AST_MAX_EXTENSION];
char parkinglot[AST_MAX_CONTEXT]; /*!< Parkinglot */
- struct stasis_subscription *mwi_event_sub;
+ struct ast_mwi_subscriber *mwi_event_sub;
ast_group_t callgroup;
ast_group_t pickupgroup;
int callwaiting;
ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
ast_copy_string(e->parkinglot, parkinglot, sizeof(e->parkinglot));
if (!ast_strlen_zero(e->mailbox)) {
- struct stasis_topic *mailbox_specific_topic;
-
- mailbox_specific_topic = ast_mwi_topic(e->mailbox);
- if (mailbox_specific_topic) {
- /* 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
- * knows that we care about it. Then, chan_mgcp will get the MWI from the
- * event cache instead of checking the mailbox directly. */
- e->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, stasis_subscription_cb_noop, NULL);
- stasis_subscription_accept_message_type(e->mwi_event_sub, ast_mwi_state_type());
- stasis_subscription_set_filter(e->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
- }
+ /* 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
+ * knows that we care about it. Then, chan_mgcp will get the MWI from the
+ * event cache instead of checking the mailbox directly. */
+ e->mwi_event_sub = ast_mwi_subscribe_pool(e->mailbox, stasis_subscription_cb_noop, NULL);
}
snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", (unsigned long)ast_random());
e->msgstate = -1;
}
if (e->mwi_event_sub) {
- e->mwi_event_sub = stasis_unsubscribe(e->mwi_event_sub);
+ e->mwi_event_sub = ast_mwi_unsubscribe(e->mwi_event_sub);
}
if (e->chanvars) {
static void destroy_mailbox(struct sip_mailbox *mailbox)
{
if (mailbox->event_sub) {
- mailbox->event_sub = stasis_unsubscribe_and_join(mailbox->event_sub);
+ mailbox->event_sub = ast_mwi_unsubscribe_and_join(mailbox->event_sub);
}
ast_free(mailbox);
}
struct sip_mailbox *mailbox;
AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {
- struct stasis_topic *mailbox_specific_topic;
-
if (mailbox->status != SIP_MAILBOX_STATUS_NEW) {
continue;
}
-
- mailbox_specific_topic = ast_mwi_topic(mailbox->id);
- if (mailbox_specific_topic) {
- mailbox->event_sub = stasis_subscribe_pool(mailbox_specific_topic, mwi_event_cb, peer);
- stasis_subscription_accept_message_type(mailbox->event_sub, ast_mwi_state_type());
- stasis_subscription_accept_message_type(mailbox->event_sub, stasis_subscription_change_type());
- stasis_subscription_set_filter(mailbox->event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
+ mailbox->event_sub = ast_mwi_subscribe_pool(mailbox->id, mwi_event_cb, peer);
+ if (mailbox->event_sub) {
+ stasis_subscription_accept_message_type(
+ ast_mwi_subscriber_subscription(mailbox->event_sub),
+ stasis_subscription_change_type());
}
}
}
SKINNY_LINE_OPTIONS
ast_mutex_t lock;
struct skinny_container *container;
- struct stasis_subscription *mwi_event_sub; /* Event based MWI */
+ struct ast_mwi_subscriber *mwi_event_sub; /* Event based MWI */
struct skinny_subchannel *activesub;
AST_LIST_HEAD(, skinny_subchannel) sub;
AST_LIST_HEAD(, skinny_subline) sublines;
config_parse_variables(TYPE_LINE, l, v);
if (!ast_strlen_zero(l->mailbox)) {
- struct stasis_topic *mailbox_specific_topic;
-
ast_verb(3, "Setting mailbox '%s' on line %s\n", l->mailbox, l->name);
-
- mailbox_specific_topic = ast_mwi_topic(l->mailbox);
- if (mailbox_specific_topic) {
- l->mwi_event_sub = stasis_subscribe_pool(mailbox_specific_topic, mwi_event_cb, l);
- stasis_subscription_accept_message_type(l->mwi_event_sub, ast_mwi_state_type());
- stasis_subscription_set_filter(l->mwi_event_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
- }
+ l->mwi_event_sub = ast_mwi_subscribe_pool(l->mailbox, mwi_event_cb, l);
}
if (!ast_strlen_zero(vmexten) && ast_strlen_zero(l->vmexten)) {
will happen below. */
while ((l = AST_LIST_REMOVE_HEAD(&d->lines, list))) {
if (l->mwi_event_sub) {
- l->mwi_event_sub = stasis_unsubscribe(l->mwi_event_sub);
+ l->mwi_event_sub = ast_mwi_unsubscribe(l->mwi_event_sub);
}
}
/* Delete all speeddials for this device */
skinny_unlocksub(sub);
}
if (l->mwi_event_sub) {
- l->mwi_event_sub = stasis_unsubscribe_and_join(l->mwi_event_sub);
+ l->mwi_event_sub = ast_mwi_unsubscribe_and_join(l->mwi_event_sub);
}
ast_mutex_unlock(&l->lock);
unregister_exten(l);
#if defined(HAVE_PRI_MWI)
for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
if (pri->mbox[idx].sub) {
- pri->mbox[idx].sub = stasis_unsubscribe_and_join(pri->mbox[idx].sub);
+ pri->mbox[idx].sub = ast_mwi_unsubscribe_and_join(pri->mbox[idx].sub);
}
}
#endif /* defined(HAVE_PRI_MWI) */
/* Prepare the mbox[] for use. */
for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {
if (pri->mbox[i].sub) {
- pri->mbox[i].sub = stasis_unsubscribe(pri->mbox[i].sub);
+ pri->mbox[i].sub = ast_mwi_unsubscribe(pri->mbox[i].sub);
}
}
#endif /* defined(HAVE_PRI_MWI) */
saveptr = pri->mwi_mailboxes;
for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) {
char *mbox_id;
- struct stasis_topic *mailbox_specific_topic;
mbox_id = strsep(&saveptr, ",");
if (mbox_id) {
continue;
}
- mailbox_specific_topic = ast_mwi_topic(mbox_id);
- if (mailbox_specific_topic) {
- pri->mbox[i].sub = stasis_subscribe_pool(mailbox_specific_topic, sig_pri_mwi_event_cb, pri);
- }
+ pri->mbox[i].sub = ast_mwi_subscribe_pool(mbox_id, sig_pri_mwi_event_cb, pri);
if (!pri->mbox[i].sub) {
ast_log(LOG_ERROR, "%s span %d could not subscribe to MWI events for %s(%s).\n",
sig_pri_cc_type_name, pri->span, pri->mbox[i].vm_box, mbox_id);
- } else {
- stasis_subscription_accept_message_type(pri->mbox[i].sub, ast_mwi_state_type());
- stasis_subscription_set_filter(pri->mbox[i].sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
}
#if defined(HAVE_PRI_MWI_V2)
if (ast_strlen_zero(pri->mbox[i].vm_number)) {
* \brief MWI mailbox event subscription.
* \note NULL if mailbox not configured.
*/
- struct stasis_subscription *sub;
+ struct ast_mwi_subscriber *sub;
/*! \brief Mailbox uniqueid. */
const char *uniqueid;
/*! \brief Mailbox number sent to span. */
*/
struct sip_mailbox {
/*! Associated MWI subscription */
- struct stasis_subscription *event_sub;
+ struct ast_mwi_subscriber *event_sub;
AST_LIST_ENTRY(sip_mailbox) entry;
struct sip_peer *peer;
enum sip_mailbox_status status;
*/
struct mwi_stasis_subscription {
/*! The MWI stasis subscription */
- struct stasis_subscription *stasis_sub;
+ struct ast_mwi_subscriber *mwi_subscriber;
/*! The mailbox corresponding with the MWI subscription. Used as a hash key */
char mailbox[1];
};
static struct mwi_stasis_subscription *mwi_stasis_subscription_alloc(const char *mailbox, struct mwi_subscription *mwi_sub)
{
struct mwi_stasis_subscription *mwi_stasis_sub;
- struct stasis_topic *topic;
if (!mwi_sub) {
return NULL;
return NULL;
}
- topic = ast_mwi_topic(mailbox);
-
/* Safe strcpy */
strcpy(mwi_stasis_sub->mailbox, mailbox);
- ast_debug(3, "Creating stasis MWI subscription to mailbox %s for endpoint %s. Topic: '%s':%p %d\n",
- mailbox, mwi_sub->id, stasis_topic_name(topic), topic, (int)ao2_ref(topic, 0));
ao2_ref(mwi_sub, +1);
- mwi_stasis_sub->stasis_sub = stasis_subscribe_pool(topic, mwi_stasis_cb, mwi_sub);
- ao2_ref(topic, -1);
-
- if (!mwi_stasis_sub->stasis_sub) {
+ mwi_stasis_sub->mwi_subscriber = ast_mwi_subscribe_pool(mailbox, mwi_stasis_cb, mwi_sub);
+ if (!mwi_stasis_sub->mwi_subscriber) {
/* Failed to subscribe. */
ao2_ref(mwi_stasis_sub, -1);
ao2_ref(mwi_sub, -1);
- mwi_stasis_sub = NULL;
+ return NULL;
}
- stasis_subscription_accept_message_type(mwi_stasis_sub->stasis_sub, ast_mwi_state_type());
- stasis_subscription_accept_message_type(mwi_stasis_sub->stasis_sub, stasis_subscription_change_type());
- stasis_subscription_set_filter(mwi_stasis_sub->stasis_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
+
+ stasis_subscription_accept_message_type(
+ ast_mwi_subscriber_subscription(mwi_stasis_sub->mwi_subscriber),
+ stasis_subscription_change_type());
+
return mwi_stasis_sub;
}
static int get_message_count(void *obj, void *arg, int flags)
{
- struct stasis_message *msg;
struct mwi_stasis_subscription *mwi_stasis = obj;
struct ast_sip_message_accumulator *counter = arg;
struct ast_mwi_state *mwi_state;
- msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), mwi_stasis->mailbox);
- if (!msg) {
+ mwi_state = ast_mwi_subscriber_data(mwi_stasis->mwi_subscriber);
+ if (!mwi_state) {
return 0;
}
- mwi_state = stasis_message_data(msg);
counter->old_msgs += mwi_state->old_msgs;
counter->new_msgs += mwi_state->new_msgs;
- ao2_ref(msg, -1);
+ ao2_ref(mwi_state, -1);
return 0;
}
static int unsubscribe_stasis(void *obj, void *arg, int flags)
{
struct mwi_stasis_subscription *mwi_stasis = obj;
- if (mwi_stasis->stasis_sub) {
+ if (mwi_stasis->mwi_subscriber) {
ast_debug(3, "Removing stasis subscription to mailbox %s\n", mwi_stasis->mailbox);
- mwi_stasis->stasis_sub = stasis_unsubscribe_and_join(mwi_stasis->stasis_sub);
+ mwi_stasis->mwi_subscriber = ast_mwi_unsubscribe_and_join(mwi_stasis->mwi_subscriber);
}
+
return CMP_MATCH;
}