#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"
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 | sendurl_exec (struct ast_channel *chan, void *data) |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
char * | app = "SendURL" |
char * | descrip |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
char * | synopsis = "Send a URL" |
char * | tdesc = "Send URL Applications" |
Definition in file app_url.c.
|
Provides a description of the module.
Definition at line 181 of file app_url.c. 00182 {
00183 return tdesc;
00184 }
|
|
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 193 of file app_url.c. 00194 {
00195 return ASTERISK_GPL_KEY;
00196 }
|
|
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 176 of file app_url.c. References app, ast_register_application(), descrip, sendurl_exec(), and synopsis. 00177 { 00178 return ast_register_application(app, sendurl_exec, synopsis, descrip); 00179 }
|
|
Definition at line 74 of file app_url.c. References ast_channel_sendurl(), ast_channel_supports_html(), ast_frfree(), ast_goto_if_exists(), AST_HTML_LDCOMPLETE, AST_HTML_NOSUPPORT, ast_log(), ast_read(), ast_strdupa, ast_strlen_zero(), ast_waitfor(), ast_channel::context, ast_channel::exten, ast_frame::frametype, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, LOG_WARNING, pbx_builtin_setvar_helper(), ast_channel::priority, strsep(), and ast_frame::subclass. Referenced by load_module(). 00075 { 00076 int res = 0; 00077 struct localuser *u; 00078 char *tmp; 00079 char *options; 00080 int local_option_wait=0; 00081 int local_option_jump = 0; 00082 struct ast_frame *f; 00083 char *stringp=NULL; 00084 char *status = "FAILURE"; 00085 00086 if (ast_strlen_zero(data)) { 00087 ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n"); 00088 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); 00089 return -1; 00090 } 00091 00092 LOCAL_USER_ADD(u); 00093 00094 tmp = ast_strdupa(data); 00095 if (!tmp) { 00096 ast_log(LOG_ERROR, "Out of memory\n"); 00097 LOCAL_USER_REMOVE(u); 00098 return -1; 00099 } 00100 00101 stringp=tmp; 00102 strsep(&stringp, "|"); 00103 options = strsep(&stringp, "|"); 00104 if (options && !strcasecmp(options, "wait")) 00105 local_option_wait = 1; 00106 if (options && !strcasecmp(options, "j")) 00107 local_option_jump = 1; 00108 00109 if (!ast_channel_supports_html(chan)) { 00110 /* Does not support transport */ 00111 if (local_option_jump || option_priority_jumping) 00112 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); 00113 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED"); 00114 LOCAL_USER_REMOVE(u); 00115 return 0; 00116 } 00117 res = ast_channel_sendurl(chan, tmp); 00118 if (res == -1) { 00119 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE"); 00120 LOCAL_USER_REMOVE(u); 00121 return res; 00122 } 00123 status = "SUCCESS"; 00124 if (local_option_wait) { 00125 for(;;) { 00126 /* Wait for an event */ 00127 res = ast_waitfor(chan, -1); 00128 if (res < 0) 00129 break; 00130 f = ast_read(chan); 00131 if (!f) { 00132 res = -1; 00133 status = "FAILURE"; 00134 break; 00135 } 00136 if (f->frametype == AST_FRAME_HTML) { 00137 switch(f->subclass) { 00138 case AST_HTML_LDCOMPLETE: 00139 res = 0; 00140 ast_frfree(f); 00141 status = "NOLOAD"; 00142 goto out; 00143 break; 00144 case AST_HTML_NOSUPPORT: 00145 /* Does not support transport */ 00146 status ="UNSUPPORTED"; 00147 if (local_option_jump || option_priority_jumping) 00148 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); 00149 res = 0; 00150 goto out; 00151 break; 00152 default: 00153 ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass); 00154 }; 00155 } 00156 ast_frfree(f); 00157 } 00158 } 00159 out: 00160 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); 00161 LOCAL_USER_REMOVE(u); 00162 return res; 00163 }
|
|
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 165 of file app_url.c. References app, and ast_unregister_application(). 00166 { 00167 int res; 00168 00169 res = ast_unregister_application(app); 00170 00171 STANDARD_HANGUP_LOCALUSERS; 00172 00173 return res; 00174 }
|
|
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 186 of file app_url.c. References STANDARD_USECOUNT. 00187 { 00188 int res; 00189 STANDARD_USECOUNT(res); 00190 return res; 00191 }
|
|
Definition at line 45 of file app_url.c. Referenced by load_module(), and unload_module(). |
|
Definition at line 49 of file app_url.c. Referenced by load_module(). |
|
|
|
|
|
Definition at line 47 of file app_url.c. Referenced by load_module(). |
|
|