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
32 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
34 #include "asterisk/file.h"
35 #include "asterisk/channel.h"
36 #include "asterisk/pbx.h"
37 #include "asterisk/module.h"
38 #include "asterisk/app.h"
40 static const char *app
= "SendText";
42 static const char *synopsis
= "Send a Text Message";
44 static const char *descrip
=
45 " SendText(text[,options]): Sends text to current channel (callee).\n"
46 "Result of transmission will be stored in the SENDTEXTSTATUS\n"
48 " SUCCESS Transmission succeeded\n"
49 " FAILURE Transmission failed\n"
50 " UNSUPPORTED Text transmission not supported by channel\n"
52 "At this moment, text is supposed to be 7 bit ASCII in most channels.\n";
54 static int sendtext_exec(struct ast_channel
*chan
, void *data
)
57 char *status
= "UNSUPPORTED";
59 AST_DECLARE_APP_ARGS(args
,
64 if (ast_strlen_zero(data
)) {
65 ast_log(LOG_WARNING
, "SendText requires an argument (text[,options])\n");
68 parse
= ast_strdupa(data
);
70 AST_STANDARD_APP_ARGS(args
, parse
);
75 ast_channel_lock(chan
);
76 if (!chan
->tech
->send_text
) {
77 ast_channel_unlock(chan
);
78 /* Does not support transport */
82 ast_channel_unlock(chan
);
83 res
= ast_sendtext(chan
, args
.text
);
86 pbx_builtin_setvar_helper(chan
, "SENDTEXTSTATUS", status
);
90 static int unload_module(void)
92 return ast_unregister_application(app
);
95 static int load_module(void)
97 return ast_register_application(app
, sendtext_exec
, synopsis
, descrip
);
100 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Send Text Applications");