[asterisk-commits] mmichelson: branch mmichelson/queue-penalty r94247 - /team/mmichelson/queue-p...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 20 13:09:54 CST 2007


Author: mmichelson
Date: Thu Dec 20 13:09:53 2007
New Revision: 94247

URL: http://svn.digium.com/view/asterisk?view=rev&rev=94247
Log:
Adding a CLI command to show rules defined in queuerules.conf


Modified:
    team/mmichelson/queue-penalty/apps/app_queue.c

Modified: team/mmichelson/queue-penalty/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-penalty/apps/app_queue.c?view=diff&rev=94247&r1=94246&r2=94247
==============================================================================
--- team/mmichelson/queue-penalty/apps/app_queue.c (original)
+++ team/mmichelson/queue-penalty/apps/app_queue.c Thu Dec 20 13:09:53 2007
@@ -170,8 +170,8 @@
 "calling party's channel once they are connected to a queue member.\n"
 "  The optional gosub parameter will run a gosub on the \n"
 "calling party's channel once they are connected to a queue member.\n"
-"  The optional rule parameter will cause the queue's defaultrule to be.\n"
-"overridden by the rule specified
+"  The optional rule parameter will cause the queue's defaultrule to be\n"
+"overridden by the rule specified.\n"
 "  The timeout will cause the queue to fail out after a specified number of\n"
 "seconds, checked between each queues.conf 'timeout' and 'retry' cycle.\n"
 "  This application sets the following channel variable upon completion:\n"
@@ -5756,6 +5756,63 @@
 	}
 }
 
+static char *complete_queue_show_rule(const char *line, const char *word, int pos, int state) 
+{
+	int which = 0;
+	struct rule_list *rl_iter;
+	int wordlen = strlen(word);
+	char *ret = NULL;
+	if (pos != 3) /* Wha? */ {
+		ast_log(LOG_DEBUG, "Hitting this???, pos is %d\n", pos);
+		return NULL;
+	}
+
+	AST_LIST_LOCK(&rule_lists);
+	AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) {
+		if (!strncasecmp(word, rl_iter->name, wordlen) && ++which > state) {
+			ret = ast_strdup(rl_iter->name);
+			break;
+		}
+	}
+	AST_LIST_UNLOCK(&rule_lists);
+
+	return ret;
+}
+
+static char *handle_queue_show_rules(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	char *rule;
+	struct rule_list *rl_iter;
+	struct penalty_rule *pr_iter;
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "queue rule show";
+		e->usage =
+		"Usage: queue rule show [rulename]\n"
+		"Show the list of rules associated with rulename. If no\n"
+		"rulename is specified, list all rules defined in queuerules.conf\n";
+		return NULL;
+	case CLI_GENERATE:
+		return complete_queue_show_rule(a->line, a->word, a->pos, a->n);
+	}
+
+	if (a->argc != 3 && a->argc != 4)
+		return CLI_SHOWUSAGE;
+
+	rule = a->argc == 4 ? a->argv[3] : "";
+	AST_LIST_LOCK(&rule_lists);
+	AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) {
+		if (ast_strlen_zero(rule) || !strcasecmp(rl_iter->name, rule)) {
+			ast_cli(a->fd, "Rule: %s\n", rl_iter->name);
+			AST_LIST_TRAVERSE(&rl_iter->rules, pr_iter, list) {
+				ast_cli(a->fd, "\tAfter %d seconds, adjust QUEUE_MAX_PENALTY %s %d and adjust QUEUE_MIN_PENALTY %s %d\n", pr_iter->time, pr_iter->max_relative ? "by" : "to", pr_iter->max_value, pr_iter->min_relative ? "by" : "to", pr_iter->min_value);
+			}
+		}
+	}
+	AST_LIST_UNLOCK(&rule_lists);
+	return CLI_SUCCESS; 
+}
+
 static const char qpm_cmd_usage[] = 
 "Usage: queue pause member <channel> in <queue> reason <reason>\n";
 
@@ -5771,6 +5828,7 @@
 	AST_CLI_DEFINE(handle_queue_remove_member, "Removes a channel from a specified queue"),
 	AST_CLI_DEFINE(handle_queue_pause_member, "Pause or unpause a queue member"),
 	AST_CLI_DEFINE(handle_queue_set_member_penalty, "Set penalty for a channel of a specified queue"),
+	AST_CLI_DEFINE(handle_queue_show_rules, "Show the rules defined in queuerules.conf"),
 };
 
 static int unload_module(void)




More information about the asterisk-commits mailing list