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
00031
00032
00033
00034 #include "asterisk.h"
00035
00036 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328209 $")
00037
00038 #include "asterisk/file.h"
00039 #include "asterisk/channel.h"
00040 #include "asterisk/pbx.h"
00041 #include "asterisk/module.h"
00042 #include "asterisk/app.h"
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 static const char * const app = "SendText";
00078
00079 static int sendtext_exec(struct ast_channel *chan, const char *data)
00080 {
00081 char *status = "UNSUPPORTED";
00082 struct ast_str *str;
00083
00084
00085
00086 if (!data) {
00087 ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
00088 return -1;
00089 }
00090
00091 if (!(str = ast_str_alloca(strlen(data) + 1))) {
00092 return -1;
00093 }
00094
00095 ast_str_get_encoded_str(&str, -1, data);
00096
00097 ast_channel_lock(chan);
00098 if (!chan->tech->send_text) {
00099 ast_channel_unlock(chan);
00100
00101 pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00102 return 0;
00103 }
00104 status = "FAILURE";
00105 if (!ast_sendtext(chan, ast_str_buffer(str))) {
00106 status = "SUCCESS";
00107 }
00108 ast_channel_unlock(chan);
00109 pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00110 return 0;
00111 }
00112
00113 static int unload_module(void)
00114 {
00115 return ast_unregister_application(app);
00116 }
00117
00118 static int load_module(void)
00119 {
00120 return ast_register_application_xml(app, sendtext_exec);
00121 }
00122
00123 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Send Text Applications");