<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/5881">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_queue: Add change priority of call<br><br>This patch include a feature to change the priority a caller in a<br>queue by CLI and AMI.<br><br>Change-Id: I55d520d71cc1cefe9a9b81fefaefc14679e96133<br>---<br>M apps/app_queue.c<br>1 file changed, 152 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/apps/app_queue.c b/apps/app_queue.c<br>index ae2d645..25aff4d 100644<br>--- a/apps/app_queue.c<br>+++ b/apps/app_queue.c<br>@@ -1009,6 +1009,26 @@<br> <para>Reset the statistics for a queue.</para><br> </description><br> </manager><br>+ <manager name="QueueChangePriorityCaller" language="en_US"><br>+ <synopsis><br>+ Change priority of a caller on queue.<br>+ </synopsis><br>+ <syntax><br>+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /><br>+ <parameter name="Queue" required="true"><br>+ <para>The name of the queue to take action on.</para><br>+ </parameter><br>+ <parameter name="Caller" required="true"><br>+ <para>The caller (channel) to change priority on queue.</para><br>+ </parameter><br>+<br>+ <parameter name="Priority" required="true"><br>+ <para>Priority value for change for caller on queue.</para><br>+ </parameter><br>+ </syntax><br>+ <description><br>+ </description><br>+ </manager><br> <br> <managerEvent language="en_US" name="QueueMemberStatus"><br> <managerEventInstance class="EVENT_FLAG_AGENT"><br>@@ -1408,6 +1428,7 @@<br> #define RES_OUTOFMEMORY (-2) /*!< Out of memory */<br> #define RES_NOSUCHQUEUE (-3) /*!< No such queue */<br> #define RES_NOT_DYNAMIC (-4) /*!< Member is not dynamic */<br>+#define RES_NOT_CALLER (-5) /*!< Caller not found */<br> <br> static char *app = "Queue";<br> <br>@@ -7232,6 +7253,39 @@<br> return res;<br> }<br> <br>+<br>+/*! \brief Change priority caller into a queue<br>+ * \retval RES_NOSUCHQUEUE queue does not exist<br>+ * \retval RES_OKAY change priority<br>+ * \retval RES_NOT_CALLER queue exists but no caller<br>+*/<br>+static int change_priority_caller_on_queue(const char *queuename, const char *caller, int priority)<br>+{<br>+ struct call_queue *q;<br>+ struct queue_ent *qe;<br>+ int res = RES_NOSUCHQUEUE;<br>+<br>+ /*! \note Ensure the appropriate realtime queue is loaded. Note that this<br>+ * short-circuits if the queue is already in memory. */<br>+ if (!(q = find_load_queue_rt_friendly(queuename))) {<br>+ return res;<br>+ }<br>+<br>+ ao2_lock(q);<br>+ res = RES_NOT_CALLER;<br>+ for (qe = q->head; qe; qe = qe->next) {<br>+ if (strcmp(ast_channel_name(qe->chan), caller) == 0) {<br>+ ast_debug(1, "%s Caller new prioriry %d in queue %s\n",<br>+ caller, priority, queuename);<br>+ qe->prio = priority;<br>+ res = RES_OKAY;<br>+ }<br>+ }<br>+ ao2_unlock(q);<br>+ return res;<br>+}<br>+<br>+<br> static int publish_queue_member_pause(struct call_queue *q, struct member *member, const char *reason)<br> {<br> struct ast_json *json_blob = queue_member_blob_create(q, member);<br>@@ -10189,6 +10243,50 @@<br> return 0;<br> }<br> <br>+static int manager_change_priority_caller_on_queue(struct mansession *s, const struct message *m)<br>+{<br>+ const char *queuename, *caller, *priority_s;<br>+ int priority = 0;<br>+<br>+ queuename = astman_get_header(m, "Queue");<br>+ caller = astman_get_header(m, "Caller");<br>+ priority_s = astman_get_header(m, "Priority");<br>+<br>+ if (ast_strlen_zero(queuename)) {<br>+ astman_send_error(s, m, "'Queue' not specified.");<br>+ return 0;<br>+ }<br>+<br>+ if (ast_strlen_zero(caller)) {<br>+ astman_send_error(s, m, "'Caller' not specified.");<br>+ return 0;<br>+ }<br>+<br>+ if (ast_strlen_zero(priority_s)) {<br>+ astman_send_error(s, m, "'Priority' not specified.");<br>+ return 0;<br>+ } else if (sscanf(priority_s, "%30d", &priority) != 1) {<br>+ astman_send_error(s, m, "'Priority' need integer.");<br>+ return 0;<br>+ }<br>+<br>+ switch (change_priority_caller_on_queue(queuename, caller, priority)) {<br>+ case RES_OKAY:<br>+ astman_send_ack(s, m, "Priority change for caller on queue");<br>+ break;<br>+ case RES_NOSUCHQUEUE:<br>+ astman_send_error(s, m, "Unable to change priority caller on queue: No such queue");<br>+ break;<br>+ case RES_NOT_CALLER:<br>+ astman_send_error(s, m, "Unable to change priority caller on queue: No such caller");<br>+ break;<br>+ }<br>+<br>+ return 0;<br>+}<br>+<br>+<br>+<br> static char *handle_queue_add_member(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br> {<br> const char *queuename, *interface, *membername = NULL, *state_interface = NULL;<br>@@ -10375,6 +10473,57 @@<br> <br> return res;<br> }<br>+<br>+<br>+<br>+static char *handle_queue_change_priority_caller(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)<br>+{<br>+ const char *queuename, *caller;<br>+ int priority;<br>+ char *res = CLI_FAILURE;<br>+<br>+ switch (cmd) {<br>+ case CLI_INIT:<br>+ e->command = "queue priority caller";<br>+ e->usage =<br>+ "Usage: queue priority caller <channel> on <queue> to <priority>\n"<br>+ " Change the priority of a channel on a queue.\n";<br>+ return NULL;<br>+ case CLI_GENERATE:<br>+ return NULL;<br>+ }<br>+<br>+ if (a->argc != 8) {<br>+ return CLI_SHOWUSAGE;<br>+ } else if (strcmp(a->argv[4], "on")) {<br>+ return CLI_SHOWUSAGE;<br>+ } else if (strcmp(a->argv[6], "to")) {<br>+ return CLI_SHOWUSAGE;<br>+ } else if (sscanf(a->argv[7], "%30d", &priority) != 1) {<br>+ ast_log (LOG_ERROR, "<priority> parameter must be an integer.\n");<br>+ return CLI_SHOWUSAGE;<br>+ }<br>+<br>+ caller = a->argv[3];<br>+ queuename = a->argv[5];<br>+<br>+ switch (change_priority_caller_on_queue(queuename, caller, priority)) {<br>+ case RES_OKAY:<br>+ res = CLI_SUCCESS;<br>+ break;<br>+ case RES_NOSUCHQUEUE:<br>+ ast_cli(a->fd, "Unable change priority caller %s on queue '%s': No such queue\n", caller, queuename);<br>+ break;<br>+ case RES_NOT_CALLER:<br>+ ast_cli(a->fd, "Unable to change priority caller '%s' on queue '%s': Not there\n", caller, queuename);<br>+<br>+ break;<br>+ }<br>+<br>+ return res;<br>+}<br>+<br>+<br> <br> static char *complete_queue_pause_member(const char *line, const char *word, int pos, int state)<br> {<br>@@ -10821,6 +10970,7 @@<br> AST_CLI_DEFINE(handle_queue_set_member_ringinuse, "Set ringinuse for a channel of a specified queue"),<br> AST_CLI_DEFINE(handle_queue_reload, "Reload queues, members, queue rules, or parameters"),<br> AST_CLI_DEFINE(handle_queue_reset, "Reset statistics for a queue"),<br>+ AST_CLI_DEFINE(handle_queue_change_priority_caller, "Change priority caller on queue"),<br> };<br> <br> /* struct call_queue astdata mapping. */<br>@@ -11132,6 +11282,7 @@<br> ast_manager_unregister("QueueReload");<br> ast_manager_unregister("QueueReset");<br> ast_manager_unregister("QueueMemberRingInUse");<br>+ ast_manager_unregister("QueueChangePriorityCaller");<br> ast_unregister_application(app_aqm);<br> ast_unregister_application(app_rqm);<br> ast_unregister_application(app_pqm);<br>@@ -11250,6 +11401,7 @@<br> err |= ast_manager_register_xml("QueueRule", 0, manager_queue_rule_show);<br> err |= ast_manager_register_xml("QueueReload", 0, manager_queue_reload);<br> err |= ast_manager_register_xml("QueueReset", 0, manager_queue_reset);<br>+ err |= ast_manager_register_xml("QueueChangePriorityCaller", 0, manager_change_priority_caller_on_queue);<br> err |= ast_custom_function_register(&queuevar_function);<br> err |= ast_custom_function_register(&queueexists_function);<br> err |= ast_custom_function_register(&queuemembercount_function);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5881">change 5881</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/5881"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I55d520d71cc1cefe9a9b81fefaefc14679e96133 </div>
<div style="display:none"> Gerrit-Change-Number: 5881 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Rodrigo Ramirez Norambuena <a@rodrigoramirez.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Rodrigo Ramirez Norambuena <a@rodrigoramirez.com> </div>