Asterisk - The Open Source Telephony Project  18.5.0
mwi.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2019, Sangoma Technologies Corporation
5  *
6  * Kevin Harwell <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 #ifndef _ASTERISK_MWI_H
20 #define _ASTERISK_MWI_H
21 
22 /*! \file
23  *
24  * \brief Asterisk MWI API.
25  *
26  * \par Intro
27  *
28  * This module manages, and processes all things MWI. Defined are mechanisms for subscribing
29  * and publishing to MWI topics. User modules wishing to receive MWI updates for a particular
30  * mailbox should do so by adding an MWI subscriber to that mailbox, followed by subscribing
31  * to the mailbox's topic. Likewise, user modules that want to publish MWI updates about a
32  * particular mailbox should first add a publisher for that mailbox prior to publishing.
33  *
34  * MWI state is managed via an underlying \ref stasis_state_manager (if interested see the
35  * stasis_state.c module for the gory details). As such all last known mailbox state can be
36  * retrieve and iterated over by using the \ref ast_mwi_callback function.
37  *
38  * \par ast_mwi_subscriber
39  *
40  * Created via \ref ast_mwi_add_subscriber, a subscriber subscribes to a given mailbox in
41  * order to receive updates about the given mailbox. Adding a subscriber will create the
42  * underlying topic, and associated state data if those do not already exist for it. The
43  * topic, and last known state data is guaranteed to exist for the lifetime of the subscriber.
44  * State data can be NULL if nothing has been published to the mailbox's topic yet.
45  *
46  * NOTE, currently adding a subscriber here will either create, or add a reference to the
47  * underlying stasis state (and associated topic). However, it does not actually subscribe to
48  * the stasis topic itself. You still need to explicitly call \ref stasis_subscribe, or
49  * similar on the topic if you wish to receive published event updates.
50  *
51  * So given that when subscribing to an MWI topic the following order should be adhered to:
52  *
53  * 1. Add an MWI state subscriber using \ref ast_mwi_add_subscriber
54  * 2. Retrieve the topic from the subscriber using \ref ast_mwi_subscriber_topic
55  * 3. Subscribe to the topic itself using \ref stasis_subscribe or \ref stasis_subscribe_pool
56  *
57  * Or simply call \ref ast_mwi_subscribe_pool, which combines those steps into a single call and
58  * returns the subscriber that is now subscribed to both the stasis topic and state.
59  *
60  * Similarly, releasing the subscriber's reference removes a reference to the underlying state,
61  * but does not unsubscribe from the MWI topic. This should be done separately and prior to
62  * removing the subscriber's state reference:
63  *
64  * 1. Unsubscribe from the stasis topic subscription using \ref stasis_unsubscribe or
65  * \ref stasis_unsubscribe_and_join
66  * 2. Remove the MWI subscriber reference
67  *
68  * Or call \ref ast_mwi_unsubscribe (or _and_join), which combines those two steps into a
69  * single call.
70  *
71  * \par ast_mwi_publisher
72  *
73  * Before publishing to a particular topic a publisher should be created. This can be achieved
74  * by using \ref ast_mwi_add_publisher. Publishing to a mailbox should then be done using the
75  * \ref ast_mwi_publish function. This ensures the message is published to the appropriate
76  * topic, and the last known state is maintained.
77  *
78  * Publishing by mailbox id alone is also allowed. However, it is not recommended to do so,
79  * and exists mainly for backwards compatibility, and legacy subsystems. If, and when this
80  * method of publishing is employed a call to one of the \ref ast_delete_mwi_state functions
81  * should also be called for a given mailbox id after no more publishing will be done for
82  * that id. Otherwise a memory leak on the underlying stasis_state object will occur.
83  *
84  * \par ast_mwi_observer
85  *
86  * Add an observer in order to watch for particular MWI module related events. For instance if
87  * a submodule needs to know when a subscription is added to any mailbox an observer can be
88  * added to watch for that.
89  */
90 
91 #include "asterisk/utils.h"
92 #include "asterisk/stasis_state.h"
93 
94 #if defined(__cplusplus) || defined(c_plusplus)
95 extern "C" {
96 #endif
97 
98 struct ast_json;
99 struct stasis_message_type;
100 struct ast_mwi_state;
101 
102 /*!
103  * \brief An MWI state subscriber
104  *
105  * An ao2 managed object. Holds a reference to the latest MWI state for its lifetime.
106  *
107  * \since 13.28.0
108  * \since 16.5.0
109  */
110 struct ast_mwi_subscriber;
111 
112 /*!
113  * \brief Add an MWI state subscriber to the mailbox
114  *
115  * Adding a subscriber to a mailbox will create a stasis topic for the mailbox if one
116  * does not already exist. It does not however subscribe to the topic itself. This is
117  * done separately using a call to \ref stasis_subscribe or \ref stasis_subscribe_pool.
118  *
119  * A subscriber can be removed by releasing its reference. Doing so releases its underlying
120  * reference to the MWI state. It does not unsubscribe from the topic. Unsubscribing from
121  * a topic should be done prior to unsubscribing the state.
122  *
123  * \param mailbox The subscription state mailbox id
124  *
125  * \retval An MWI subscriber object
126  * \retval NULL on error
127  *
128  * \since 13.28.0
129  * \since 16.5.0
130  */
132 
133 /*!
134  * \brief Add an MWI state subscriber, and stasis subscription to the mailbox
135  *
136  * Adding a subscriber to a mailbox will create a stasis topic for the mailbox if one
137  * does not already exist. Once successfully create the underlying stasis topic is then
138  * subscribed to as well.
139  *
140  * A subscriber can be removed by releasing its reference. Doing so releases its underlying
141  * reference to the MWI state. It does not unsubscribe from the topic. Unsubscribing from
142  * a topic should be done prior to unsubscribing the state.
143  *
144  * \param mailbox The subscription state mailbox id
145  * \param callback The stasis subscription callback
146  * \param data A user data object passed to the stasis subscription
147  *
148  * \retval An MWI subscriber object
149  * \retval NULL on error
150  *
151  * \since 13.28.0
152  * \since 16.5.0
153  */
155  stasis_subscription_cb callback, void *data);
156 
157 /*!
158  * \brief Unsubscribe from the stasis topic and MWI.
159  *
160  * \param sub An MWI subscriber
161  *
162  * \retval NULL
163  *
164  * \since 13.28.0
165  * \since 16.5.0
166  */
168 
169 /*!
170  * \brief Unsubscribe from the stasis topic, block until the final message
171  * is received, and then unsubscribe from MWI.
172  *
173  * \param sub An MWI subscriber
174  *
175  * \retval NULL
176  *
177  * \since 13.28.0
178  * \since 16.5.0
179  */
181 
182 /*!
183  * \brief Retrieves the MWI subscriber's topic
184  *
185  * \note Returned topic's reference count is NOT incremented. However, the topic is
186  * guaranteed to live for the lifetime of the subscriber.
187  *
188  * \param sub An MWI subscriber
189  *
190  * \retval A stasis topic subscribed to by the subscriber
191  *
192  * \since 13.28.0
193  * \since 16.5.0
194  */
196 
197 /*!
198  * \brief Retrieves the state data object associated with the MWI subscriber
199  *
200  * \note Returned data's reference count is incremented
201  *
202  * \param sub An MWI subscriber
203  *
204  * \retval The state data object
205  *
206  * \since 13.28.0
207  * \since 16.5.0
208  */
210 
211 /*!
212  * \brief Retrieve the stasis MWI topic subscription if available.
213  *
214  * \param sub An MWI subscriber
215  *
216  * \retval The subscriber's stasis subscription
217  * \retval NULL if no subscription available
218  *
219  * \since 13.28.0
220  * \since 16.5.0
221  */
223 
224 /*!
225  * \brief An MWI state publisher
226  *
227  * An ao2 managed object. Holds a reference to the latest MWI state for its lifetime.
228  *
229  * \since 13.28.0
230  * \since 16.5.0
231  */
232 struct ast_mwi_publisher;
233 
234 /*!
235  * \brief Add an MWI state publisher to the mailbox
236  *
237  * Adding a publisher to a mailbox will create a stasis topic for the mailbox if one
238  * does not already exist. A publisher can be removed by releasing its reference. Doing
239  * so releases its underlying reference to the MWI state.
240  *
241  * \param mailbox The mailbox id to publish to
242  *
243  * \retval An MWI publisher object
244  * \retval NULl on error
245  *
246  * \since 13.28.0
247  * \since 16.5.0
248  */
249 struct ast_mwi_publisher *ast_mwi_add_publisher(const char *mailbox);
250 
251 /*! \brief MWI state event interface */
253  /*!
254  * \brief Raised when MWI is being subscribed
255  *
256  * \param mailbox The mailbox id subscribed
257  * \param sub The subscriber subscribed
258  */
259  void (*on_subscribe)(const char *mailbox, struct ast_mwi_subscriber *sub);
260 
261  /*!
262  * \brief Raised when MWI is being unsubscribed
263  *
264  * \param mailbox The mailbox id being unsubscribed
265  * \param sub The subscriber to unsubscribe
266  */
267  void (*on_unsubscribe)(const char *mailbox, struct ast_mwi_subscriber *sub);
268 };
269 
270 /*!
271  * \brief Add an observer to receive MWI state related events.
272  *
273  * \param observer The observer handling events
274  *
275  * \retval 0 if successfully registered, -1 otherwise
276  *
277  * \since 13.28.0
278  * \since 16.5.0
279  */
281 
282 /*!
283  * \brief Remove an MWI state observer.
284  *
285  * \param observer The observer being removed
286  *
287  * \since 13.28.0
288  * \since 16.5.0
289  */
291 
292 /*!
293  * \brief The delegate called for each managed mailbox state.
294  *
295  * \param mwi_state The mwi state object
296  * \param data User data passed in by the initiator
297  *
298  * \retval 0 to continue traversing, or CMP_STOP (2) to stop traversing
299  *
300  * \since 13.28.0
301  * \since 16.5.0
302  */
303 typedef int (*on_mwi_state)(struct ast_mwi_state *mwi_state, void *data);
304 
305 /*!
306  * \brief For each managed mailbox call the given handler.
307  *
308  * \param handler The mwi state handler to call for each managed mailbox
309  * \param data User to data to pass on to the handler
310  *
311  * \since 13.28.0
312  * \since 16.5.0
313  */
315 
316 /*!
317  * \brief For each managed mailbox that has a subscriber call the given handler.
318  *
319  * \param handler The mwi state handler to call for each managed mailbox
320  * \param data User to data to pass on to the handler
321  *
322  * \since 13.28.0
323  * \since 16.5.0
324  */
326 
327 /*!
328  * \brief Publish MWI for the given mailbox.
329  *
330  * \param publisher The publisher to publish a mailbox update on
331  * \param urgent_msgs The number of urgent messages in this mailbox
332  * \param new_msgs The number of new messages in this mailbox
333  * \param old_msgs The number of old messages in this mailbox
334  * \param channel_id A unique identifier for a channel associated with this
335  * change in mailbox state
336  * \param eid The EID of the server that originally published the message
337  *
338  * \retval 0 on success
339  * \retval -1 on failure
340  *
341  * \since 13.28.0
342  * \since 16.5.0
343  */
344 int ast_mwi_publish(struct ast_mwi_publisher *publisher, int urgent_msgs,
345  int new_msgs, int old_msgs, const char *channel_id, struct ast_eid *eid);
346 
347 /*!
348  * \brief Publish MWI for the given mailbox.
349  *
350  * \param mailbox The mailbox identifier string.
351  * \param context The context this mailbox resides in (NULL or "" if only using mailbox)
352  * \param urgent_msgs The number of urgent messages in this mailbox
353  * \param new_msgs The number of new messages in this mailbox
354  * \param old_msgs The number of old messages in this mailbox
355  * \param channel_id A unique identifier for a channel associated with this
356  * change in mailbox state
357  * \param eid The EID of the server that originally published the message
358  *
359  * \retval 0 on success
360  * \retval -1 on failure
361  *
362  * \since 13.28.0
363  * \since 16.5.0
364  */
365 int ast_mwi_publish_by_mailbox(const char *mailbox, const char *context, int urgent_msgs,
366  int new_msgs, int old_msgs, const char *channel_id, struct ast_eid *eid);
367 
368 /*!
369  * \since 12
370  * \brief Publish a MWI state update via stasis
371  *
372  * \param[in] mailbox The mailbox identifier string.
373  * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
374  * \param[in] new_msgs The number of new messages in this mailbox
375  * \param[in] old_msgs The number of old messages in this mailbox
376  *
377  * \retval 0 Success
378  * \retval -1 Failure
379  */
380 #define ast_publish_mwi_state(mailbox, context, new_msgs, old_msgs) \
381  ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL, NULL)
382 
383 /*!
384  * \since 12
385  * \brief Publish a MWI state update associated with some channel
386  *
387  * \param[in] mailbox The mailbox identifier string.
388  * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
389  * \param[in] new_msgs The number of new messages in this mailbox
390  * \param[in] old_msgs The number of old messages in this mailbox
391  * \param[in] channel_id A unique identifier for a channel associated with this
392  * change in mailbox state
393  *
394  * \retval 0 Success
395  * \retval -1 Failure
396  */
397 #define ast_publish_mwi_state_channel(mailbox, context, new_msgs, old_msgs, channel_id) \
398  ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, channel_id, NULL)
399 
400 /*!
401  * \since 12
402  * \brief Publish a MWI state update via stasis with all parameters
403  *
404  * \param[in] mailbox The mailbox identifier string.
405  * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
406  * \param[in] new_msgs The number of new messages in this mailbox
407  * \param[in] old_msgs The number of old messages in this mailbox
408  * \param[in] channel_id A unique identifier for a channel associated with this
409  * change in mailbox state
410  * \param[in] eid The EID of the server that originally published the message
411  *
412  * \retval 0 Success
413  * \retval -1 Failure
414  */
416  const char *mailbox,
417  const char *context,
418  int new_msgs,
419  int old_msgs,
420  const char *channel_id,
421  struct ast_eid *eid);
422 
423 /*!
424  * \since 12.2.0
425  * \brief Delete MWI state cached by stasis
426  *
427  * \param[in] mailbox The mailbox identifier string.
428  * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
429  *
430  * \retval 0 Success
431  * \retval -1 Failure
432  */
433 #define ast_delete_mwi_state(mailbox, context) \
434  ast_delete_mwi_state_full(mailbox, context, NULL)
435 
436 /*!
437  * \since 12.2.0
438  * \brief Delete MWI state cached by stasis with all parameters
439  *
440  * \param[in] mailbox The mailbox identifier string.
441  * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
442  * \param[in] eid The EID of the server that originally published the message
443  *
444  * \retval 0 Success
445  * \retval -1 Failure
446  */
447 int ast_delete_mwi_state_full(const char *mailbox, const char *context, struct ast_eid *eid);
448 
449 /*! \addtogroup StasisTopicsAndMessages
450  * @{
451  */
452 
453 /*!
454  * \brief The structure that contains MWI state
455  * \since 12
456  */
459  AST_STRING_FIELD(uniqueid); /*!< Unique identifier for this mailbox */
460  );
461  int new_msgs; /*!< The current number of new messages for this mailbox */
462  int old_msgs; /*!< The current number of old messages for this mailbox */
463  /*! If applicable, a snapshot of the channel that caused this MWI change */
465  struct ast_eid eid; /*!< The EID of the server where this message originated */
466  int urgent_msgs; /*!< The current number of urgent messages for this mailbox */
467 };
468 
469 /*!
470  * \brief Object that represents an MWI update with some additional application
471  * defined data
472  */
473 struct ast_mwi_blob {
474  struct ast_mwi_state *mwi_state; /*!< MWI state */
475  struct ast_json *blob; /*!< JSON blob of data */
476 };
477 
478 /*!
479  * \since 12
480  * \brief Create a \ref ast_mwi_state object
481  *
482  * \param[in] mailbox The mailbox identifier string.
483  * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
484  *
485  * \retval \ref ast_mwi_state object on success
486  * \retval NULL on error
487  */
488 struct ast_mwi_state *ast_mwi_create(const char *mailbox, const char *context);
489 
490 /*!
491  * \since 12
492  * \brief Creates a \ref ast_mwi_blob message.
493  *
494  * The \a blob JSON object requires a \c "type" field describing the blob. It
495  * should also be treated as immutable and not modified after it is put into the
496  * message.
497  *
498  * \param mwi_state MWI state associated with the update
499  * \param message_type The type of message to create
500  * \param blob JSON object representing the data.
501  * \return \ref ast_mwi_blob message.
502  * \return \c NULL on error
503  */
504 struct stasis_message *ast_mwi_blob_create(struct ast_mwi_state *mwi_state,
505  struct stasis_message_type *message_type,
506  struct ast_json *blob);
507 
508 /*!
509  * \brief Get the \ref stasis topic for MWI messages
510  * \retval The topic structure for MWI messages
511  * \retval NULL if it has not been allocated
512  * \since 12
513  */
514 struct stasis_topic *ast_mwi_topic_all(void);
515 
516 /*!
517  * \brief Get the \ref stasis topic for MWI messages on a unique ID
518  * \param uniqueid The unique id for which to get the topic
519  * \retval The topic structure for MWI messages for a given uniqueid
520  * \retval NULL if it failed to be found or allocated
521  * \since 12
522  */
523 struct stasis_topic *ast_mwi_topic(const char *uniqueid);
524 
525 /*!
526  * \brief Get the \ref stasis caching topic for MWI messages
527  * \retval The caching topic structure for MWI messages
528  * \retval NULL if it has not been allocated
529  * \since 12
530  */
531 struct stasis_topic *ast_mwi_topic_cached(void);
532 
533 /*!
534  * \brief Backend cache for ast_mwi_topic_cached().
535  * \retval Cache of \ref ast_mwi_state.
536  */
537 struct stasis_cache *ast_mwi_state_cache(void);
538 
539 /*!
540  * \brief Get the \ref stasis message type for MWI messages
541  * \retval The message type structure for MWI messages
542  * \retval NULL on error
543  * \since 12
544  */
546 
547 /*!
548  * \brief Get the \ref stasis message type for voicemail application specific messages
549  *
550  * This message type exists for those messages a voicemail application may wish to send
551  * that have no logical relationship with other voicemail applications. Voicemail apps
552  * that use this message type must pass a \ref ast_mwi_blob. Any extraneous information
553  * in the JSON blob must be packed as key/value pair tuples of strings.
554  *
555  * At least one key/value tuple must have a key value of "Event".
556  *
557  * \retval The \ref stasis_message_type for voicemail application specific messages
558  * \retval NULL on error
559  * \since 12
560  */
562 
563 /*!
564  * \brief Initialize the mwi core
565  *
566  * \retval 0 Success
567  * \retval -1 Failure
568  *
569  * \since 13.27.0
570  * \since 16.4.0
571  */
572 int mwi_init(void);
573 
574 #define AST_MAX_MAILBOX_UNIQUEID (AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2)
575 
576 #if defined(__cplusplus) || defined(c_plusplus)
577 }
578 #endif
579 
580 #endif /* _ASTERISK_MWI_H */
void(* on_unsubscribe)(const char *mailbox, struct ast_mwi_subscriber *sub)
Raised when MWI is being unsubscribed.
Definition: mwi.h:267
struct ast_mwi_state * mwi_state
Definition: mwi.h:474
int ast_delete_mwi_state_full(const char *mailbox, const char *context, struct ast_eid *eid)
Delete MWI state cached by stasis with all parameters.
Definition: mwi.c:399
void * ast_mwi_unsubscribe(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic and MWI.
Definition: mwi.c:249
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
Definition: mwi.c:90
struct ast_mwi_state * ast_mwi_create(const char *mailbox, const char *context)
Create a ast_mwi_state object.
Definition: mwi.c:148
int mwi_init(void)
Initialize the mwi core.
Definition: mwi.c:502
struct stasis_message * ast_mwi_blob_create(struct ast_mwi_state *mwi_state, struct stasis_message_type *message_type, struct ast_json *blob)
Creates a ast_mwi_blob message.
Definition: mwi.c:462
void(* on_subscribe)(const char *mailbox, struct ast_mwi_subscriber *sub)
Raised when MWI is being subscribed.
Definition: mwi.h:259
struct stasis_subscription * ast_mwi_subscriber_subscription(struct ast_mwi_subscriber *sub)
Retrieve the stasis MWI topic subscription if available.
Definition: mwi.c:272
Structure representing a snapshot of channel state.
struct stasis_topic * ast_mwi_subscriber_topic(struct ast_mwi_subscriber *sub)
Retrieves the MWI subscriber&#39;s topic.
Definition: mwi.c:259
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:337
void ast_mwi_state_callback_subscribed(on_mwi_state handler, void *data)
For each managed mailbox that has a subscriber call the given handler.
Definition: mwi.c:343
struct stasis_topic * ast_mwi_topic_all(void)
Get the Stasis Message Bus API topic for MWI messages.
Definition: mwi.c:85
struct ast_mwi_state * ast_mwi_subscriber_data(struct ast_mwi_subscriber *sub)
Retrieves the state data object associated with the MWI subscriber.
Definition: mwi.c:264
struct ast_json * blob
Definition: mwi.h:475
int ast_mwi_add_observer(struct ast_mwi_observer *observer)
Add an observer to receive MWI state related events.
Definition: mwi.c:296
An Entity ID is essentially a MAC address, brief and unique.
Definition: utils.h:786
Utility functions.
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:299
int old_msgs
Definition: mwi.h:462
int(* on_mwi_state)(struct ast_mwi_state *mwi_state, void *data)
The delegate called for each managed mailbox state.
Definition: mwi.h:303
Stasis State API.
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)
Publish a MWI state update via stasis with all parameters.
Definition: mwi.c:388
unsigned char eid[6]
Definition: utils.h:787
int ast_mwi_publish(struct ast_mwi_publisher *publisher, int urgent_msgs, int new_msgs, int old_msgs, const char *channel_id, struct ast_eid *eid)
Publish MWI for the given mailbox.
Definition: mwi.c:353
struct ast_mwi_subscriber * ast_mwi_add_subscriber(const char *mailbox)
Add an MWI state subscriber to the mailbox.
Definition: mwi.c:224
void ast_mwi_remove_observer(struct ast_mwi_observer *observer)
Remove an MWI state observer.
Definition: mwi.c:302
void(* stasis_subscription_cb)(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Callback function type for Stasis subscriptions.
Definition: stasis.h:615
void ast_mwi_state_callback_all(on_mwi_state handler, void *data)
For each managed mailbox call the given handler.
Definition: mwi.c:333
void * ast_mwi_unsubscribe_and_join(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic, block until the final message is received, and then unsubscribe fr...
Definition: mwi.c:254
struct ast_channel_snapshot * snapshot
Definition: mwi.h:464
int urgent_msgs
Definition: mwi.h:466
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
Object that represents an MWI update with some additional application defined data.
Definition: mwi.h:473
struct ast_mwi_publisher * ast_mwi_add_publisher(const char *mailbox)
Add an MWI state publisher to the mailbox.
Definition: mwi.c:290
struct stasis_topic * ast_mwi_topic_cached(void)
Get the Stasis Message Bus API caching topic for MWI messages.
Definition: mwi.c:95
MWI state event interface.
Definition: mwi.h:252
int new_msgs
Definition: mwi.h:461
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Definition: test_ari.c:59
struct ast_sorcery_instance_observer observer
struct stasis_forward * sub
Definition: res_corosync.c:240
Abstract JSON element (object, array, string, int, ...).
int ast_mwi_publish_by_mailbox(const char *mailbox, const char *context, int urgent_msgs, int new_msgs, int old_msgs, const char *channel_id, struct ast_eid *eid)
Publish MWI for the given mailbox.
Definition: mwi.c:370
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
The structure that contains MWI state.
Definition: mwi.h:457
struct stasis_topic * ast_mwi_topic(const char *uniqueid)
Get the Stasis Message Bus API topic for MWI messages on a unique ID.
Definition: mwi.c:100
struct ast_mwi_subscriber * ast_mwi_subscribe_pool(const char *mailbox, stasis_subscription_cb callback, void *data)
Add an MWI state subscriber, and stasis subscription to the mailbox.
Definition: mwi.c:230
struct ast_eid eid
Definition: mwi.h:465
struct stasis_message_type * ast_mwi_vm_app_type(void)
Get the Stasis Message Bus API message type for voicemail application specific messages.