<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13557">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_page.c: Simplify dialplan using Page.<br><br>Dialplan has to be careful about passing an empty destination list or<br>empty positions in the list.  As a result, dialplan has to check for<br>these conditions before using Page.  Simplify dialplan by making Page<br>handle these conditions gracefully.<br><br>* Made tolerate empty positions in the paged device list.<br><br>* Reduced some warnings associated with the 's' option to verbose<br>messages.  The warning level for those messages really serves no purpose<br>as that is why the 's' option exists.<br><br>ASTERISK-28638<br><br>Change-Id: I95b64a6d6800cd1a25279c88889314ae60fc21e3<br>---<br>M apps/app_page.c<br>A doc/CHANGES-staging/app_page_empty_page_list.txt<br>2 files changed, 23 insertions(+), 14 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_page.c b/apps/app_page.c</span><br><span>index 302b2b3..3f5b0b8 100644</span><br><span>--- a/apps/app_page.c</span><br><span>+++ b/apps/app_page.c</span><br><span>@@ -50,7 +50,7 @@</span><br><span>                      Page series of phones</span><br><span>                </synopsis></span><br><span>            <syntax></span><br><span style="color: hsl(0, 100%, 40%);">-                  <parameter name="Technology/Resource" required="true" argsep="&amp;"></span><br><span style="color: hsl(120, 100%, 40%);">+                 <parameter name="Technology/Resource" required="false" argsep="&amp;"></span><br><span>                               <argument name="Technology/Resource" required="true"></span><br><span>                                      <para>Specification of the device(s) to dial. These must be in the format of</span><br><span>                                   <literal>Technology/Resource</literal>, where <replaceable>Technology</replaceable></span><br><span>@@ -272,17 +272,12 @@</span><br><span>          AST_APP_ARG(timeout);</span><br><span>        );</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  if (ast_strlen_zero(data)) {</span><br><span style="color: hsl(0, 100%, 40%);">-            ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n");</span><br><span style="color: hsl(0, 100%, 40%);">-           return -1;</span><br><span style="color: hsl(0, 100%, 40%);">-      }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>    if (!(app = pbx_findapp("ConfBridge"))) {</span><br><span>          ast_log(LOG_WARNING, "There is no ConfBridge application available!\n");</span><br><span>           return -1;</span><br><span>   };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  parse = ast_strdupa(data);</span><br><span style="color: hsl(120, 100%, 40%);">+    parse = ast_strdupa(data ?: "");</span><br><span> </span><br><span>       AST_STANDARD_APP_ARGS(args, parse);</span><br><span> </span><br><span>@@ -303,7 +298,7 @@</span><br><span> </span><br><span>    /* Count number of extensions in list by number of ampersands + 1 */</span><br><span>         num_dials = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-  tmp = args.devices;</span><br><span style="color: hsl(120, 100%, 40%);">+   tmp = args.devices ?: "";</span><br><span>  while (*tmp) {</span><br><span>               if (*tmp == '&') {</span><br><span>                       num_dials++;</span><br><span>@@ -336,13 +331,20 @@</span><br><span>                 int state = 0;</span><br><span>               struct ast_dial *dial = NULL;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-               /* don't call the originating device */</span><br><span style="color: hsl(0, 100%, 40%);">-             if (!strcasecmp(tech, originator))</span><br><span style="color: hsl(120, 100%, 40%);">+            tech = ast_strip(tech);</span><br><span style="color: hsl(120, 100%, 40%);">+               if (ast_strlen_zero(tech)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  /* No tech/resource in this position. */</span><br><span>                     continue;</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%);">+           /* don't call the originating device */</span><br><span style="color: hsl(120, 100%, 40%);">+           if (!strcasecmp(tech, originator)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  continue;</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span> </span><br><span>                /* If no resource is available, continue on */</span><br><span>               if (!(resource = strchr(tech, '/'))) {</span><br><span style="color: hsl(0, 100%, 40%);">-                  ast_log(LOG_WARNING, "Incomplete destination '%s' supplied.\n", tech);</span><br><span style="color: hsl(120, 100%, 40%);">+                      ast_log(LOG_WARNING, "Incomplete destination: '%s' supplied.\n", tech);</span><br><span>                    continue;</span><br><span>            }</span><br><span> </span><br><span>@@ -350,9 +352,11 @@</span><br><span>                 if (ast_test_flag(&options.flags, PAGE_SKIP)) {</span><br><span>                  state = ast_device_state(tech);</span><br><span>                      if (state == AST_DEVICE_UNKNOWN) {</span><br><span style="color: hsl(0, 100%, 40%);">-                              ast_log(LOG_WARNING, "Destination '%s' has device state '%s'. Paging anyway.\n", tech, ast_devstate2str(state));</span><br><span style="color: hsl(120, 100%, 40%);">+                            ast_verb(3, "Destination '%s' has device state '%s'. Paging anyway.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                     tech, ast_devstate2str(state));</span><br><span>                      } else if (state != AST_DEVICE_NOT_INUSE) {</span><br><span style="color: hsl(0, 100%, 40%);">-                             ast_log(LOG_WARNING, "Destination '%s' has device state '%s'.\n", tech, ast_devstate2str(state));</span><br><span style="color: hsl(120, 100%, 40%);">+                           ast_verb(3, "Destination '%s' has device state '%s'.\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                    tech, ast_devstate2str(state));</span><br><span>                              continue;</span><br><span>                    }</span><br><span>            }</span><br><span>@@ -367,7 +371,7 @@</span><br><span> </span><br><span>          /* Append technology and resource */</span><br><span>                 if (ast_dial_append(dial, tech, resource, NULL) == -1) {</span><br><span style="color: hsl(0, 100%, 40%);">-                        ast_log(LOG_ERROR, "Failed to add %s to outbound dial\n", tech);</span><br><span style="color: hsl(120, 100%, 40%);">+                    ast_log(LOG_ERROR, "Failed to add %s/%s to outbound dial\n", tech, resource);</span><br><span>                      ast_dial_destroy(dial);</span><br><span>                      continue;</span><br><span>            }</span><br><span>diff --git a/doc/CHANGES-staging/app_page_empty_page_list.txt b/doc/CHANGES-staging/app_page_empty_page_list.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..73e8420</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_page_empty_page_list.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_page</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The Page application now tolerates empty positions in the supplied</span><br><span style="color: hsl(120, 100%, 40%);">+destination list.  Dialplan can now be simplified by not having to check</span><br><span style="color: hsl(120, 100%, 40%);">+for empty positions in the destination list.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13557">change 13557</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/c/asterisk/+/13557"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I95b64a6d6800cd1a25279c88889314ae60fc21e3 </div>
<div style="display:none"> Gerrit-Change-Number: 13557 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>