Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
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 = AST_BUILDOPT_SUM, .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 642 of file res_mwi_external.c.
#define FORMAT_MAILBOX_ROW "%6u %6u %s\n" |
Definition at line 643 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.
#define MWI_MAILBOX_TYPE "mailboxes" |
Definition at line 73 of file res_mwi_external.c.
enum folder_map |
Enumerator | |
---|---|
FOLDER_INVALID | |
FOLDER_INBOX | |
FOLDER_OLD |
Definition at line 318 of file res_mwi_external.c.
|
static |
Definition at line 943 of file res_mwi_external.c.
|
static |
Definition at line 943 of file res_mwi_external.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 943 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. |
NULL | on error. |
Definition at line 192 of file res_mwi_external.c.
References ast_sorcery_alloc(), ast_strlen_zero(), MWI_MAILBOX_TYPE, mwi_sorcery, 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. |
NULL | on error. |
Definition at line 201 of file res_mwi_external.c.
References ast_sorcery_copy(), voicemailpwcheck::mailbox, and mwi_sorcery.
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 302 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, ast_strlen_zero(), voicemailpwcheck::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 278 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 290 of file res_mwi_external.c.
References ao2_ref, ast_mwi_mailbox_get_by_regex(), mailboxes, mwi_mailbox_delete_all(), and regex().
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. |
NULL | on error or no mailbox. |
Definition at line 183 of file res_mwi_external.c.
References ast_sorcery_retrieve_by_id(), ast_strlen_zero(), MWI_MAILBOX_TYPE, mwi_sorcery, 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.
NULL | on error. |
Definition at line 172 of file res_mwi_external.c.
References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), MWI_MAILBOX_TYPE, mwi_sorcery, 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 "") |
NULL | on error. |
Definition at line 178 of file res_mwi_external.c.
References ast_sorcery_retrieve_by_regex(), MWI_MAILBOX_TYPE, mwi_sorcery, and regex().
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 206 of file res_mwi_external.c.
References ast_sorcery_object_get_id(), and voicemailpwcheck::mailbox.
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 211 of file res_mwi_external.c.
References voicemailpwcheck::mailbox.
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 216 of file res_mwi_external.c.
References voicemailpwcheck::mailbox.
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 221 of file res_mwi_external.c.
References voicemailpwcheck::mailbox.
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 226 of file res_mwi_external.c.
References voicemailpwcheck::mailbox.
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 231 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(), voicemailpwcheck::mailbox, MWI_MAILBOX_TYPE, and mwi_sorcery.
Referenced by mwi_mailbox_update(), and stasis_app_mailbox_update().
|
static |
Definition at line 910 of file res_mwi_external.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sorcery_observer_add(), ast_vm_register, LOG_ERROR, mwi_initial_events(), MWI_MAILBOX_TYPE, mwi_observers, mwi_sorcery, mwi_sorcery_init(), unload_module(), and vm_table.
|
static |
Definition at line 333 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 399 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, ast_strdupa, FOLDER_INBOX, FOLDER_INVALID, FOLDER_OLD, voicemailpwcheck::mailbox, mailboxes, mwi_folder_map(), and strsep().
|
static |
Definition at line 459 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, ast_strdupa, voicemailpwcheck::mailbox, mailboxes, and strsep().
Referenced by mwi_inboxcount2().
|
static |
Definition at line 512 of file res_mwi_external.c.
References mailboxes, and mwi_inboxcount().
|
static |
Definition at line 874 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, voicemailpwcheck::mailbox, mailboxes, and mwi_post_event().
Referenced by load_module().
|
static |
Definition at line 254 of file res_mwi_external.c.
References ast_sorcery_delete(), voicemailpwcheck::mailbox, and mwi_sorcery.
Referenced by ast_mwi_mailbox_delete(), and mwi_mailbox_delete_all().
|
static |
Definition at line 266 of file res_mwi_external.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, AO2_ITERATOR_UNLINK, ast_mwi_mailbox_unref, voicemailpwcheck::mailbox, mailboxes, and mwi_mailbox_delete().
Referenced by ast_mwi_mailbox_delete_all(), and ast_mwi_mailbox_delete_by_regex().
|
static |
Definition at line 357 of file res_mwi_external.c.
References ast_mwi_mailbox_get(), ast_mwi_mailbox_unref, FOLDER_INBOX, FOLDER_INVALID, FOLDER_OLD, voicemailpwcheck::mailbox, and mwi_folder_map().
|
static |
Definition at line 106 of file res_mwi_external.c.
References ast_delete_mwi_state, ast_publish_mwi_state, ast_sorcery_object_get_id(), voicemailpwcheck::mailbox, and NULL.
|
static |
Definition at line 96 of file res_mwi_external.c.
References mwi_post_event().
|
static |
Definition at line 90 of file res_mwi_external.c.
References ast_publish_mwi_state, ast_sorcery_object_get_id(), voicemailpwcheck::mailbox, and NULL.
Referenced by mwi_initial_events(), and mwi_observe_update().
|
static |
Definition at line 139 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, MWI_ASTDB_PREFIX, MWI_MAILBOX_TYPE, mwi_sorcery, mwi_sorcery_object_alloc(), NULL, and OPT_UINT_T.
Referenced by load_module().
|
static |
Internal function to allocate a mwi object.
Definition at line 126 of file res_mwi_external.c.
References ast_sorcery_generic_alloc(), and NULL.
Referenced by mwi_sorcery_init().
|
static |
Definition at line 896 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, mwi_observers, mwi_sorcery, NULL, and vm_table.
Referenced by load_module().
|
static |
Definition at line 943 of file res_mwi_external.c.
|
static |
Definition at line 943 of file res_mwi_external.c.
|
static |
Definition at line 119 of file res_mwi_external.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 83 of file res_mwi_external.c.
Referenced by ast_mwi_mailbox_alloc(), ast_mwi_mailbox_copy(), ast_mwi_mailbox_get(), ast_mwi_mailbox_get_all(), ast_mwi_mailbox_get_by_regex(), ast_mwi_mailbox_update(), load_module(), mwi_mailbox_delete(), mwi_sorcery_init(), and unload_module().
|
static |
Definition at line 521 of file res_mwi_external.c.
Referenced by load_module(), and unload_module().