diff options
author | Mark Michelson <mmichelson@digium.com> | 2014-04-28 14:40:21 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2014-04-28 14:40:21 +0000 |
commit | 7dd64ff993261da54d96a320ea261c32b622d9b1 (patch) | |
tree | 5a897f7e65ca76a17e6ade40a491e0b620041591 /main/devicestate.c | |
parent | d3433771c9b736b4f06c8c637e679b7b8ab9bd03 (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 'main/devicestate.c')
-rw-r--r-- | main/devicestate.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/main/devicestate.c b/main/devicestate.c index 5c2340863..839557485 100644 --- a/main/devicestate.c +++ b/main/devicestate.c @@ -117,6 +117,30 @@ <support_level>core</support_level> ***/ +/*** DOCUMENTATION + <managerEvent language="en_US" name="DeviceStateChange"> + <managerEventInstance class="EVENT_FLAG_CALL"> + <synopsis>Raised when a device state changes</synopsis> + <syntax> + <parameter name="Device"> + <para>The device whose state has changed</para> + </parameter> + <parameter name="State"> + <para>The new state of the device</para> + </parameter> + </syntax> + <description> + <para>This differs from the <literal>ExtensionStatus</literal> + event because this event is raised for all device state changes, + not only for changes that affect dialplan hints.</para> + </description> + <see-also> + <ref type="managerEvent">ExtensionStatus</ref> + </see-also> + </managerEventInstance> + </managerEvent> +***/ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -199,7 +223,11 @@ static struct stasis_cache *device_state_cache; static struct stasis_caching_topic *device_state_topic_cached; static struct stasis_topic_pool *device_state_topic_pool; -STASIS_MESSAGE_TYPE_DEFN(ast_device_state_message_type); +static struct ast_manager_event_blob *devstate_to_ami(struct stasis_message *msg); + +STASIS_MESSAGE_TYPE_DEFN(ast_device_state_message_type, + .to_ami = devstate_to_ami, +); /* Forward declarations */ static int getproviderstate(const char *provider, const char *address); @@ -880,3 +908,20 @@ int devstate_init(void) return 0; } + +static struct ast_manager_event_blob *devstate_to_ami(struct stasis_message *msg) +{ + struct ast_device_state_message *dev_state; + + dev_state = stasis_message_data(msg); + + /* Ignore non-aggregate states */ + if (dev_state->eid) { + return NULL; + } + + return ast_manager_event_blob_create(EVENT_FLAG_CALL, "DeviceStateChange", + "Device: %s\r\n" + "State: %s\r\n", + dev_state->device, ast_devstate_str(dev_state->state)); +} |