[asterisk-commits] mmichelson: branch group/manager2 r110315 - in /team/group/manager2: apps/ in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 20 15:20:57 CDT 2008
Author: mmichelson
Date: Thu Mar 20 15:20:56 2008
New Revision: 110315
URL: http://svn.digium.com/view/asterisk?view=rev&rev=110315
Log:
Updated the vars2manager function in app_queue to append channel variables to
an event when necessary. May I just vent and say that the strsep function is
very finicky? Thanks.
Headers are jumbled like mad in this branch and need some work. That's the next
task
Modified:
team/group/manager2/apps/app_queue.c
team/group/manager2/include/asterisk/event_defs.h
team/group/manager2/include/asterisk/manager2.h
Modified: team/group/manager2/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/apps/app_queue.c?view=diff&rev=110315&r1=110314&r2=110315
==============================================================================
--- team/group/manager2/apps/app_queue.c (original)
+++ team/group/manager2/apps/app_queue.c Thu Mar 20 15:20:56 2008
@@ -2065,45 +2065,22 @@
o->chan = NULL;
}
/*temporarily comment this out since we're not using it but may need it for later */
-#if 0
/*! \brief convert "\n" to "\nVariable: " ready for manager to use */
-static char *vars2manager(struct ast_channel *chan, char *vars, size_t len)
+static void vars2manager(struct ast_channel *chan struct ast_event *event)
{
struct ast_str *buf = ast_str_alloca(len + 1);
- char *tmp;
if (pbx_builtin_serialize_variables(chan, &buf)) {
- int i, j;
-
- /* convert "\n" to "\nVariable: " */
- strcpy(vars, "Variable: ");
- tmp = buf->str;
-
- 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;
-}
-#endif
+ char *var;
+ char *vars = ast_strdupa(buf->str);
+
+ while ((var = strsep(&vars, "\n"))) {
+ if (!ast_strlen_zero(var)) {
+ ast_event_append_ie_str(&event, AST_EVENT_IE_CHANVAR, var);
+ }
+ }
+ }
+}
/*!
* \brief Part 2 of ring_one
*
@@ -2224,7 +2201,6 @@
(*busies)++;
return 0;
} else if (qe->parent->eventwhencalled) {
- /*char vars[2048];*/
struct ast_event *event = NULL;
event = ast_event_new(AST_EVENT_QUEUE_MEMBER_CALLED,
@@ -2240,30 +2216,12 @@
AST_EVENT_IE_INFO_QUEUE_PRIORITY, AST_EVENT_IE_PLTYPE_UINT, qe->chan->priority,
AST_EVENT_IE_INFO_QUEUE_SOURCE_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, qe->chan->uniqueid,
AST_EVENT_IE_END);
- /*Add channelvars stuff later*/
+
+ if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
+ vars2manager(qe->chan, event);
+ }
ast_event_queue(event);
-#if 0
-
- 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"
- "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, qe->chan->name, tmp->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->chan->uniqueid,
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
-#endif
ast_verb(3, "Called %s\n", tmp->interface);
}
@@ -3016,7 +2974,7 @@
/*! \brief Send out AMI message with member call completion status information */
static void send_agent_complete(const struct queue_ent *qe, const char *queuename,
const struct ast_channel *peer, const struct member *member, time_t callstart,
- char *vars, size_t vars_len, enum agent_complete_reason rsn)
+ enum agent_complete_reason rsn)
{
const char *reason = NULL; /* silence dumb compilers */
struct ast_event *event = NULL;
@@ -3047,24 +3005,11 @@
AST_EVENT_IE_INFO_QUEUE_REASON, AST_EVENT_IE_PLTYPE_STR, reason,
AST_EVENT_IE_END);
+ if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
+ vars2manager(qe->chan, event);
+ }
+
ast_event_queue(event);
-#if 0
-
- 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, qe->chan->uniqueid, peer->name, 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) : "");
-#endif
-
}
/*! \brief A large function which calls members, updates statistics, and bridges the caller and a member
@@ -3129,7 +3074,6 @@
char mixmonargs[1512];
struct ast_app *mixmonapp = NULL;
char *p;
- char vars[2048];
int forwardsallowed = 1;
int callcompletedinsl;
struct ao2_iterator memi;
@@ -3404,18 +3348,11 @@
AST_EVENT_IE_INFO_QUEUE_MEMBER_NAME, AST_EVENT_IE_PLTYPE_STR, member->membername,
AST_EVENT_IE_END);
+ if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
+ vars2manager(qe->chan, event);
+ }
+
ast_event_queue(event);
-#if 0
- 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, qe->chan->uniqueid, peer->name, member->interface, member->membername,
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
-#endif
}
ast_hangup(peer);
ao2_ref(member, -1);
@@ -3702,23 +3639,11 @@
AST_EVENT_IE_INFO_QUEUE_RINGTIME, AST_EVENT_IE_PLTYPE_UINT, orig - to > 0 ? (orig - to) / 1000 : 0,
AST_EVENT_IE_END);
+ if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
+ vars2manager(qe->chan, event);
+ }
+
ast_event_queue(event);
-
-#if 0
- manager_event(EVENT_FLAG_AGENT, "AgentConnect",
- "Queue: %s\r\n"
- "Uniqueid: %s\r\n"
- "Channel: %s\r\n"
- "Member: %s\r\n"
- "MemberName: %s\r\n"
- "Holdtime: %ld\r\n"
- "BridgedChannel: %s\r\n"
- "Ringtime: %ld\r\n"
- "%s",
- queuename, qe->chan->uniqueid, peer->name, member->interface, member->membername,
- (long) time(NULL) - qe->start, peer->uniqueid, (long)(orig - to > 0 ? (orig - to) / 1000 : 0),
- qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
-#endif
}
ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
@@ -3730,15 +3655,15 @@
ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
qe->chan->exten, qe->chan->context, (long) (callstart - qe->start),
(long) (time(NULL) - callstart));
- send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER);
+ send_agent_complete(qe, queuename, peer, member, callstart, TRANSFER);
} else if (ast_check_hangup(qe->chan)) {
ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETECALLER", "%ld|%ld|%d",
(long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
- send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), CALLER);
+ send_agent_complete(qe, queuename, peer, member, callstart, CALLER);
} else {
ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETEAGENT", "%ld|%ld|%d",
(long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
- send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), AGENT);
+ send_agent_complete(qe, queuename, peer, member, callstart, AGENT);
}
if (bridge != AST_PBX_NO_HANGUP_PEER)
Modified: team/group/manager2/include/asterisk/event_defs.h
URL: http://svn.digium.com/view/asterisk/team/group/manager2/include/asterisk/event_defs.h?view=diff&rev=110315&r1=110314&r2=110315
==============================================================================
--- team/group/manager2/include/asterisk/event_defs.h (original)
+++ team/group/manager2/include/asterisk/event_defs.h Thu Mar 20 15:20:56 2008
@@ -124,7 +124,6 @@
*/
AST_EVENT_IE_CONTEXT = 0x09,
};
-
/*!
* \brief Payload types for event information elements
*/
Modified: team/group/manager2/include/asterisk/manager2.h
URL: http://svn.digium.com/view/asterisk/team/group/manager2/include/asterisk/manager2.h?view=diff&rev=110315&r1=110314&r2=110315
==============================================================================
--- team/group/manager2/include/asterisk/manager2.h (original)
+++ team/group/manager2/include/asterisk/manager2.h Thu Mar 20 15:20:56 2008
@@ -54,6 +54,8 @@
AST_EVENT_IE_INFO_QUEUE_RINGTIME,
/*! Member channel's uniqueid, string */
AST_EVENT_IE_INFO_QUEUE_DESTINATION_UNIQUEID,
+ /*! Channel variable */
+ AST_EVENT_IE_CHANVAR,
};
struct ast_event_info_ie_map {
@@ -86,6 +88,7 @@
{AST_EVENT_IE_INFO_QUEUE_REASON, AST_EVENT_IE_PLTYPE_STR, "Reason"},
{AST_EVENT_IE_INFO_QUEUE_RINGTIME, AST_EVENT_IE_PLTYPE_UINT, "RingTime"},
{AST_EVENT_IE_INFO_QUEUE_DESTINATION_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, "DestinationUniqueID"},
+ {AST_EVENT_IE_CHANVAR, AST_EVENT_IE_PLTYPE_STR, "Variable"},
};
#endif
More information about the asterisk-commits
mailing list