[Asterisk-code-review] res_mwi_external: Update to use new MWI state publishing API (...asterisk[master])
Kevin Harwell
asteriskteam at digium.com
Wed Jun 12 16:29:44 CDT 2019
Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11465
Change subject: res_mwi_external: Update to use new MWI state publishing API
......................................................................
res_mwi_external: Update to use new MWI state publishing API
MWI recently received some new API calls to help manage topic subscriptions
and publishing for associated state. This patch updates res_mwi_external to use
the new publishing mechanisms.
ASTERISK-28442
Change-Id: I07d41f1a0f0a0bae2e3621adf36057fa416a9bc9
---
M res/res_mwi_external.c
1 file changed, 20 insertions(+), 9 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/65/11465/1
diff --git a/res/res_mwi_external.c b/res/res_mwi_external.c
index 9d56558..4a2c4c2 100644
--- a/res/res_mwi_external.c
+++ b/res/res_mwi_external.c
@@ -78,6 +78,8 @@
unsigned int msgs_new;
/*! Number of old messages in mailbox. */
unsigned int msgs_old;
+ /*! State publisher object */
+ struct ast_mwi_publisher *publisher;
};
static struct ast_sorcery *mwi_sorcery;
@@ -91,8 +93,8 @@
*/
static void mwi_post_event(const struct ast_mwi_mailbox_object *mailbox)
{
- ast_publish_mwi_state(ast_sorcery_object_get_id(mailbox), NULL,
- mailbox->msgs_new, mailbox->msgs_old);
+ ast_mwi_publish(mailbox->publisher, 0, mailbox->msgs_new,
+ mailbox->msgs_old, NULL, NULL);
}
static void mwi_observe_update(const void *obj)
@@ -111,13 +113,9 @@
{
const struct ast_mwi_mailbox_object *mailbox = obj;
- if (mailbox->msgs_new || mailbox->msgs_old) {
- /* Post a count clearing event. */
- ast_publish_mwi_state(ast_sorcery_object_get_id(mailbox), NULL, 0, 0);
- }
+ mwi_post_event(mailbox);
- /* Post a cache remove event. */
- ast_delete_mwi_state(ast_sorcery_object_get_id(mailbox), NULL);
+ ao2_cleanup(mailbox->publisher);
}
static const struct ast_sorcery_observer mwi_observers = {
@@ -129,7 +127,20 @@
/*! \brief Internal function to allocate a mwi object */
static void *mwi_sorcery_object_alloc(const char *id)
{
- return ast_sorcery_generic_alloc(sizeof(struct ast_mwi_mailbox_object), NULL);
+ struct ast_mwi_mailbox_object *mailbox;
+
+ mailbox = ast_sorcery_generic_alloc(sizeof(struct ast_mwi_mailbox_object), NULL);
+ if (!mailbox) {
+ return NULL;
+ }
+
+ mailbox->publisher = ast_mwi_add_publisher(id);
+ if (!mailbox->publisher) {
+ ao2_ref(mailbox, -1);
+ return NULL;
+ }
+
+ return mailbox;
}
/*!
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11465
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I07d41f1a0f0a0bae2e3621adf36057fa416a9bc9
Gerrit-Change-Number: 11465
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190612/19aa73ed/attachment.html>
More information about the asterisk-code-review
mailing list