[svn-commits] mmichelson: branch mmichelson/queue-log-atxfer r121954 - /team/mmichelson/que...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jun 11 16:27:31 CDT 2008


Author: mmichelson
Date: Wed Jun 11 16:27:30 2008
New Revision: 121954

URL: http://svn.digium.com/view/asterisk?view=rev&rev=121954
Log:
Progress commit. At this point attended transfers are logged properly in the
queue_log and with the proper information no less! The following things need
to be cleared up though:

1. Currently, an attended transfer will log both a TRANSFER and a *COMPLETE
event, whereas blind transfers will only log one or the other. This needs
to be corrected.

2. The datastore attached to the calling channel is not removed, and so if
that caller were transferred multiple times, then conceivably, multiple
TRANSFER messages would be logged.


Modified:
    team/mmichelson/queue-log-atxfer/apps/app_queue.c

Modified: team/mmichelson/queue-log-atxfer/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-log-atxfer/apps/app_queue.c?view=diff&rev=121954&r1=121953&r2=121954
==============================================================================
--- team/mmichelson/queue-log-atxfer/apps/app_queue.c (original)
+++ team/mmichelson/queue-log-atxfer/apps/app_queue.c Wed Jun 11 16:27:30 2008
@@ -3042,6 +3042,59 @@
 		qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, vars_len) : "");
 }
 
+struct queue_transfer_ds {
+	struct queue_ent *qe;
+	struct member *member;
+	int starttime;
+};
+
+static void queue_transfer_destroy(void *data) 
+{
+	/*stub*/
+}
+
+static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan) 
+{
+	struct queue_transfer_ds *qtds = data;
+	struct queue_ent *qe = qtds->qe;
+	struct member *member = qtds->member;
+	int callstart = qtds->starttime;
+	ast_log(LOG_NOTICE, "This would be where we would log a transfer!\n");
+	ast_log(LOG_NOTICE, "old_chan is %s(%p) and new_chan is %s(%p)\n", old_chan->name, old_chan, new_chan->name, new_chan);
+	ast_log(LOG_NOTICE, "old_chan has exten %s and context %s. new_chan has exten %s and context %s\n", old_chan->exten, old_chan->context, new_chan->exten, new_chan->context);
+	ast_queue_log(qe->parent->name, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
+				new_chan->exten, new_chan->context, (long) (callstart - qe->start),
+				(long) (time(NULL) - callstart));
+}
+
+static const struct ast_datastore_info queue_transfer_info = {
+	.type = "queue_transfer",
+	.destroy = queue_transfer_destroy,
+	.chan_fixup = queue_transfer_fixup,
+};
+
+static void setup_transfer_datastore(struct queue_ent *qe, struct member *member, int starttime)
+{
+	struct ast_datastore *ds;
+	struct queue_transfer_ds qtds;
+
+	ast_channel_lock(qe->chan);
+	if (!(ds = ast_channel_datastore_alloc(&queue_transfer_info, NULL))) {
+		ast_channel_unlock(qe->chan);
+		ast_log(LOG_WARNING, "Unable to create transfer datastore. queue_log will not show attended transfer\n");
+		return;
+	}
+
+	qtds.qe = qe;
+	/* This member is refcounted in try_calling, so no need to add it here, too */
+	qtds.member = member;
+	qtds.starttime = starttime;
+	ds->data = &qtds;
+	ast_log(LOG_NOTICE, "Adding datastore to channel %s\n", qe->chan->name);
+	ast_channel_datastore_add(qe->chan, ds);
+	ast_channel_unlock(qe->chan);
+}
+
 /*! \brief A large function which calls members, updates statistics, and bridges the caller and a member
  * 
  * Here is the process of this function
@@ -3681,9 +3734,12 @@
 		ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
 		ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
 		time(&callstart);
-
+		setup_transfer_datastore(qe, member, callstart);
 		bridge = ast_bridge_call(qe->chan,peer, &bridge_config);
 
+		/* If the queue member did an attended transfer, then the TRANSFER already was logged in the queue_log
+		 * when the masquerade occurred. These other "ending" queue_log messages are unnecessary
+		 */
 		if (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten)) {
 			ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
 				qe->chan->exten, qe->chan->context, (long) (callstart - qe->start),




More information about the svn-commits mailing list