186 static const char *
const app =
"SendText";
187 static const char *
const app2 =
"ReceiveText";
196 const char *content_type;
200 ast_channel_lock(chan);
205 body =
S_OR(body,
"");
207 if (!(str = ast_str_alloca(strlen(body) + 1))) {
215 status =
"UNSUPPORTED";
221 .type = AST_MSG_DATA_ATTR_FROM,
222 .value = (
char *)
S_OR(from,
""),
225 .type = AST_MSG_DATA_ATTR_TO,
226 .value = (
char *)
S_OR(to,
""),
229 .type = AST_MSG_DATA_ATTR_CONTENT_TYPE,
230 .value = (
char *)
S_OR(content_type,
""),
233 .type = AST_MSG_DATA_ATTR_BODY,
234 .value = (
char *)
S_OR(body,
""),
238 msg_type =
"ENHANCED";
239 msg =
ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_IN_DIALOG, attrs, ARRAY_LEN(attrs));
254 if (!ast_strlen_zero(content_type) && !
ast_begins_with(content_type,
"text/")) {
275 ast_channel_unlock(chan);
280 static int recvtext_exec(
struct ast_channel *chan,
const char *data)
282 double timeout = 0, timeout_ms = 0;
293 if (!ast_strlen_zero(args.timeout)) {
294 if (sscanf(args.timeout,
"%30lg", &timeout) != 1) {
295 ast_log(LOG_WARNING,
"Invalid timeout provided: %s. No timeout set.\n", args.timeout);
298 timeout_ms = timeout * 1000.0;
311 static int unload_module(
void)
321 static int load_module(
void)
331 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Send and Receive Text Applications");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Structure used to transport a message through the frame core.
struct ast_msg_data * ast_msg_data_alloc(enum ast_msg_data_source_type source, struct ast_msg_data_attribute attributes[], size_t count)
Allocates an ast_msg_data structure.
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback...
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
Out-of-call text message support.
int ast_unregister_application(const char *app)
Unregister an application.
int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream)
Decode a stream of encoded control or extended ASCII characters.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static void cleanup(void)
Clean up any old apps that we don't need any more.
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Core PBX routines and definitions.
Support for dynamic strings.
char * ast_recvtext(struct ast_channel *chan, int timeout)
Receives a text string from a channel Read a string of text from a channel.
union ast_frame::@224 data
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
#define AST_APP_ARG(name)
Define an application argument.