[svn-commits] trunk r35504 - in /trunk: apps/app_queue.c
configs/queues.conf.sample
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Thu Jun 22 08:43:03 MST 2006
Author: tilghman
Date: Thu Jun 22 10:43:02 2006
New Revision: 35504
URL: http://svn.digium.com/view/asterisk?rev=35504&view=rev
Log:
Bug 6589 - option to display channel variables in queue events
Modified:
trunk/apps/app_queue.c
trunk/configs/queues.conf.sample
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=35504&r1=35503&r2=35504&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Jun 22 10:43:02 2006
@@ -330,6 +330,7 @@
#define QUEUE_EMPTY_STRICT 2
#define ANNOUNCEHOLDTIME_ALWAYS 1
#define ANNOUNCEHOLDTIME_ONCE 2
+#define QUEUE_EVENT_VARIABLES 3
struct call_queue {
ast_mutex_t lock;
@@ -340,7 +341,7 @@
unsigned int monjoin:1;
unsigned int dead:1;
unsigned int joinempty:2;
- unsigned int eventwhencalled:1;
+ unsigned int eventwhencalled:2;
unsigned int leavewhenempty:2;
unsigned int ringinuse:1;
unsigned int setinterfacevar:1;
@@ -874,7 +875,11 @@
} else if (!strcasecmp(param, "eventmemberstatus")) {
q->maskmemberstatus = !ast_true(val);
} else if (!strcasecmp(param, "eventwhencalled")) {
- q->eventwhencalled = ast_true(val);
+ if (strcasecmp(val, "vars")) {
+ q->eventwhencalled = QUEUE_EVENT_VARIABLES;
+ } else {
+ q->eventwhencalled = ast_true(val);
+ }
} else if (!strcasecmp(param, "reportholdtime")) {
q->reportholdtime = ast_true(val);
} else if (!strcasecmp(param, "memberdelay")) {
@@ -1496,6 +1501,41 @@
o->stillgoing = 0;
ast_hangup(o->chan);
o->chan = NULL;
+}
+
+static char *vars2manager(struct ast_channel *chan, char *vars, size_t len)
+{
+ char *tmp = alloca(len);
+
+ if (pbx_builtin_serialize_variables(chan, tmp, len)) {
+ int i, j;
+
+ /* convert "\n" to "\nVariable: " */
+ strcpy(vars, "Variable: ");
+
+ 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 - 1)
+ j = len - 1;
+ vars[j - 2] = '\r';
+ vars[j - 1] = '\n';
+ vars[j] = '\0';
+ } else {
+ /* there are no channel variables; leave it blank */
+ *vars = '\0';
+ }
+ return vars;
}
static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies)
@@ -1589,21 +1629,23 @@
do_hang(tmp);
(*busies)++;
return 0;
- } else {
- if (qe->parent->eventwhencalled) {
- manager_event(EVENT_FLAG_AGENT, "AgentCalled",
- "AgentCalled: %s\r\n"
- "ChannelCalling: %s\r\n"
- "CallerID: %s\r\n"
- "CallerIDName: %s\r\n"
- "Context: %s\r\n"
- "Extension: %s\r\n"
- "Priority: %d\r\n",
- tmp->interface, qe->chan->name,
- S_OR(tmp->chan->cid.cid_num, "unknown"),
- S_OR(tmp->chan->cid.cid_name, "unknown"),
- qe->chan->context, qe->chan->exten, qe->chan->priority);
- }
+ } else if (qe->parent->eventwhencalled) {
+ char vars[2048];
+
+ manager_event(EVENT_FLAG_AGENT, "AgentCalled",
+ "AgentCalled: %s\r\n"
+ "ChannelCalling: %s\r\n"
+ "CallerID: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "Context: %s\r\n"
+ "Extension: %s\r\n"
+ "Priority: %d\r\n"
+ "%s",
+ tmp->interface, qe->chan->name,
+ tmp->chan->cid.cid_num ? tmp->chan->cid.cid_num : "unknown",
+ tmp->chan->cid.cid_name ? tmp->chan->cid.cid_name : "unknown",
+ qe->chan->context, qe->chan->exten, qe->chan->priority,
+ qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", tmp->interface);
}
@@ -2233,6 +2275,7 @@
char mixmonargs[1512];
struct ast_app *mixmonapp = NULL;
char *p;
+ char vars[2048];
memset(&bridge_config, 0, sizeof(bridge_config));
time(&now);
@@ -2381,14 +2424,15 @@
ast_log(LOG_WARNING, "Agent on %s hungup on the customer. They're going to be pissed.\n", peer->name);
ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "AGENTDUMP", "%s", "");
record_abandoned(qe);
- if (qe->parent->eventwhencalled) {
+ if (qe->parent->eventwhencalled)
manager_event(EVENT_FLAG_AGENT, "AgentDump",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Channel: %s\r\n"
- "Member: %s\r\n",
- queuename, qe->chan->uniqueid, peer->name, member->interface);
- }
+ "Queue: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Channel: %s\r\n"
+ "Member: %s\r\n"
+ "%s",
+ queuename, qe->chan->uniqueid, peer->name, member->interface,
+ qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
ast_hangup(peer);
goto out;
} else if (res2) {
@@ -2526,14 +2570,16 @@
ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "CONNECT", "%ld|%s", (long)time(NULL) - qe->start, peer->uniqueid);
if (qe->parent->eventwhencalled)
manager_event(EVENT_FLAG_AGENT, "AgentConnect",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Channel: %s\r\n"
- "Member: %s\r\n"
- "Holdtime: %ld\r\n"
- "BridgedChannel: %s\r\n",
- queuename, qe->chan->uniqueid, peer->name, member->interface,
- (long) time(NULL) - qe->start,peer->uniqueid);
+ "Queue: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Channel: %s\r\n"
+ "Member: %s\r\n"
+ "Holdtime: %ld\r\n"
+ "BridgedChannel: %s\r\n"
+ "%s",
+ queuename, qe->chan->uniqueid, peer->name, member->interface,
+ (long)time(NULL) - qe->start, peer->uniqueid,
+ qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
time(&callstart);
@@ -2549,28 +2595,32 @@
(long) (callstart - qe->start), (long) (time(NULL) - callstart));
if (qe->parent->eventwhencalled)
manager_event(EVENT_FLAG_AGENT, "AgentComplete",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Channel: %s\r\n"
- "Member: %s\r\n"
- "HoldTime: %ld\r\n"
- "TalkTime: %ld\r\n"
- "Reason: caller\r\n",
- queuename, qe->chan->uniqueid, peer->name, member->interface,
- (long) (callstart - qe->start), (long) (time(NULL) - callstart));
+ "Queue: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Channel: %s\r\n"
+ "Member: %s\r\n"
+ "HoldTime: %ld\r\n"
+ "TalkTime: %ld\r\n"
+ "Reason: caller\r\n"
+ "%s",
+ queuename, qe->chan->uniqueid, peer->name, member->interface,
+ (long)(callstart - qe->start), (long)(time(NULL) - callstart),
+ qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
} else {
ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "COMPLETEAGENT", "%ld|%ld",
(long) (callstart - qe->start), (long) (time(NULL) - callstart));
if (qe->parent->eventwhencalled)
manager_event(EVENT_FLAG_AGENT, "AgentComplete",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Channel: %s\r\n"
- "HoldTime: %ld\r\n"
- "TalkTime: %ld\r\n"
- "Reason: agent\r\n",
- queuename, qe->chan->uniqueid, peer->name, (long)(callstart - qe->start),
- (long) (time(NULL) - callstart));
+ "Queue: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Channel: %s\r\n"
+ "HoldTime: %ld\r\n"
+ "TalkTime: %ld\r\n"
+ "Reason: agent\r\n"
+ "%s",
+ queuename, qe->chan->uniqueid, peer->name, (long)(callstart - qe->start),
+ (long)(time(NULL) - callstart),
+ qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
}
if (bridge != AST_PBX_NO_HANGUP_PEER)
Modified: trunk/configs/queues.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/queues.conf.sample?rev=35504&r1=35503&r2=35504&view=diff
==============================================================================
--- trunk/configs/queues.conf.sample (original)
+++ trunk/configs/queues.conf.sample Thu Jun 22 10:43:02 2006
@@ -250,10 +250,11 @@
;
;
; If this is set to yes, the following manager events will be generated:
-; AgentCalled, AgentDump, AgentConnect, AgentComplete
+; AgentCalled, AgentDump, AgentConnect, AgentComplete; setting this to
+; vars also sends all channel variables with the event.
; (may generate some extra manager events, but probably ones you want)
;
-; eventwhencalled = yes
+; eventwhencalled = yes|no|vars
;
; If this is set to no, the following manager events will be generated:
; QueueMemberStatus
More information about the svn-commits
mailing list