[asterisk-commits] mmichelson: branch mmichelson/queue-penalty r94318 - /team/mmichelson/queue-p...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 20 15:41:08 CST 2007
Author: mmichelson
Date: Thu Dec 20 15:41:07 2007
New Revision: 94318
URL: http://svn.digium.com/view/asterisk?view=rev&rev=94318
Log:
Added a manager command to be able to list queue rules. Also changed function names used for CLI
for consistency's sake.
At this point, I consider the coding for this to be done, but I will inspect to see if I can optimize.
I will also give everything a test, trying edge cases.
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=94318&r1=94317&r2=94318
==============================================================================
--- team/mmichelson/queue-penalty/apps/app_queue.c (original)
+++ team/mmichelson/queue-penalty/apps/app_queue.c Thu Dec 20 15:41:07 2007
@@ -5123,6 +5123,30 @@
return RESULT_SUCCESS;
}
+static int manager_queue_rule_show(struct mansession *s, const struct message *m)
+{
+ const char *rule = astman_get_header(m, "Rule");
+ struct rule_list *rl_iter;
+ struct penalty_rule *pr_iter;
+
+ AST_LIST_LOCK(&rule_lists);
+ AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) {
+ if(ast_strlen_zero(rule) || !strcasecmp(rule, rl_iter->name)) {
+ astman_append(s, "RuleList: %s\r\n", rl_iter->name);
+ AST_LIST_TRAVERSE(&rl_iter->rules, pr_iter, list) {
+ astman_append(s, "Rule: %d,%s%d,%s%d\r\n", pr_iter->time, pr_iter->max_relative && pr_iter->max_value >= 0 ? "+" : "", pr_iter->max_value, pr_iter->min_relative && pr_iter->min_value >= 0 ? "+" : "", pr_iter->min_value );
+ }
+ if(!ast_strlen_zero(rule))
+ break;
+ }
+ }
+ AST_LIST_UNLOCK(&rule_lists);
+
+ astman_append(s, "\r\n\r\n");
+
+ return RESULT_SUCCESS;
+}
+
/* Dump summary of queue info */
static int manager_queues_summary(struct mansession *s, const struct message *m)
{
@@ -5756,7 +5780,7 @@
}
}
-static char *complete_queue_show_rule(const char *line, const char *word, int pos, int state)
+static char *complete_queue_rule_show(const char *line, const char *word, int pos, int state)
{
int which = 0;
struct rule_list *rl_iter;
@@ -5779,7 +5803,7 @@
return ret;
}
-static char *handle_queue_show_rules(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_queue_rule_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
char *rule;
struct rule_list *rl_iter;
@@ -5793,7 +5817,7 @@
"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);
+ return complete_queue_rule_show(a->line, a->word, a->pos, a->n);
}
if (a->argc != 3 && a->argc != 4)
@@ -5828,7 +5852,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"),
+ AST_CLI_DEFINE(handle_queue_rule_show, "Show the rules defined in queuerules.conf"),
};
static int unload_module(void)
@@ -5922,6 +5946,7 @@
res |= ast_manager_register("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member, "Makes a queue member temporarily unavailable");
res |= ast_manager_register("QueueLog", EVENT_FLAG_AGENT, manager_queue_log_custom, "Adds custom entry in queue_log");
res |= ast_manager_register("QueuePenalty", EVENT_FLAG_AGENT, manager_queue_member_penalty, "Set the penalty for a queue member");
+ res |= ast_manager_register("QueueRule", 0, manager_queue_rule_show, "Queue Rules");
res |= ast_custom_function_register(&queuevar_function);
res |= ast_custom_function_register(&queuemembercount_function);
res |= ast_custom_function_register(&queuemembercount_dep);
More information about the asterisk-commits
mailing list