mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-16 09:46:22 +00:00
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
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
@@ -25,6 +25,36 @@
|
||||
<support_level>core</support_level>
|
||||
***/
|
||||
|
||||
/*** DOCUMENTATION
|
||||
<managerEvent language="en_US" name="PresenceStateChange">
|
||||
<managerEventInstance class="EVENT_FLAG_CALL">
|
||||
<synopsis>Raised when a presence state changes</synopsis>
|
||||
<syntax>
|
||||
<parameter name="Presentity">
|
||||
<para>The entity whose presence state has changed</para>
|
||||
</parameter>
|
||||
<parameter name="Status">
|
||||
<para>The new status of the presentity</para>
|
||||
</parameter>
|
||||
<parameter name="Subtype">
|
||||
<para>The new subtype of the presentity</para>
|
||||
</parameter>
|
||||
<parameter name="Message">
|
||||
<para>The new message of the presentity</para>
|
||||
</parameter>
|
||||
</syntax>
|
||||
<description>
|
||||
<para>This differs from the <literal>PresenceStatus</literal>
|
||||
event because this event is raised for all presence state changes,
|
||||
not only for changes that affect dialplan hints.</para>
|
||||
</description>
|
||||
<see-also>
|
||||
<ref type="managerEvent">PresenceStatus</ref>
|
||||
</see-also>
|
||||
</managerEventInstance>
|
||||
</managerEvent>
|
||||
***/
|
||||
|
||||
#include "asterisk.h"
|
||||
|
||||
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
@@ -52,7 +82,11 @@ static const struct {
|
||||
{ "dnd", AST_PRESENCE_DND},
|
||||
};
|
||||
|
||||
STASIS_MESSAGE_TYPE_DEFN(ast_presence_state_message_type);
|
||||
static struct ast_manager_event_blob *presence_state_to_ami(struct stasis_message *msg);
|
||||
|
||||
STASIS_MESSAGE_TYPE_DEFN(ast_presence_state_message_type,
|
||||
.to_ami = presence_state_to_ami,
|
||||
);
|
||||
struct stasis_topic *presence_state_topic_all;
|
||||
struct stasis_cache *presence_state_cache;
|
||||
struct stasis_caching_topic *presence_state_topic_cached;
|
||||
@@ -351,3 +385,17 @@ int ast_presence_state_engine_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ast_manager_event_blob *presence_state_to_ami(struct stasis_message *msg)
|
||||
{
|
||||
struct ast_presence_state_message *presence_state = stasis_message_data(msg);
|
||||
|
||||
return ast_manager_event_blob_create(EVENT_FLAG_CALL, "PresenceStateChange",
|
||||
"Presentity: %s\r\n"
|
||||
"Status: %s\r\n"
|
||||
"Subtype: %s\r\n"
|
||||
"Message: %s\r\n",
|
||||
presence_state->provider,
|
||||
ast_presence_state2str(presence_state->state),
|
||||
presence_state->subtype,
|
||||
presence_state->message);
|
||||
}
|
||||
|
Reference in New Issue
Block a user