mirror of
https://github.com/asterisk/asterisk.git
synced 2026-06-19 14:10:01 +00:00
Merge "MWI: Update modules that subscribe to MWI to use new API calls"
This commit is contained in:
+6
-13
@@ -5540,7 +5540,7 @@ static void destroy_dahdi_pvt(struct dahdi_pvt *pvt)
|
||||
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);
|
||||
@@ -12607,18 +12607,11 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
|
||||
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;
|
||||
|
||||
@@ -653,7 +653,7 @@ struct dahdi_pvt {
|
||||
*/
|
||||
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
|
||||
|
||||
+8
-13
@@ -582,7 +582,7 @@ struct iax2_peer {
|
||||
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 */
|
||||
@@ -12764,7 +12764,9 @@ static void peer_destructor(void *obj)
|
||||
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);
|
||||
|
||||
@@ -13069,17 +13071,10 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
+7
-14
@@ -346,7 +346,7 @@ struct mgcp_endpoint {
|
||||
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;
|
||||
@@ -4234,18 +4234,11 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
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;
|
||||
@@ -4587,7 +4580,7 @@ static void destroy_endpoint(struct mgcp_endpoint *e)
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
+6
-10
@@ -5251,7 +5251,7 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
|
||||
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);
|
||||
}
|
||||
@@ -28390,18 +28390,14 @@ static void add_peer_mwi_subs(struct sip_peer *peer)
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-12
@@ -1466,7 +1466,7 @@ struct skinny_line {
|
||||
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;
|
||||
@@ -8328,16 +8328,8 @@ static struct skinny_line *config_line(const char *lname, struct ast_variable *v
|
||||
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)) {
|
||||
@@ -8640,7 +8632,7 @@ int skinny_reload(void)
|
||||
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 */
|
||||
@@ -8797,7 +8789,7 @@ static int unload_module(void)
|
||||
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);
|
||||
|
||||
+3
-10
@@ -8982,7 +8982,7 @@ void sig_pri_stop_pri(struct sig_pri_span *pri)
|
||||
#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) */
|
||||
@@ -9051,7 +9051,7 @@ int sig_pri_start_pri(struct sig_pri_span *pri)
|
||||
/* 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) */
|
||||
@@ -9108,7 +9108,6 @@ int sig_pri_start_pri(struct sig_pri_span *pri)
|
||||
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) {
|
||||
@@ -9127,16 +9126,10 @@ int sig_pri_start_pri(struct sig_pri_span *pri)
|
||||
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)) {
|
||||
|
||||
+1
-1
@@ -424,7 +424,7 @@ struct sig_pri_mbox {
|
||||
* \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. */
|
||||
|
||||
@@ -1252,7 +1252,7 @@ enum sip_mailbox_status {
|
||||
*/
|
||||
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;
|
||||
|
||||
+15
-21
@@ -90,7 +90,7 @@ static struct ast_sip_subscription_handler mwi_handler = {
|
||||
*/
|
||||
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];
|
||||
};
|
||||
@@ -243,7 +243,6 @@ static void mwi_stasis_cb(void *userdata, struct stasis_subscription *sub,
|
||||
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;
|
||||
@@ -254,26 +253,22 @@ static struct mwi_stasis_subscription *mwi_stasis_subscription_alloc(const char
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -433,21 +428,19 @@ static int mwi_sub_cmp(void *obj, void *arg, int flags)
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -683,10 +676,11 @@ static void send_mwi_notify(struct mwi_subscription *sub)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user