Asterisk - The Open Source Telephony Project GIT-master-2de1a68
res_mwi_devstate.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2014, Schmooze Com, Inc.
5 *
6 * Jason Parker <jason.parker@schmoozecom.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*** MODULEINFO
20 <support_level>core</support_level>
21 ***/
22
23#include "asterisk.h"
24
25#include "asterisk/mwi.h"
27#include "asterisk/module.h"
29#include "asterisk/stasis.h"
30
32
33static void mwi_update_cb(void *data, struct stasis_subscription *sub,
34 struct stasis_message *msg)
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}
55
56static int mwi_cached_cb(void *obj, void *arg, int flags)
57{
58 struct stasis_message *msg = obj;
60
61 return 0;
62}
63
64static int unload_module(void)
65{
67
68 return 0;
69}
70
71static int load_module(void)
72{
73 struct ao2_container *cached;
74
77 }
78
82 }
83
87 }
88
90 if (!cached) {
93 }
95 ao2_ref(cached, -1);
96
98}
99
100AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "MWI Device State Subscriptions",
101 .support_level = AST_MODULE_SUPPORT_CORE,
102 .load = load_module,
103 .unload = unload_module,
Asterisk main include file. File version handling, generic pbx functions.
#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
Device state management.
@ 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.
Asterisk module definitions.
@ AST_MODFLAG_LOAD_ORDER
Definition: module.h:317
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition: module.h:543
@ AST_MODPRI_DEVSTATE_PROVIDER
Definition: module.h:329
@ AST_MODULE_SUPPORT_CORE
Definition: module.h:121
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
@ 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
Asterisk MWI API.
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
struct stasis_forward * sub
Definition: res_corosync.c:240
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 load_module(void)
static int unload_module(void)
#define NULL
Definition: resample.c:96
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
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:1023
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:1077
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_subscription * stasis_unsubscribe(struct stasis_subscription *subscription)
Cancel a subscription.
Definition: stasis.c:971
#define stasis_subscribe(topic, callback, data)
Definition: stasis.h:649
Generic container type.
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