<p>Rodrigo Ramirez Norambuena has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10785">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_queue: Enable set the wrapuptime from AddQueueMember application<br><br>This change add ability to set the wrapuptime per-member using the<br>AddQueueMember application.<br><br>The feature to set wrapuptime per member was include in the issue<br>ASTERISK-27483 for static member by configuration file and was not<br>added to set from AddQueueMember.<br><br>ASTERISK-28055 #close<br><br>Change-Id: I7c7ee4a6f804922cd7c42cb02eea26eb3806c6cf<br>---<br>M apps/app_queue.c<br>1 file changed, 56 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/85/10785/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_queue.c b/apps/app_queue.c</span><br><span>index 136dec5..e70e89e 100644</span><br><span>--- a/apps/app_queue.c</span><br><span>+++ b/apps/app_queue.c</span><br><span>@@ -325,6 +325,7 @@</span><br><span> <parameter name="options" /></span><br><span> <parameter name="membername" /></span><br><span> <parameter name="stateinterface" /></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="wrapuptime" /></span><br><span> </syntax></span><br><span> <description></span><br><span> <para>Dynamically adds interface to an existing queue. If the interface is</span><br><span>@@ -2274,7 +2275,7 @@</span><br><span> </span><br><span> static struct ast_json *queue_member_blob_create(struct call_queue *q, struct member *mem)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: i, s: i, s: i, s: i, s: i, s: i, s: i, s: s, s: i}",</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: i, s: i, s: i, s: i, s: i, s: i, s: i, s: s, s: i, s: i}",</span><br><span> "Queue", q->name,</span><br><span> "MemberName", mem->membername,</span><br><span> "Interface", mem->interface,</span><br><span>@@ -2288,7 +2289,8 @@</span><br><span> "Status", mem->status,</span><br><span> "Paused", mem->paused,</span><br><span> "PausedReason", mem->reason_paused,</span><br><span style="color: hsl(0, 100%, 40%);">- "Ringinuse", mem->ringinuse);</span><br><span style="color: hsl(120, 100%, 40%);">+ "Ringinuse", mem->ringinuse,</span><br><span style="color: hsl(120, 100%, 40%);">+ "Wrapuptime", mem->wrapuptime);</span><br><span> }</span><br><span> </span><br><span> /*! \brief Check if members are available</span><br><span>@@ -2693,7 +2695,7 @@</span><br><span> }</span><br><span> </span><br><span> /*! \brief allocate space for new queue member and set fields based on parameters passed */</span><br><span style="color: hsl(0, 100%, 40%);">-static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface, int ringinuse)</span><br><span style="color: hsl(120, 100%, 40%);">+static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface, int ringinuse, int wrapuptime)</span><br><span> {</span><br><span> struct member *cur;</span><br><span> </span><br><span>@@ -2701,6 +2703,7 @@</span><br><span> cur->ringinuse = ringinuse;</span><br><span> cur->penalty = penalty;</span><br><span> cur->paused = paused;</span><br><span style="color: hsl(120, 100%, 40%);">+ cur->wrapuptime = wrapuptime;</span><br><span> if (paused) {</span><br><span> time(&cur->lastpause); /* Update time of last pause */</span><br><span> }</span><br><span>@@ -3481,7 +3484,7 @@</span><br><span> </span><br><span> /* Create a new member */</span><br><span> if (!found) {</span><br><span style="color: hsl(0, 100%, 40%);">- if ((m = create_queue_member(interface, membername, penalty, paused, state_interface, ringinuse))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((m = create_queue_member(interface, membername, penalty, paused, state_interface, ringinuse, wrapuptime))) {</span><br><span> m->dead = 0;</span><br><span> m->realtime = 1;</span><br><span> ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));</span><br><span>@@ -7280,14 +7283,15 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&value, 0, "%s%s;%d;%d;%s;%s;%s",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&value, 0, "%s%s;%d;%d;%s;%s;%s;%d",</span><br><span> ast_str_strlen(value) ? "|" : "",</span><br><span> cur_member->interface,</span><br><span> cur_member->penalty,</span><br><span> cur_member->paused,</span><br><span> cur_member->membername,</span><br><span> cur_member->state_interface,</span><br><span style="color: hsl(0, 100%, 40%);">- cur_member->reason_paused);</span><br><span style="color: hsl(120, 100%, 40%);">+ cur_member->reason_paused,</span><br><span style="color: hsl(120, 100%, 40%);">+ cur_member->wrapuptime);</span><br><span> </span><br><span> ao2_ref(cur_member, -1);</span><br><span> }</span><br><span>@@ -7364,7 +7368,7 @@</span><br><span> * \retval RES_EXISTS queue exists but no members</span><br><span> * \retval RES_OUT_OF_MEMORY queue exists but not enough memory to create member</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static int add_to_queue(const char *queuename, const char *interface, const char *membername, int penalty, int paused, int dump, const char *state_interface, const char *reason_paused)</span><br><span style="color: hsl(120, 100%, 40%);">+static int add_to_queue(const char *queuename, const char *interface, const char *membername, int penalty, int paused, int dump, const char *state_interface, const char *reason_paused, int wrapuptime)</span><br><span> {</span><br><span> struct call_queue *q;</span><br><span> struct member *new_member, *old_member;</span><br><span>@@ -7378,7 +7382,7 @@</span><br><span> </span><br><span> ao2_lock(q);</span><br><span> if ((old_member = interface_exists(q, interface)) == NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">- if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface, q->ringinuse))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface, q->ringinuse, wrapuptime))) {</span><br><span> new_member->dynamic = 1;</span><br><span> if (reason_paused) {</span><br><span> ast_copy_string(new_member->reason_paused, reason_paused, sizeof(new_member->reason_paused));</span><br><span>@@ -7770,6 +7774,8 @@</span><br><span> int penalty = 0;</span><br><span> char *paused_tok;</span><br><span> int paused = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *wrapuptime_tok;</span><br><span style="color: hsl(120, 100%, 40%);">+ int wrapuptime = 0;</span><br><span> char *reason_paused;</span><br><span> struct ast_db_entry *db_tree;</span><br><span> struct ast_db_entry *entry;</span><br><span>@@ -7818,6 +7824,7 @@</span><br><span> membername = strsep(&member, ";");</span><br><span> state_interface = strsep(&member, ";");</span><br><span> reason_paused = strsep(&member, ";");</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime_tok = strsep(&member, ";");</span><br><span> </span><br><span> if (!penalty_tok) {</span><br><span> ast_log(LOG_WARNING, "Error parsing persistent member string for '%s' (penalty)\n", queue_name);</span><br><span>@@ -7839,10 +7846,18 @@</span><br><span> break;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d ReasonPause: %s\n",</span><br><span style="color: hsl(0, 100%, 40%);">- queue_name, interface, membername, penalty, paused, reason_paused);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(wrapuptime_tok)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = strtol(wrapuptime_tok, NULL, 10);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (errno == ERANGE) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Error converting wrapuptime: %s: Out of range.\n", wrapuptime_tok);</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (add_to_queue(queue_name, interface, membername, penalty, paused, 0, state_interface, reason_paused) == RES_OUTOFMEMORY) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d ReasonPause: %s Wrapuptime: %d\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ queue_name, interface, membername, penalty, paused, reason_paused, wrapuptime);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (add_to_queue(queue_name, interface, membername, penalty, paused, 0, state_interface, reason_paused, wrapuptime) == RES_OUTOFMEMORY) {</span><br><span> ast_log(LOG_ERROR, "Out of Memory when reloading persistent queue member\n");</span><br><span> break;</span><br><span> }</span><br><span>@@ -8004,7 +8019,7 @@</span><br><span> static int aqm_exec(struct ast_channel *chan, const char *data)</span><br><span> {</span><br><span> int res=-1;</span><br><span style="color: hsl(0, 100%, 40%);">- char *parse, *temppos = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *parse, *tmp, *temppos = NULL;</span><br><span> AST_DECLARE_APP_ARGS(args,</span><br><span> AST_APP_ARG(queuename);</span><br><span> AST_APP_ARG(interface);</span><br><span>@@ -8012,11 +8027,13 @@</span><br><span> AST_APP_ARG(options);</span><br><span> AST_APP_ARG(membername);</span><br><span> AST_APP_ARG(state_interface);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_ARG(wrapuptime);</span><br><span> );</span><br><span> int penalty = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ int wrapuptime;</span><br><span> </span><br><span> if (ast_strlen_zero(data)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[,interface[,penalty[,options[,membername[,stateinterface]]]]])\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[,interface[,penalty[,options[,membername[,stateinterface][,wrapuptime]]]]])\n");</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span>@@ -8039,7 +8056,18 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface, NULL)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(args.wrapuptime)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ tmp = args.wrapuptime;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_strip(tmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = atoi(tmp);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (wrapuptime < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface, NULL, wrapuptime)) {</span><br><span> case RES_OKAY:</span><br><span> if (ast_strlen_zero(args.membername) || !log_membername_as_agent) {</span><br><span> ast_queue_log(args.queuename, ast_channel_uniqueid(chan), args.interface, "ADDMEMBER", "%s", "");</span><br><span>@@ -9284,7 +9312,7 @@</span><br><span> ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface));</span><br><span> cur = ao2_find(q->members, &tmpmem, OBJ_POINTER);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if ((newm = create_queue_member(interface, membername, penalty, cur ? cur->paused : 0, state_interface, ringinuse))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((newm = create_queue_member(interface, membername, penalty, cur ? cur->paused : 0, state_interface, ringinuse, wrapuptime))) {</span><br><span> newm->wrapuptime = wrapuptime;</span><br><span> if (cur) {</span><br><span> /* Round Robin Queue Position must be copied if this is replacing an existing member */</span><br><span>@@ -10097,11 +10125,12 @@</span><br><span> "Status: %d\r\n"</span><br><span> "Paused: %d\r\n"</span><br><span> "PausedReason: %s\r\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "Wrapuptime: %d\r\n"</span><br><span> "%s"</span><br><span> "\r\n",</span><br><span> q->name, mem->membername, mem->interface, mem->state_interface, mem->dynamic ? "dynamic" : "static",</span><br><span> mem->penalty, mem->calls, (int)mem->lastcall, (int)mem->lastpause, mem->starttime ? 1 : 0, mem->status,</span><br><span style="color: hsl(0, 100%, 40%);">- mem->paused, mem->reason_paused, idText);</span><br><span style="color: hsl(120, 100%, 40%);">+ mem->paused, mem->reason_paused, mem->wrapuptime, idText);</span><br><span> ++q_items;</span><br><span> }</span><br><span> ao2_ref(mem, -1);</span><br><span>@@ -10146,8 +10175,8 @@</span><br><span> </span><br><span> static int manager_add_queue_member(struct mansession *s, const struct message *m)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *queuename, *interface, *penalty_s, *paused_s, *membername, *state_interface;</span><br><span style="color: hsl(0, 100%, 40%);">- int paused, penalty = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *queuename, *interface, *penalty_s, *paused_s, *membername, *state_interface, *wrapuptime_s;</span><br><span style="color: hsl(120, 100%, 40%);">+ int paused, penalty, wrapuptime = 0;</span><br><span> </span><br><span> queuename = astman_get_header(m, "Queue");</span><br><span> interface = astman_get_header(m, "Interface");</span><br><span>@@ -10155,6 +10184,7 @@</span><br><span> paused_s = astman_get_header(m, "Paused");</span><br><span> membername = astman_get_header(m, "MemberName");</span><br><span> state_interface = astman_get_header(m, "StateInterface");</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime_s = astman_get_header(m, "Wrapuptime");</span><br><span> </span><br><span> if (ast_strlen_zero(queuename)) {</span><br><span> astman_send_error(s, m, "'Queue' not specified.");</span><br><span>@@ -10172,13 +10202,19 @@</span><br><span> penalty = 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(wrapuptime_s)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (sscanf(wrapuptime_s, "%30d", &wrapuptime) != 1 || wrapuptime < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ wrapuptime = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_strlen_zero(paused_s)) {</span><br><span> paused = 0;</span><br><span> } else {</span><br><span> paused = abs(ast_true(paused_s));</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface, NULL)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface, NULL, wrapuptime)) {</span><br><span> case RES_OKAY:</span><br><span> if (ast_strlen_zero(membername) || !log_membername_as_agent) {</span><br><span> ast_queue_log(queuename, "MANAGER", interface, "ADDMEMBER", "%s", paused ? "PAUSED" : "");</span><br><span>@@ -10528,7 +10564,7 @@</span><br><span> state_interface = a->argv[11];</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface, NULL)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface, NULL, 0)) {</span><br><span> case RES_OKAY:</span><br><span> if (ast_strlen_zero(membername) || !log_membername_as_agent) {</span><br><span> ast_queue_log(queuename, "CLI", interface, "ADDMEMBER", "%s", "");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10785">change 10785</a>. To unsubscribe, or for help writing mail filters, 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/10785"/><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: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I7c7ee4a6f804922cd7c42cb02eea26eb3806c6cf </div>
<div style="display:none"> Gerrit-Change-Number: 10785 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Rodrigo Ramirez Norambuena <a@rodrigoramirez.com> </div>