#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
Go to the source code of this file.
Enumerations | |
enum | option_flags { OPTION_WAIT = (1 << 0) } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | load_module (void) |
static int | sendurl_exec (struct ast_channel *chan, const char *data) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Send URL 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 = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static char * | app = "SendURL" |
static struct ast_app_option | app_opts [128] = { [ 'w' ] = { .flag = OPTION_WAIT },} |
static struct ast_module_info * | ast_module_info = &__mod_info |
Definition in file app_url.c.
enum option_flags |
static int load_module | ( | void | ) | [static] |
Definition at line 177 of file app_url.c.
References ast_register_application_xml, and sendurl_exec().
00178 { 00179 return ast_register_application_xml(app, sendurl_exec); 00180 }
static int sendurl_exec | ( | struct ast_channel * | chan, | |
const char * | data | |||
) | [static] |
Definition at line 97 of file app_url.c.
References app_opts, args, AST_APP_ARG, ast_app_parse_options(), ast_channel_sendurl(), ast_channel_supports_html(), AST_DECLARE_APP_ARGS, AST_FRAME_HTML, ast_frfree, AST_HTML_LDCOMPLETE, AST_HTML_NOSUPPORT, ast_log(), ast_read(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_waitfor(), f, ast_flags::flags, LOG_WARNING, OPTION_WAIT, pbx_builtin_setvar_helper(), status, and url.
Referenced by load_module().
00098 { 00099 int res = 0; 00100 char *tmp; 00101 struct ast_frame *f; 00102 char *status = "FAILURE"; 00103 char *opts[0]; 00104 struct ast_flags flags = { 0 }; 00105 AST_DECLARE_APP_ARGS(args, 00106 AST_APP_ARG(url); 00107 AST_APP_ARG(options); 00108 ); 00109 00110 if (ast_strlen_zero(data)) { 00111 ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n"); 00112 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); 00113 return -1; 00114 } 00115 00116 tmp = ast_strdupa(data); 00117 00118 AST_STANDARD_APP_ARGS(args, tmp); 00119 if (args.argc == 2) 00120 ast_app_parse_options(app_opts, &flags, opts, args.options); 00121 00122 if (!ast_channel_supports_html(chan)) { 00123 /* Does not support transport */ 00124 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED"); 00125 return 0; 00126 } 00127 res = ast_channel_sendurl(chan, args.url); 00128 if (res == -1) { 00129 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE"); 00130 return res; 00131 } 00132 status = "SUCCESS"; 00133 if (ast_test_flag(&flags, OPTION_WAIT)) { 00134 for(;;) { 00135 /* Wait for an event */ 00136 res = ast_waitfor(chan, -1); 00137 if (res < 0) 00138 break; 00139 f = ast_read(chan); 00140 if (!f) { 00141 res = -1; 00142 status = "FAILURE"; 00143 break; 00144 } 00145 if (f->frametype == AST_FRAME_HTML) { 00146 switch (f->subclass.integer) { 00147 case AST_HTML_LDCOMPLETE: 00148 res = 0; 00149 ast_frfree(f); 00150 status = "NOLOAD"; 00151 goto out; 00152 break; 00153 case AST_HTML_NOSUPPORT: 00154 /* Does not support transport */ 00155 status = "UNSUPPORTED"; 00156 res = 0; 00157 ast_frfree(f); 00158 goto out; 00159 break; 00160 default: 00161 ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass.integer); 00162 }; 00163 } 00164 ast_frfree(f); 00165 } 00166 } 00167 out: 00168 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); 00169 return res; 00170 }
static int unload_module | ( | void | ) | [static] |
Definition at line 172 of file app_url.c.
References ast_unregister_application().
00173 { 00174 return ast_unregister_application(app); 00175 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Send URL 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 = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
struct ast_app_option app_opts[128] = { [ 'w' ] = { .flag = OPTION_WAIT },} [static] |
struct ast_module_info* ast_module_info = &__mod_info [static] |