00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "asterisk.h"
00031
00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 187365 $")
00033
00034 #include "asterisk/file.h"
00035 #include "asterisk/channel.h"
00036 #include "asterisk/pbx.h"
00037 #include "asterisk/module.h"
00038 #include "asterisk/app.h"
00039
00040 static const char *app = "SendText";
00041
00042 static const char *synopsis = "Send a Text Message";
00043
00044 static const char *descrip =
00045 " SendText(text): Sends text to current channel (callee).\n"
00046 "Result of transmission will be stored in the SENDTEXTSTATUS\n"
00047 "channel variable:\n"
00048 " SUCCESS Transmission succeeded\n"
00049 " FAILURE Transmission failed\n"
00050 " UNSUPPORTED Text transmission not supported by channel\n"
00051 "\n"
00052 "At this moment, text is supposed to be 7 bit ASCII in most channels.\n";
00053
00054 static int sendtext_exec(struct ast_channel *chan, void *data)
00055 {
00056 int res = 0;
00057 char *status = "UNSUPPORTED";
00058 char *parse = NULL;
00059 AST_DECLARE_APP_ARGS(args,
00060 AST_APP_ARG(text);
00061 );
00062
00063
00064
00065 if (!data) {
00066 ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
00067 return -1;
00068 } else
00069 parse = ast_strdupa(data);
00070
00071 AST_STANDARD_APP_ARGS(args, parse);
00072
00073 ast_channel_lock(chan);
00074 if (!chan->tech->send_text) {
00075 ast_channel_unlock(chan);
00076
00077 pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00078 return 0;
00079 }
00080 status = "FAILURE";
00081 ast_channel_unlock(chan);
00082 res = ast_sendtext(chan, args.text);
00083 if (!res)
00084 status = "SUCCESS";
00085 pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00086 return 0;
00087 }
00088
00089 static int unload_module(void)
00090 {
00091 return ast_unregister_application(app);
00092 }
00093
00094 static int load_module(void)
00095 {
00096 return ast_register_application(app, sendtext_exec, synopsis, descrip);
00097 }
00098
00099 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send Text Applications");