2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief App to transmit a URL
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
30 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
32 #include "asterisk/pbx.h"
33 #include "asterisk/module.h"
34 #include "asterisk/app.h"
35 #include "asterisk/channel.h"
37 static char *app
= "SendURL";
39 static char *synopsis
= "Send a URL";
41 static char *descrip
=
42 " SendURL(URL[,option]): Requests client go to URL (IAX2) or sends the \n"
43 "URL to the client (other channels).\n"
44 "Result is returned in the SENDURLSTATUS channel variable:\n"
45 " SUCCESS URL successfully sent to client\n"
46 " FAILURE Failed to send URL\n"
47 " NOLOAD Client failed to load URL (wait enabled)\n"
48 " UNSUPPORTED Channel does not support URL transport\n"
50 "If the option 'w' is specified, execution will wait for an\n"
51 "acknowledgement that the URL has been loaded before continuing\n"
53 "SendURL continues normally if the URL was sent correctly or if the channel\n"
54 "does not support HTML transport. Otherwise, the channel is hung up.\n";
57 OPTION_WAIT
= (1 << 0),
60 AST_APP_OPTIONS(app_opts
,{
61 AST_APP_OPTION('w', OPTION_WAIT
),
64 static int sendurl_exec(struct ast_channel
*chan
, void *data
)
69 char *status
= "FAILURE";
71 struct ast_flags flags
;
72 AST_DECLARE_APP_ARGS(args
,
77 if (ast_strlen_zero(data
)) {
78 ast_log(LOG_WARNING
, "SendURL requires an argument (URL)\n");
79 pbx_builtin_setvar_helper(chan
, "SENDURLSTATUS", status
);
83 tmp
= ast_strdupa(data
);
85 AST_STANDARD_APP_ARGS(args
, tmp
);
87 ast_app_parse_options(app_opts
, &flags
, opts
, args
.options
);
89 if (!ast_channel_supports_html(chan
)) {
90 /* Does not support transport */
91 pbx_builtin_setvar_helper(chan
, "SENDURLSTATUS", "UNSUPPORTED");
94 res
= ast_channel_sendurl(chan
, args
.url
);
96 pbx_builtin_setvar_helper(chan
, "SENDURLSTATUS", "FAILURE");
100 if (ast_test_flag(&flags
, OPTION_WAIT
)) {
102 /* Wait for an event */
103 res
= ast_waitfor(chan
, -1);
112 if (f
->frametype
== AST_FRAME_HTML
) {
113 switch(f
->subclass
) {
114 case AST_HTML_LDCOMPLETE
:
120 case AST_HTML_NOSUPPORT
:
121 /* Does not support transport */
122 status
= "UNSUPPORTED";
128 ast_log(LOG_WARNING
, "Don't know what to do with HTML subclass %d\n", f
->subclass
);
135 pbx_builtin_setvar_helper(chan
, "SENDURLSTATUS", status
);
139 static int unload_module(void)
141 return ast_unregister_application(app
);
144 static int load_module(void)
146 return ast_register_application(app
, sendurl_exec
, synopsis
, descrip
);
149 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Send URL Applications");