[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r322181 - /team/irroot/distrot...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 7 04:10:35 CDT 2011


Author: irroot
Date: Tue Jun  7 04:10:31 2011
New Revision: 322181

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=322181
Log:
app_queue Cleanups

Modified:
    team/irroot/distrotech-customers-1.8/apps/app_queue.c

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=322181&r1=322180&r2=322181
==============================================================================
--- team/irroot/distrotech-customers-1.8/apps/app_queue.c (original)
+++ team/irroot/distrotech-customers-1.8/apps/app_queue.c Tue Jun  7 04:10:31 2011
@@ -537,7 +537,7 @@
 		<description>
 			<para>Allows access to queue counts [R] and member information [R/W].</para>
 			<para>
-				<replaceable>queuename</replaceable> is required for all operations 
+				<replaceable>queuename</replaceable> is required for all operations
 				<replaceable>interface</replaceable> is required for all member operations.
 			</para>
 		</description>
@@ -1212,7 +1212,7 @@
 static struct member *interface_exists(struct call_queue *q, const char *interface);
 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 void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
 /*! \brief sets the QUEUESTATUS channel variable */
 static void set_queue_result(struct ast_channel *chan, enum queue_result res)
 {
@@ -2107,11 +2107,11 @@
 	int ignorebusy = 0;
 
 	const char *config_val;
-	const char *rt_uniqueid=ast_variable_retrieve(member_config, interface, "uniqueid");
-	const char *membername=S_OR(ast_variable_retrieve(member_config, interface, "membername"),interface);
-	const char *state_interface=S_OR(ast_variable_retrieve(member_config, interface, "state_interface"),interface);
-	const char *penalty_str=ast_variable_retrieve(member_config, interface, "penalty");
-	const char *paused_str=ast_variable_retrieve(member_config, interface, "paused");
+	const char *rt_uniqueid = ast_variable_retrieve(member_config, interface, "uniqueid");
+	const char *membername = S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface);
+	const char *state_interface = S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface);
+	const char *penalty_str = ast_variable_retrieve(member_config, interface, "penalty");
+	const char *paused_str = ast_variable_retrieve(member_config, interface, "paused");
 
 	if (ast_strlen_zero(rt_uniqueid)) {
 		ast_log(LOG_WARNING, "Realtime field uniqueid is empty for member %s\n", S_OR(membername, "NULL"));
@@ -2120,10 +2120,11 @@
 
 	if (penalty_str) {
 		penalty = atoi(penalty_str);
-		if ((penalty < 0) && negitive_penalty_invalid)
+		if ((penalty < 0) && negitive_penalty_invalid) {
 			return;
-		else if (penalty < 0)
+		} else if (penalty < 0) {
 			penalty = 0;
+		}
 	}
 
 	if (paused_str) {
@@ -2132,34 +2133,35 @@
 			paused = 0;
 	}
 
-	if ((config_val = ast_variable_retrieve(member_config, interface, "ignorebusy")))
-		ignorebusy=ast_true(config_val);
-	else
-		ignorebusy=1;
-
- 	/* Find member by realtime uniqueid and update */
- 	mem_iter = ao2_iterator_init(q->members, 0);
- 	while ((m = ao2_iterator_next(&mem_iter))) {
- 		if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) {
- 			m->dead = 0;	/* Do not delete this one. */
- 			ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
- 			if (paused_str)
- 				m->paused = paused;
- 			if (strcasecmp(state_interface, m->state_interface)) {
- 				ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface));
- 			}	   
- 			m->penalty = penalty;
+	if ((config_val = ast_variable_retrieve(member_config, interface, "ignorebusy"))) {
+		ignorebusy = ast_true(config_val);
+	} else {
+		ignorebusy = 1;
+	}
+
+	/* Find member by realtime uniqueid and update */
+	mem_iter = ao2_iterator_init(q->members, 0);
+	while ((m = ao2_iterator_next(&mem_iter))) {
+		if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) {
+			m->dead = 0;	/* Do not delete this one. */
+			ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
+			if (paused_str)
+				m->paused = paused;
+			if (strcasecmp(state_interface, m->state_interface)) {
+				ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface));
+			}
+			m->penalty = penalty;
 			m->ignorebusy = ignorebusy;
- 			found = 1;
- 			ao2_ref(m, -1);
- 			break;
- 		}
- 		ao2_ref(m, -1);
- 	}
+			found = 1;
+			ao2_ref(m, -1);
+			break;
+		}
+		ao2_ref(m, -1);
+	}
 	ao2_iterator_destroy(&mem_iter);
 
- 	/* Create a new member */
- 	if (!found) {
+	/* Create a new member */
+	if (!found) {
 		if ((m = create_queue_member(interface, membername, penalty, paused, state_interface))) {
 			m->dead = 0;
 			m->realtime = 1;
@@ -2915,8 +2917,9 @@
 			case AST_DEVICE_RINGING:
 			case AST_DEVICE_RINGINUSE:
 			case AST_DEVICE_ONHOLD:
-				if ((!q->ringinuse) || (!mem->ignorebusy))
+				if ((!q->ringinuse) || (!mem->ignorebusy)) {
 					break;
+				}
 				/* else fall through */
 			case AST_DEVICE_NOT_INUSE:
 			case AST_DEVICE_UNKNOWN:
@@ -3056,15 +3059,16 @@
 	/* on entry here, we know that tmp->chan == NULL */
 	if (tmp->member->paused) {
 		ast_debug(1, "%s paused, can't receive call\n", tmp->interface);
-		if (qe->chan->cdr)
+		if (qe->chan->cdr) {
 			ast_cdr_busy(qe->chan->cdr);
+		}
 		tmp->stillgoing = 0;
 		return 0;
 	}
 
 	if ((tmp->lastqueue && tmp->lastqueue->wrapuptime && (time(NULL) - tmp->lastcall < tmp->lastqueue->wrapuptime)) ||
 		(!tmp->lastqueue && qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime))) {
-		ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n", 
+		ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n",
 				(tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface);
 		if (qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
@@ -3077,7 +3081,7 @@
 		if ((tmp->member->status == AST_DEVICE_UNKNOWN) || (tmp->member->status == AST_DEVICE_NOT_INUSE)) {
 			newstate = ast_parse_device_state(tmp->member->interface);
 			if (newstate != tmp->member->status) {
-				ast_log(LOG_ERROR, "Found a channel matching iterface %s while status was %i changed to %i\n", 
+				ast_log(LOG_ERROR, "Found a channel matching iterface %s while status was %i changed to %i\n",
 					tmp->member->interface, tmp->member->status, newstate);
 				update_status(qe->parent, tmp->member, newstate);
 			}
@@ -3454,7 +3458,7 @@
 			ao2_lock(qe->parent);
 			if ((mem = interface_exists(qe->parent, interface))) {
 				time_t idletime = time(&idletime)-mem->lastcall;
- 				if ((mem->lastcall != 0) && (qe->parent->autopausedelay > idletime)) {
+				if ((mem->lastcall != 0) && (qe->parent->autopausedelay > idletime)) {
 					ao2_unlock(qe->parent);
 					return;
 				}
@@ -5436,10 +5440,10 @@
 			foundqueue++;
 			if ((mem = interface_exists(q, interface))) {
 				foundinterface++;
-				if (!mem->realtime)
+				if (!mem->realtime) {
 					mem->penalty = penalty;
-				else {
-					sprintf(rtpenalty,"%i",penalty);
+				} else {
+					sprintf(rtpenalty,"%i", penalty);
 					update_realtime_member_field(mem, q->name, "penalty", rtpenalty);
 				}
 				ast_queue_log(q->name, "NONE", interface, "PENALTY", "%d", penalty);
@@ -6228,7 +6232,7 @@
 	return 0;
 }
 
-/*! 
+/*!
  * \brief Get number either busy / free / ready or total members of a specific queue
  * \brief Get or set member properties penalty / paused / ignorebusy
  * \retval number of members (busy / free / ready / total) or member info (penalty / paused / ignorebusy)
@@ -6293,20 +6297,21 @@
 			ao2_iterator_destroy(&mem_iter);
 		} else if (!strcasecmp(args.option, "count") || ast_strlen_zero(args.option)) {
 			count = q->membercount;
-		} else if (!strcasecmp(args.option, "penalty") && !ast_strlen_zero(args.interface)) {
-			if ((m = interface_exists(q, args.interface)))
-				count = m->penalty;
-		} else if (!strcasecmp(args.option, "paused") && !ast_strlen_zero(args.interface)) {
-			if ((m = interface_exists(q, args.interface)))
-				count = m->paused;
-		} else if (!strcasecmp(args.option, "ignorebusy") && !ast_strlen_zero(args.interface)) {
-			if ((m = interface_exists(q, args.interface)))
-				count = m->ignorebusy;
+		} else if (!strcasecmp(args.option, "penalty") && !ast_strlen_zero(args.interface) &&
+			   ((m = interface_exists(q, args.interface)))) {
+			count = m->penalty;
+		} else if (!strcasecmp(args.option, "paused") && !ast_strlen_zero(args.interface) &&
+			   ((m = interface_exists(q, args.interface)))) {
+			count = m->paused;
+		} else if (!strcasecmp(args.option, "ignorebusy") && !ast_strlen_zero(args.interface) &&
+			   ((m = interface_exists(q, args.interface)))) {
+			count = m->ignorebusy;
 		}
 		ao2_unlock(q);
 		queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER()");
-	} else
+	} else {
 		ast_log(LOG_WARNING, "queue %s was not found\n", args.queuename);
+	}
 
 	snprintf(buf, len, "%d", count);
 
@@ -6347,7 +6352,7 @@
 	memvalue = atoi(value);
 
 	if (!strcasecmp(args.option, "penalty")) {
-		/* if queuename = NULL then penalty will be set for interface in all the queues. */
+		/* if queuename = NULL then penalty will be set for interface in all the queues.*/
 		if (set_member_penalty(args.queuename, args.interface, memvalue)) {
 			ast_log(LOG_ERROR, "Invalid interface, queue or penalty\n");
 			return -1;
@@ -6355,17 +6360,19 @@
 	} else if ((q = load_realtime_queue(args.queuename))) {
 		ao2_lock(q);
 		if ((m = interface_exists(q, args.interface))) {
-			sprintf(rtvalue, "%s",(memvalue <= 0)?"0":"1");
+			sprintf(rtvalue, "%s",(memvalue <= 0) ? "0" : "1");
 			if (!strcasecmp(args.option, "paused")) {
-				if (m->realtime)
+				if (m->realtime) {
 					update_realtime_member_field(m, q->name, args.option, rtvalue);
-				else
-					m->paused = (memvalue <= 0)?0:1;
+				} else {
+					m->paused = (memvalue <= 0) ? 0 : 1;
+				}
 			} else if (!strcasecmp(args.option, "ignorebusy")) {
-				if (m->realtime)
+				if (m->realtime) {
 					update_realtime_member_field(m, q->name, args.option, rtvalue);
-				else
-					m->ignorebusy = (memvalue <= 0)?0:1;
+				} else {
+					m->ignorebusy = (memvalue <= 0) ? 0 : 1;
+				}
 			} else {
 				ast_log(LOG_ERROR, "Invalid option, only penalty , paused or ignorebusy are valid\n");
 				return -1;
@@ -6382,10 +6389,10 @@
 	return 0;
 }
 
-/*! 
+/*!
  * \brief Get the total number of members in a specific queue (Deprecated)
- * \retval number of members 
- * \retval -1 on error 
+ * \retval number of members
+ * \retval -1 on error
 */
 static int queue_function_qac_dep(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
@@ -6674,8 +6681,9 @@
 {
 	const char *general_val = NULL;
 	queue_persistent_members = 0;
-	if ((general_val = ast_variable_retrieve(cfg, "general", "persistentmembers")))
+	if ((general_val = ast_variable_retrieve(cfg, "general", "persistentmembers"))) {
 		queue_persistent_members = ast_true(general_val);
+	}
 	autofill_default = 0;
 	if ((general_val = ast_variable_retrieve(cfg, "general", "autofill")))
 		autofill_default = ast_true(general_val);




More information about the asterisk-commits mailing list