2 * Asterisk -- A telephony toolkit for Linux.
4 * App to transmit a URL
6 * Copyright (C) 1999, Mark Spencer
8 * Mark Spencer <markster@linux-support.net>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 #include <asterisk/lock.h>
15 #include <asterisk/file.h>
16 #include <asterisk/logger.h>
17 #include <asterisk/channel.h>
18 #include <asterisk/pbx.h>
19 #include <asterisk/module.h>
20 #include <asterisk/translate.h>
21 #include <asterisk/image.h>
26 static char *tdesc = "Send URL Applications";
28 static char *app = "SendURL";
30 static char *synopsis = "Send a URL";
32 static char *descrip =
33 " SendURL(URL[|option]): Requests client go to URL. If the client\n"
34 "does not support html transport, and there exists a step with\n"
35 "priority n + 101, then execution will continue at that step.\n"
36 "Otherwise, execution will continue at the next priority level.\n"
37 "SendURL only returns 0 if the URL was sent correctly or if\n"
38 "the channel does not support HTML transport, and -1 otherwise.\n"
39 "If the option 'wait' is specified, execution will wait for an\n"
40 "acknowledgement that the URL has been loaded before continuing\n"
41 "and will return -1 if the peer is unable to load the URL\n";
47 static int sendurl_exec(struct ast_channel *chan, void *data)
56 if (!data || !strlen((char *)data)) {
57 ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n");
60 strncpy(tmp, (char *)data, sizeof(tmp)-1);
62 strsep(&stringp, "|");
63 options = strsep(&stringp, "|");
64 if (options && !strcasecmp(options, "wait"))
67 if (!ast_channel_supports_html(chan)) {
68 /* Does not support transport */
69 if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
70 chan->priority += 100;
74 res = ast_channel_sendurl(chan, tmp);
78 /* Wait for an event */
79 res = ast_waitfor(chan, -1);
87 if (f->frametype == AST_FRAME_HTML) {
89 case AST_HTML_LDCOMPLETE:
94 case AST_HTML_NOSUPPORT:
95 /* Does not support transport */
96 if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
97 chan->priority += 100;
102 ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass);
110 LOCAL_USER_REMOVE(u);
114 int unload_module(void)
116 STANDARD_HANGUP_LOCALUSERS;
117 return ast_unregister_application(app);
120 int load_module(void)
122 return ast_register_application(app, sendurl_exec, synopsis, descrip);
125 char *description(void)
133 STANDARD_USECOUNT(res);
139 return ASTERISK_GPL_KEY;