diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2003-12-27 04:50:02 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2003-12-27 04:50:02 +0000 |
commit | fe1e4efac27026832852b3d70ce4e69aa004f57f (patch) | |
tree | 25c3cdaec79348b5798fe09e36b6b48fb75a9a45 /riscos | |
parent | 02915bb58365f783b5ebed4612ccb19840bb6157 (diff) | |
download | netsurf-fe1e4efac27026832852b3d70ce4e69aa004f57f.tar.gz netsurf-fe1e4efac27026832852b3d70ce4e69aa004f57f.tar.bz2 |
[project @ 2003-12-27 04:50:02 by jmb]
Add rudimentary ANT URL protocol support
svn path=/import/netsurf/; revision=458
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/gui.c | 13 | ||||
-rw-r--r-- | riscos/url.c | 76 | ||||
-rw-r--r-- | riscos/url.h | 15 |
3 files changed, 103 insertions, 1 deletions
diff --git a/riscos/gui.c b/riscos/gui.c index 1df4b19cf..a00857c64 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -14,6 +14,7 @@ #include <string.h> #include <time.h> #include <unixlib/local.h> +#include "oslib/inetsuite.h" #include "oslib/os.h" #include "oslib/osfile.h" #include "oslib/plugin.h" @@ -31,6 +32,7 @@ #include "netsurf/riscos/plugin.h" #include "netsurf/riscos/theme.h" #include "netsurf/riscos/uri.h" +#include "netsurf/riscos/url.h" #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" #include "netsurf/utils/utils.h" @@ -46,12 +48,13 @@ bool gui_reformat_pending = false; /**< Some windows have been resized, and should be reformatted. */ static wimp_t task_handle; /**< RISC OS wimp task handle. */ /** Accepted wimp user messages. */ -static const wimp_MESSAGE_LIST(24) task_messages = { { +static const wimp_MESSAGE_LIST(25) task_messages = { { message_DATA_SAVE, message_DATA_SAVE_ACK, message_DATA_LOAD, message_DATA_OPEN, message_URI_PROCESS, + message_INET_SUITE_OPEN_URL, message_PLUG_IN_OPENING, message_PLUG_IN_CLOSED, message_PLUG_IN_RESHAPE_REQUEST, @@ -344,6 +347,10 @@ void gui_poll(bool active) ro_uri_message_received(&(block.message)); break; + case message_INET_SUITE_OPEN_URL: + ro_url_message_received(&(block.message)); + break; + case message_PLUG_IN_OPENING: case message_PLUG_IN_CLOSED: case message_PLUG_IN_RESHAPE_REQUEST: @@ -502,6 +509,10 @@ void gui_multitask(void) ro_uri_message_received(&(block.message)); break; + case message_INET_SUITE_OPEN_URL: + ro_url_message_received(&(block.message)); + break; + case message_PLUG_IN_OPENING: case message_PLUG_IN_CLOSED: case message_PLUG_IN_RESHAPE_REQUEST: diff --git a/riscos/url.c b/riscos/url.c new file mode 100644 index 000000000..681e4a35f --- /dev/null +++ b/riscos/url.c @@ -0,0 +1,76 @@ +/* + * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * Licensed under the GNU General Public License, + * http://www.opensource.org/licenses/gpl-license + * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk> + * Shamelessly hacked from Rob Jackson's URI handler (see uri.c) + */ + +#include <stdio.h> +#include <string.h> +#include "oslib/inetsuite.h" +#include "oslib/wimp.h" +#include "netsurf/desktop/browser.h" +#include "netsurf/riscos/theme.h" +#include "netsurf/desktop/gui.h" +#include "netsurf/riscos/gui.h" +#include "netsurf/riscos/url.h" +#include "netsurf/utils/log.h" +#include "netsurf/utils/utils.h" + +void ro_url_message_received(wimp_message* message) +{ + char* uri_requested = NULL; + struct browser_window* bw; + inetsuite_message_open_url *url_message = (inetsuite_message_open_url*)&message->data; + + if (strlen(url_message->url) > 0) { + uri_requested = xstrdup(url_message->url); + LOG(("%s", url_message->url)); + } + else { + + /* TODO - handle indirected message data */ + return; +#if 0 + if (url_message->indirect.url.offset == 0 || + url_message->indirect.url.offset > 256) { + /* pointer to shared memory */ + LOG(("shared: %x", url_message->indirect.url.pointer)); + uri_requested = xstrdup(url_message->indirect.url.pointer); + } + else { /* offset into message block */ + LOG(("in message")); + uri_requested = xstrdup((char*)&url_message[url_message->indirect.url.offset]); + } + LOG(("%s", uri_requested)); +#endif + } + + if ( (strspn(uri_requested, "http://") != strlen("http://")) && + (strspn(uri_requested, "https://") != strlen("https://")) && + (strspn(uri_requested, "file:/") != strlen("file:/")) ) { + xfree(uri_requested); + return; + } + + /* send ack */ + message->your_ref = message->my_ref; + xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE, message, + message->sender); + + /* create new browser window */ + bw = create_browser_window(browser_TITLE | browser_TOOLBAR + | browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 640, 480, NULL); + + gui_window_show(bw->window); + browser_window_open_location(bw, uri_requested); + + wimp_set_caret_position(bw->window->data.browser.toolbar, + ICON_TOOLBAR_URL, + 0,0,-1, (int) strlen(bw->window->url) - 1); + + xfree(uri_requested); + + return; +} diff --git a/riscos/url.h b/riscos/url.h new file mode 100644 index 000000000..01b99b7c1 --- /dev/null +++ b/riscos/url.h @@ -0,0 +1,15 @@ +/* + * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * Licensed under the GNU General Public License, + * http://www.opensource.org/licenses/gpl-license + * Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk> + */ + +#ifndef _NETSURF_RISCOS_URL_H_ +#define _NETSURF_RISCOS_URL_H_ + +#include "oslib/wimp.h" + +void ro_url_message_received(wimp_message *message); + +#endif |