33#define test_category "/mwi/"
35#define MAILBOX_PREFIX "test~"
36#define MAILBOX_COUNT 500
37#define MAILBOX_SIZE 32
67 const char *p = strchr(
mailbox,
'~');
137 ast_log(
LOG_ERROR,
"Failed to destroy all MWI subscriptions: running=%zu, sum=%zu\n",
181 ast_log(
LOG_ERROR,
"Failed to create all MWI subscriptions: running=%zu, sum=%zu\n",
340 info->name = __func__;
342 info->summary =
"Test implicit publishing of MWI state";
370 info->name = __func__;
372 info->summary =
"Test explicit publishing of MWI state";
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Conversion utility functions.
int ast_str_to_umax(const char *str, uintmax_t *res)
Convert the given string to an unsigned max size integer.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
int(* on_mwi_state)(struct ast_mwi_state *mwi_state, void *data)
The delegate called for each managed mailbox state.
void ast_mwi_state_callback_all(on_mwi_state handler, void *data)
For each managed mailbox call the given handler.
struct ast_mwi_publisher * ast_mwi_add_publisher(const char *mailbox)
Add an MWI state publisher to the mailbox.
int ast_mwi_add_observer(struct ast_mwi_observer *observer)
Add an observer to receive MWI state related events.
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.
#define ast_delete_mwi_state(mailbox, context)
Delete MWI state cached by stasis.
void ast_mwi_remove_observer(struct ast_mwi_observer *observer)
Remove an MWI state observer.
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...
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.
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.
struct ast_mwi_state * ast_mwi_subscriber_data(struct ast_mwi_subscriber *sub)
Retrieves the state data object associated with the MWI subscriber.
static void * cleanup(void *unused)
struct stasis_forward * sub
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
MWI state event interface.
void(* on_subscribe)(const char *mailbox, struct ast_mwi_subscriber *sub)
Raised when MWI is being subscribed.
The structure that contains MWI state.
const ast_string_field uniqueid
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
static int subscriptions_destroy(struct subscriptions *subs)
static int num_to_mailbox(char *mailbox, size_t size, size_t num)
static int publishers_create(struct publishers *pubs)
static int mailbox_to_num(const char *mailbox, size_t *num)
static void mwi_type_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct ast_mwi_observer mwi_observer
static int publishers_destroy(struct publishers *pubs)
AST_TEST_DEFINE(implicit_publish)
static int publish(on_mwi_state cb, void *user_data)
static void handle_validate(const char *mailbox, struct ast_mwi_subscriber *sub)
static int load_module(void)
static size_t running_total
static int unload_module(void)
static int validate_data(struct ast_mwi_state *mwi_state)
static int subscriptions_create(struct subscriptions *subs)
static int explicit_publish_cb(struct ast_mwi_state *mwi_state, void *data)
static int implicit_publish_cb(struct ast_mwi_state *mwi_state, void *data)
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.