From 7c474c848ee97bf0c72e5e216c36aaf6b6a3be91 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 30 Jul 2003 13:06:22 +0000 Subject: [project @ 2003-07-30 13:06:22 by jmb] Add support for Acorn URI Protocol and URI files (Rob Jackson) svn path=/import/netsurf/; revision=242 --- !NetSurf/!Boot | 17 ++++++++++ !NetSurf/!Boot,feb | 17 ++++++++++ !NetSurf/!Run,feb | 9 +++--- !NetSurf/URILaunch,feb | 1 + Docs/TODO-General | 4 +-- makefile | 2 +- riscos/gui.c | 80 ++++++++++++++++++++++++---------------------- riscos/gui.h | 41 ++++++++++++++++++++++++ riscos/uri.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ riscos/uri.h | 13 ++++++++ 10 files changed, 225 insertions(+), 46 deletions(-) create mode 100644 !NetSurf/!Boot create mode 100644 !NetSurf/!Boot,feb create mode 100644 !NetSurf/URILaunch,feb create mode 100644 riscos/gui.h create mode 100644 riscos/uri.c create mode 100644 riscos/uri.h diff --git a/!NetSurf/!Boot b/!NetSurf/!Boot new file mode 100644 index 000000000..e2e7e6ce1 --- /dev/null +++ b/!NetSurf/!Boot @@ -0,0 +1,17 @@ +Set NetSurf$Dir + +IconSprites .!Sprites +Set File$Type_F79 CSS + +| Acorn URI protocol +Set NetSurf$start_uri_handler "no" +RMEnsure AcornURI 0.10 Set NetSurf$start_uri_handler "yes" +RMEnsure AcornURI 0.10 RMLoad System:310.Modules.Network.URI +If "" = "yes" Then Desktop + +If "" = "" Then Set Alias$Open_URI_http .URILaunch +If "" = "" Then Set Alias$Open_URI_https .URILaunch +If "" = "" Then Set Alias$Open_URI_file .URILaunch + +| Claim URI files +If "" = "" Then Set Alias$@RunType_F91 .URILaunch diff --git a/!NetSurf/!Boot,feb b/!NetSurf/!Boot,feb new file mode 100644 index 000000000..e2e7e6ce1 --- /dev/null +++ b/!NetSurf/!Boot,feb @@ -0,0 +1,17 @@ +Set NetSurf$Dir + +IconSprites .!Sprites +Set File$Type_F79 CSS + +| Acorn URI protocol +Set NetSurf$start_uri_handler "no" +RMEnsure AcornURI 0.10 Set NetSurf$start_uri_handler "yes" +RMEnsure AcornURI 0.10 RMLoad System:310.Modules.Network.URI +If "" = "yes" Then Desktop + +If "" = "" Then Set Alias$Open_URI_http .URILaunch +If "" = "" Then Set Alias$Open_URI_https .URILaunch +If "" = "" Then Set Alias$Open_URI_file .URILaunch + +| Claim URI files +If "" = "" Then Set Alias$@RunType_F91 .URILaunch diff --git a/!NetSurf/!Run,feb b/!NetSurf/!Run,feb index 4adcb819d..fddf59b0c 100644 --- a/!NetSurf/!Run,feb +++ b/!NetSurf/!Run,feb @@ -1,15 +1,16 @@ |rafs_flush -Set NetSurf$Dir - -IconSprites .!Sprites -Set File$Type_F79 CSS +If "" = "" Then Obey .!Boot RMensure WindowManager 3.80 Error 0 NetSurf requires the Nested Window Manager. RMEnsure UtilityModule 3.70 RMensure CallASWI 0.00 RMload .CallASWI RMEnsure SharedUnixLibrary 1.00 RMLoad System:Modules.SharedULib + | drag the 'next' slot in the task manager to something huge and ridiculous, | and/or increase the number below Wimpslot -min 2000k + +Set NetSurf$running "yes" .!RunImage 2>.stderr +UnSet NetSurf$running diff --git a/!NetSurf/URILaunch,feb b/!NetSurf/URILaunch,feb new file mode 100644 index 000000000..f0d485ce4 --- /dev/null +++ b/!NetSurf/URILaunch,feb @@ -0,0 +1 @@ +If "" <> "yes" Then Run .!Run \ No newline at end of file diff --git a/Docs/TODO-General b/Docs/TODO-General index 93190c501..702ba6b9e 100644 --- a/Docs/TODO-General +++ b/Docs/TODO-General @@ -1,4 +1,4 @@ -$Id: TODO-General,v 1.4 2003/07/07 22:10:51 jmb Exp $ +$Id: TODO-General,v 1.5 2003/07/30 13:06:22 jmb Exp $ TODO-General for NetSurf. @@ -8,10 +8,8 @@ This file documents general things which need doing. Disk Cache Saving Printing -View Source Global Clipboard Support More Image file formats JavaScript? -URI Protocol support ANT URL protocol support #targets in URLS eg: http://www.moo.com/index.html#blah \ No newline at end of file diff --git a/makefile b/makefile index 9fcfbe89c..6b52124eb 100644 --- a/makefile +++ b/makefile @@ -13,7 +13,7 @@ OBJECTS_COMMON = cache.o content.o fetch.o fetchcache.o other.o \ OBJECTS = $(OBJECTS_COMMON) \ browser.o netsurf.o \ gif.o gui.o jpeg.o png.o theme.o plugin.o \ - options.o filetype.o font.o + options.o filetype.o font.o uri.o OBJECTS_DEBUG = $(OBJECTS_COMMON) \ netsurfd.o \ optionsd.o filetyped.o fontd.o diff --git a/riscos/gui.c b/riscos/gui.c index b4bad929f..4e24c9132 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -19,12 +19,15 @@ #include "oslib/osgbpb.h" #include "oslib/wimp.h" #include "oslib/wimpspriteop.h" +#include "oslib/uri.h" #include "netsurf/desktop/gui.h" #include "netsurf/desktop/netsurf.h" #include "netsurf/desktop/options.h" #include "netsurf/render/font.h" #include "netsurf/render/html.h" +#include "netsurf/riscos/gui.h" #include "netsurf/riscos/theme.h" +#include "netsurf/riscos/uri.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -138,32 +141,6 @@ int ro_y_units(unsigned long browser_units); unsigned long browser_x_units(int ro_units); unsigned long browser_y_units(int ro_units); -struct ro_gui_window -{ - gui_window_type type; - - union { - struct { - wimp_w window; - wimp_w toolbar; - int toolbar_width; - struct browser_window* bw; - } browser; - } data; - - char status[256]; - char title[256]; - char url[256]; - gui_window* next; - - int throbber; - float throbtime; - - gui_safety redraw_safety; - enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status; - int old_width; -}; - void ro_gui_window_click(gui_window* g, wimp_pointer* mouse); //void ro_gui_window_mouse_at(gui_window* g, wimp_pointer* mouse); void ro_gui_window_open(gui_window* g, wimp_open* open); @@ -366,7 +343,7 @@ ro_theme* current_theme = NULL; const char* BROWSER_VALIDATION = "\0"; const char* task_name = "NetSurf"; -const wimp_MESSAGE_LIST(3) task_messages = { {message_DATA_SAVE, message_DATA_LOAD, 0} }; +const wimp_MESSAGE_LIST(4) task_messages = { {message_DATA_SAVE, message_DATA_LOAD, message_URI_PROCESS, 0} }; wimp_t task_handle; wimp_i ro_gui_iconbar_i; @@ -2007,11 +1984,24 @@ void gui_multitask(void) case wimp_USER_MESSAGE : case wimp_USER_MESSAGE_RECORDED : case wimp_USER_MESSAGE_ACKNOWLEDGE: + fprintf(stderr, "MESSAGE %d (%x) HAS ARRIVED\n", block.message.action, block.message.action); - if (block.message.action == message_DATA_SAVE) - ro_msg_datasave(&(block.message)); - else if (block.message.action == message_DATA_LOAD) - ro_msg_dataload(&(block.message)); + + switch (block.message.action) + { + case message_DATA_SAVE : + ro_msg_datasave(&(block.message)); + break; + + case message_DATA_LOAD : + ro_msg_dataload(&(block.message)); + break; + + case message_URI_PROCESS : + ro_uri_message_received(&(block.message)); + break; + } + if (block.message.action == message_QUIT) netsurf_quit = 1; else @@ -2317,14 +2307,28 @@ void gui_poll(void) case wimp_USER_MESSAGE : case wimp_USER_MESSAGE_RECORDED : case wimp_USER_MESSAGE_ACKNOWLEDGE: + fprintf(stderr, "MESSAGE %d (%x) HAS ARRIVED\n", block.message.action, block.message.action); - if (block.message.action == message_DATA_SAVE) - ro_msg_datasave(&(block.message)); - else if (block.message.action == message_DATA_LOAD) - ro_msg_dataload(&(block.message)); - else if (block.message.action == message_QUIT) - netsurf_quit = 1; - break; + + switch (block.message.action) + { + case message_DATA_SAVE : + ro_msg_datasave(&(block.message)); + break; + + case message_DATA_LOAD : + ro_msg_dataload(&(block.message)); + break; + + case message_URI_PROCESS : + ro_uri_message_received(&(block.message)); + break; + + case message_QUIT : + netsurf_quit = 1; + break; + } + break; } } while (finished == 0); diff --git a/riscos/gui.h b/riscos/gui.h new file mode 100644 index 000000000..3426c59d3 --- /dev/null +++ b/riscos/gui.h @@ -0,0 +1,41 @@ +/* + * 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 Phil Mellor + */ + +#ifndef _NETSURF_RISCOS_GUI_H_ +#define _NETSURF_RISCOS_GUI_H_ + +#include "netsurf/desktop/browser.h" +#include "netsurf/desktop/gui.h" +#include "oslib/wimp.h" + +struct ro_gui_window +{ + gui_window_type type; + + union { + struct { + wimp_w window; + wimp_w toolbar; + int toolbar_width; + struct browser_window* bw; + } browser; + } data; + + char status[256]; + char title[256]; + char url[256]; + gui_window* next; + + int throbber; + float throbtime; + + gui_safety redraw_safety; + enum { drag_NONE, drag_UNKNOWN, drag_BROWSER_TEXT_SELECTION } drag_status; + int old_width; +}; + +#endif diff --git a/riscos/uri.c b/riscos/uri.c new file mode 100644 index 000000000..46afa76a3 --- /dev/null +++ b/riscos/uri.c @@ -0,0 +1,87 @@ +/* + * 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 Rob Jackson + */ + +#include +#include +#include "oslib/uri.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/utils/log.h" +#include "netsurf/utils/utils.h" + +void ro_uri_message_received(uri_full_message_process*); + +extern ro_theme* current_theme; + +void ro_uri_message_received(uri_full_message_process* uri_message) +{ + uri_h uri_handle; + char* uri_requested; + char* temp; + + struct browser_window* bw; + int uri_length; + int i; + + uri_handle = uri_message->handle; + + LOG(("URI message... %s, handle = %d", uri_message->uri, + (int)uri_message->handle)); + + if ( (strspn(uri_message->uri, "http://") != strlen("http://")) && + (strspn(uri_message->uri, "https://") != strlen("https://")) && + (strspn(uri_message->uri, "file:/") != strlen("file:/")) ) + return; + + else LOG(("URI message deemed relevant")); + + uri_message->your_ref = uri_message->my_ref; + uri_message->action = message_URI_PROCESS_ACK; + + xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE, + (wimp_message*)uri_message, + uri_message->sender); + + xuri_request_uri(0, 0, 0, uri_handle, &uri_length); + uri_requested = xcalloc(uri_length, sizeof(char)); + + if (uri_requested == NULL) + return; + + xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL); + + /* Kludge for file:/ URLs (changes them into file:/// URLs) */ + if( (strncasecmp(uri_requested, "file:/", 6) == 0) && + (strncasecmp(uri_requested, "file://", 7) != 0) ) { + + temp = xcalloc(strlen(uri_requested) + 5, sizeof(char)); + strcpy(temp, "file:///"); + for(i=6; i!=strlen(uri_requested); i++) { + + temp[i+2] = uri_message->uri[i]; + } + xfree(uri_requested); + uri_requested = strdup(temp); + xfree(temp); + } + + bw = create_browser_window(browser_TITLE | browser_TOOLBAR + | browser_SCROLL_X_ALWAYS | browser_SCROLL_Y_ALWAYS, 640, 480); + + gui_window_show(bw->window); + browser_window_open_location(bw, uri_requested); + + wimp_set_caret_position(bw->window->data.browser.toolbar, + ro_theme_icon(current_theme, THEME_TOOLBAR, "TOOLBAR_URL"), + 0,0,-1, (int) strlen(bw->window->url) - 1); + + + xfree(uri_requested); +} diff --git a/riscos/uri.h b/riscos/uri.h new file mode 100644 index 000000000..70564bfa7 --- /dev/null +++ b/riscos/uri.h @@ -0,0 +1,13 @@ +/* + * 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 Rob Jackson + */ + +#ifndef _NETSURF_RISCOS_URI_H_ +#define _NETSURF_RISCOS_URI_H_ + +static void ro_uri_message_received(uri_full_message_process*); + +#endif -- cgit v1.2.3