Asterisk - The Open Source Telephony Project
18.5.0
|
Core external MWI support. More...
#include "asterisk.h"
#include "asterisk/app.h"
#include "asterisk/mwi.h"
#include "asterisk/module.h"
#include "asterisk/res_mwi_external.h"
#include "asterisk/sorcery.h"
#include "asterisk/cli.h"
Go to the source code of this file.
Data Structures | |
struct | ast_mwi_mailbox_object |
Macros | |
#define | FORMAT_MAILBOX_HDR "%6s %6s %s\n" |
#define | FORMAT_MAILBOX_ROW "%6u %6u %s\n" |
#define | MWI_ASTDB_PREFIX "mwi_external" |
#define | MWI_MAILBOX_TYPE "mailboxes" |
Enumerations | |
enum | folder_map { FOLDER_INVALID = 0, FOLDER_INBOX = 1, FOLDER_OLD = 2 } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
struct ast_mwi_mailbox_object * | ast_mwi_mailbox_alloc (const char *mailbox_id) |
Allocate an external MWI object. More... | |
struct ast_mwi_mailbox_object * | ast_mwi_mailbox_copy (const struct ast_mwi_mailbox_object *mailbox) |
Copy the external MWI counts object. More... | |
int | ast_mwi_mailbox_delete (const char *mailbox_id) |
Delete matching external MWI object. More... | |
int | ast_mwi_mailbox_delete_all (void) |
Delete all external MWI objects. More... | |
int | ast_mwi_mailbox_delete_by_regex (const char *regex) |
Delete all external MWI objects selected by the regular expression. More... | |
const struct ast_mwi_mailbox_object * | ast_mwi_mailbox_get (const char *mailbox_id) |
Get matching external MWI object. More... | |
struct ao2_container * | ast_mwi_mailbox_get_all (void) |
Get all external MWI objects. More... | |
struct ao2_container * | ast_mwi_mailbox_get_by_regex (const char *regex) |
Get all external MWI objects selected by the regular expression. More... | |
const char * | ast_mwi_mailbox_get_id (const struct ast_mwi_mailbox_object *mailbox) |
Get mailbox id. More... | |
unsigned int | ast_mwi_mailbox_get_msgs_new (const struct ast_mwi_mailbox_object *mailbox) |
Get the number of new messages. More... | |
unsigned int | ast_mwi_mailbox_get_msgs_old (const struct ast_mwi_mailbox_object *mailbox) |
Get the number of old messages. More... | |
void | ast_mwi_mailbox_set_msgs_new (struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs) |
Set the number of new messages. More... | |
void | ast_mwi_mailbox_set_msgs_old (struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs) |
Set the number of old messages. More... | |
int | ast_mwi_mailbox_update (struct ast_mwi_mailbox_object *mailbox) |
Update the external MWI counts with the given object. More... | |
static int | load_module (void) |
static enum folder_map | mwi_folder_map (const char *folder) |
static int | mwi_has_voicemail (const char *mailboxes, const char *folder) |
static int | mwi_inboxcount (const char *mailboxes, int *newmsgs, int *oldmsgs) |
static int | mwi_inboxcount2 (const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs) |
static void | mwi_initial_events (void) |
static void | mwi_mailbox_delete (struct ast_mwi_mailbox_object *mailbox) |
static void | mwi_mailbox_delete_all (struct ao2_container *mailboxes) |
static int | mwi_messagecount (const char *mailbox_id, const char *folder) |
static void | mwi_observe_delete (const void *obj) |
static void | mwi_observe_update (const void *obj) |
static void | mwi_post_event (const struct ast_mwi_mailbox_object *mailbox) |
static int | mwi_sorcery_init (void) |
static void * | mwi_sorcery_object_alloc (const char *id) |
Internal function to allocate a mwi object. More... | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Core external MWI resource" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 5, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static const struct ast_sorcery_observer | mwi_observers |
static struct ast_sorcery * | mwi_sorcery |
static const struct ast_vm_functions | vm_table |
Core external MWI support.
The module manages the persistent message counts cache and supplies an API to allow the protocol specific modules to control the counts or a subset.
See Also:
Definition in file res_mwi_external.c.
#define FORMAT_MAILBOX_HDR "%6s %6s %s\n" |
Definition at line 650 of file res_mwi_external.c.
#define FORMAT_MAILBOX_ROW "%6u %6u %s\n" |
Definition at line 651 of file res_mwi_external.c.
#define MWI_ASTDB_PREFIX "mwi_external" |
Define to include CLI commands to manipulate the external MWI mailboxes. Useful for testing the module functionality.
Definition at line 72 of file res_mwi_external.c.
Referenced by mwi_sorcery_init().
#define MWI_MAILBOX_TYPE "mailboxes" |
Definition at line 73 of file res_mwi_external.c.
Referenced by ast_mwi_mailbox_alloc(), ast_mwi_mailbox_get(), ast_mwi_mailbox_get_all(), ast_mwi_mailbox_get_by_regex(), ast_mwi_mailbox_update(), load_module(), mwi_sorcery_init(), and unload_module().
enum folder_map |
Enumerator | |
---|---|
FOLDER_INVALID | |
FOLDER_INBOX | |
FOLDER_OLD |
Definition at line 326 of file res_mwi_external.c.
|
static |
Definition at line 957 of file res_mwi_external.c.
|
static |
Definition at line 957 of file res_mwi_external.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 957 of file res_mwi_external.c.
struct ast_mwi_mailbox_object* ast_mwi_mailbox_alloc | ( | const char * | mailbox_id | ) |
Allocate an external MWI object.
mailbox_id | Name of mailbox. |
object | on success. The object is an ao2 object. |
NULL | on error. |
Definition at line 196 of file res_mwi_external.c.
References ast_sorcery_alloc(), ast_strlen_zero, MWI_MAILBOX_TYPE, and NULL.
Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().
struct ast_mwi_mailbox_object* ast_mwi_mailbox_copy | ( | const struct ast_mwi_mailbox_object * | mailbox | ) |
Copy the external MWI counts object.
mailbox | What to copy. |
copy | on success. The object is an ao2 object. |
NULL | on error. |
Definition at line 205 of file res_mwi_external.c.
References ast_sorcery_copy().
int ast_mwi_mailbox_delete | ( | const char * | mailbox_id | ) |
Delete matching external MWI object.
mailbox_id | Name of mailbox to delete. |
0 | on success. |
-1 | on error. |
Definition at line 310 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, ast_strlen_zero, mailbox, and mwi_mailbox_delete().
Referenced by mwi_mailbox_delete(), and stasis_app_mailbox_delete().
int ast_mwi_mailbox_delete_all | ( | void | ) |
Delete all external MWI objects.
0 | on success. |
-1 | on error. |
Definition at line 286 of file res_mwi_external.c.
References ao2_ref, ast_mwi_mailbox_get_all(), mailboxes, and mwi_mailbox_delete_all().
int ast_mwi_mailbox_delete_by_regex | ( | const char * | regex | ) |
Delete all external MWI objects selected by the regular expression.
regex | Regular expression in extended syntax. (NULL is same as "") |
0 | on success. |
-1 | on error. |
Definition at line 298 of file res_mwi_external.c.
References ao2_ref, ast_mwi_mailbox_get_by_regex(), mailboxes, and mwi_mailbox_delete_all().
Referenced by mwi_mailbox_delete().
const struct ast_mwi_mailbox_object* ast_mwi_mailbox_get | ( | const char * | mailbox_id | ) |
Get matching external MWI object.
mailbox_id | Name of mailbox to retrieve. |
requested | mailbox on success. The object is an ao2 object. |
NULL | on error or no mailbox. |
Definition at line 187 of file res_mwi_external.c.
References ast_sorcery_retrieve_by_id(), ast_strlen_zero, MWI_MAILBOX_TYPE, and NULL.
Referenced by ast_mwi_mailbox_delete(), mwi_has_voicemail(), mwi_inboxcount(), mwi_mailbox_get(), mwi_messagecount(), stasis_app_mailbox_delete(), and stasis_app_mailbox_to_json().
struct ao2_container* ast_mwi_mailbox_get_all | ( | void | ) |
Get all external MWI objects.
container | of struct ast_mwi_mailbox_object on success. |
NULL | on error. |
Definition at line 176 of file res_mwi_external.c.
References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), MWI_MAILBOX_TYPE, and NULL.
Referenced by ast_mwi_mailbox_delete_all(), mwi_initial_events(), and stasis_app_mailboxes_to_json().
struct ao2_container* ast_mwi_mailbox_get_by_regex | ( | const char * | regex | ) |
Get all external MWI objects selected by the regular expression.
regex | Regular expression in extended syntax. (NULL is same as "") |
container | of struct ast_mwi_mailbox_object on success. |
NULL | on error. |
Definition at line 182 of file res_mwi_external.c.
References ast_sorcery_retrieve_by_regex(), and MWI_MAILBOX_TYPE.
Referenced by ast_mwi_mailbox_delete_by_regex(), and mwi_mailbox_get().
const char* ast_mwi_mailbox_get_id | ( | const struct ast_mwi_mailbox_object * | mailbox | ) |
Get mailbox id.
mailbox | Object to get id. |
Definition at line 210 of file res_mwi_external.c.
References ast_sorcery_object_get_id().
Referenced by mailbox_to_json(), and mwi_mailbox_get().
unsigned int ast_mwi_mailbox_get_msgs_new | ( | const struct ast_mwi_mailbox_object * | mailbox | ) |
Get the number of new messages.
mailbox | Object to get number of new messages. |
Definition at line 215 of file res_mwi_external.c.
References ast_mwi_mailbox_object::msgs_new.
Referenced by mailbox_to_json(), and mwi_mailbox_get().
unsigned int ast_mwi_mailbox_get_msgs_old | ( | const struct ast_mwi_mailbox_object * | mailbox | ) |
Get the number of old messages.
mailbox | Object to get number of old messages. |
Definition at line 220 of file res_mwi_external.c.
References ast_mwi_mailbox_object::msgs_old.
Referenced by mailbox_to_json(), and mwi_mailbox_get().
void ast_mwi_mailbox_set_msgs_new | ( | struct ast_mwi_mailbox_object * | mailbox, |
unsigned int | num_msgs | ||
) |
Set the number of new messages.
mailbox | Object to set number of new messages. |
num_msgs | Number of messages to set. |
Definition at line 225 of file res_mwi_external.c.
References ast_mwi_mailbox_object::msgs_new.
Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().
void ast_mwi_mailbox_set_msgs_old | ( | struct ast_mwi_mailbox_object * | mailbox, |
unsigned int | num_msgs | ||
) |
Set the number of old messages.
mailbox | Object to set number of old messages. |
num_msgs | Number of messages to set. |
Definition at line 230 of file res_mwi_external.c.
References ast_mwi_mailbox_object::msgs_old.
Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().
int ast_mwi_mailbox_update | ( | struct ast_mwi_mailbox_object * | mailbox | ) |
Update the external MWI counts with the given object.
mailbox | What to update. |
0 | on success. |
-1 | on error. |
Definition at line 235 of file res_mwi_external.c.
References ast_mwi_mailbox_unref, ast_sorcery_create(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_id(), ast_sorcery_update(), exists(), and MWI_MAILBOX_TYPE.
Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().
|
static |
Definition at line 924 of file res_mwi_external.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_log, AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, ast_sorcery_observer_add(), ast_vm_register, ASTERISK_GPL_KEY, LOG_ERROR, mwi_initial_events(), MWI_MAILBOX_TYPE, mwi_sorcery_init(), and unload_module().
|
static |
Definition at line 341 of file res_mwi_external.c.
References ast_strlen_zero, FOLDER_INBOX, FOLDER_INVALID, and FOLDER_OLD.
Referenced by mwi_has_voicemail(), and mwi_messagecount().
|
static |
Definition at line 407 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, ast_strdupa, FOLDER_INBOX, FOLDER_INVALID, FOLDER_OLD, mailbox, ast_mwi_mailbox_object::msgs_new, ast_mwi_mailbox_object::msgs_old, mwi_folder_map(), parse(), and strsep().
|
static |
Definition at line 467 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, ast_strdupa, mailbox, ast_mwi_mailbox_object::msgs_new, ast_mwi_mailbox_object::msgs_old, parse(), and strsep().
Referenced by mwi_inboxcount2().
|
static |
Definition at line 520 of file res_mwi_external.c.
References mwi_inboxcount().
|
static |
Definition at line 888 of file res_mwi_external.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, AO2_ITERATOR_UNLINK, ao2_ref, ast_mwi_mailbox_get_all(), ast_mwi_mailbox_unref, mailbox, mailboxes, and mwi_post_event().
Referenced by load_module().
|
static |
Definition at line 260 of file res_mwi_external.c.
References ast_sorcery_delete().
Referenced by ast_mwi_mailbox_delete(), and mwi_mailbox_delete_all().
|
static |
Definition at line 274 of file res_mwi_external.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, AO2_ITERATOR_UNLINK, ast_mwi_mailbox_unref, mailbox, and mwi_mailbox_delete().
Referenced by ast_mwi_mailbox_delete_all(), and ast_mwi_mailbox_delete_by_regex().
|
static |
Definition at line 365 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, FOLDER_INBOX, FOLDER_INVALID, FOLDER_OLD, mailbox, ast_mwi_mailbox_object::msgs_new, ast_mwi_mailbox_object::msgs_old, and mwi_folder_map().
|
static |
Definition at line 110 of file res_mwi_external.c.
References ast_delete_mwi_state, ast_publish_mwi_state, ast_sorcery_object_get_id(), mailbox, ast_mwi_mailbox_object::msgs_new, ast_mwi_mailbox_object::msgs_old, and NULL.
|
static |
Definition at line 98 of file res_mwi_external.c.
References mwi_post_event().
|
static |
Definition at line 92 of file res_mwi_external.c.
References ast_publish_mwi_state, ast_sorcery_object_get_id(), ast_mwi_mailbox_object::msgs_new, ast_mwi_mailbox_object::msgs_old, and NULL.
Referenced by mwi_initial_events(), and mwi_observe_update().
|
static |
Definition at line 143 of file res_mwi_external.c.
References ast_log, ast_sorcery_apply_default, AST_SORCERY_APPLY_FAIL, ast_sorcery_object_field_register_nodoc, ast_sorcery_object_register, ast_sorcery_open, FLDSET, LOG_ERROR, ast_mwi_mailbox_object::msgs_new, ast_mwi_mailbox_object::msgs_old, MWI_ASTDB_PREFIX, MWI_MAILBOX_TYPE, mwi_sorcery_object_alloc(), NULL, and OPT_UINT_T.
Referenced by load_module().
|
static |
Internal function to allocate a mwi object.
Definition at line 130 of file res_mwi_external.c.
References ast_sorcery_generic_alloc(), and NULL.
Referenced by mwi_sorcery_init().
|
static |
Definition at line 910 of file res_mwi_external.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), ast_sorcery_observer_remove(), ast_sorcery_unref, ast_vm_unregister(), ast_vm_functions::module_name, MWI_MAILBOX_TYPE, and NULL.
Referenced by load_module().
|
static |
Definition at line 957 of file res_mwi_external.c.
|
static |
Definition at line 957 of file res_mwi_external.c.
|
static |
Definition at line 123 of file res_mwi_external.c.
|
static |
Definition at line 83 of file res_mwi_external.c.
|
static |
Definition at line 529 of file res_mwi_external.c.