<p>cmaj has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13363">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip/dialplan_functions.c: Get dialable string from function.<br><br>It is convenient to get back a dialable string from the PJSIP_DIAL_CONTACTS<br>function so you can pass it in to the Dial() application without modification.<br><br>Change-Id: I1709ee211705edac4d93f55723b8153bb653a338<br>---<br>M channels/pjsip/dialplan_functions.c<br>1 file changed, 21 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/63/13363/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c</span><br><span>index 3a6f0a4..a69146a 100644</span><br><span>--- a/channels/pjsip/dialplan_functions.c</span><br><span>+++ b/channels/pjsip/dialplan_functions.c</span><br><span>@@ -44,9 +44,12 @@</span><br><span> <parameter name="request_user" required="false"></span><br><span> <para>Optional request user to use in the request URI</para></span><br><span> </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="please" required="false"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>Optional return of 'PJSIP/endpoint' if no contacts are found. Otherwise, with no contacts, this function will return an empty string that will cause the Dial application to exit with an error and hang up the call.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span> </syntax></span><br><span> <description></span><br><span style="color: hsl(0, 100%, 40%);">- <para>Returns a properly formatted dial string for dialing all contacts on an AOR.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>Returns a properly formatted dial string for dialing all contacts on an AOR. If there are no contacts, then an empty string is returned -- unless you specify the 'please' argument.</para></span><br><span> </description></span><br><span> </function></span><br><span> <function name="PJSIP_MEDIA_OFFER" language="en_US"></span><br><span>@@ -985,13 +988,14 @@</span><br><span> {</span><br><span> RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);</span><br><span> RAII_VAR(struct ast_str *, dial, NULL, ast_free_ptr);</span><br><span style="color: hsl(0, 100%, 40%);">- const char *aor_name;</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *aor_name = "";</span><br><span> char *rest;</span><br><span> </span><br><span> AST_DECLARE_APP_ARGS(args,</span><br><span> AST_APP_ARG(endpoint_name);</span><br><span> AST_APP_ARG(aor_name);</span><br><span> AST_APP_ARG(request_user);</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_ARG(please);</span><br><span> );</span><br><span> </span><br><span> AST_STANDARD_APP_ARGS(args, data);</span><br><span>@@ -1000,13 +1004,19 @@</span><br><span> ast_log(LOG_WARNING, "An endpoint name must be specified when using the '%s' dialplan function\n", cmd);</span><br><span> return -1;</span><br><span> } else if (!(endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", args.endpoint_name))) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_WARNING, "Specified endpoint '%s' was not found\n", args.endpoint_name);</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(args.please)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Specified endpoint '%s' was not found but the 'please' argument was provided so keeping calm and carrying on\n", args.endpoint_name);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Specified endpoint '%s' was not found\n", args.endpoint_name);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- aor_name = S_OR(args.aor_name, endpoint->aors);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (endpoint) {</span><br><span style="color: hsl(120, 100%, 40%);">+ aor_name = S_OR(args.aor_name, endpoint->aors);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(aor_name)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(aor_name) && ast_strlen_zero(args.please)) {</span><br><span> ast_log(LOG_WARNING, "No AOR has been provided and no AORs are configured on endpoint '%s'\n", args.endpoint_name);</span><br><span> return -1;</span><br><span> } else if (!(dial = ast_str_create(len))) {</span><br><span>@@ -1049,6 +1059,11 @@</span><br><span> /* Trim the '&' at the end off */</span><br><span> ast_str_truncate(dial, ast_str_strlen(dial) - 1);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_str_strlen(dial) == 0 && !ast_strlen_zero(args.please)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "No current Contacts found for endpoint '%s' but the 'please' argument was provided so keeping calm and carrying on\n", args.endpoint_name);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&dial, -1, "PJSIP/%s", args.endpoint_name);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_copy_string(buf, ast_str_buffer(dial), len);</span><br><span> </span><br><span> return 0;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13363">change 13363</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/+/13363"/><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: I1709ee211705edac4d93f55723b8153bb653a338 </div>
<div style="display:none"> Gerrit-Change-Number: 13363 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: cmaj <chris@penguinpbx.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>