Wed Mar 4 19:58:20 2009

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 = "f450f61f60e761b3aa089ebed76ca8a5" , .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 131 of file app_sendtext.c.

static void __unreg_module ( void   )  [static]

Definition at line 131 of file app_sendtext.c.

static int load_module ( void   )  [static]

Definition at line 126 of file app_sendtext.c.

References ast_register_application(), and sendtext_exec().

00127 {
00128    return ast_register_application(app, sendtext_exec, synopsis, descrip);
00129 }

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_strlen_zero(), 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    if (ast_strlen_zero(data)) {
00082       ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n");
00083       ast_module_user_remove(u);
00084       return -1;
00085    } else
00086       parse = ast_strdupa(data);
00087    
00088    AST_STANDARD_APP_ARGS(args, parse);
00089 
00090    if (args.options) {
00091       if (strchr(args.options, 'j'))
00092          priority_jump = 1;
00093    }
00094 
00095    ast_channel_lock(chan);
00096    if (!chan->tech->send_text) {
00097       ast_channel_unlock(chan);
00098       pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00099       /* Does not support transport */
00100       if (priority_jump || ast_opt_priority_jumping)
00101          ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
00102       ast_module_user_remove(u);
00103       return 0;
00104    }
00105    status = "FAILURE";
00106    ast_channel_unlock(chan);
00107    res = ast_sendtext(chan, args.text);
00108    if (!res)
00109       status = "SUCCESS";
00110    pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
00111    ast_module_user_remove(u);
00112    return 0;
00113 }

static int unload_module ( void   )  [static]

Definition at line 115 of file app_sendtext.c.

References ast_module_user_hangup_all, and ast_unregister_application().

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


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 = "f450f61f60e761b3aa089ebed76ca8a5" , .load = load_module, .unload = unload_module, } [static]

Definition at line 131 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 131 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 Wed Mar 4 19:58:21 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7