[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r328932 - in /team/irroot/dist...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 20 07:36:32 CDT 2011


Author: irroot
Date: Wed Jul 20 07:36:28 2011
New Revision: 328932

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=328932
Log:
app_queue log membername when state_interface is set for ADDMEMBER and REMOVEMEMBER events
https://reviewboard.asterisk.org/r/1286/
Merging diff for testing

Modified:
    team/irroot/distrotech-customers-1.8/apps/app_queue.c
    team/irroot/distrotech-customers-1.8/configs/queues.conf.sample

Modified: team/irroot/distrotech-customers-1.8/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/apps/app_queue.c?view=diff&rev=328932&r1=328931&r2=328932
==============================================================================
--- team/irroot/distrotech-customers-1.8/apps/app_queue.c (original)
+++ team/irroot/distrotech-customers-1.8/apps/app_queue.c Wed Jul 20 07:36:28 2011
@@ -952,6 +952,9 @@
 /*! \brief queues.conf [general] option */
 static int negative_penalty_invalid = 0;
 
+/*! \brief queues.conf [general] option */
+static int log_membername_as_agent = 0;
+
 enum queue_result {
 	QUEUE_UNKNOWN = 0,
 	QUEUE_TIMEOUT = 1,
@@ -1214,6 +1217,8 @@
 static int set_member_paused(const char *queuename, const char *interface, const char *reason, int paused);
 
 static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
+
+static struct member *find_member_by_queuename_and_interface(const char *queuename, const char *interface);
 /*! \brief sets the QUEUESTATUS channel variable */
 static void set_queue_result(struct ast_channel *chan, enum queue_result res)
 {
@@ -2168,7 +2173,11 @@
 			m->realtime = 1;
 			m->ignorebusy = ignorebusy;
 			ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
-			ast_queue_log(q->name, "REALTIME", m->interface, "ADDMEMBER", "%s", "");
+			if (!log_membername_as_agent) {
+				ast_queue_log(q->name, "REALTIME", m->interface, "ADDMEMBER", "%s", "");
+			} else {
+				ast_queue_log(q->name, "REALTIME", m->membername, "ADDMEMBER", "%s", "");
+			}
 			ao2_link(q->members, m);
 			ao2_ref(m, -1);
 			m = NULL;
@@ -2349,7 +2358,11 @@
 	mem_iter = ao2_iterator_init(q->members, 0);
 	while ((m = ao2_iterator_next(&mem_iter))) {
 		if (m->dead) {
-			ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+			if (m->membername == NULL || !log_membername_as_agent) {
+				ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+			} else {
+				ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
+			}
 			ao2_unlink(q->members, m);
 			q->membercount--;
 		}
@@ -2471,7 +2484,11 @@
 	mem_iter = ao2_iterator_init(q->members, 0);
 	while ((m = ao2_iterator_next(&mem_iter))) {
 		if (m->dead) {
-			ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+			if (m->membername == NULL || !log_membername_as_agent) {
+				ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", "");
+			} else {
+				ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
+			}
 			ao2_unlink(q->members, m);
 			q->membercount--;
 		}
@@ -5701,6 +5718,8 @@
 {
 	int res=-1;
 	char *parse, *temppos = NULL;
+	struct member *mem = NULL;
+
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(queuename);
 		AST_APP_ARG(interface);
@@ -5726,9 +5745,17 @@
 
 	ast_debug(1, "queue: %s, member: %s\n", args.queuename, args.interface);
 
+	if (log_membername_as_agent) {
+		mem = find_member_by_queuename_and_interface(args.queuename, args.interface);
+	}
+
 	switch (remove_from_queue(args.queuename, args.interface)) {
 	case RES_OKAY:
-		ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", "");
+		if (mem->membername == NULL || !log_membername_as_agent) {
+			ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", "");
+		} else {
+			ast_queue_log(args.queuename, chan->uniqueid, mem->membername, "REMOVEMEMBER", "%s", "");
+		}
 		ast_log(LOG_NOTICE, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename);
 		pbx_builtin_setvar_helper(chan, "RQMSTATUS", "REMOVED");
 		res = 0;
@@ -5793,7 +5820,11 @@
 
 	switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface)) {
 	case RES_OKAY:
-		ast_queue_log(args.queuename, chan->uniqueid, args.interface, "ADDMEMBER", "%s", "");
+		if (ast_strlen_zero(args.membername) || !log_membername_as_agent) {
+			ast_queue_log(args.queuename, chan->uniqueid, args.interface, "ADDMEMBER", "%s", "");
+		} else {
+			ast_queue_log(args.queuename, chan->uniqueid, args.membername, "ADDMEMBER", "%s", "");
+		}
 		ast_log(LOG_NOTICE, "Added interface '%s' to queue '%s'\n", args.interface, args.queuename);
 		pbx_builtin_setvar_helper(chan, "AQMSTATUS", "ADDED");
 		res = 0;
@@ -5809,7 +5840,7 @@
 		res = 0;
 		break;
 	case RES_OUTOFMEMORY:
-		ast_log(LOG_ERROR, "Out of memory adding member %s to queue %s\n", args.interface, args.queuename);
+		ast_log(LOG_ERROR, "Out of memory adding interface %s to queue %s\n", args.interface, args.queuename);
 		break;
 	}
 
@@ -6723,6 +6754,9 @@
 	negative_penalty_invalid = 0;
 	if ((general_val = ast_variable_retrieve(cfg, "general", "negative_penalty_invalid")))
 		negative_penalty_invalid = ast_true(general_val);
+	log_membername_as_agent = 0;
+	if ((general_val = ast_variable_retrieve(cfg, "general", "log_membername_as_agent")))
+		log_membername_as_agent = ast_true(general_val);
 }
 
 /*! \brief reload information pertaining to a single member
@@ -7519,7 +7553,11 @@
 
 	switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface)) {
 	case RES_OKAY:
-		ast_queue_log(queuename, "MANAGER", interface, "ADDMEMBER", "%s", "");
+		if (ast_strlen_zero(membername) || !log_membername_as_agent) {
+			ast_queue_log(queuename, "MANAGER", interface, "ADDMEMBER", "%s", "");
+		} else {
+			ast_queue_log(queuename, "MANAGER", membername, "ADDMEMBER", "%s", "");
+		}
 		astman_send_ack(s, m, "Added interface to queue");
 		break;
 	case RES_EXISTS:
@@ -7539,6 +7577,7 @@
 static int manager_remove_queue_member(struct mansession *s, const struct message *m)
 {
 	const char *queuename, *interface;
+	struct member *mem = NULL;
 
 	queuename = astman_get_header(m, "Queue");
 	interface = astman_get_header(m, "Interface");
@@ -7548,9 +7587,17 @@
 		return 0;
 	}
 
+	if (log_membername_as_agent) {
+		mem = find_member_by_queuename_and_interface(queuename, interface);
+	}
+
 	switch (remove_from_queue(queuename, interface)) {
 	case RES_OKAY:
-		ast_queue_log(queuename, "MANAGER", interface, "REMOVEMEMBER", "%s", "");
+		if (mem->membername == NULL || !log_membername_as_agent) {
+			ast_queue_log(queuename, "MANAGER", interface, "REMOVEMEMBER", "%s", "");
+		} else {
+			ast_queue_log(queuename, "MANAGER", mem->membername, "REMOVEMEMBER", "%s", "");
+		}
 		astman_send_ack(s, m, "Removed interface from queue");
 		break;
 	case RES_EXISTS:
@@ -7772,7 +7819,11 @@
 
 	switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface)) {
 	case RES_OKAY:
-		ast_queue_log(queuename, "CLI", interface, "ADDMEMBER", "%s", "");
+		if (membername == NULL || !log_membername_as_agent) {
+			ast_queue_log(queuename, "CLI", interface, "ADDMEMBER", "%s", "");
+		} else {
+			ast_queue_log(queuename, "CLI", membername, "ADDMEMBER", "%s", "");
+		}
 		ast_cli(a->fd, "Added interface '%s' to queue '%s'\n", interface, queuename);
 		return CLI_SUCCESS;
 	case RES_EXISTS:
@@ -7840,11 +7891,12 @@
 static char *handle_queue_remove_member(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	const char *queuename, *interface;
+	struct member *mem = NULL;
 
 	switch (cmd) {
 	case CLI_INIT:
 		e->command = "queue remove member";
-		e->usage = 
+		e->usage =
 			"Usage: queue remove member <channel> from <queue>\n"
 			"       Remove a specific channel from a queue.\n";
 		return NULL;
@@ -7861,10 +7913,18 @@
 	queuename = a->argv[5];
 	interface = a->argv[3];
 
+	if (log_membername_as_agent) {
+		mem = find_member_by_queuename_and_interface(queuename, interface);
+	}
+
 	switch (remove_from_queue(queuename, interface)) {
 	case RES_OKAY:
-		ast_queue_log(queuename, "CLI", interface, "REMOVEMEMBER", "%s", "");
-		ast_cli(a->fd, "Removed interface '%s' from queue '%s'\n", interface, queuename);
+		if (mem->membername == NULL || !log_membername_as_agent) {
+			ast_queue_log(queuename, "CLI", interface, "REMOVEMEMBER", "%s", "");
+		} else {
+			ast_queue_log(queuename, "CLI", mem->membername, "REMOVEMEMBER", "%s", "");
+		}
+		ast_cli(a->fd, "Removed interface %s from queue '%s'\n", interface, queuename);
 		return CLI_SUCCESS;
 	case RES_EXISTS:
 		ast_cli(a->fd, "Unable to remove interface '%s' from queue '%s': Not there\n", interface, queuename);
@@ -8584,6 +8644,27 @@
 	return 0;
 }
 
+/* \brief Find a member by looking up queuename and interface.
+ * \return Returns a member or NULL if member not found.
+*/
+static struct member *find_member_by_queuename_and_interface(const char *queuename, const char *interface)
+{
+	struct member tmpmem, *mem = NULL;
+	struct call_queue *q;
+
+	ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface));
+	if ((q = load_realtime_queue(queuename)))
+	{
+		ao2_lock(q);
+		if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER))) {
+			ao2_ref(mem, -1);
+			queue_t_unref(q, "Expiring temporary reference.");
+		}
+		ao2_unlock(q);
+	}
+	return mem;
+}
+
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "True Call Queueing",
 		.load = load_module,
 		.unload = unload_module,

Modified: team/irroot/distrotech-customers-1.8/configs/queues.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/configs/queues.conf.sample?view=diff&rev=328932&r1=328931&r2=328932
==============================================================================
--- team/irroot/distrotech-customers-1.8/configs/queues.conf.sample (original)
+++ team/irroot/distrotech-customers-1.8/configs/queues.conf.sample Wed Jul 20 07:36:28 2011
@@ -64,6 +64,12 @@
 ; Negative_penalty_invalid will treat members with a negative penalty as logged off
 ;
 ;negative_penalty_invalid = no
+;
+; log_membername_as_agent will cause app_queue to log the membername rather than
+; the interface for the ADDMEMBER and REMOVEMEMBER events when a state_interface
+; is set.  The default value (no) maintains backward compatibility.
+;
+;log_membername_as_agent = no
 ;
 ;[markq]
 ;




More information about the asterisk-commits mailing list