157 if (ast_strlen_zero(mailbox_id)) {
162 if (*mailbox_id ==
'/') {
174 ast_free(regex_string);
179 ast_free(regex_string);
185 if (!
ao2_link(mailboxes, (
void *) mailbox)) {
201 if (!ast_strlen_zero(
id)) {
202 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
215 "OldMessages: %u\r\n"
216 "NewMessages: %u\r\n"
248 if (ast_strlen_zero(mailbox_id)) {
253 if (*mailbox_id ==
'/') {
265 ast_free(regex_string);
270 ast_free(regex_string);
296 unsigned int num_old;
297 unsigned int num_new;
299 if (ast_strlen_zero(mailbox_id)) {
305 if (!ast_strlen_zero(msgs_old)) {
306 if (sscanf(msgs_old,
"%u", &num_old) != 1) {
313 if (!ast_strlen_zero(msgs_new)) {
314 if (sscanf(msgs_new,
"%u", &num_new) != 1) {
339 static int unload_module(
void)
348 static int load_module(
void)
364 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
"AMI support for external MWI",
365 .support_level = AST_MODULE_SUPPORT_CORE,
367 .unload = unload_module,
369 .requires =
"res_mwi_external",
void astman_append(struct mansession *s, const char *fmt,...)
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_mwi_mailbox_get_id(const struct ast_mwi_mailbox_object *mailbox)
Get mailbox id.
struct ast_mwi_mailbox_object * ast_mwi_mailbox_alloc(const char *mailbox_id)
Allocate an external MWI object.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
void ast_mwi_mailbox_set_msgs_new(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs)
Set the number of new messages.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Core external MWI support.
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
int ast_mwi_mailbox_update(struct ast_mwi_mailbox_object *mailbox)
Update the external MWI counts with the given object.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
const struct ast_mwi_mailbox_object * ast_mwi_mailbox_get(const char *mailbox_id)
Get matching external MWI object.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
In case you didn't read that giant block of text above the mansession_session struct, the mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
Support for dynamic strings.
int ast_mwi_mailbox_delete(const char *mailbox_id)
Delete matching external MWI object.
int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str **regex_pattern)
Given a string regex_string in the form of "/regex/", convert it into the form of "regex"...
unsigned int ast_mwi_mailbox_get_msgs_new(const struct ast_mwi_mailbox_object *mailbox)
Get the number of new messages.
#define ast_mwi_mailbox_unref(mailbox)
Convenience unref function for mailbox object.
Module has failed to load, may be in an inconsistent state.
void ast_mwi_mailbox_set_msgs_old(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs)
Set the number of old messages.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
unsigned int ast_mwi_mailbox_get_msgs_old(const struct ast_mwi_mailbox_object *mailbox)
Get the number of old messages.
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define ASTERISK_GPL_KEY
The text the key() function should return.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
int ast_mwi_mailbox_delete_by_regex(const char *regex)
Delete all external MWI objects selected by the regular expression.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
struct ao2_container * ast_mwi_mailbox_get_by_regex(const char *regex)
Get all external MWI objects selected by the regular expression.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
#define ao2_link(container, obj)
Add an object to a container.