Tue Aug 24 20:34:28 2010

Asterisk developer's documentation


app_sendtext.c File Reference

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"
Include dependency graph for app_sendtext.c:

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, void *data)
static int unload_module (void)

Variables

static const char * app = "SendText"

Detailed Description

App to transmit a text message.

Author:
Mark Spencer <markster@digium.com>
Note:
Requires support of sending text messages from channel driver

Definition in file app_sendtext.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Send Text Applications"   
)
static int load_module ( void   )  [static]

Definition at line 115 of file app_sendtext.c.

References ast_register_application_xml, and sendtext_exec().

00116 {
00117    return ast_register_application_xml(app, sendtext_exec);
00118 }

static int sendtext_exec ( struct ast_channel *  chan,
void *  data 
) [static]

Definition at line 75 of file app_sendtext.c.

References AST_APP_ARG, ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, ast_log(), ast_sendtext(), AST_STANDARD_APP_ARGS, ast_strdupa, LOG_WARNING, parse(), pbx_builtin_setvar_helper(), ast_channel_tech::send_text, status, ast_channel::tech, and text.

Referenced by load_module().

00076 {
00077    int res = 0;
00078    char *status = "UNSUPPORTED";
00079    char *parse = NULL;
00080    AST_DECLARE_APP_ARGS(args,
00081       AST_APP_ARG(text);
00082    );
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    } else
00090       parse = ast_strdupa(data);
00091    
00092    AST_STANDARD_APP_ARGS(args, parse);
00093 
00094    ast_channel_lock(chan);
00095    if (!chan->tech->send_text) {
00096       ast_channel_unlock(chan);
00097       /* Does not support transport */
00098       pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00099       return 0;
00100    }
00101    status = "FAILURE";
00102    ast_channel_unlock(chan);
00103    res = ast_sendtext(chan, args.text);
00104    if (!res)
00105       status = "SUCCESS";
00106    pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00107    return 0;
00108 }

static int unload_module ( void   )  [static]

Definition at line 110 of file app_sendtext.c.

References ast_unregister_application().

00111 {
00112    return ast_unregister_application(app);
00113 }


Variable Documentation

const char* app = "SendText" [static]

Definition at line 73 of file app_sendtext.c.


Generated on 24 Aug 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1