2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief App to transmit a text message
23 * \author Mark Spencer <markster@digium.com>
25 * \note Requires support of sending text messages from channel driver
27 * \ingroup applications
31 <support_level>core</support_level>
36 ASTERISK_REGISTER_FILE()
38 #include "asterisk/file.h"
39 #include "asterisk/channel.h"
40 #include "asterisk/pbx.h"
41 #include "asterisk/module.h"
42 #include "asterisk/app.h"
45 <application name="SendText" language="en_US">
50 <parameter name="text" required="true" />
53 <para>Sends <replaceable>text</replaceable> to current channel (callee).</para>
54 <para>Result of transmission will be stored in the <variable>SENDTEXTSTATUS</variable></para>
56 <variable name="SENDTEXTSTATUS">
57 <value name="SUCCESS">
58 Transmission succeeded.
60 <value name="FAILURE">
63 <value name="UNSUPPORTED">
64 Text transmission not supported by channel.
68 <note><para>At this moment, text is supposed to be 7 bit ASCII in most channels.</para></note>
71 <ref type="application">SendImage</ref>
72 <ref type="application">SendURL</ref>
77 static const char * const app = "SendText";
79 static int sendtext_exec(struct ast_channel *chan, const char *data)
81 char *status = "UNSUPPORTED";
84 /* NOT ast_strlen_zero, because some protocols (e.g. SIP) MUST be able to
85 * send a zero-length message. */
87 ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
91 if (!(str = ast_str_alloca(strlen(data) + 1))) {
95 ast_str_get_encoded_str(&str, -1, data);
97 ast_channel_lock(chan);
98 if (!ast_channel_tech(chan)->send_text) {
99 ast_channel_unlock(chan);
100 /* Does not support transport */
101 pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
105 if (!ast_sendtext(chan, ast_str_buffer(str))) {
108 ast_channel_unlock(chan);
109 pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
113 static int unload_module(void)
115 return ast_unregister_application(app);
118 static int load_module(void)
120 return ast_register_application_xml(app, sendtext_exec);
123 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send Text Applications");