diff options
-rw-r--r-- | desktop/browser.c | 14 | ||||
-rw-r--r-- | desktop/gui.h | 2 | ||||
-rw-r--r-- | riscos/gui.c | 26 | ||||
-rw-r--r-- | riscos/uri.c | 38 | ||||
-rw-r--r-- | riscos/uri.h | 2 | ||||
-rw-r--r-- | riscos/url_protocol.c | 55 | ||||
-rw-r--r-- | riscos/url_protocol.h | 3 |
7 files changed, 135 insertions, 5 deletions
diff --git a/desktop/browser.c b/desktop/browser.c index 8735a7ca2..149f5a2e2 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -162,16 +162,26 @@ void browser_window_go_post(struct browser_window *bw, const char *url, browser_window_set_status(bw, messages_get("Loading")); bw->history_add = history_add; bw->time0 = clock(); - if (strncmp(url2, "about:", 6) == 0) + if (strncmp(url2, "about:", 6) == 0) { c = about_create(url2, browser_window_callback, bw, 0, gui_window_get_width(bw->window), 0); - else + } + /* check that we can handle the URL - just http/https/file for now */ + else if (strncmp(url2, "http:", 5) != 0 && strncmp(url2, "https:", 6) != 0 && + strncmp(url2, "file:", 5) != 0) { + gui_launch_url(url2); + browser_window_set_status(bw, messages_get("LaunchURL")); + free(url2); + return; + } + else { c = fetchcache(url2, 0, browser_window_callback, bw, 0, gui_window_get_width(bw->window), 0, false, post_urlenc, post_multipart, true); + } free(url2); if (!c) { browser_window_set_status(bw, messages_get("FetchFailed")); diff --git a/desktop/gui.h b/desktop/gui.h index 684332c56..9bb8412e4 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -55,6 +55,8 @@ void gui_gadget_combo(struct browser_window* bw, struct form_control* g, unsigne void gui_window_place_caret(gui_window *g, int x, int y, int height); +void gui_launch_url(char *url); + void warn_user(const char *warning); #endif diff --git a/riscos/gui.c b/riscos/gui.c index dee2320a0..9a4d9ab1d 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -61,7 +61,7 @@ gui_window *over_window = 0; /**< Window which the pointer is over. */ bool gui_reformat_pending = false; /**< Some windows have been resized, and should be reformatted. */ gui_drag_type gui_current_drag_type; -static wimp_t task_handle; /**< RISC OS wimp task handle. */ +wimp_t task_handle; /**< RISC OS wimp task handle. */ static clock_t gui_last_poll; /**< Time of last wimp_poll. */ osspriteop_area *pointers; /**< Sprite area containing pointer data */ gui_pointer_shape curr_pointer; /**< Current shape of the pointer */ @@ -74,6 +74,7 @@ static const wimp_MESSAGE_LIST(26) task_messages = { { message_MENU_WARNING, #ifdef WITH_URI message_URI_PROCESS, + message_URI_RETURN_RESULT, #endif #ifdef WITH_URL message_INET_SUITE_OPEN_URL, @@ -544,6 +545,15 @@ void gui_window_set_pointer(gui_pointer_shape shape) curr_pointer = shape; } +void gui_launch_url(char *url) { + /* Try ant broadcast first */ + if (!ro_url_broadcast(url)) + /* then uri */ + if (!ro_uri_launch(url)) + /* then ant load */ + ro_url_load(url); +} + /** * Handle Redraw_Window_Request events. @@ -734,12 +744,22 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message) #ifdef WITH_URI case message_URI_PROCESS: - ro_uri_message_received(message); + if (event != wimp_USER_MESSAGE_ACKNOWLEDGE) + ro_uri_message_received(message); + break; + case message_URI_RETURN_RESULT: + if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) + ro_uri_bounce(message); break; #endif #ifdef WITH_URL case message_INET_SUITE_OPEN_URL: - ro_url_message_received(message); + if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) { + ro_url_bounce(message); + } + else { + ro_url_message_received(message); + } break; #endif #ifdef WITH_PLUGIN diff --git a/riscos/uri.c b/riscos/uri.c index ae13ba0ea..4e0205391 100644 --- a/riscos/uri.c +++ b/riscos/uri.c @@ -5,6 +5,7 @@ * Copyright 2003 Rob Jackson <jacko@xms.ms> */ +#include <stdbool.h> #include <stdio.h> #include <string.h> #include "oslib/uri.h" @@ -14,12 +15,17 @@ #include "netsurf/riscos/theme.h" #include "netsurf/desktop/gui.h" #include "netsurf/riscos/gui.h" +#include "netsurf/riscos/url_protocol.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" #ifdef WITH_URI void ro_uri_message_received(uri_full_message_process*); +bool ro_uri_launch(char *uri); +void ro_uri_bounce(uri_full_message_return_result*); + +extern wimp_t task_handle; void ro_uri_message_received(uri_full_message_process* uri_message) @@ -61,4 +67,36 @@ void ro_uri_message_received(uri_full_message_process* uri_message) xfree(uri_requested); } + +bool ro_uri_launch(char *uri) { + + uri_h uri_handle; + wimp_t handle_task; + uri_dispatch_flags returned; + os_error *e; + + e = xuri_dispatch(0, uri, task_handle, &returned, &handle_task, &uri_handle); + + if (e || returned & 1) { + return false; + } + + return true; +} + +void ro_uri_bounce(uri_full_message_return_result *message) { + + char uri_buf[512]; + os_error *e; + + if ((message->flags & 1) == 0) return; + + e = xuri_request_uri(0, uri_buf, sizeof uri_buf, message->handle, 0); + + if (e) return; + + ro_url_load(uri_buf); + + return; +} #endif diff --git a/riscos/uri.h b/riscos/uri.h index a7eb5d198..24774bc9f 100644 --- a/riscos/uri.h +++ b/riscos/uri.h @@ -11,5 +11,7 @@ #include "oslib/wimp.h" void ro_uri_message_received(wimp_message *message); +bool ro_uri_launch(char *uri); +void ro_uri_bounce(wimp_message *message); #endif diff --git a/riscos/url_protocol.c b/riscos/url_protocol.c index 1553d17ac..e1b32e691 100644 --- a/riscos/url_protocol.c +++ b/riscos/url_protocol.c @@ -15,6 +15,7 @@ #include "netsurf/riscos/theme.h" #include "netsurf/desktop/gui.h" #include "netsurf/riscos/gui.h" +#include "netsurf/riscos/uri.h" #include "netsurf/riscos/url_protocol.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -125,3 +126,57 @@ char *read_string_value(os_string_value string, char *msg) { if(string.offset > 256) return string.pointer; return &msg[string.offset]; } + +bool ro_url_broadcast(char *url) { + + inetsuite_full_message_open_url_direct message; + os_error *e; + int len = (strlen(url)>235) ? 235 : strlen(url); + + message.size = (((20+len-1)+3) & ~3); + message.your_ref = 0; + message.action = message_INET_SUITE_OPEN_URL; + + *message.url = 0; + strncat(message.url, url, 235); + e = xwimp_send_message(wimp_USER_MESSAGE_RECORDED, + (wimp_message*)&message, 0); + if (e) { + return false; + } + + return true; +} + +bool ro_url_load(char *url) { + + char url_buf[512]; + char *colon; + os_error *e; + + colon = strchr(url, ':'); + if (!colon) return false; + + strcpy(url_buf, "Alias$URLOpen_"); + strncat(url_buf, url, colon-url); + if (!getenv(url_buf)) return false; + + strcat(url_buf, " "); + strncat(url_buf, url, 512-strlen(url_buf)-1); + + e = xwimp_start_task(url_buf+5, 0); + + if (e) { + return false; + } + + return true; +} + +void ro_url_bounce(wimp_message *message) { + + inetsuite_message_open_url *url_message = (inetsuite_message_open_url*)&message->data; + + /* ant broadcast bounced -> try uri broadcast / load */ + ro_uri_launch(url_message->url); +} diff --git a/riscos/url_protocol.h b/riscos/url_protocol.h index 01b99b7c1..4e06d462a 100644 --- a/riscos/url_protocol.h +++ b/riscos/url_protocol.h @@ -11,5 +11,8 @@ #include "oslib/wimp.h" void ro_url_message_received(wimp_message *message); +bool ro_url_broadcast(char *url); +bool ro_url_load(char *url); +void ro_url_bounce(wimp_message *message); #endif |