2003-07-30 17:06:22 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Rob Jackson <jacko@xms.ms>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-07-30 17:06:22 +04:00
|
|
|
*/
|
|
|
|
|
2008-07-27 03:42:24 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
|
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"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#include "content/fetch.h"
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "riscos/gui.h"
|
2008-07-27 03:42:24 +04:00
|
|
|
#include "riscos/uri.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/url_protocol.h"
|
|
|
|
#include "utils/log.h"
|
2011-09-27 16:02:15 +04:00
|
|
|
#include "utils/nsurl.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/utils.h"
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2008-07-27 03:42:24 +04:00
|
|
|
void ro_uri_message_received(wimp_message *msg)
|
2003-07-30 17:06:22 +04:00
|
|
|
{
|
2008-07-27 03:42:24 +04:00
|
|
|
uri_full_message_process *uri_message = (uri_full_message_process *)msg;
|
2005-01-02 06:58:21 +03:00
|
|
|
uri_h uri_handle;
|
|
|
|
char* uri_requested;
|
|
|
|
int uri_length;
|
2011-09-27 16:02:15 +04:00
|
|
|
nsurl *nsurl;
|
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
|
|
|
|
2011-09-27 16:02:15 +04:00
|
|
|
if (nsurl_create(uri_message->uri, &nsurl) != NSERROR_OK) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fetch_can_fetch(nsurl)) {
|
|
|
|
nsurl_unref(nsurl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsurl_unref(nsurl);
|
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));
|
|
|
|
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
|
|
|
|
2008-08-24 14:31:38 +04:00
|
|
|
browser_window_create(uri_requested, NULL, 0, true, false);
|
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
|
|
|
|
2009-07-01 16:05:51 +04:00
|
|
|
bool ro_uri_launch(const char *uri)
|
2005-01-02 06:58:21 +03:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2008-07-27 03:42:24 +04:00
|
|
|
void ro_uri_bounce(wimp_message *msg)
|
2005-01-02 06:58:21 +03:00
|
|
|
{
|
2008-07-27 03:42:24 +04:00
|
|
|
uri_full_message_process *message = (uri_full_message_process *)msg;
|
2009-07-01 16:05:51 +04:00
|
|
|
int size;
|
|
|
|
char *uri_buf;
|
2004-04-02 04:41:10 +04:00
|
|
|
os_error *e;
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2008-07-27 03:42:24 +04:00
|
|
|
if ((message->flags & 1) == 0)
|
|
|
|
return;
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2009-07-01 16:05:51 +04:00
|
|
|
/* Get required buffer size */
|
|
|
|
e = xuri_request_uri(0, NULL, 0, message->handle, &size);
|
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
|
|
|
|
2009-07-01 16:05:51 +04:00
|
|
|
uri_buf = malloc(size);
|
|
|
|
if (uri_buf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Get URI */
|
|
|
|
e = xuri_request_uri(0, uri_buf, size, message->handle, 0);
|
|
|
|
if (e) {
|
|
|
|
LOG(("xuri_request_uri: %d: %s", e->errnum, e->errmess));
|
|
|
|
free(uri_buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
ro_url_load(uri_buf);
|
2004-04-02 19:16:15 +04:00
|
|
|
|
2009-07-01 16:05:51 +04:00
|
|
|
free(uri_buf);
|
|
|
|
|
2004-04-02 04:41:10 +04:00
|
|
|
return;
|
|
|
|
}
|