Add module support level to ast_module_info structure. Print it in CLI "module show" .
[asterisk/asterisk.git] / res / res_manager_devicestate.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2014, Digium, Inc.
5  *
6  * Mark Michelson <mmichelson@digium.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 #include "asterisk/module.h"
25 #include "asterisk/stasis.h"
26 #include "asterisk/devicestate.h"
27
28 static struct stasis_forward *topic_forwarder;
29
30 static int unload_module(void)
31 {
32         topic_forwarder = stasis_forward_cancel(topic_forwarder);
33         return 0;
34 }
35
36 static int load_module(void)
37 {
38         struct stasis_topic *manager_topic;
39
40         manager_topic = ast_manager_get_topic();
41         if (!manager_topic) {
42                 return AST_MODULE_LOAD_DECLINE;
43         }
44
45         topic_forwarder = stasis_forward_all(ast_device_state_topic_all(), manager_topic);
46
47         return AST_MODULE_LOAD_SUCCESS;
48 }
49
50 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Manager Device State Topic Forwarder",
51                 .support_level = AST_MODULE_SUPPORT_CORE,
52                 .load = load_module,
53                 .unload = unload_module,
54                 .load_pri = AST_MODPRI_DEVSTATE_CONSUMER,
55         );