<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15827">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: 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;">Updates for the MessageSend Dialplan App<br><br>Enhancements:<br><br> * The MessageSend dialplan application now takes an optional<br>   third argument that can set the message's "To" field on<br>   outgoing messages.  It's an alternative to using the<br>   MESSAGE(to) dialplan function.<br><br>   NOTE: No channel driver currently implements this field.  A<br>   follow-on commit for res_pjsip_messaging will implement it for<br>   the chan_pjsip channel driver.<br><br> * To prevent confusion with the first argument, currently named<br>   "to", it's been renamed to "destination". Its function,<br>   creating the request URI, hasn't changed.<br><br> * The documentation for MessageSend was updated to be<br>   more clear about the parameters and how they interact<br>   the MESSAGE() dialplan function.<br><br> * With the rename of MessageSend's first parameter, and the fact<br>   that message.c references <info> elements in chan_sip.c,<br>   res_pjsip_messaging.c and res_xmpp, they each needed<br>   documentation updates to use MessageDestinationInfo instead of<br>   MessageToInfo.<br><br> * appdocsxml.dtd was updated to include a missing element<br>   declaration for "dataType".  This was showing up as an error<br>   in Eclipse's dtd editor.<br><br> * Despite the changes in this commit, there should be<br>   no impact to current users of MessageSend.<br><br>Change-Id: I6fb5b569657a02866a66ea352fd53d30d8ac965a<br>---<br>M channels/chan_sip.c<br>A doc/CHANGES-staging/messagesend.txt<br>M doc/appdocsxml.dtd<br>M main/message.c<br>M res/res_pjsip_messaging.c<br>M res/res_xmpp.c<br>6 files changed, 81 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_sip.c b/channels/chan_sip.c</span><br><span>index da0e0de..77e1b24 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -619,13 +619,16 @@</span><br><span>                        for all of the sip peers will be retrieved.</para></span><br><span>             </description></span><br><span>         </manager></span><br><span style="color: hsl(120, 100%, 40%);">+      <info name="MessageDestinationInfo" language="en_US" tech="SIP"></span><br><span style="color: hsl(120, 100%, 40%);">+          <para>Specifying a prefix of <literal>sip:</literal> will send the</span><br><span style="color: hsl(120, 100%, 40%);">+          message as a SIP MESSAGE request.</para></span><br><span style="color: hsl(120, 100%, 40%);">+        </info></span><br><span>        <info name="MessageFromInfo" language="en_US" tech="SIP"></span><br><span>                <para>The <literal>from</literal> parameter can be a configured peer name</span><br><span>          or in the form of "display-name" &lt;URI&gt;.</para></span><br><span>         </info></span><br><span>        <info name="MessageToInfo" language="en_US" tech="SIP"></span><br><span style="color: hsl(0, 100%, 40%);">-             <para>Specifying a prefix of <literal>sip:</literal> will send the</span><br><span style="color: hsl(0, 100%, 40%);">-            message as a SIP MESSAGE request.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                <para>Ignored</para></span><br><span>     </info></span><br><span>        <managerEvent language="en_US" name="SIPQualifyPeerDone"></span><br><span>          <managerEventInstance class="EVENT_FLAG_CALL"></span><br><span>diff --git a/doc/CHANGES-staging/messagesend.txt b/doc/CHANGES-staging/messagesend.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..7977ff1</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/messagesend.txt</span><br><span>@@ -0,0 +1,16 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: MessageSend</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The MessageSend dialplan application now takes an</span><br><span style="color: hsl(120, 100%, 40%);">+optional third argument that can set the message's</span><br><span style="color: hsl(120, 100%, 40%);">+"To" field on outgoing messages.  It's an alternative</span><br><span style="color: hsl(120, 100%, 40%);">+to using the MESSAGE(to) dialplan function.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+To prevent confusion with the first argument, currently</span><br><span style="color: hsl(120, 100%, 40%);">+named "to", it's been renamed to "destination".</span><br><span style="color: hsl(120, 100%, 40%);">+Its function, creating the request URI, hasn't changed.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The online documentation has also been enhanced to</span><br><span style="color: hsl(120, 100%, 40%);">+explain the behavior.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Despite the changes in this commit, there should be</span><br><span style="color: hsl(120, 100%, 40%);">+no impact to current users of MessageSend.</span><br><span>diff --git a/doc/appdocsxml.dtd b/doc/appdocsxml.dtd</span><br><span>index 7723bd5..93fdd3a 100644</span><br><span>--- a/doc/appdocsxml.dtd</span><br><span>+++ b/doc/appdocsxml.dtd</span><br><span>@@ -83,6 +83,8 @@</span><br><span> </span><br><span>   <!ELEMENT matchInfo (category|field?)></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  <!ELEMENT dataType (#PCDATA)></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   <!ELEMENT category (#PCDATA)></span><br><span>   <!ATTLIST category match (yes|no|true|false) #REQUIRED></span><br><span> </span><br><span>diff --git a/main/message.c b/main/message.c</span><br><span>index b6f254d..c667b0c 100644</span><br><span>--- a/main/message.c</span><br><span>+++ b/main/message.c</span><br><span>@@ -52,13 +52,25 @@</span><br><span>                  <para>Field of the message to get or set.</para></span><br><span>                         <enumlist></span><br><span>                             <enum name="to"></span><br><span style="color: hsl(0, 100%, 40%);">-                                        <para>Read-only.  The destination of the message.  When processing an</span><br><span style="color: hsl(120, 100%, 40%);">+                                   <para>When processing an</span><br><span>                                       incoming message, this will be set to the destination listed as</span><br><span>                                      the recipient of the message that was received by Asterisk.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                      <para></span><br><span style="color: hsl(120, 100%, 40%);">+                                  </para></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <para>For an ourgoing message, this will set the To header in the</span><br><span style="color: hsl(120, 100%, 40%);">+                                       outgoing SIP message.  This may be overridden by the "to" parameter</span><br><span style="color: hsl(120, 100%, 40%);">+                                 of MessageSend.</span><br><span style="color: hsl(120, 100%, 40%);">+                                       </para></span><br><span>                                </enum></span><br><span>                                <enum name="from"></span><br><span style="color: hsl(0, 100%, 40%);">-                                      <para>Read-only.  The source of the message.  When processing an</span><br><span style="color: hsl(120, 100%, 40%);">+                                        <para>When processing an</span><br><span>                                       incoming message, this will be set to the source of the message.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <para></span><br><span style="color: hsl(120, 100%, 40%);">+                                  </para></span><br><span style="color: hsl(120, 100%, 40%);">+                                 <para>For an ourgoing message, this will set the From header in the</span><br><span style="color: hsl(120, 100%, 40%);">+                                     outgoing SIP message. This may be overridden by the "from" parameter</span><br><span style="color: hsl(120, 100%, 40%);">+                                        of MessageSend.</span><br><span style="color: hsl(120, 100%, 40%);">+                                       </para></span><br><span>                                </enum></span><br><span>                                <enum name="custom_data"></span><br><span>                                    <para>Write-only.  Mark or unmark all message headers for an outgoing</span><br><span>@@ -119,23 +131,39 @@</span><br><span>                  Send a text message.</span><br><span>                 </synopsis></span><br><span>            <syntax></span><br><span style="color: hsl(0, 100%, 40%);">-                  <parameter name="to" required="true"></span><br><span style="color: hsl(120, 100%, 40%);">+                       <parameter name="destination" required="true"></span><br><span>                             <para>A To URI for the message.</para></span><br><span style="color: hsl(0, 100%, 40%);">-                              <xi:include xpointer="xpointer(/docs/info[@name='MessageToInfo'])" /></span><br><span style="color: hsl(120, 100%, 40%);">+                         <xi:include xpointer="xpointer(/docs/info[@name='MessageDestinationInfo'])" /></span><br><span>                       </parameter></span><br><span>                   <parameter name="from" required="false"></span><br><span>                           <para>A From URI for the message if needed for the</span><br><span>                             message technology being used to send this message. This can be a</span><br><span>                            SIP(S) URI, such as <literal>Alice &lt;sip:alice@atlanta.com&gt;</literal>,</span><br><span style="color: hsl(0, 100%, 40%);">-                         a string in the format <literal>alice@atlanta.com</literal>, or simply</span><br><span style="color: hsl(0, 100%, 40%);">-                              a username such as <literal>alice</literal>.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                         or a string in the format <literal>alice@atlanta.com</literal>.</span><br><span style="color: hsl(120, 100%, 40%);">+                           This will override a <literal>from</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                              specified using the MESSAGE dialplan function or the <literal>from</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                              that may have been on an incoming message.</span><br><span style="color: hsl(120, 100%, 40%);">+                            </para></span><br><span style="color: hsl(120, 100%, 40%);">+                         <xi:include xpointer="xpointer(/docs/info[@name='MessageFromInfo'])" /></span><br><span style="color: hsl(120, 100%, 40%);">+                       </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+                    <parameter name="to" required="false"></span><br><span style="color: hsl(120, 100%, 40%);">+                              <para>A To URI for the message if needed for the</span><br><span style="color: hsl(120, 100%, 40%);">+                                message technology being used to send this message. This can be a</span><br><span style="color: hsl(120, 100%, 40%);">+                             SIP(S) URI, such as <literal>Alice &lt;sip:alice@atlanta.com&gt;</literal>,</span><br><span style="color: hsl(120, 100%, 40%);">+                               or a string in the format <literal>alice@atlanta.com</literal>.</span><br><span style="color: hsl(120, 100%, 40%);">+                           This will override a <literal>to</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                                specified using the MESSAGE dialplan function or the <literal>to</literal></span><br><span style="color: hsl(120, 100%, 40%);">+                                that may have been on an incoming message.</span><br><span style="color: hsl(120, 100%, 40%);">+                            </para></span><br><span style="color: hsl(120, 100%, 40%);">+                         <xi:include xpointer="xpointer(/docs/info[@name='MessageToInfo'])" /></span><br><span>                        </parameter></span><br><span>           </syntax></span><br><span>              <description></span><br><span>                  <para>Send a text message.  The body of the message that will be</span><br><span>                       sent is what is currently set to <literal>MESSAGE(body)</literal>.</span><br><span style="color: hsl(0, 100%, 40%);">-                    The technology chosen for sending the message is determined</span><br><span style="color: hsl(0, 100%, 40%);">-                   based on a prefix to the <literal>to</literal> parameter.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                    This may he come from an incoming message.</span><br><span style="color: hsl(120, 100%, 40%);">+                    The technology chosen for sending the message is determined</span><br><span style="color: hsl(120, 100%, 40%);">+                   based on a prefix to the <literal>destination</literal> parameter.</para></span><br><span>                  <para>This application sets the following channel variables:</para></span><br><span>                      <variablelist></span><br><span>                                 <variable name="MESSAGE_SEND_STATUS"></span><br><span>@@ -1204,8 +1232,9 @@</span><br><span>        char *parse;</span><br><span>         int res = -1;</span><br><span>        AST_DECLARE_APP_ARGS(args,</span><br><span style="color: hsl(0, 100%, 40%);">-              AST_APP_ARG(to);</span><br><span style="color: hsl(120, 100%, 40%);">+              AST_APP_ARG(destination);</span><br><span>            AST_APP_ARG(from);</span><br><span style="color: hsl(120, 100%, 40%);">+            AST_APP_ARG(to);</span><br><span>     );</span><br><span> </span><br><span>       if (ast_strlen_zero(data)) {</span><br><span>@@ -1217,7 +1246,7 @@</span><br><span>         parse = ast_strdupa(data);</span><br><span>   AST_STANDARD_APP_ARGS(args, parse);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(args.to)) {</span><br><span style="color: hsl(120, 100%, 40%);">+       if (ast_strlen_zero(args.destination)) {</span><br><span>             ast_log(LOG_WARNING, "A 'to' URI is required for MessageSend()\n");</span><br><span>                pbx_builtin_setvar_helper(chan, "MESSAGE_SEND_STATUS", "INVALID_URI");</span><br><span>           return 0;</span><br><span>@@ -1236,7 +1265,7 @@</span><br><span>    ao2_ref(msg, +1);</span><br><span>    ast_channel_unlock(chan);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   tech_name = ast_strdupa(args.to);</span><br><span style="color: hsl(120, 100%, 40%);">+     tech_name = ast_strdupa(args.destination);</span><br><span>   tech_name = strsep(&tech_name, ":");</span><br><span> </span><br><span>       ast_rwlock_rdlock(&msg_techs_lock);</span><br><span>@@ -1249,12 +1278,20 @@</span><br><span>    }</span><br><span> </span><br><span>        /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * If there was a "to" in the call to MessageSend,</span><br><span style="color: hsl(120, 100%, 40%);">+   * replace the to already in the channel datastore.</span><br><span style="color: hsl(120, 100%, 40%);">+    */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!ast_strlen_zero(args.to)) {</span><br><span style="color: hsl(120, 100%, 40%);">+              ast_string_field_set(msg, to, args.to);</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%);">+   /*</span><br><span>    * The message lock is held here to safely allow the technology</span><br><span>       * implementation to access the message fields without worrying</span><br><span>       * that they could change.</span><br><span>    */</span><br><span>  ao2_lock(msg);</span><br><span style="color: hsl(0, 100%, 40%);">-  res = msg_tech->msg_send(msg, S_OR(args.to, ""), S_OR(args.from, ""));</span><br><span style="color: hsl(120, 100%, 40%);">+ res = msg_tech->msg_send(msg, S_OR(args.destination, ""), S_OR(args.from, ""));</span><br><span>       ao2_unlock(msg);</span><br><span> </span><br><span>         pbx_builtin_setvar_helper(chan, "MESSAGE_SEND_STATUS", res ? "FAILURE" : "SUCCESS");</span><br><span>diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c</span><br><span>index 5378b8c..9287324 100644</span><br><span>--- a/res/res_pjsip_messaging.c</span><br><span>+++ b/res/res_pjsip_messaging.c</span><br><span>@@ -24,13 +24,16 @@</span><br><span>  ***/</span><br><span> </span><br><span> /*** DOCUMENTATION</span><br><span style="color: hsl(120, 100%, 40%);">+  <info name="MessageDestinationInfo" language="en_US" tech="PJSIP"></span><br><span style="color: hsl(120, 100%, 40%);">+                <para>Specifying a prefix of <literal>pjsip:</literal> will send the</span><br><span style="color: hsl(120, 100%, 40%);">+                message as a SIP MESSAGE request.</para></span><br><span style="color: hsl(120, 100%, 40%);">+        </info></span><br><span>        <info name="MessageFromInfo" language="en_US" tech="PJSIP"></span><br><span>              <para>The <literal>from</literal> parameter can be a configured endpoint</span><br><span>           or in the form of "display-name" &lt;URI&gt;.</para></span><br><span>         </info></span><br><span>        <info name="MessageToInfo" language="en_US" tech="PJSIP"></span><br><span style="color: hsl(0, 100%, 40%);">-           <para>Specifying a prefix of <literal>pjsip:</literal> will send the</span><br><span style="color: hsl(0, 100%, 40%);">-          message as a SIP MESSAGE request.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                <para>Ignored</para></span><br><span>     </info></span><br><span>  ***/</span><br><span> #include "asterisk.h"</span><br><span>diff --git a/res/res_xmpp.c b/res/res_xmpp.c</span><br><span>index 0f30437..63dc257 100644</span><br><span>--- a/res/res_xmpp.c</span><br><span>+++ b/res/res_xmpp.c</span><br><span>@@ -251,7 +251,7 @@</span><br><span>                         <para>Sends a message to a Jabber Client.</para></span><br><span>                 </description></span><br><span>         </manager></span><br><span style="color: hsl(0, 100%, 40%);">-        <info name="MessageToInfo" language="en_US" tech="XMPP"></span><br><span style="color: hsl(120, 100%, 40%);">+  <info name="MessageDestinationInfo" language="en_US" tech="XMPP"></span><br><span>                <para>Specifying a prefix of <literal>xmpp:</literal> will send the</span><br><span>                message as an XMPP chat message.</para></span><br><span>        </info></span><br><span>@@ -260,6 +260,9 @@</span><br><span>          account defined in <literal>xmpp.conf</literal> to send the message from.</span><br><span>                Note that this field is required for XMPP messages.</para></span><br><span>     </info></span><br><span style="color: hsl(120, 100%, 40%);">+ <info name="MessageToInfo" language="en_US" tech="XMPP"></span><br><span style="color: hsl(120, 100%, 40%);">+          <para>Ignored</para></span><br><span style="color: hsl(120, 100%, 40%);">+      </info></span><br><span>        <configInfo name="res_xmpp" language="en_US"></span><br><span>              <synopsis>XMPP Messaging</synopsis></span><br><span>              <configFile name="xmpp.conf"></span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15827">change 15827</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/+/15827"/><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-Change-Id: I6fb5b569657a02866a66ea352fd53d30d8ac965a </div>
<div style="display:none"> Gerrit-Change-Number: 15827 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@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: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>