Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include "asterisk/astdb.h"
#include "asterisk/astobj2.h"
#include "asterisk/module.h"
#include "asterisk/stasis_app_impl.h"
#include "asterisk/stasis_app_device_state.h"
Go to the source code of this file.
Data Structures | |
struct | device_state_subscription |
Device state subscription object. More... | |
Macros | |
#define | DEVICE_STATE_ALL "__AST_DEVICE_STATE_ALL_TOPIC" |
#define | DEVICE_STATE_BUCKETS 37 |
#define | DEVICE_STATE_FAMILY "StasisDeviceState" |
#define | DEVICE_STATE_PROVIDER_STASIS "Stasis" |
#define | DEVICE_STATE_SCHEME_STASIS "Stasis:" |
#define | DEVICE_STATE_SCHEME_SUB "deviceState:" |
#define | DEVICE_STATE_SIZE 64 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | device_state_cb (void *data, struct stasis_subscription *sub, struct stasis_message *msg) |
static struct device_state_subscription * | device_state_subscription_create (const struct stasis_app *app, const char *device_name) |
static void | device_state_subscription_destroy (void *obj) |
static int | device_state_subscriptions_cmp (void *obj, void *arg, int flags) |
static int | device_state_subscriptions_hash (const void *obj, const int flags) |
static int | device_to_json_cb (void *obj, void *arg, void *data, int flags) |
static void | devices_to_json (const struct stasis_app *app, struct ast_json *json) |
static void * | find_device_state (const struct stasis_app *app, const char *name) |
static struct device_state_subscription * | find_device_state_subscription (struct stasis_app *app, const char *name) |
static int | is_subscribed_device_state (struct stasis_app *app, const char *name) |
static int | is_subscribed_device_state_lock (struct stasis_app *app, const char *name) |
static int | load_module (void) |
static void | populate_cache (void) |
static void | remove_device_state_subscription (struct device_state_subscription *sub) |
static void | send_device_state (struct device_state_subscription *sub, const char *name, enum ast_device_state state) |
enum stasis_device_state_result | stasis_app_device_state_delete (const char *name) |
Delete a device controlled by ARI. More... | |
struct ast_json * | stasis_app_device_state_to_json (const char *name, enum ast_device_state state) |
Convert device state to json. More... | |
enum stasis_device_state_result | stasis_app_device_state_update (const char *name, const char *value) |
Changes the state of a device controlled by ARI. More... | |
struct ast_json * | stasis_app_device_states_to_json (void) |
Convert device states to json array. More... | |
static enum ast_device_state | stasis_device_state_cb (const char *data) |
static int | subscribe_device_state (struct stasis_app *app, void *obj) |
static int | unload_module (void) |
static int | unsubscribe_device_state (struct stasis_app *app, const char *name) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS , .description = "Stasis application device state support" , .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, .requires = "res_stasis", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
struct stasis_app_event_source | device_state_event_source |
static struct ao2_container * | device_state_subscriptions |
#define DEVICE_STATE_ALL "__AST_DEVICE_STATE_ALL_TOPIC" |
The key used for tracking a subscription to all device states
Definition at line 46 of file res_stasis_device_state.c.
Referenced by device_state_subscription_create(), is_subscribed_device_state(), and subscribe_device_state().
#define DEVICE_STATE_BUCKETS 37 |
Number of hash buckets for device state subscriptions
Definition at line 43 of file res_stasis_device_state.c.
Referenced by load_module().
#define DEVICE_STATE_FAMILY "StasisDeviceState" |
astdb family name
Definition at line 34 of file res_stasis_device_state.c.
Referenced by populate_cache(), stasis_app_device_state_delete(), stasis_app_device_state_update(), stasis_app_device_states_to_json(), and stasis_device_state_cb().
#define DEVICE_STATE_PROVIDER_STASIS "Stasis" |
Stasis device state provider
Definition at line 36 of file res_stasis_device_state.c.
Referenced by load_module(), and unload_module().
#define DEVICE_STATE_SCHEME_STASIS "Stasis:" |
Scheme for custom device states
Definition at line 38 of file res_stasis_device_state.c.
Referenced by populate_cache(), stasis_app_device_state_delete(), stasis_app_device_state_update(), and stasis_app_device_states_to_json().
#define DEVICE_STATE_SCHEME_SUB "deviceState:" |
Scheme for device state subscriptions
Definition at line 40 of file res_stasis_device_state.c.
#define DEVICE_STATE_SIZE 64 |
Definition at line 32 of file res_stasis_device_state.c.
Referenced by stasis_app_device_states_to_json(), and stasis_device_state_cb().
|
static |
Definition at line 490 of file res_stasis_device_state.c.
|
static |
Definition at line 490 of file res_stasis_device_state.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 490 of file res_stasis_device_state.c.
|
static |
Definition at line 301 of file res_stasis_device_state.c.
References ao2_ref, ast_device_state_message_type(), ast_device_state_message::device, ast_device_state_message::eid, send_device_state(), stasis_message_data(), stasis_message_type(), stasis_subscription_final_message(), and ast_device_state_message::state.
Referenced by subscribe_device_state().
|
static |
Definition at line 112 of file res_stasis_device_state.c.
References ao2_alloc, ao2_ref, device_state_subscription::app_name, ast_string_field_init, ast_string_field_set, ast_strlen_zero, DEVICE_STATE_ALL, device_state_subscription_destroy(), NULL, stasis_app_name(), and device_state_subscription::sub.
Referenced by find_device_state(), and subscribe_device_state().
|
static |
Definition at line 106 of file res_stasis_device_state.c.
References ast_string_field_free_memory, and device_state_subscription::sub.
Referenced by device_state_subscription_create().
|
static |
Definition at line 79 of file res_stasis_device_state.c.
References device_state_subscription::app_name, ast_assert, CMP_MATCH, CMP_STOP, device_state_subscription::device_name, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.
Referenced by load_module().
|
static |
Definition at line 63 of file res_stasis_device_state.c.
References ast_assert, ast_str_hash(), device_state_subscription::device_name, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.
Referenced by load_module().
|
static |
Definition at line 423 of file res_stasis_device_state.c.
References device_state_subscription::app_name, array(), ast_json_array_append(), ast_json_string_create(), device_state_subscription::device_name, and device_state_subscription::sub.
Referenced by devices_to_json().
|
static |
Definition at line 439 of file res_stasis_device_state.c.
References ao2_callback_data, array(), ast_json_array_create(), ast_json_object_set(), device_to_json_cb(), OBJ_NODATA, and stasis_app_name().
|
static |
Definition at line 325 of file res_stasis_device_state.c.
References device_state_subscription_create().
|
static |
Definition at line 140 of file res_stasis_device_state.c.
References ao2_find, device_state_subscription::app_name, OBJ_NOLOCK, OBJ_SEARCH_OBJECT, and stasis_app_name().
Referenced by is_subscribed_device_state(), and unsubscribe_device_state().
|
static |
Definition at line 330 of file res_stasis_device_state.c.
References ao2_ref, DEVICE_STATE_ALL, find_device_state_subscription(), and device_state_subscription::sub.
Referenced by is_subscribed_device_state_lock(), and subscribe_device_state().
|
static |
Definition at line 349 of file res_stasis_device_state.c.
References ao2_lock, ao2_unlock, and is_subscribed_device_state().
|
static |
Definition at line 456 of file res_stasis_device_state.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_devstate_prov_add(), ast_devstate_prov_del(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, DEVICE_STATE_BUCKETS, DEVICE_STATE_PROVIDER_STASIS, device_state_subscriptions_cmp(), device_state_subscriptions_hash(), NULL, populate_cache(), stasis_app_register_event_source(), and stasis_device_state_cb().
Referenced by unload_module().
|
static |
Definition at line 275 of file res_stasis_device_state.c.
References ast_db_freetree(), ast_db_gettree(), AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_devstate_val(), ast_strlen_zero, ast_db_entry::data, DEVICE_STATE_FAMILY, DEVICE_STATE_SCHEME_STASIS, ast_db_entry::key, name, ast_db_entry::next, NULL, and RAII_VAR.
Referenced by load_module().
|
static |
Definition at line 151 of file res_stasis_device_state.c.
References ao2_unlink_flags, OBJ_NOLOCK, stasis_unsubscribe_and_join(), and device_state_subscription::sub.
Referenced by unsubscribe_device_state().
|
static |
Definition at line 191 of file res_stasis_device_state.c.
References device_state_subscription::app_name, ast_json_pack(), ast_json_timeval(), ast_json_unref(), ast_log, ast_tvnow(), LOG_ERROR, NULL, RAII_VAR, stasis_app_device_state_to_json(), and stasis_app_send().
Referenced by device_state_cb().
enum stasis_device_state_result stasis_app_device_state_delete | ( | const char * | name | ) |
Delete a device controlled by ARI.
name | the name of the ARI controlled device |
stasis device state application result.
Definition at line 244 of file res_stasis_device_state.c.
References ast_db_del(), ast_device_state_clear_cache(), AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_log, ast_strlen_zero, DEVICE_STATE_FAMILY, DEVICE_STATE_SCHEME_STASIS, LOG_ERROR, name, STASIS_DEVICE_STATE_MISSING, STASIS_DEVICE_STATE_NOT_CONTROLLED, STASIS_DEVICE_STATE_OK, and STASIS_DEVICE_STATE_UNKNOWN.
Referenced by ast_ari_device_states_delete().
struct ast_json* stasis_app_device_state_to_json | ( | const char * | name, |
enum ast_device_state | state | ||
) |
Convert device state to json.
name | the name of the device |
state | the device state |
NULL
on error. Definition at line 160 of file res_stasis_device_state.c.
References ast_devstate_str(), and ast_json_pack().
Referenced by ast_ari_device_states_get(), send_device_state(), and stasis_app_device_states_to_json().
enum stasis_device_state_result stasis_app_device_state_update | ( | const char * | name, |
const char * | value | ||
) |
Changes the state of a device controlled by ARI.
name | the name of the ARI controlled device |
value | a valid device state value |
Definition at line 211 of file res_stasis_device_state.c.
References ast_db_put(), ast_debug, AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_devstate_val(), ast_log, ast_strlen_zero, DEVICE_STATE_FAMILY, DEVICE_STATE_SCHEME_STASIS, LOG_ERROR, STASIS_DEVICE_STATE_MISSING, STASIS_DEVICE_STATE_NOT_CONTROLLED, STASIS_DEVICE_STATE_OK, STASIS_DEVICE_STATE_UNKNOWN, and state.
Referenced by ast_ari_device_states_update().
struct ast_json* stasis_app_device_states_to_json | ( | void | ) |
Convert device states to json array.
NULL
on error. Definition at line 168 of file res_stasis_device_state.c.
References array(), ast_db_freetree(), ast_db_gettree(), ast_json_array_append(), ast_json_array_create(), ast_strlen_zero, DEVICE_STATE_FAMILY, DEVICE_STATE_SCHEME_STASIS, DEVICE_STATE_SIZE, ast_db_entry::key, name, ast_db_entry::next, NULL, and stasis_app_device_state_to_json().
Referenced by ast_ari_device_states_list().
|
static |
Definition at line 292 of file res_stasis_device_state.c.
References ast_db_get(), ast_devstate_val(), buf, DEVICE_STATE_FAMILY, and DEVICE_STATE_SIZE.
Referenced by load_module().
|
static |
Definition at line 360 of file res_stasis_device_state.c.
References ao2_bump, ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_debug, ast_device_state_message_type(), ast_device_state_topic(), ast_device_state_topic_all(), ast_log, device_state_subscription::device_name, DEVICE_STATE_ALL, device_state_cb(), device_state_subscription_create(), is_subscribed_device_state(), LOG_ERROR, NULL, OBJ_NOLOCK, stasis_app_name(), stasis_subscribe_pool, stasis_subscription_accept_message_type(), stasis_subscription_change_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), and device_state_subscription::sub.
|
static |
Definition at line 476 of file res_stasis_device_state.c.
References ao2_cleanup, ast_devstate_prov_del(), AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, DEVICE_STATE_PROVIDER_STASIS, load_module(), NULL, and stasis_app_unregister_event_source().
|
static |
Definition at line 407 of file res_stasis_device_state.c.
References ao2_cleanup, ao2_lock, ao2_unlock, find_device_state_subscription(), remove_device_state_subscription(), and device_state_subscription::sub.
|
static |
Definition at line 490 of file res_stasis_device_state.c.
|
static |
Definition at line 490 of file res_stasis_device_state.c.
struct stasis_app_event_source device_state_event_source |
Definition at line 447 of file res_stasis_device_state.c.
|
static |
Container for subscribed device states
Definition at line 49 of file res_stasis_device_state.c.