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