#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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .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 173 of file app_url.c.
References ast_register_application_xml, and sendurl_exec().
00174 { 00175 return ast_register_application_xml(app, sendurl_exec); 00176 }
static int sendurl_exec | ( | struct ast_channel * | chan, | |
const char * | data | |||
) | [static] |
Definition at line 93 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().
00094 { 00095 int res = 0; 00096 char *tmp; 00097 struct ast_frame *f; 00098 char *status = "FAILURE"; 00099 char *opts[0]; 00100 struct ast_flags flags; 00101 AST_DECLARE_APP_ARGS(args, 00102 AST_APP_ARG(url); 00103 AST_APP_ARG(options); 00104 ); 00105 00106 if (ast_strlen_zero(data)) { 00107 ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n"); 00108 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); 00109 return -1; 00110 } 00111 00112 tmp = ast_strdupa(data); 00113 00114 AST_STANDARD_APP_ARGS(args, tmp); 00115 if (args.argc == 2) 00116 ast_app_parse_options(app_opts, &flags, opts, args.options); 00117 00118 if (!ast_channel_supports_html(chan)) { 00119 /* Does not support transport */ 00120 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED"); 00121 return 0; 00122 } 00123 res = ast_channel_sendurl(chan, args.url); 00124 if (res == -1) { 00125 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE"); 00126 return res; 00127 } 00128 status = "SUCCESS"; 00129 if (ast_test_flag(&flags, OPTION_WAIT)) { 00130 for(;;) { 00131 /* Wait for an event */ 00132 res = ast_waitfor(chan, -1); 00133 if (res < 0) 00134 break; 00135 f = ast_read(chan); 00136 if (!f) { 00137 res = -1; 00138 status = "FAILURE"; 00139 break; 00140 } 00141 if (f->frametype == AST_FRAME_HTML) { 00142 switch (f->subclass.integer) { 00143 case AST_HTML_LDCOMPLETE: 00144 res = 0; 00145 ast_frfree(f); 00146 status = "NOLOAD"; 00147 goto out; 00148 break; 00149 case AST_HTML_NOSUPPORT: 00150 /* Does not support transport */ 00151 status = "UNSUPPORTED"; 00152 res = 0; 00153 ast_frfree(f); 00154 goto out; 00155 break; 00156 default: 00157 ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass.integer); 00158 }; 00159 } 00160 ast_frfree(f); 00161 } 00162 } 00163 out: 00164 pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status); 00165 return res; 00166 }
static int unload_module | ( | void | ) | [static] |
Definition at line 168 of file app_url.c.
References ast_unregister_application().
00169 { 00170 return ast_unregister_application(app); 00171 }
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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .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] |