App to transmit a text message. More...
#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
Go to the source code of this file.
Functions | |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Send Text Applications") | |
static int | load_module (void) |
static int | sendtext_exec (struct ast_channel *chan, const char *data) |
static int | unload_module (void) |
Variables | |
static const char *const | app = "SendText" |
App to transmit a text message.
Definition in file app_sendtext.c.
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"Send Text Applications" | ||||
) |
static int load_module | ( | void | ) | [static] |
Definition at line 118 of file app_sendtext.c.
References ast_register_application_xml, and sendtext_exec().
00119 { 00120 return ast_register_application_xml(app, sendtext_exec); 00121 }
static int sendtext_exec | ( | struct ast_channel * | chan, | |
const char * | data | |||
) | [static] |
Definition at line 79 of file app_sendtext.c.
References ast_channel_lock, ast_channel_unlock, ast_log(), ast_sendtext(), ast_str_alloca, ast_str_buffer(), ast_str_get_encoded_str(), LOG_WARNING, pbx_builtin_setvar_helper(), ast_channel_tech::send_text, status, str, and ast_channel::tech.
Referenced by load_module().
00080 { 00081 char *status = "UNSUPPORTED"; 00082 struct ast_str *str; 00083 00084 /* NOT ast_strlen_zero, because some protocols (e.g. SIP) MUST be able to 00085 * send a zero-length message. */ 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 /* Does not support transport */ 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 }
static int unload_module | ( | void | ) | [static] |
Definition at line 113 of file app_sendtext.c.
References ast_unregister_application().
00114 { 00115 return ast_unregister_application(app); 00116 }
const char* const app = "SendText" [static] |
Definition at line 77 of file app_sendtext.c.