Asterisk - The Open Source Telephony Project
18.5.0
|
Custom presence provider. More...
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/presencestate.h"
#include "asterisk/cli.h"
#include "asterisk/astdb.h"
#include "asterisk/app.h"
#include "asterisk/test.h"
#include "asterisk/sem.h"
Go to the source code of this file.
Data Structures | |
struct | test_cb_data |
struct | test_string |
Macros | |
#define | PRES_MESSAGE "Quarterly financial meeting" |
#define | PRES_STATE "away" |
#define | PRES_SUBTYPE "down the hall" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (test_valid_parse_data) | |
AST_TEST_DEFINE (test_invalid_parse_data) | |
AST_TEST_DEFINE (test_presence_state_change) | |
AST_TEST_DEFINE (test_presence_state_base64_encode) | |
static enum ast_presence_state | custom_presence_callback (const char *data, char **subtype, char **message) |
static char * | handle_cli_presencestate_change (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_presencestate_list (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | load_module (void) |
static int | parse_data (char *data, enum ast_presence_state *state, char **subtype, char **message, char **options) |
static enum ast_test_result_state | presence_change_common (struct ast_test *test, const char *state, const char *subtype, const char *message, const char *options, char *out_state, size_t out_state_size, char *out_subtype, size_t out_subtype_size, char *out_message, size_t out_message_size) |
static int | presence_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | presence_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
static void | test_cb (void *userdata, struct stasis_subscription *sub, struct stasis_message *msg) |
static struct test_cb_data * | test_cb_data_alloc (void) |
static void | test_cb_data_destroy (struct test_cb_data *cb_data) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Gets or sets a presence state in the dialplan" , .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_DEVSTATE_PROVIDER, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static const char | astdb_family [] = "CustomPresence" |
static struct ast_cli_entry | cli_funcpresencestate [] |
static struct ast_custom_function | presence_function |
Custom presence provider.
Definition in file func_presencestate.c.
#define PRES_MESSAGE "Quarterly financial meeting" |
Definition at line 662 of file func_presencestate.c.
Referenced by AST_TEST_DEFINE().
#define PRES_STATE "away" |
Definition at line 660 of file func_presencestate.c.
Referenced by AST_TEST_DEFINE().
#define PRES_SUBTYPE "down the hall" |
Definition at line 661 of file func_presencestate.c.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 884 of file func_presencestate.c.
|
static |
Definition at line 884 of file func_presencestate.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 884 of file func_presencestate.c.
AST_TEST_DEFINE | ( | test_valid_parse_data | ) |
Definition at line 460 of file func_presencestate.c.
References ARRAY_LEN, ast_free, AST_PRESENCE_AVAILABLE, AST_PRESENCE_AWAY, AST_PRESENCE_CHAT, AST_PRESENCE_DND, AST_PRESENCE_NOT_SET, AST_PRESENCE_UNAVAILABLE, AST_PRESENCE_XA, ast_strdup, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), test_string::message, test_string::options, test_string::outputs, parse_data(), test_string::parse_string, state, test_string::subtype, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | test_invalid_parse_data | ) |
Definition at line 609 of file func_presencestate.c.
References ARRAY_LEN, ast_free, ast_log, ast_strdup, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), LOG_WARNING, test_string::message, test_string::options, parse_data(), test_string::parse_string, state, test_string::subtype, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | test_presence_state_change | ) |
Definition at line 742 of file func_presencestate.c.
References AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, sip_to_pjsip::info(), NULL, PRES_MESSAGE, PRES_STATE, PRES_SUBTYPE, presence_change_common(), TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | test_presence_state_base64_encode | ) |
Definition at line 780 of file func_presencestate.c.
References ast_base64encode(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, sip_to_pjsip::info(), PRES_MESSAGE, PRES_STATE, PRES_SUBTYPE, presence_change_common(), TEST_EXECUTE, and TEST_INIT.
|
static |
Definition at line 248 of file func_presencestate.c.
References ast_base64decode(), ast_db_get(), AST_PRESENCE_INVALID, AST_PRESENCE_NOT_SET, ast_strdup, ast_strlen_zero, astdb_family, buf, NULL, parse_data(), state, and tmp().
Referenced by load_module().
|
static |
Definition at line 366 of file func_presencestate.c.
References ast_cli_args::argc, args, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), ast_cli_complete(), ast_db_put(), AST_PRESENCE_NOT_SET, ast_presence_state_changed_literal(), ast_strdupa, ast_strlen_zero, astdb_family, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, len(), ast_cli_args::n, NULL, options, parse_data(), ast_cli_args::pos, state, ast_cli_entry::usage, and ast_cli_args::word.
|
static |
Definition at line 295 of file func_presencestate.c.
References ast_cli_args::argc, ast_cli_entry::args, ast_cli(), AST_CLI_YESNO, ast_copy_string(), ast_db_freetree(), ast_db_gettree(), ast_log, ast_presence_state2str(), astdb_family, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_db_entry::data, ast_cli_args::fd, ast_db_entry::key, LOG_WARNING, ast_db_entry::next, NULL, options, parse_data(), state, and ast_cli_entry::usage.
|
static |
Definition at line 842 of file func_presencestate.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_custom_function_register, ast_db_freetree(), ast_db_gettree(), ast_free, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_DEVSTATE_PROVIDER, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ast_presence_state_changed(), ast_presence_state_prov_add(), AST_TEST_REGISTER, astdb_family, ASTERISK_GPL_KEY, custom_presence_callback(), ast_db_entry::key, test_string::message, ast_db_entry::next, NULL, state, test_string::subtype, and unload_module().
|
static |
Definition at line 162 of file func_presencestate.c.
References ast_log, AST_PRESENCE_INVALID, ast_presence_state_val(), ast_strlen_zero, LOG_NOTICE, LOG_WARNING, and strsep().
Referenced by AST_TEST_DEFINE(), custom_presence_callback(), handle_cli_presencestate_change(), handle_cli_presencestate_list(), and presence_write().
|
static |
Definition at line 705 of file func_presencestate.c.
References ast_copy_string(), ast_db_del(), ast_presence_state2str(), ast_presence_state_topic_all(), ast_sem_wait(), ast_strlen_zero, AST_TEST_FAIL, AST_TEST_PASS, NULL, presence_write(), RAII_VAR, stasis_subscribe, stasis_unsubscribe_and_join(), test_cb(), test_cb_data_alloc(), test_cb_data_destroy(), and test_sub().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 102 of file func_presencestate.c.
References args, AST_APP_ARG, ast_base64encode(), ast_copy_string(), AST_DECLARE_APP_ARGS, ast_free, ast_log, AST_PRESENCE_INVALID, ast_presence_state2str(), ast_presence_state_nocache(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, LOG_WARNING, NULL, options, parse(), provider, and state.
|
static |
Definition at line 207 of file func_presencestate.c.
References args, ast_base64decode(), ast_db_put(), ast_log, ast_presence_state_changed_literal(), ast_strdupa, ast_strlen_zero, astdb_family, len(), LOG_WARNING, options, parse_data(), state, and tmp().
Referenced by presence_change_common().
|
static |
Definition at line 693 of file func_presencestate.c.
References ao2_ref, ast_presence_state_message_type(), ast_sem_post(), test_cb_data::presence_state, test_cb_data::sem, stasis_message_data(), and stasis_message_type().
Referenced by presence_change_common().
|
static |
Definition at line 670 of file func_presencestate.c.
References ast_calloc, ast_free, ast_sem_init(), NULL, and test_cb_data::sem.
Referenced by presence_change_common().
|
static |
Definition at line 686 of file func_presencestate.c.
References ao2_cleanup, ast_free, ast_sem_destroy(), test_cb_data::presence_state, and test_cb_data::sem.
Referenced by presence_change_common().
|
static |
Definition at line 826 of file func_presencestate.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), ast_custom_function_unregister(), ast_presence_state_prov_del(), and AST_TEST_UNREGISTER.
Referenced by load_module().
|
static |
Definition at line 884 of file func_presencestate.c.
|
static |
Definition at line 884 of file func_presencestate.c.
|
static |
Definition at line 100 of file func_presencestate.c.
Referenced by custom_presence_callback(), handle_cli_presencestate_change(), handle_cli_presencestate_list(), load_module(), and presence_write().
|
static |
Definition at line 443 of file func_presencestate.c.
|
static |
Definition at line 289 of file func_presencestate.c.