[asterisk-commits] eliel: branch eliel/per_member_wrapuptime r188447 - /team/eliel/per_member_wr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 14 14:20:05 CDT 2009


Author: eliel
Date: Tue Apr 14 14:19:58 2009
New Revision: 188447

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=188447
Log:
Make possible to set the wrapuptime as an offset but also as an absolute value.

This will make easy to set wrapuptime = wrapuptime + 60 without needing to remember
the actual wrapuptime value.

Modified:
    team/eliel/per_member_wrapuptime/apps/app_queue.c

Modified: team/eliel/per_member_wrapuptime/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/per_member_wrapuptime/apps/app_queue.c?view=diff&rev=188447&r1=188446&r2=188447
==============================================================================
--- team/eliel/per_member_wrapuptime/apps/app_queue.c (original)
+++ team/eliel/per_member_wrapuptime/apps/app_queue.c Tue Apr 14 14:19:58 2009
@@ -4376,10 +4376,11 @@
  * \param interface The members interface.
  * \param offset The wrapuptime offset in seconds.
  * \param modify_defaults Modify the static values.
+ * \param absolute_value The passed offset is an absolute value.
  * \retval < 0 on error.
  * \retval 0 on success.
  */
-static int set_member_wrapuptime(const char *queuename, const char *interface, int offset, int modify_defaults)
+static int set_member_wrapuptime(const char *queuename, const char *interface, int offset, int modify_defaults, int absolute_value)
 {
 	int foundinterface = 0;
 	struct call_queue *q;
@@ -4394,7 +4395,11 @@
 				foundinterface++;
 				/* modify static configuration. */
 				if (modify_defaults) {
-					mem->wrapuptime += offset;
+					if (absolute_value) {
+						mem->wrapuptime = offset;
+					} else {
+						mem->wrapuptime += offset;
+					}
 					if (mem->wrapuptime < 0) {
 						mem->wrapuptime = -1;
 					}
@@ -4407,7 +4412,11 @@
 							q->name, mem->interface, mem->wrapuptime);
 				}
 				/* this wrapuptime will be used only for the next call to this agent. */
-				mem->current_wrapuptime += offset;
+				if (absolute_value) {
+					mem->current_wrapuptime = offset;
+				} else {
+					mem->current_wrapuptime += offset;
+				}
 			}
 		}
 		ao2_unlock(q);
@@ -6777,16 +6786,23 @@
  */
 static int manager_queue_member_wrapuptime(struct mansession *s, const struct message *m)
 {
-	const char *interface, *offset, *static_value, *queue;
-	int default_wrapuptime = 0;
+	const char *interface, *offset, *static_value, *queue, *absolute;
+	int default_wrapuptime = 0, is_absolute = 0, value;
 
 	interface = astman_get_header(m, "Interface");
 	queue = astman_get_header(m, "Queue");
 	offset = astman_get_header(m, "Offset");
+	absolute = astman_get_header(m, "Absolute");
 	static_value = astman_get_header(m, "Static");
 
-	if (ast_strlen_zero(interface) || ast_strlen_zero(offset)) {
-		astman_send_error(s, m, "Need 'Interface' and 'Offset' parameters.");
+	if (ast_strlen_zero(interface) || (ast_strlen_zero(offset) && ast_strlen_zero(absolute))) {
+		astman_send_error(s, m, "Need 'Interface' and ('Offset' or 'Absolute') parameters.");
+		return -1;
+	}
+
+	if (ast_strlen_zero(absolute) && ast_strlen_zero(offset)) {
+		astman_send_error(s, m, "Only specify 'Offset' or 'Absolute'.");
+		return -1;
 	}
 
 	if (ast_strlen_zero(static_value)) {
@@ -6794,7 +6810,14 @@
 		default_wrapuptime = ast_true(static_value);
 	}
 
-	set_member_wrapuptime(queue, interface, atoi(offset), default_wrapuptime);
+	if (ast_strlen_zero(absolute)) {
+		is_absolute = 1;
+		value = atoi(absolute);
+	} else {
+		value = atoi(offset);
+	}
+
+	set_member_wrapuptime(queue, interface, value, default_wrapuptime, is_absolute);
 
 	return 0;
 }
@@ -7178,7 +7201,7 @@
 		member_default = 1;
 	}
 
-	if (set_member_wrapuptime(queuename, interface, wrapuptime, !member_default)) {
+	if (set_member_wrapuptime(queuename, interface, wrapuptime, !member_default, 1)) {
 		ast_cli(a->fd, "Failed to set wrapuptime on interface '%s'", interface);
 		ret = CLI_FAILURE;
 	} else {




More information about the asterisk-commits mailing list