2003-07-30 17:06:22 +04:00
|
|
|
/*
|
|
|
|
* 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 <jacko@xms.ms>
|
|
|
|
*/
|
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
#include <stdbool.h>
|
2003-07-30 17:06:22 +04:00
|
|
|
#include <stdio.h>
|
2004-08-08 15:39:31 +04:00
|
|
|
#include <stdlib.h>
|
2003-07-30 17:06:22 +04:00
|
|
|
#include <string.h>
|
|
|
|
#include "oslib/uri.h"
|
|
|
|
#include "oslib/wimp.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2004-04-13 03:59:01 +04:00
|
|
|
#include "netsurf/content/fetch.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "netsurf/desktop/browser.h"
|
|
|
|
#include "netsurf/riscos/theme.h"
|
|
|
|
#include "netsurf/desktop/gui.h"
|
|
|
|
#include "netsurf/riscos/gui.h"
|
2004-04-02 04:41:10 +04:00
|
|
|
#include "netsurf/riscos/url_protocol.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
#include "netsurf/utils/log.h"
|
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_URI
|
|
|
|
|
2003-07-30 17:06:22 +04:00
|
|
|
void ro_uri_message_received(uri_full_message_process*);
|
2004-04-02 04:41:10 +04:00
|
|
|
bool ro_uri_launch(char *uri);
|
|
|
|
void ro_uri_bounce(uri_full_message_return_result*);
|
|
|
|
|
2003-07-30 17:06:22 +04:00
|
|
|
|
|
|
|
void ro_uri_message_received(uri_full_message_process* uri_message)
|
|
|
|
{
|
2005-01-02 06:58:21 +03:00
|
|
|
uri_h uri_handle;
|
|
|
|
char* uri_requested;
|
|
|
|
int uri_length;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
uri_handle = uri_message->handle;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
if (!fetch_can_fetch(uri_message->uri)) return;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
uri_message->your_ref = uri_message->my_ref;
|
|
|
|
uri_message->action = message_URI_PROCESS_ACK;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)uri_message,
|
|
|
|
uri_message->sender);
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
xuri_request_uri(0, 0, 0, uri_handle, &uri_length);
|
|
|
|
uri_requested = calloc((unsigned int)uri_length, sizeof(char));
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
if (uri_requested == NULL)
|
|
|
|
return;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
xuri_request_uri(0, uri_requested, uri_length, uri_handle, NULL);
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2006-04-22 22:24:18 +04:00
|
|
|
browser_window_create(uri_requested, NULL, 0, true);
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
free(uri_requested);
|
2003-07-30 17:06:22 +04:00
|
|
|
}
|
2004-04-02 04:41:10 +04:00
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
bool ro_uri_launch(char *uri)
|
|
|
|
{
|
2004-04-02 04:41:10 +04:00
|
|
|
uri_h uri_handle;
|
|
|
|
wimp_t handle_task;
|
|
|
|
uri_dispatch_flags returned;
|
|
|
|
os_error *e;
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-06-29 03:57:26 +04:00
|
|
|
e = xuri_dispatch(uri_DISPATCH_INFORM_CALLER, uri, task_handle,
|
2005-01-02 06:58:21 +03:00
|
|
|
&returned, &handle_task, &uri_handle);
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
if (e || returned & 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-01-02 06:58:21 +03:00
|
|
|
void ro_uri_bounce(uri_full_message_return_result *message)
|
|
|
|
{
|
2004-04-02 04:41:10 +04:00
|
|
|
char uri_buf[512];
|
|
|
|
os_error *e;
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
if ((message->flags & 1) == 0) return;
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
e = xuri_request_uri(0, uri_buf, sizeof uri_buf, message->handle, 0);
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-06-29 03:57:26 +04:00
|
|
|
if (e) {
|
2005-01-02 06:58:21 +03:00
|
|
|
LOG(("xuri_request_uri: %d: %s", e->errnum, e->errmess));
|
|
|
|
return;
|
2004-06-29 03:57:26 +04:00
|
|
|
}
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
ro_url_load(uri_buf);
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
return;
|
|
|
|
}
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|