<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17672">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_sendtext: Add ReceiveText application<br><br>Adds a ReceiveText application that can be used in<br>conjunction with SendText. Currently, there is no<br>way in Asterisk to receive text in the dialplan<br>(or anywhere else, really). This allows for Asterisk<br>to be the recipient of text instead of just the sender.<br><br>ASTERISK-29759 #close<br><br>Change-Id: Ica2c354a42bff69f323a0493d3a7cd0fb129d52d<br>---<br>M apps/app_sendtext.c<br>A doc/CHANGES-staging/app_sendtext.txt<br>2 files changed, 88 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_sendtext.c b/apps/app_sendtext.c</span><br><span>index 45ae073..07e6acc 100644</span><br><span>--- a/apps/app_sendtext.c</span><br><span>+++ b/apps/app_sendtext.c</span><br><span>@@ -21,6 +21,7 @@</span><br><span> * \brief App to transmit a text message</span><br><span> *</span><br><span> * \author Mark Spencer <markster@digium.com></span><br><span style="color: hsl(120, 100%, 40%);">+ * \author Naveen Albert <asterisk@phreaknet.org></span><br><span> *</span><br><span> * \note Requires support of sending text messages from channel driver</span><br><span> *</span><br><span>@@ -140,11 +141,50 @@</span><br><span> <see-also></span><br><span> <ref type="application">SendImage</ref></span><br><span> <ref type="application">SendURL</ref></span><br><span style="color: hsl(120, 100%, 40%);">+ <ref type="application">ReceiveText</ref></span><br><span style="color: hsl(120, 100%, 40%);">+ </see-also></span><br><span style="color: hsl(120, 100%, 40%);">+ </application></span><br><span style="color: hsl(120, 100%, 40%);">+ <application name="ReceiveText" language="en_US"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ Receive a Text Message on a channel.</span><br><span style="color: hsl(120, 100%, 40%);">+ </synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ <syntax></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="timeout" required="false"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>Time in seconds to wait for text. Default is 0 (forever).</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+ </syntax></span><br><span style="color: hsl(120, 100%, 40%);">+ <description></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>Waits for <replaceable>timeout</replaceable> seconds on the current channel</span><br><span style="color: hsl(120, 100%, 40%);">+ to receive text.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>Result of transmission will be stored in the following variables:</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <variablelist></span><br><span style="color: hsl(120, 100%, 40%);">+ <variable name="RECEIVETEXTMESSAGE"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>The received text message.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </variable></span><br><span style="color: hsl(120, 100%, 40%);">+ <variable name="RECEIVETEXTSTATUS"></span><br><span style="color: hsl(120, 100%, 40%);">+ <value name="SUCCESS"></span><br><span style="color: hsl(120, 100%, 40%);">+ Transmission succeeded.</span><br><span style="color: hsl(120, 100%, 40%);">+ </value></span><br><span style="color: hsl(120, 100%, 40%);">+ <value name="FAILURE"></span><br><span style="color: hsl(120, 100%, 40%);">+ Transmission failed or timed out.</span><br><span style="color: hsl(120, 100%, 40%);">+ </value></span><br><span style="color: hsl(120, 100%, 40%);">+ </variable></span><br><span style="color: hsl(120, 100%, 40%);">+ </variablelist></span><br><span style="color: hsl(120, 100%, 40%);">+ <example title="Receive message on channel"></span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ReceiveText()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp(${RECEIVETEXTMESSAGE})</span><br><span style="color: hsl(120, 100%, 40%);">+ </example></span><br><span style="color: hsl(120, 100%, 40%);">+ </description></span><br><span style="color: hsl(120, 100%, 40%);">+ <see-also></span><br><span style="color: hsl(120, 100%, 40%);">+ <ref type="application">SendText</ref></span><br><span style="color: hsl(120, 100%, 40%);">+ <ref type="application">SendImage</ref></span><br><span style="color: hsl(120, 100%, 40%);">+ <ref type="application">SendURL</ref></span><br><span> </see-also></span><br><span> </application></span><br><span> ***/</span><br><span> </span><br><span> static const char * const app = "SendText";</span><br><span style="color: hsl(120, 100%, 40%);">+static const char * const app2 = "ReceiveText";</span><br><span> </span><br><span> static int sendtext_exec(struct ast_channel *chan, const char *data)</span><br><span> {</span><br><span>@@ -237,14 +277,55 @@</span><br><span> return rc;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int recvtext_exec(struct ast_channel *chan, const char *data)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ double timeout = 0, timeout_ms = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *parse, *buf;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_DECLARE_APP_ARGS(args,</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_APP_ARG(timeout);</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%);">+ parse = ast_strdupa(data);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_STANDARD_APP_ARGS(args, parse);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(args.timeout)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (sscanf(args.timeout, "%30lg", &timeout) != 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_WARNING, "Invalid timeout provided: %s. No timeout set.\n", args.timeout);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ timeout_ms = timeout * 1000.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%);">+ buf = ast_recvtext(chan, timeout_ms);</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "RECEIVETEXTSTATUS", buf ? "SUCCESS" : "FAILURE");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (buf) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "RECEIVETEXTMESSAGE", buf);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_free(buf);</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%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int unload_module(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_unregister_application(app);</span><br><span style="color: hsl(120, 100%, 40%);">+ int res;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_unregister_application(app);</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= ast_unregister_application(app2);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return res;</span><br><span> }</span><br><span> </span><br><span> static int load_module(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_register_application_xml(app, sendtext_exec);</span><br><span style="color: hsl(120, 100%, 40%);">+ int res;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_register_application_xml(app, sendtext_exec);</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= ast_register_application_xml(app2, recvtext_exec);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return res;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send Text Applications");</span><br><span style="color: hsl(120, 100%, 40%);">+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send and Receive Text Applications");</span><br><span>diff --git a/doc/CHANGES-staging/app_sendtext.txt b/doc/CHANGES-staging/app_sendtext.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..37dd64b</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_sendtext.txt</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_sendtext</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+A ReceiveText application has been added that can be</span><br><span style="color: hsl(120, 100%, 40%);">+used in conjunction with the SendText application.</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17672">change 17672</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/+/17672"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: Ica2c354a42bff69f323a0493d3a7cd0fb129d52d </div>
<div style="display:none"> Gerrit-Change-Number: 17672 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.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-MessageType: merged </div>