summaryrefslogtreecommitdiff
path: root/res/res_manager_presencestate.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-04-28 14:40:21 +0000
committerMark Michelson <mmichelson@digium.com>2014-04-28 14:40:21 +0000
commit7dd64ff993261da54d96a320ea261c32b622d9b1 (patch)
tree5a897f7e65ca76a17e6ade40a491e0b620041591 /res/res_manager_presencestate.c
parentd3433771c9b736b4f06c8c637e679b7b8ab9bd03 (diff)
Add DeviceStateChanged and PresenceStateChanged AMI events.
These events are controlled by two new modules, res_manager_devicestate and res_manager_presencestate. Review: https://reviewboard.asterisk.org/r/3417 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413060 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_manager_presencestate.c')
-rw-r--r--res/res_manager_presencestate.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/res/res_manager_presencestate.c b/res/res_manager_presencestate.c
new file mode 100644
index 000000000..2b3ef418e
--- /dev/null
+++ b/res/res_manager_presencestate.c
@@ -0,0 +1,50 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2014, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+#include "asterisk.h"
+#include "asterisk/module.h"
+#include "asterisk/stasis.h"
+#include "asterisk/presencestate.h"
+
+static struct stasis_forward *topic_forwarder;
+
+static int unload_module(void)
+{
+ topic_forwarder = stasis_forward_cancel(topic_forwarder);
+ return 0;
+}
+
+static int load_module(void)
+{
+ struct stasis_topic *manager_topic;
+
+ manager_topic = ast_manager_get_topic();
+ if (!manager_topic) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
+ topic_forwarder = stasis_forward_all(ast_presence_state_topic_all(), manager_topic);
+
+ return AST_MODULE_LOAD_SUCCESS;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Manager Presence State Topic Forwarder",
+ .load = load_module,
+ .unload = unload_module,
+ .load_pri = AST_MODPRI_DEVSTATE_CONSUMER,
+ );