Sat Aug 6 00:39:37 2011

Asterisk developer's documentation


app_sendtext.c File Reference

App to transmit a text message. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/image.h"
#include "asterisk/options.h"
#include "asterisk/app.h"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int sendtext_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Send Text Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, }
static const char * app = "SendText"
static const struct ast_module_infoast_module_info = &__mod_info
static const char * descrip
static const char * synopsis = "Send a Text Message"


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

static void __reg_module ( void   )  [static]

Definition at line 133 of file app_sendtext.c.

static void __unreg_module ( void   )  [static]

Definition at line 133 of file app_sendtext.c.

static int load_module ( void   )  [static]

Definition at line 128 of file app_sendtext.c.

References ast_register_application(), and sendtext_exec().

00129 {
00130    return ast_register_application(app, sendtext_exec, synopsis, descrip);
00131 }

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

Definition at line 67 of file app_sendtext.c.

References AST_APP_ARG, ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, ast_goto_if_exists(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_opt_priority_jumping, ast_sendtext(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_module_user::chan, ast_channel::context, LOG_WARNING, parse(), pbx_builtin_setvar_helper(), ast_channel_tech::send_text, ast_channel::tech, and text.

Referenced by load_module().

00068 {
00069    int res = 0;
00070    struct ast_module_user *u;
00071    char *status = "UNSUPPORTED";
00072    char *parse = NULL;
00073    int priority_jump = 0;
00074    AST_DECLARE_APP_ARGS(args,
00075       AST_APP_ARG(text);
00076       AST_APP_ARG(options);
00077    );
00078       
00079    u = ast_module_user_add(chan);   
00080 
00081    /* NOT ast_strlen_zero, because some protocols (e.g. SIP) MUST be able to
00082     * send a zero-length message. */
00083    if (!data) {
00084       ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n");
00085       ast_module_user_remove(u);
00086       return -1;
00087    } else
00088       parse = ast_strdupa(data);
00089    
00090    AST_STANDARD_APP_ARGS(args, parse);
00091 
00092    if (args.options) {
00093       if (strchr(args.options, 'j'))
00094          priority_jump = 1;
00095    }
00096 
00097    ast_channel_lock(chan);
00098    if (!chan->tech->send_text) {
00099       ast_channel_unlock(chan);
00100       pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00101       /* Does not support transport */
00102       if (priority_jump || ast_opt_priority_jumping)
00103          ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
00104       ast_module_user_remove(u);
00105       return 0;
00106    }
00107    status = "FAILURE";
00108    res = ast_sendtext(chan, args.text);
00109    if (!res)
00110       status = "SUCCESS";
00111    ast_channel_unlock(chan);
00112    pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00113    ast_module_user_remove(u);
00114    return 0;
00115 }

static int unload_module ( void   )  [static]

Definition at line 117 of file app_sendtext.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00118 {
00119    int res;
00120    
00121    res = ast_unregister_application(app);
00122    
00123    ast_module_user_hangup_all();
00124 
00125    return res; 
00126 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Send Text Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 133 of file app_sendtext.c.

const char* app = "SendText" [static]

Definition at line 49 of file app_sendtext.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 133 of file app_sendtext.c.

const char* descrip [static]

Definition at line 53 of file app_sendtext.c.

const char* synopsis = "Send a Text Message" [static]

Definition at line 51 of file app_sendtext.c.


Generated on Sat Aug 6 00:39:37 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7