[asterisk-commits] qwell: branch qwell/queue_events r390118 - in /team/qwell/queue_events: apps/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 30 10:28:47 CDT 2013
Author: qwell
Date: Thu May 30 10:28:45 2013
New Revision: 390118
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390118
Log:
Commit progress. Things might compile. This needs to be reworked though.
Modified:
team/qwell/queue_events/apps/app_queue.c
team/qwell/queue_events/include/asterisk/manager.h
team/qwell/queue_events/main/manager.c
Modified: team/qwell/queue_events/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/apps/app_queue.c?view=diff&rev=390118&r1=390117&r2=390118
==============================================================================
--- team/qwell/queue_events/apps/app_queue.c (original)
+++ team/qwell/queue_events/apps/app_queue.c Thu May 30 10:28:45 2013
@@ -108,6 +108,7 @@
#include "asterisk/term.h"
#include "asterisk/dial.h"
#include "asterisk/stasis_channels.h"
+#include "asterisk/stasis_message_router.h"
#include "asterisk/bridging.h"
/* Define, to debug reference counts on queues, without debugging reference counts on queue members */
@@ -827,7 +828,6 @@
<description>
</description>
</manager>
-
<manager name="QueueMemberRingInUse" language="en_US">
<synopsis>
Set the ringinuse value for a queue member.
@@ -841,7 +841,6 @@
<description>
</description>
</manager>
-
<manager name="QueueRule" language="en_US">
<synopsis>
Queue Rules.
@@ -893,6 +892,286 @@
<description>
</description>
</manager>
+
+ <managerEvent language="en_US" name="QueueMemberStatus">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a Queue member's status has changed.</synopsis>
+ <syntax>
+ <parameter name="Queue">
+ <para>The name of the queue.</para>
+ </parameter>
+ <parameter name="Location">
+ <para>The queue member's channel technology or location.</para>
+ </parameter>
+ <parameter name="MemberName">
+ <para>The name of the queue member.</para>
+ </parameter>
+ <parameter name="StateInterface">
+ <para>Channel technology or location from which to read device state changes.</para>
+ </parameter>
+ <parameter name="Membership">
+ <enumlist>
+ <enum name="dynamic"/>
+ <enum name="realtime"/>
+ <enum name="static"/>
+ </enumlist>
+ </parameter>
+ <parameter name="Penalty">
+ <para>The penalty associated with the queue member.</para>
+ </parameter>
+ <parameter name="CallsTaken">
+ <para>The number of calls this queue member has serviced.</para>
+ </parameter>
+ <parameter name="LastCall">
+ <para>The time this member last took call, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
+ </parameter>
+ <parameter name="Status">
+ <para>The numeric device state status of the queue member.</para>
+ <enumlist>
+ <enum name="0"><para>AST_DEVICE_UNKNOWN</para></enum>
+ <enum name="1"><para>AST_DEVICE_NOT_INUSE</para></enum>
+ <enum name="2"><para>AST_DEVICE_INUSE</para></enum>
+ <enum name="3"><para>AST_DEVICE_BUSY</para></enum>
+ <enum name="4"><para>AST_DEVICE_INVALID</para></enum>
+ <enum name="5"><para>AST_DEVICE_UNAVAILABLE</para></enum>
+ <enum name="6"><para>AST_DEVICE_RINGING</para></enum>
+ <enum name="7"><para>AST_DEVICE_RINGINUSE</para></enum>
+ <enum name="8"><para>AST_DEVICE_ONHOLD</para></enum>
+ </enumlist>
+ </parameter>
+ <parameter name="Paused">
+ <enumlist>
+ <enum name="0"/>
+ <enum name="1"/>
+ </enumlist>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueMemberAdded">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a member is added to the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Location'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='StateInterface'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Membership'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Penalty'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='CallsTaken'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='LastCall'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Status'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Paused'])" />
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">QueueMemberRemoved</ref>
+ <ref type="application">AddQueueMember</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueMemberRemoved">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a member is removed from the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Location'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">QueueMemberAdded</ref>
+ <ref type="application">RemoveQueueMember</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueMemberPaused">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a member is paused/unpaused in the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Location'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Paused'])" />
+ </syntax>
+ <see-also>
+ <ref type="application">PauseQueueMember</ref>
+ <ref type="application">UnPauseQueueMember</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueMemberPenalty">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a member's penalty is changed.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Location'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Penalty'])" />
+ </syntax>
+ <see-also>
+ <ref type="function">QUEUE_MEMBER</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueMemberRinginuse">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a member's ringinuse setting is changed.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Location'])" />
+ <parameter name="Ringinuse">
+ <enumlist>
+ <enum name="0"/>
+ <enum name="1"/>
+ </enumlist>
+ </parameter>
+ </syntax>
+ <see-also>
+ <ref type="function">QUEUE_MEMBER</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueJoin">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a channel joins a Queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <parameter name="Position">
+ <para>This channel's current position in the queue.</para>
+ </parameter>
+ <parameter name="Count">
+ <para>The total number of channels in the queue.</para>
+ </parameter>
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">QueueLeave</ref>
+ <ref type="application">Queue</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueLeave">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when a channel leaves a Queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueJoin']/managerEventInstance/syntax/parameter[@name='Count'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueJoin']/managerEventInstance/syntax/parameter[@name='Position'])" />
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">QueueJoin</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="QueueCallerAbandon">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when an caller abandons the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueJoin']/managerEventInstance/syntax/parameter[@name='Position'])" />
+ <parameter name="OriginalPosition">
+ <para>The channel's original position in the queue.</para>
+ </parameter>
+ <parameter name="HoldTime">
+ <para>The time the channel was in the queue, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="AgentCalled">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when an Agent is notified of a member in the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <parameter name="AgentCalled">
+ <para>The agent's technology or location.</para>
+ </parameter>
+ <parameter name="AgentName">
+ <para>The name of the agent.</para>
+ </parameter>
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">AgentRingNoAnswer</ref>
+ <ref type="managerEvent">AgentComplete</ref>
+ <ref type="managerEvent">AgentConnect</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="AgentRingNoAnswer">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when an agent is notified of a member in the queue and fails to answer.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentCalled']/managerEventInstance/syntax/parameter[@name='Variable'])" />
+ <parameter name="Member">
+ <para>The queue member's channel technology or location.</para>
+ </parameter>
+ <parameter name="RingTime">
+ <para>The time the agent was rung, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
+ </parameter>
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">AgentCalled</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="AgentComplete">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when an agent has finished servicing a member in the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentRingNoAnswer']/managerEventInstance/syntax/parameter[@name='Member'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueCallerAbandon']/managerEventInstance/syntax/parameter[@name='HoldTime'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentCalled']/managerEventInstance/syntax/parameter[@name='Variable'])" />
+ <parameter name="TalkTime">
+ <para>The time the agent talked with the member in the queue, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
+ </parameter>
+ <parameter name="Reason">
+ <enumlist>
+ <enum name="caller"/>
+ <enum name="agent"/>
+ <enum name="transfer"/>
+ </enumlist>
+ </parameter>
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">AgentCalled</ref>
+ <ref type="managerEvent">AgentConnect</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="AgentDump">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when an agent hangs up on a member in the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentRingNoAnswer']/managerEventInstance/syntax/parameter[@name='Member'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentCalled']/managerEventInstance/syntax/parameter[@name='Variable'])" />
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">AgentCalled</ref>
+ <ref type="managerEvent">AgentConnect</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="AgentConnect">
+ <managerEventInstance class="EVENT_FLAG_AGENT">
+ <synopsis>Raised when an agent answers and is bridged to a member in the queue.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentRingNoAnswer']/managerEventInstance/syntax/parameter[@name='Member'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentRingNoAnswer']/managerEventInstance/syntax/parameter[@name='RingTime'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueCallerAbandon']/managerEventInstance/syntax/parameter[@name='HoldTime'])" />
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentCalled']/managerEventInstance/syntax/parameter[@name='Variable'])" />
+ </syntax>
+ <see-also>
+ <ref type="managerEvent">AgentCalled</ref>
+ <ref type="managerEvent">AgentComplete</ref>
+ <ref type="managerEvent">AgentDump</ref>
+ </see-also>
+ </managerEventInstance>
+ </managerEvent>
***/
enum {
@@ -1248,7 +1527,6 @@
/*! Sound files: Custom announce, no default */
struct ast_str *sound_periodicannounce[MAX_PERIODIC_ANNOUNCEMENTS];
unsigned int dead:1;
- unsigned int eventwhencalled:2;
unsigned int ringinuse:1;
unsigned int setinterfacevar:1;
unsigned int setqueuevar:1;
@@ -1512,7 +1790,7 @@
q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, q->callsabandoned, q->servicelevel, sl);
ao2_unlock(q);
-
+
pbx_builtin_setvar_multiple(chan, interfacevar);
} else {
ao2_unlock(q);
@@ -1542,6 +1820,120 @@
new->parent = q;
new->pos = ++(*pos);
new->opos = *pos;
+}
+
+struct stasis_message_type *queue_caller_join_type(void);
+struct stasis_message_type *queue_caller_leave_type(void);
+struct stasis_message_type *queue_caller_abandon_type(void);
+
+STASIS_MESSAGE_TYPE_DEFN(queue_caller_join_type);
+STASIS_MESSAGE_TYPE_DEFN(queue_caller_leave_type);
+STASIS_MESSAGE_TYPE_DEFN(queue_caller_abandon_type);
+
+static void queue_caller_join_cb(void *data,
+ struct stasis_subscription *sub, struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ struct ast_channel_blob *obj = stasis_message_data(message);
+ RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
+ const char *queue = ast_json_string_get(ast_json_object_get(obj->blob, "queue"));
+ int position = ast_json_integer_get(ast_json_object_get(obj->blob, "position"));
+ int count = ast_json_integer_get(ast_json_object_get(obj->blob, "count"));
+
+ channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+
+ if (!channel_event_string) {
+ return;
+ }
+
+ manager_event(EVENT_FLAG_AGENT, "QueueCallerJoin",
+ "%s"
+ "Queue: %s\r\n"
+ "Position: %d\r\n"
+ "Count: %d\r\n",
+ ast_str_buffer(channel_event_string),
+ queue, position, count);
+}
+
+static void queue_caller_leave_cb(void *data,
+ struct stasis_subscription *sub, struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ struct ast_channel_blob *obj = stasis_message_data(message);
+ RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
+ const char *queue = ast_json_string_get(ast_json_object_get(obj->blob, "queue"));
+ int position = ast_json_integer_get(ast_json_object_get(obj->blob, "position"));
+ int count = ast_json_integer_get(ast_json_object_get(obj->blob, "count"));
+
+ channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+
+ if (!channel_event_string) {
+ return;
+ }
+
+ manager_event(EVENT_FLAG_AGENT, "QueueCallerLeave",
+ "%s"
+ "Queue: %s\r\n"
+ "Position: %d\r\n"
+ "Count: %d\r\n",
+ ast_str_buffer(channel_event_string),
+ queue, position, count);
+}
+
+static void queue_caller_abandon_cb(void *data,
+ struct stasis_subscription *sub, struct stasis_topic *topic,
+ struct stasis_message *message)
+{
+ struct ast_channel_blob *obj = stasis_message_data(message);
+ RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
+ const char *queue = ast_json_string_get(ast_json_object_get(obj->blob, "queue"));
+ int position = ast_json_integer_get(ast_json_object_get(obj->blob, "position"));
+ int original_position = ast_json_integer_get(ast_json_object_get(obj->blob, "originalposition"));
+ int hold_time = ast_json_integer_get(ast_json_object_get(obj->blob, "holdtime"));
+
+ channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+
+ if (!channel_event_string) {
+ return;
+ }
+
+ manager_event(EVENT_FLAG_AGENT, "QueueCallerAbandon",
+ "%s"
+ "Queue: %s\r\n"
+ "Position: %d\r\n"
+ "OriginalPosition: %d\r\n"
+ "HoldTime: %d\r\n",
+ ast_str_buffer(channel_event_string),
+ queue, position, original_position, hold_time);
+}
+
+static void queue_publish_channel_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
+{
+ RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+
+ msg = ast_channel_blob_create(chan, ast_channel_varset_type(), blob);
+
+ if (!msg) {
+ return;
+ }
+
+ stasis_publish(ast_channel_topic(chan), msg);
+}
+
+static struct ast_json *queue_member_blob_create(struct call_queue *q, struct member *mem)
+{
+ return ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: i, s: i, s: i, s: i, s: i, s: b}",
+ "Queue", q->name,
+ "MemberName", mem->membername,
+ "Interface", mem->interface,
+ "StateInterface", mem->state_interface,
+ "Membership", (mem->dynamic ? "dynamic" : (mem->realtime ? "realtime" : "static")),
+ "Penalty", mem->penalty,
+ "CallsTaken", mem->calls,
+ "LastCall", (int)mem->lastcall,
+ "Status", mem->status,
+ "Paused", mem->paused,
+ "Ringinuse", mem->ringinuse);
}
/*! \brief Check if members are available
@@ -1633,75 +2025,7 @@
return;
}
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a Queue member's status has changed.</synopsis>
- <syntax>
- <parameter name="Queue">
- <para>The name of the queue.</para>
- </parameter>
- <parameter name="Location">
- <para>The queue member's channel technology or location.</para>
- </parameter>
- <parameter name="MemberName">
- <para>The name of the queue member.</para>
- </parameter>
- <parameter name="StateInterface">
- <para>Channel technology or location from which to read device state changes.</para>
- </parameter>
- <parameter name="Membership">
- <enumlist>
- <enum name="dynamic"/>
- <enum name="realtime"/>
- <enum name="static"/>
- </enumlist>
- </parameter>
- <parameter name="Penalty">
- <para>The penalty associated with the queue member.</para>
- </parameter>
- <parameter name="CallsTaken">
- <para>The number of calls this queue member has serviced.</para>
- </parameter>
- <parameter name="LastCall">
- <para>The time this member last took call, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
- </parameter>
- <parameter name="Status">
- <para>The numeric device state status of the queue member.</para>
- <enumlist>
- <enum name="0"><para>AST_DEVICE_UNKNOWN</para></enum>
- <enum name="1"><para>AST_DEVICE_NOT_INUSE</para></enum>
- <enum name="2"><para>AST_DEVICE_INUSE</para></enum>
- <enum name="3"><para>AST_DEVICE_BUSY</para></enum>
- <enum name="4"><para>AST_DEVICE_INVALID</para></enum>
- <enum name="5"><para>AST_DEVICE_UNAVAILABLE</para></enum>
- <enum name="6"><para>AST_DEVICE_RINGING</para></enum>
- <enum name="7"><para>AST_DEVICE_RINGINUSE</para></enum>
- <enum name="8"><para>AST_DEVICE_ONHOLD</para></enum>
- </enumlist>
- </parameter>
- <parameter name="Paused">
- <enumlist>
- <enum name="0"/>
- <enum name="1"/>
- </enumlist>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
- "Queue: %s\r\n"
- "Location: %s\r\n"
- "MemberName: %s\r\n"
- "StateInterface: %s\r\n"
- "Membership: %s\r\n"
- "Penalty: %d\r\n"
- "CallsTaken: %d\r\n"
- "LastCall: %d\r\n"
- "Status: %d\r\n"
- "Paused: %d\r\n",
- q->name, m->interface, m->membername, m->state_interface, m->dynamic ? "dynamic" : m->realtime ? "realtime" : "static",
- m->penalty, m->calls, (int)m->lastcall, m->status, m->paused
- );
+ ast_manager_publish_event("QueueMemberStatus", EVENT_FLAG_AGENT, queue_member_blob_create(q, m));
}
/*!
@@ -2011,7 +2335,6 @@
q->leavewhenempty = 0;
q->memberdelay = 0;
q->maskmemberstatus = 0;
- q->eventwhencalled = 0;
q->weight = 0;
q->timeoutrestart = 0;
q->periodicannouncefrequency = 0;
@@ -2401,12 +2724,6 @@
parse_empty_options(val, &q->leavewhenempty, 0);
} else if (!strcasecmp(param, "eventmemberstatus")) {
q->maskmemberstatus = !ast_true(val);
- } else if (!strcasecmp(param, "eventwhencalled")) {
- if (!strcasecmp(val, "vars")) {
- q->eventwhencalled = QUEUE_EVENT_VARIABLES;
- } else {
- q->eventwhencalled = ast_true(val) ? 1 : 0;
- }
} else if (!strcasecmp(param, "reportholdtime")) {
q->reportholdtime = ast_true(val);
} else if (!strcasecmp(param, "memberdelay")) {
@@ -2909,6 +3226,8 @@
if (*reason == QUEUE_UNKNOWN && q->maxlen && (q->count >= q->maxlen)) {
*reason = QUEUE_FULL;
} else if (*reason == QUEUE_UNKNOWN) {
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+
/* There's space for us, put us at the right position inside
* the queue.
* Take into account the priority of the calling user */
@@ -2951,40 +3270,12 @@
}
res = 0;
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a channel joins a Queue.</synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
- <parameter name="Position">
- <para>This channel's current position in the queue.</para>
- </parameter>
- <parameter name="Count">
- <para>The total number of channels in the queue.</para>
- </parameter>
- </syntax>
- <see-also>
- <ref type="managerEvent">Leave</ref>
- <ref type="application">Queue</ref>
- </see-also>
- </managerEventInstance>
- ***/
- ast_manager_event(qe->chan, EVENT_FLAG_CALL, "Join",
- "Channel: %s\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "ConnectedLineNum: %s\r\n"
- "ConnectedLineName: %s\r\n"
- "Queue: %s\r\n"
- "Position: %d\r\n"
- "Count: %d\r\n"
- "Uniqueid: %s\r\n",
- ast_channel_name(qe->chan),
- S_COR(ast_channel_caller(qe->chan)->id.number.valid, ast_channel_caller(qe->chan)->id.number.str, "unknown"),/* XXX somewhere else it is <unknown> */
- S_COR(ast_channel_caller(qe->chan)->id.name.valid, ast_channel_caller(qe->chan)->id.name.str, "unknown"),
- S_COR(ast_channel_connected(qe->chan)->id.number.valid, ast_channel_connected(qe->chan)->id.number.str, "unknown"),/* XXX somewhere else it is <unknown> */
- S_COR(ast_channel_connected(qe->chan)->id.name.valid, ast_channel_connected(qe->chan)->id.name.str, "unknown"),
- q->name, qe->pos, q->count, ast_channel_uniqueid(qe->chan));
+
+ blob = ast_json_pack("{s: s, s: i, s: i}",
+ "queue", q->name,
+ "position", qe->pos,
+ "count", q->count);
+ queue_publish_channel_blob(qe->chan, queue_caller_join_type(), blob);
ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, ast_channel_name(qe->chan), qe->pos );
}
ao2_unlock(q);
@@ -3252,29 +3543,18 @@
prev = NULL;
for (current = q->head; current; current = current->next) {
if (current == qe) {
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
char posstr[20];
q->count--;
if (!q->count) {
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s", q->name);
}
- /* Take us out of the queue */
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a channel leaves a Queue.</synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='Join']/managerEventInstance/syntax/parameter[@name='Count'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='Join']/managerEventInstance/syntax/parameter[@name='Position'])" />
- </syntax>
- <see-also>
- <ref type="managerEvent">Join</ref>
- </see-also>
- </managerEventInstance>
- ***/
- ast_manager_event(qe->chan, EVENT_FLAG_CALL, "Leave",
- "Channel: %s\r\nQueue: %s\r\nCount: %d\r\nPosition: %d\r\nUniqueid: %s\r\n",
- ast_channel_name(qe->chan), q->name, q->count, qe->pos, ast_channel_uniqueid(qe->chan));
+ blob = ast_json_pack("{s: s, s: i, s: i}",
+ "queue", q->name,
+ "position", qe->pos,
+ "count", q->count);
+ queue_publish_channel_blob(qe->chan, queue_caller_leave_type(), blob);
ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, ast_channel_name(qe->chan));
/* Take us out of the queue */
if (prev) {
@@ -3446,46 +3726,6 @@
o->stillgoing = 0;
ast_hangup(o->chan);
o->chan = NULL;
-}
-
-/*! \brief convert "\n" to "\nVariable: " ready for manager to use */
-static char *vars2manager(struct ast_channel *chan, char *vars, size_t len)
-{
- struct ast_str *buf = ast_str_thread_get(&ast_str_thread_global_buf, len + 1);
- const char *tmp;
-
- if (pbx_builtin_serialize_variables(chan, &buf)) {
- int i, j;
-
- /* convert "\n" to "\nVariable: " */
- strcpy(vars, "Variable: ");
- tmp = ast_str_buffer(buf);
-
- for (i = 0, j = 10; (i < len - 1) && (j < len - 1); i++, j++) {
- vars[j] = tmp[i];
-
- if (tmp[i + 1] == '\0') {
- break;
- }
- if (tmp[i] == '\n') {
- vars[j++] = '\r';
- vars[j++] = '\n';
-
- ast_copy_string(&(vars[j]), "Variable: ", len - j);
- j += 9;
- }
- }
- if (j > len - 3) {
- j = len - 3;
- }
- vars[j++] = '\r';
- vars[j++] = '\n';
- vars[j] = '\0';
- } else {
- /* there are no channel variables; leave it blank */
- *vars = '\0';
- }
- return vars;
}
/*!
@@ -3728,54 +3968,12 @@
ast_channel_lock_both(tmp->chan, qe->chan);
- if (qe->parent->eventwhencalled) {
- char vars[2048];
-
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an Agent is notified of a member in the queue.</synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
- <parameter name="AgentCalled">
- <para>The agent's technology or location.</para>
- </parameter>
- <parameter name="AgentName">
- <para>The name of the agent.</para>
- </parameter>
- <parameter name="Variable" required="no" multiple="yes">
- <para>Optional channel variables from the ChannelCalling channel</para>
- </parameter>
- </syntax>
- <see-also>
- <ref type="managerEvent">AgentRingNoAnswer</ref>
- <ref type="managerEvent">AgentComplete</ref>
- <ref type="managerEvent">AgentConnect</ref>
- </see-also>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_AGENT, "AgentCalled",
- "Queue: %s\r\n"
- "AgentCalled: %s\r\n"
- "AgentName: %s\r\n"
- "ChannelCalling: %s\r\n"
- "DestinationChannel: %s\r\n"
- "CallerIDNum: %s\r\n"
- "CallerIDName: %s\r\n"
- "ConnectedLineNum: %s\r\n"
- "ConnectedLineName: %s\r\n"
- "Context: %s\r\n"
- "Extension: %s\r\n"
- "Priority: %d\r\n"
- "Uniqueid: %s\r\n"
- "%s",
- qe->parent->name, tmp->interface, tmp->member->membername, ast_channel_name(qe->chan), ast_channel_name(tmp->chan),
- S_COR(ast_channel_caller(qe->chan)->id.number.valid, ast_channel_caller(qe->chan)->id.number.str, "unknown"),
- S_COR(ast_channel_caller(qe->chan)->id.name.valid, ast_channel_caller(qe->chan)->id.name.str, "unknown"),
- S_COR(ast_channel_connected(qe->chan)->id.number.valid, ast_channel_connected(qe->chan)->id.number.str, "unknown"),
- S_COR(ast_channel_connected(qe->chan)->id.name.valid, ast_channel_connected(qe->chan)->id.name.str, "unknown"),
- ast_channel_context(qe->chan), ast_channel_exten(qe->chan), ast_channel_priority(qe->chan), ast_channel_uniqueid(qe->chan),
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
- }
+ manager_event(EVENT_FLAG_AGENT, "AgentCalled",
+ "Queue: %s\r\n"
+ "AgentCalled: %s\r\n"
+ "AgentName: %s\r\n"
+ "DestinationChannel: %s\r\n",
+ qe->parent->name, tmp->interface, tmp->member->membername, ast_channel_name(tmp->chan));
ast_channel_publish_dial(qe->chan, tmp->chan, tmp->interface, NULL);
@@ -3955,37 +4153,23 @@
if (!qe->parent->randomperiodicannounce) {
qe->last_periodic_announce_sound++;
}
-
+
return res;
}
/*! \brief Record that a caller gave up on waiting in queue */
static void record_abandoned(struct queue_ent *qe)
{
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+
set_queue_variables(qe->parent, qe->chan);
ao2_lock(qe->parent);
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an caller abandons the queue.</synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='Join']/managerEventInstance/syntax/parameter[@name='Position'])" />
- <parameter name="OriginalPosition">
- <para>The channel's original position in the queue.</para>
- </parameter>
- <parameter name="HoldTime">
- <para>The time the channel was in the queue, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_AGENT, "QueueCallerAbandon",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Position: %d\r\n"
- "OriginalPosition: %d\r\n"
- "HoldTime: %d\r\n",
- qe->parent->name, ast_channel_uniqueid(qe->chan), qe->pos, qe->opos, (int)(time(NULL) - qe->start));
+ blob = ast_json_pack("{s: s, s: i, s: i}",
+ "queue", qe->parent->name,
+ "position", qe->pos,
+ "originalposition", qe->opos,
+ "holdtime", (int)(time(NULL) - qe->start));
+ queue_publish_channel_blob(qe->chan, queue_caller_abandon_type(), blob);
qe->parent->callsabandoned++;
ao2_unlock(qe->parent);
@@ -4002,43 +4186,16 @@
ast_moh_start(qe->chan, qe->moh, NULL);
}
- if (qe->parent->eventwhencalled) {
- char vars[2048];
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an agent is notified of a member in the queue and fails to answer.</synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentCalled']/managerEventInstance/syntax/parameter[@name='Variable'])" />
- <parameter name="Member">
- <para>The queue member's channel technology or location.</para>
- </parameter>
- <parameter name="RingTime">
- <para>The time the agent was rung, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
- </parameter>
- </syntax>
- <see-also>
- <ref type="managerEvent">AgentCalled</ref>
- </see-also>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_AGENT, "AgentRingNoAnswer",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Channel: %s\r\n"
- "Member: %s\r\n"
- "MemberName: %s\r\n"
- "RingTime: %d\r\n"
- "%s",
- qe->parent->name,
- ast_channel_uniqueid(qe->chan),
- ast_channel_name(qe->chan),
- interface,
- membername,
- rnatime,
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
- }
+ manager_event(EVENT_FLAG_AGENT, "AgentRingNoAnswer",
+ "Queue: %s\r\n"
+ "Member: %s\r\n"
+ "MemberName: %s\r\n"
+ "RingTime: %d\r\n",
+ qe->parent->name,
+ interface,
+ membername,
+ rnatime);
+
ast_queue_log(qe->parent->name, ast_channel_uniqueid(qe->chan), membername, "RINGNOANSWER", "%d", rnatime);
if (qe->parent->autopause != QUEUE_AUTOPAUSE_OFF && autopause) {
if (qe->parent->autopausedelay > 0) {
@@ -4959,10 +5116,6 @@
{
const char *reason = NULL; /* silence dumb compilers */
- if (!qe->parent->eventwhencalled) {
- return;
- }
-
switch (rsn) {
case CALLER:
reason = "caller";
@@ -4975,45 +5128,16 @@
break;
}
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an agent has finished servicing a member in the queue.</synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentRingNoAnswer']/managerEventInstance/syntax/parameter[@name='Member'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueCallerAbandon']/managerEventInstance/syntax/parameter[@name='HoldTime'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentCalled']/managerEventInstance/syntax/parameter[@name='Variable'])" />
- <parameter name="TalkTime">
- <para>The time the agent talked with the member in the queue, expressed in seconds since 00:00, Jan 1, 1970 UTC.</para>
- </parameter>
- <parameter name="Reason">
- <enumlist>
- <enum name="caller"/>
- <enum name="agent"/>
- <enum name="transfer"/>
- </enumlist>
- </parameter>
- </syntax>
- <see-also>
- <ref type="managerEvent">AgentCalled</ref>
- <ref type="managerEvent">AgentConnect</ref>
- </see-also>
- </managerEventInstance>
- ***/
manager_event(EVENT_FLAG_AGENT, "AgentComplete",
"Queue: %s\r\n"
- "Uniqueid: %s\r\n"
"Channel: %s\r\n"
"Member: %s\r\n"
"MemberName: %s\r\n"
"HoldTime: %ld\r\n"
"TalkTime: %ld\r\n"
- "Reason: %s\r\n"
- "%s",
- queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername,
- (long)(callstart - qe->start), (long)(time(NULL) - callstart), reason,
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, vars_len) : "");
+ "Reason: %s\r\n",
+ queuename, ast_channel_name(peer), member->interface, member->membername,
+ (long)(callstart - qe->start), (long)(time(NULL) - callstart), reason);
}
#endif // BUGBUG
@@ -5246,7 +5370,6 @@
char mixmonargs[1512];
struct ast_app *mixmonapp = NULL;
char *p;
- char vars[2048];
int forwardsallowed = 1;
int block_connected_line = 0;
#if 0 // BUGBUG
@@ -5586,32 +5709,14 @@
/* Agent must have hung up */
ast_log(LOG_WARNING, "Agent on %s hungup on the customer.\n", ast_channel_name(peer));
ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "AGENTDUMP", "%s", "");
- if (qe->parent->eventwhencalled) {
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when an agent hangs up on a member in the queue.</synopsis>
- <syntax>
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='Queue'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentRingNoAnswer']/managerEventInstance/syntax/parameter[@name='Member'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='QueueMemberStatus']/managerEventInstance/syntax/parameter[@name='MemberName'])" />
- <xi:include xpointer="xpointer(/docs/managerEvent[@name='AgentCalled']/managerEventInstance/syntax/parameter[@name='Variable'])" />
- </syntax>
- <see-also>
- <ref type="managerEvent">AgentCalled</ref>
- <ref type="managerEvent">AgentConnect</ref>
- </see-also>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_AGENT, "AgentDump",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Channel: %s\r\n"
- "Member: %s\r\n"
- "MemberName: %s\r\n"
- "%s",
- queuename, ast_channel_uniqueid(qe->chan), ast_channel_name(peer), member->interface, member->membername,
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
- }
+
[... 495 lines stripped ...]
More information about the asterisk-commits
mailing list