Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
res_mwi_devstate.c File Reference
#include "asterisk.h"
#include "asterisk/mwi.h"
#include "asterisk/devicestate.h"
#include "asterisk/module.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/stasis.h"
Include dependency graph for res_mwi_devstate.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int mwi_cached_cb (void *obj, void *arg, int flags)
 
static void mwi_update_cb (void *data, struct stasis_subscription *sub, struct stasis_message *msg)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "MWI Device State Subscriptions" , .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_DEVSTATE_PROVIDER, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct stasis_subscriptionmwi_sub
 

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 105 of file res_mwi_devstate.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 105 of file res_mwi_devstate.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 105 of file res_mwi_devstate.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 71 of file res_mwi_devstate.c.

72{
73 struct ao2_container *cached;
74
77 }
78
82 }
83
87 }
88
90 if (!cached) {
93 }
95 ao2_ref(cached, -1);
96
98}
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
@ OBJ_NODATA
Definition: astobj2.h:1044
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
Definition: mwi.c:94
struct stasis_topic * ast_mwi_topic_all(void)
Get the Stasis Message Bus API topic for MWI messages.
Definition: mwi.c:89
static int mwi_cached_cb(void *obj, void *arg, int flags)
static struct stasis_subscription * mwi_sub
static void mwi_update_cb(void *data, struct stasis_subscription *sub, struct stasis_message *msg)
static int unload_module(void)
#define NULL
Definition: resample.c:96
struct ao2_container * stasis_cache_dump(struct stasis_cache *cache, struct stasis_message_type *type)
Dump cached items to a subscription for the ast_eid_default entity.
Definition: stasis_cache.c:736
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
Definition: stasis.h:297
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
Definition: stasis.c:1024
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
Definition: stasis.c:1078
#define stasis_subscribe(topic, callback, data)
Definition: stasis.h:649
Generic container type.

References ao2_callback, ao2_ref, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_mwi_state_cache(), ast_mwi_state_type(), ast_mwi_topic_all(), mwi_cached_cb(), mwi_sub, mwi_update_cb(), NULL, OBJ_NODATA, stasis_cache_dump(), stasis_subscribe, stasis_subscription_accept_message_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), and unload_module().

◆ mwi_cached_cb()

static int mwi_cached_cb ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 56 of file res_mwi_devstate.c.

57{
58 struct stasis_message *msg = obj;
60
61 return 0;
62}

References mwi_sub, mwi_update_cb(), and NULL.

Referenced by load_module().

◆ mwi_update_cb()

static void mwi_update_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message msg 
)
static

Definition at line 33 of file res_mwi_devstate.c.

35{
36 struct ast_mwi_state *mwi_state;
37
39 return;
40 }
41
42 mwi_state = stasis_message_data(msg);
43 if (!mwi_state) {
44 return;
45 }
46
47 if (mwi_state->new_msgs > 0) {
48 ast_debug(1, "Sending inuse devstate change for MWI:%s\n", mwi_state->uniqueid);
50 } else {
51 ast_debug(1, "Sending not inuse devstate change for MWI:%s\n", mwi_state->uniqueid);
53 }
54}
@ AST_DEVSTATE_CACHABLE
Definition: devicestate.h:70
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
Definition: devicestate.c:510
@ AST_DEVICE_INUSE
Definition: devicestate.h:55
@ AST_DEVICE_NOT_INUSE
Definition: devicestate.h:54
#define ast_debug(level,...)
Log a DEBUG message.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
The structure that contains MWI state.
Definition: mwi.h:455
int new_msgs
Definition: mwi.h:459
const ast_string_field uniqueid
Definition: mwi.h:458

References ast_debug, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_mwi_state_type(), ast_mwi_state::new_msgs, stasis_message_data(), stasis_message_type(), and ast_mwi_state::uniqueid.

Referenced by load_module(), and mwi_cached_cb().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 64 of file res_mwi_devstate.c.

65{
67
68 return 0;
69}
struct stasis_subscription * stasis_unsubscribe(struct stasis_subscription *subscription)
Cancel a subscription.
Definition: stasis.c:972

References mwi_sub, and stasis_unsubscribe().

Referenced by load_module().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "MWI Device State Subscriptions" , .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_DEVSTATE_PROVIDER, }
static

Definition at line 105 of file res_mwi_devstate.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 105 of file res_mwi_devstate.c.

◆ mwi_sub

struct stasis_subscription* mwi_sub
static