summaryrefslogtreecommitdiff
path: root/include/asterisk/app.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk/app.h')
-rw-r--r--include/asterisk/app.h116
1 files changed, 94 insertions, 22 deletions
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 6cfb38004..85c2aefb1 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -1104,8 +1104,8 @@ void ast_safe_fork_cleanup(void);
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit);
/*!
+ * \since 12
* \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
@@ -1114,26 +1114,44 @@ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen def
* \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)
+#define ast_publish_mwi_state(mailbox, context, new_msgs, old_msgs) \
+ ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL, NULL)
+
+/*!
+ * \since 12
+ * \brief Publish a MWI state update associated with some channel
+ * \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] channel_id A unique identifier for a channel associated with this
+ * change in mailbox state
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+#define ast_publish_mwi_state_channel(mailbox, context, new_msgs, old_msgs, channel_id) \
+ ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, channel_id, NULL)
/*!
- * \brief Publish a MWI state update via stasis with EID
- * \param[in] uniqueid A unique identifier for this mailbox (usually mailbox@context)
+ * \since 12
+ * \brief Publish a MWI state update via stasis with all parameters
* \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] channel_id A unique identifier for a channel associated with this
* \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(
+int ast_publish_mwi_state_full(
const char *mailbox,
const char *context,
int new_msgs,
int old_msgs,
+ const char *channel_id,
struct ast_eid *eid);
/*! \addtogroup StasisTopicsAndMessages
@@ -1144,49 +1162,103 @@ int stasis_publish_mwi_state_full(
* \brief The structure that contains MWI state
* \since 12
*/
-struct stasis_mwi_state {
+struct ast_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 */
+ 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 */
+ int new_msgs; /*!< The current number of new messages for this mailbox */
+ int old_msgs; /*!< The current number of old messages for this mailbox */
+ /*! If applicable, a snapshot of the channel that caused this MWI change */
+ struct ast_channel_snapshot *snapshot;
+ struct ast_eid eid; /*!< The EID of the server where this message originated */
};
/*!
- * \brief Get the Stasis topic for MWI messages
+ * \brief Object that represents an MWI update with some additional application
+ * defined data
+ */
+struct ast_mwi_blob {
+ struct ast_mwi_state *mwi_state; /*!< MWI state */
+ struct ast_json *blob; /*!< JSON blob of data */
+};
+
+/*!
+ * \since 12
+ * \brief Create a \ref ast_mwi_state object
+ *
+ * \retval \ref ast_mwi_state object on success
+ * \retval NULL on error
+ */
+struct ast_mwi_state *ast_mwi_create(const char *mailbox, const char *context);
+
+/*!
+ * \since 12
+ * \brief Creates a \ref ast_mwi_blob message.
+ *
+ * The \a blob JSON object requires a \c "type" field describing the blob. It
+ * should also be treated as immutable and not modified after it is put into the
+ * message.
+ *
+ * \param mwi_state MWI state associated with the update
+ * \param message_type The type of message to create
+ * \param blob JSON object representing the data.
+ * \return \ref ast_mwi_blob message.
+ * \return \c NULL on error
+ */
+struct stasis_message *ast_mwi_blob_create(struct ast_mwi_state *mwi_state,
+ struct stasis_message_type *message_type,
+ struct ast_json *blob);
+
+/*!
+ * \brief Get the \ref 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);
+struct stasis_topic *ast_mwi_topic_all(void);
/*!
- * \brief Get the Stasis topic for MWI messages on a unique ID
+ * \brief Get the \ref 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);
+struct stasis_topic *ast_mwi_topic(const char *uniqueid);
/*!
- * \brief Get the Stasis caching topic for MWI messages
+ * \brief Get the \ref 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);
+struct stasis_caching_topic *ast_mwi_topic_cached(void);
/*!
- * \brief Get the Stasis message type for MWI messages
+ * \brief Get the \ref stasis message type for MWI messages
* \retval The message type structure for MWI messages
- * \retval NULL if it has not been allocated
+ * \retval NULL on error
+ * \since 12
+ */
+struct stasis_message_type *ast_mwi_state_type(void);
+
+/*!
+ * \brief Get the \ref stasis message type for voicemail application specific messages
+ *
+ * This message type exists for those messages a voicemail application may wish to send
+ * that have no logical relationship with other voicemail applications. Voicemail apps
+ * that use this message type must pass a \ref ast_mwi_blob. Any extraneous information
+ * in the JSON blob must be packed as key/value pair tuples of strings.
+ *
+ * At least one key/value tuple must have a key value of "Event".
+ *
+ * \retval The \ref stasis_message_type for voicemail application specific messages
+ * \retval NULL on error
* \since 12
*/
-struct stasis_message_type *stasis_mwi_state_type(void);
+struct stasis_message_type *ast_mwi_vm_app_type(void);
/*! @} */