App to transmit a URL. More...
#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_WAIT = (1 << 0) } |
Functions | |
| AST_APP_OPTIONS (app_opts,{AST_APP_OPTION('w', OPTION_WAIT),}) | |
| AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Send URL Applications") | |
| static int | load_module (void) |
| static int | sendurl_exec (struct ast_channel *chan, void *data) |
| static int | unload_module (void) |
Variables | |
| static char * | app = "SendURL" |
| enum { ... } | option_flags |
App to transmit a URL.
Definition in file app_url.c.
| anonymous enum |
Definition at line 85 of file app_url.c.
00085 { 00086 OPTION_WAIT = (1 << 0), 00087 } option_flags;
| AST_APP_OPTIONS | ( | app_opts | ) |
| AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
| "Send URL Applications" | ||||
| ) |
| 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, | |
| void * | data | |||
| ) | [static] |
Definition at line 93 of file app_url.c.
References 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_frame::frametype, LOG_WARNING, OPTION_WAIT, pbx_builtin_setvar_helper(), status, ast_frame::subclass, 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) { 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); 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 }
| enum { ... } option_flags |
1.6.1