summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-03-16 15:45:58 +0000
committerKinsey Moore <kmoore@digium.com>2013-03-16 15:45:58 +0000
commit99aa02d17f7f1815f9a2abf75282f815a975cd67 (patch)
tree5ebb9cf3ddecd7153afb9e30f767d170c44b2142 /include
parent5d45596f6257b86189bef2dfaf5d9cc0b001fa46 (diff)
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383284 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/app.h91
-rw-r--r--include/asterisk/stasis.h21
-rw-r--r--include/asterisk/xmpp.h2
3 files changed, 113 insertions, 1 deletions
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index cdc40e7d0..0505786e6 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -28,6 +28,7 @@
#include "asterisk/threadstorage.h"
#include "asterisk/file.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/utils.h"
struct ast_flags64;
@@ -1086,6 +1087,96 @@ void ast_safe_fork_cleanup(void);
*/
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit);
+/*!
+ * \brief Publish a MWI state update via stasis
+ * \param[in] uniqueid A unique identifier for this mailbox (usually mailbox@context)
+ * \param[in] mailbox The number identifying this mailbox
+ * \param[in] context The context this mailbox resides in
+ * \param[in] new_msgs The number of new messages in this mailbox
+ * \param[in] old_msgs The number of old messages in this mailbox
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+#define stasis_publish_mwi_state(mailbox, context, new_msgs, old_msgs) \
+ stasis_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL)
+
+/*!
+ * \brief Publish a MWI state update via stasis with EID
+ * \param[in] uniqueid A unique identifier for this mailbox (usually mailbox@context)
+ * \param[in] mailbox The number identifying this mailbox
+ * \param[in] context The context this mailbox resides in
+ * \param[in] new_msgs The number of new messages in this mailbox
+ * \param[in] old_msgs The number of old messages in this mailbox
+ * \param[in] eid The EID of the server that originally published the message
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+int stasis_publish_mwi_state_full(
+ const char *mailbox,
+ const char *context,
+ int new_msgs,
+ int old_msgs,
+ struct ast_eid *eid);
+
+/*!
+ * \brief The structure that contains MWI state
+ * \since 12
+ */
+struct stasis_mwi_state {
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(uniqueid); /*!< Unique identifier for this mailbox/context */
+ AST_STRING_FIELD(mailbox); /*!< Mailbox for this event */
+ AST_STRING_FIELD(context); /*!< Context that this mailbox belongs to */
+ );
+ int new_msgs; /*!< The current number of new messages for this mailbox */
+ int old_msgs; /*!< The current number of old messages for this mailbox */
+ struct ast_eid eid; /*!< The EID of the server where this message originated */
+};
+
+/*!
+ * \brief Get the Stasis topic for MWI messages
+ * \retval The topic structure for MWI messages
+ * \retval NULL if it has not been allocated
+ * \since 12
+ */
+struct stasis_topic *stasis_mwi_topic_all(void);
+
+/*!
+ * \brief Get the Stasis topic for MWI messages on a unique ID
+ * \param uniqueid The unique id for which to get the topic
+ * \retval The topic structure for MWI messages for a given uniqueid
+ * \retval NULL if it failed to be found or allocated
+ * \since 12
+ */
+struct stasis_topic *stasis_mwi_topic(const char *uniqueid);
+
+/*!
+ * \brief Get the Stasis caching topic for MWI messages
+ * \retval The caching topic structure for MWI messages
+ * \retval NULL if it has not been allocated
+ * \since 12
+ */
+struct stasis_caching_topic *stasis_mwi_topic_cached(void);
+
+/*!
+ * \brief Get the Stasis message type for MWI messages
+ * \retval The message type structure for MWI messages
+ * \retval NULL if it has not been allocated
+ * \since 12
+ */
+struct stasis_message_type *stasis_mwi_state_message(void);
+
+/*!
+ * \brief Initialize the application core
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+int app_init(void);
+
+#define AST_MAX_MAILBOX_UNIQUEID (AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2)
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 9a5f7537c..f0d73fd72 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -377,6 +377,27 @@ struct stasis_subscription_change {
*/
struct stasis_message_type *stasis_subscription_change(void);
+/*!
+ * \brief Pool for topic aggregation
+ */
+struct stasis_topic_pool;
+
+/*!
+ * \brief Create a topic pool that routes messages from dynamically generated topics to the given topic
+ * \param pooled_topic Topic to which messages will be routed
+ * \retval the new stasis_topic_pool or NULL on failure
+ */
+struct stasis_topic_pool *stasis_topic_pool_create(struct stasis_topic *pooled_topic);
+
+/*!
+ * \brief Find or create a topic in the pool
+ * \param pool Pool for which to get the topic
+ * \param topic_name Name of the topic to get
+ * \retval The already stored or newly allocated topic
+ * \retval NULL if the topic was not found and could not be allocated
+ */
+struct stasis_topic *stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name);
+
/*! @} */
/*! @{ */
diff --git a/include/asterisk/xmpp.h b/include/asterisk/xmpp.h
index 07abb6e67..6833b6cce 100644
--- a/include/asterisk/xmpp.h
+++ b/include/asterisk/xmpp.h
@@ -134,7 +134,7 @@ struct ast_xmpp_client {
pthread_t thread;
int timeout;
unsigned int reconnect:1; /*!< Reconnect this client */
- struct ast_event_sub *mwi_sub; /*!< If distributing event information the MWI subscription */
+ struct stasis_subscription *mwi_sub; /*!< If distributing event information the MWI subscription */
struct ast_event_sub *device_state_sub; /*!< If distributing event information the device state subscription */
};