#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk.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 | |
char * | description (void) |
Provides a description of the module. | |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
int | sendtext_exec (struct ast_channel *chan, void *data) |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
const char * | app = "SendText" |
const char * | descrip |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
const char * | synopsis = "Send a Text Message" |
const char * | tdesc = "Send Text Applications" |
Requires support of sending text messages from channel driver
Definition in file app_sendtext.c.
|
Provides a description of the module.
Definition at line 139 of file app_sendtext.c. 00140 { 00141 return (char *) tdesc; 00142 }
|
|
Returns the ASTERISK_GPL_KEY. This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:
char *key(void) { return ASTERISK_GPL_KEY; }
Definition at line 153 of file app_sendtext.c. 00154 {
00155 return ASTERISK_GPL_KEY;
00156 }
|
|
Initialize the module. Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
Definition at line 134 of file app_sendtext.c. References app, ast_register_application(), descrip, sendtext_exec(), and synopsis. 00135 { 00136 return ast_register_application(app, sendtext_exec, synopsis, descrip); 00137 }
|
|
Definition at line 70 of file app_sendtext.c. References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_goto_if_exists(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_sendtext(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_channel::context, ast_channel::exten, LOCAL_USER_ADD, LOCAL_USER_REMOVE, ast_channel::lock, LOG_ERROR, LOG_WARNING, pbx_builtin_setvar_helper(), ast_channel::priority, ast_channel_tech::send_text, ast_channel::tech, and text. Referenced by load_module(). 00071 { 00072 int res = 0; 00073 struct localuser *u; 00074 char *status = "UNSUPPORTED"; 00075 char *parse = NULL; 00076 int priority_jump = 0; 00077 AST_DECLARE_APP_ARGS(args, 00078 AST_APP_ARG(text); 00079 AST_APP_ARG(options); 00080 ); 00081 00082 LOCAL_USER_ADD(u); 00083 00084 if (ast_strlen_zero(data)) { 00085 ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n"); 00086 LOCAL_USER_REMOVE(u); 00087 return -1; 00088 } else { 00089 parse = ast_strdupa(data); 00090 if (!parse) { 00091 ast_log(LOG_ERROR, "Out of memory!\n"); 00092 LOCAL_USER_REMOVE(u); 00093 return -1; 00094 } 00095 } 00096 00097 AST_STANDARD_APP_ARGS(args, parse); 00098 00099 if (args.options) { 00100 if (strchr(args.options, 'j')) 00101 priority_jump = 1; 00102 } 00103 00104 ast_mutex_lock(&chan->lock); 00105 if (!chan->tech->send_text) { 00106 ast_mutex_unlock(&chan->lock); 00107 /* Does not support transport */ 00108 if (priority_jump || option_priority_jumping) 00109 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); 00110 LOCAL_USER_REMOVE(u); 00111 return 0; 00112 } 00113 status = "FAILURE"; 00114 ast_mutex_unlock(&chan->lock); 00115 res = ast_sendtext(chan, args.text); 00116 if (!res) 00117 status = "SUCCESS"; 00118 pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status); 00119 LOCAL_USER_REMOVE(u); 00120 return 0; 00121 }
|
|
Cleanup all module structures, sockets, etc. This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).
Definition at line 123 of file app_sendtext.c. References app, and ast_unregister_application(). 00124 { 00125 int res; 00126 00127 res = ast_unregister_application(app); 00128 00129 STANDARD_HANGUP_LOCALUSERS; 00130 00131 return res; 00132 }
|
|
Provides a usecount. This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.
Definition at line 144 of file app_sendtext.c. References STANDARD_USECOUNT. 00145 { 00146 int res; 00147 00148 STANDARD_USECOUNT(res); 00149 00150 return res; 00151 }
|
|
Definition at line 49 of file app_sendtext.c. Referenced by load_module(), and unload_module(). |
|
Definition at line 53 of file app_sendtext.c. Referenced by load_module(). |
|
Definition at line 68 of file app_sendtext.c. |
|
Definition at line 66 of file app_sendtext.c. |
|
Definition at line 51 of file app_sendtext.c. Referenced by load_module(). |
|
Definition at line 47 of file app_sendtext.c. |