2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2008-06-07 23:00:46 +04:00
|
|
|
* Copyright 2004-2008 James Bursa <bursa@users.sourceforge.net>
|
2003-06-30 16:44:03 +04:00
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
2005-03-20 17:57:19 +03:00
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2004-07-19 02:21:32 +04:00
|
|
|
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
|
2009-01-31 16:50:17 +03:00
|
|
|
* Copyright 2004-2009 John Tytgat <joty@netsurf-browser.org>
|
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/>.
|
2002-09-11 18:24:02 +04:00
|
|
|
*/
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <assert.h>
|
2004-07-17 17:00:38 +04:00
|
|
|
#include <errno.h>
|
2005-02-08 02:00:09 +03:00
|
|
|
#include <signal.h>
|
2003-11-08 02:51:13 +03:00
|
|
|
#include <unixlib/local.h>
|
2014-06-04 19:44:29 +04:00
|
|
|
#include <fpu_control.h>
|
|
|
|
#include <oslib/help.h>
|
|
|
|
#include <oslib/uri.h>
|
|
|
|
#include <oslib/inetsuite.h>
|
|
|
|
#include <oslib/pdriver.h>
|
|
|
|
#include <oslib/osfile.h>
|
|
|
|
#include <oslib/hourglass.h>
|
|
|
|
#include <oslib/osgbpb.h>
|
|
|
|
#include <oslib/osbyte.h>
|
|
|
|
#include <oslib/osmodule.h>
|
|
|
|
#include <oslib/osfscontrol.h>
|
|
|
|
|
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "utils/nsoption.h"
|
2014-02-01 14:45:20 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "utils/file.h"
|
|
|
|
#include "utils/filename.h"
|
2014-02-01 14:45:20 +04:00
|
|
|
#include "utils/url.h"
|
2014-05-27 03:08:04 +04:00
|
|
|
#include "utils/corestrings.h"
|
2016-05-30 13:29:39 +03:00
|
|
|
#include "netsurf/fetch.h"
|
2016-05-30 13:23:32 +03:00
|
|
|
#include "netsurf/misc.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "netsurf/content.h"
|
2016-05-30 13:51:10 +03:00
|
|
|
#include "netsurf/netsurf.h"
|
2016-05-30 19:32:57 +03:00
|
|
|
#include "netsurf/browser_window.h"
|
2016-06-14 01:34:45 +03:00
|
|
|
#include "netsurf/cookie_db.h"
|
|
|
|
#include "netsurf/url_db.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "desktop/save_complete.h"
|
2016-12-29 17:51:43 +03:00
|
|
|
#include "desktop/hotlist.h"
|
2014-06-05 15:06:47 +04:00
|
|
|
#include "content/backing_store.h"
|
2014-02-01 14:45:20 +04:00
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/gui.h"
|
2015-04-16 01:57:39 +03:00
|
|
|
#include "riscos/bitmap.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "riscos/wimputils.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "riscos/hotlist.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "riscos/buffer.h"
|
|
|
|
#include "riscos/textselection.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/print.h"
|
|
|
|
#include "riscos/save.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "riscos/dialog.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/message.h"
|
|
|
|
#include "riscos/help.h"
|
|
|
|
#include "riscos/query.h"
|
|
|
|
#include "riscos/window.h"
|
|
|
|
#include "riscos/iconbar.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "riscos/sslcert.h"
|
2017-05-29 00:07:33 +03:00
|
|
|
#include "riscos/local_history.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "riscos/global_history.h"
|
|
|
|
#include "riscos/cookies.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/uri.h"
|
|
|
|
#include "riscos/url_protocol.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "riscos/mouse.h"
|
2014-02-02 02:17:36 +04:00
|
|
|
#include "riscos/ucstables.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "riscos/filetype.h"
|
2014-06-05 18:14:49 +04:00
|
|
|
#include "riscos/font.h"
|
2014-06-06 02:01:37 +04:00
|
|
|
#include "riscos/toolbar.h"
|
2014-06-04 19:44:29 +04:00
|
|
|
#include "riscos/content-handlers/artworks.h"
|
|
|
|
#include "riscos/content-handlers/draw.h"
|
|
|
|
#include "riscos/content-handlers/sprite.h"
|
2005-04-05 02:14:51 +04:00
|
|
|
|
2014-10-13 03:56:09 +04:00
|
|
|
bool riscos_done = false;
|
|
|
|
|
2006-07-16 20:52:28 +04:00
|
|
|
extern bool ro_plot_patterned_lines;
|
|
|
|
|
2005-04-22 01:36:23 +04:00
|
|
|
int os_version = 0;
|
|
|
|
|
2005-06-27 02:25:49 +04:00
|
|
|
const char * const __dynamic_da_name = "NetSurf"; /**< For UnixLib. */
|
2005-01-29 19:17:23 +03:00
|
|
|
int __dynamic_da_max_size = 128 * 1024 * 1024; /**< For UnixLib. */
|
2004-12-09 13:30:44 +03:00
|
|
|
int __feature_imagefs_is_file = 1; /**< For UnixLib. */
|
2004-07-31 16:56:25 +04:00
|
|
|
/* default filename handling */
|
|
|
|
int __riscosify_control = __RISCOSIFY_NO_SUFFIX |
|
|
|
|
__RISCOSIFY_NO_REVERSE_SUFFIX;
|
2009-01-31 16:50:17 +03:00
|
|
|
#ifndef __ELF__
|
2008-06-07 23:00:46 +04:00
|
|
|
extern int __dynamic_num;
|
2009-01-31 16:50:17 +03:00
|
|
|
#endif
|
2003-06-25 03:22:00 +04:00
|
|
|
|
2005-01-23 19:09:05 +03:00
|
|
|
const char * NETSURF_DIR;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2006-01-08 04:51:33 +03:00
|
|
|
static const char *task_name = "NetSurf";
|
|
|
|
#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
|
|
|
|
|
2012-01-11 18:20:26 +04:00
|
|
|
ro_gui_drag_type gui_current_drag_type;
|
2014-06-04 19:44:29 +04:00
|
|
|
wimp_t task_handle; /**< RISC OS wimp task handle. */
|
|
|
|
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
|
|
|
|
osspriteop_area *gui_sprites; /**< Sprite area containing pointer and hotlist sprites */
|
|
|
|
|
|
|
|
#define DIR_SEP ('.')
|
2004-05-08 22:12:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Accepted wimp user messages.
|
|
|
|
*/
|
2010-10-05 23:14:46 +04:00
|
|
|
static ns_wimp_message_list task_messages = {
|
2004-12-09 13:30:44 +03:00
|
|
|
message_HELP_REQUEST,
|
2009-03-28 22:10:29 +03:00
|
|
|
{
|
|
|
|
message_DATA_SAVE,
|
|
|
|
message_DATA_SAVE_ACK,
|
|
|
|
message_DATA_LOAD,
|
|
|
|
message_DATA_LOAD_ACK,
|
|
|
|
message_DATA_OPEN,
|
|
|
|
message_PRE_QUIT,
|
|
|
|
message_SAVE_DESKTOP,
|
|
|
|
message_MENU_WARNING,
|
|
|
|
message_MENUS_DELETED,
|
|
|
|
message_WINDOW_INFO,
|
|
|
|
message_CLAIM_ENTITY,
|
|
|
|
message_DATA_REQUEST,
|
|
|
|
message_DRAGGING,
|
|
|
|
message_DRAG_CLAIM,
|
|
|
|
message_MODE_CHANGE,
|
2011-02-26 02:26:36 +03:00
|
|
|
message_PALETTE_CHANGE,
|
2009-03-28 22:10:29 +03:00
|
|
|
message_FONT_CHANGED,
|
|
|
|
message_URI_PROCESS,
|
|
|
|
message_URI_RETURN_RESULT,
|
|
|
|
message_INET_SUITE_OPEN_URL,
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_PLUGIN
|
2009-03-28 22:10:29 +03:00
|
|
|
message_PLUG_IN_OPENING,
|
|
|
|
message_PLUG_IN_CLOSED,
|
|
|
|
message_PLUG_IN_RESHAPE_REQUEST,
|
|
|
|
message_PLUG_IN_FOCUS,
|
|
|
|
message_PLUG_IN_URL_ACCESS,
|
|
|
|
message_PLUG_IN_STATUS,
|
|
|
|
message_PLUG_IN_BUSY,
|
|
|
|
message_PLUG_IN_STREAM_NEW,
|
|
|
|
message_PLUG_IN_STREAM_WRITE,
|
|
|
|
message_PLUG_IN_STREAM_WRITTEN,
|
|
|
|
message_PLUG_IN_STREAM_DESTROY,
|
|
|
|
message_PLUG_IN_OPEN,
|
|
|
|
message_PLUG_IN_CLOSE,
|
|
|
|
message_PLUG_IN_RESHAPE,
|
|
|
|
message_PLUG_IN_STREAM_AS_FILE,
|
|
|
|
message_PLUG_IN_NOTIFY,
|
|
|
|
message_PLUG_IN_ABORT,
|
|
|
|
message_PLUG_IN_ACTION,
|
|
|
|
/* message_PLUG_IN_INFORMED, (not provided by oslib) */
|
2004-08-09 10:28:57 +04:00
|
|
|
#endif
|
2009-03-28 22:10:29 +03:00
|
|
|
message_PRINT_SAVE,
|
|
|
|
message_PRINT_ERROR,
|
|
|
|
message_PRINT_TYPE_ODD,
|
2011-10-14 00:40:52 +04:00
|
|
|
message_HOTLIST_ADD_URL,
|
2011-10-09 17:32:43 +04:00
|
|
|
message_HOTLIST_CHANGED,
|
2009-03-28 22:10:29 +03:00
|
|
|
0
|
|
|
|
}
|
|
|
|
};
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
2006-02-04 00:20:43 +03:00
|
|
|
static struct
|
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
int width; /* in OS units */
|
|
|
|
int height;
|
2006-02-04 00:20:43 +03:00
|
|
|
} screen_info;
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Callback to translate resource to full url for RISC OS.
|
|
|
|
*
|
|
|
|
* Transforms a resource: path into a full URL. The returned URL is
|
|
|
|
* used as the target for a redirect. The caller takes ownership of
|
|
|
|
* the returned nsurl including unrefing it when finished with it.
|
|
|
|
*
|
|
|
|
* \param path The path of the resource to locate.
|
|
|
|
* \return A string containing the full URL of the target object or
|
|
|
|
* NULL if no suitable resource can be found.
|
|
|
|
*/
|
2014-01-15 03:31:54 +04:00
|
|
|
static nsurl *gui_get_resource_url(const char *path)
|
2011-02-24 01:27:55 +03:00
|
|
|
{
|
2011-10-05 12:32:52 +04:00
|
|
|
static const char base_url[] = "file:///NetSurf:/Resources/";
|
|
|
|
size_t path_len, length;
|
|
|
|
char *raw;
|
|
|
|
nsurl *url = NULL;
|
2011-03-17 14:57:09 +03:00
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
/* Map paths first */
|
2012-03-06 22:34:02 +04:00
|
|
|
if (strcmp(path, "adblock.css") == 0) {
|
2011-10-05 12:32:52 +04:00
|
|
|
path = "AdBlock";
|
2012-03-06 22:34:02 +04:00
|
|
|
|
|
|
|
} else if (strcmp(path, "default.css") == 0) {
|
2011-10-05 12:32:52 +04:00
|
|
|
path = "CSS";
|
2012-03-06 22:34:02 +04:00
|
|
|
|
|
|
|
} else if (strcmp(path, "quirks.css") == 0) {
|
2011-10-05 12:32:52 +04:00
|
|
|
path = "Quirks";
|
2012-03-06 22:34:02 +04:00
|
|
|
|
|
|
|
} else if (strcmp(path, "favicon.ico") == 0) {
|
2011-10-09 14:41:20 +04:00
|
|
|
path = "Icons/content.png";
|
2011-10-05 12:32:52 +04:00
|
|
|
|
2012-03-06 22:34:02 +04:00
|
|
|
} else if (strcmp(path, "user.css") == 0) {
|
|
|
|
/* Special case; this file comes from Choices: */
|
|
|
|
nsurl_create("file:///Choices:WWW/NetSurf/User", &url);
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
path_len = strlen(path);
|
2011-03-16 00:26:33 +03:00
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
/* Find max URL length */
|
|
|
|
length = SLEN(base_url) + SLEN("xx/") + path_len + 1;
|
|
|
|
|
|
|
|
raw = malloc(length);
|
|
|
|
if (raw != NULL) {
|
|
|
|
/* Insert base URL */
|
|
|
|
char *ptr = memcpy(raw, base_url, SLEN(base_url));
|
|
|
|
ptr += SLEN(base_url);
|
|
|
|
|
|
|
|
/* Add language directory to URL, for translated files */
|
|
|
|
/* TODO: handle non-en langauages
|
|
|
|
* handle non-html translated files */
|
|
|
|
if (path_len > SLEN(".html") &&
|
|
|
|
strncmp(path + path_len - SLEN(".html"),
|
|
|
|
".html", SLEN(".html")) == 0) {
|
|
|
|
memcpy(ptr, "en/", SLEN("en/"));
|
|
|
|
ptr += SLEN("en/");
|
|
|
|
}
|
2011-03-16 00:31:44 +03:00
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
/* Add filename to URL */
|
|
|
|
memcpy(ptr, path, path_len);
|
2011-10-05 15:54:15 +04:00
|
|
|
ptr += path_len;
|
|
|
|
|
|
|
|
/* Terminate string */
|
|
|
|
*ptr = '\0';
|
2011-03-16 02:23:27 +03:00
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
nsurl_create(raw, &url);
|
|
|
|
free(raw);
|
2011-03-16 02:23:27 +03:00
|
|
|
}
|
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
return url;
|
2011-02-24 01:27:55 +03:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
2013-05-28 18:01:15 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Set colour option from wimp.
|
|
|
|
*
|
|
|
|
* \param opts The netsurf options.
|
|
|
|
* \param wimp wimp colour value
|
|
|
|
* \param option the netsurf option enum.
|
|
|
|
* \param def_colour The default colour value to use.
|
|
|
|
* \return NSERROR_OK on success or error code.
|
2013-05-28 18:01:15 +04:00
|
|
|
*/
|
|
|
|
static nserror
|
|
|
|
set_colour_from_wimp(struct nsoption_s *opts,
|
2014-06-04 19:44:29 +04:00
|
|
|
wimp_colour wimp,
|
|
|
|
enum nsoption_e option,
|
|
|
|
colour def_colour)
|
2013-05-28 18:01:15 +04:00
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
os_PALETTE(20) palette;
|
|
|
|
|
2013-05-28 21:34:55 +04:00
|
|
|
error = xwimp_read_true_palette((os_palette *) &palette);
|
2013-05-28 18:01:15 +04:00
|
|
|
if (error != NULL) {
|
2017-09-07 20:12:09 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimp_read_palette: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2013-05-28 18:01:15 +04:00
|
|
|
} else {
|
2013-05-28 21:59:50 +04:00
|
|
|
/* entries are in B0G0R0LL */
|
|
|
|
def_colour = palette.entries[wimp] >> 8;
|
2013-05-28 18:01:15 +04:00
|
|
|
}
|
|
|
|
|
2013-05-28 21:59:50 +04:00
|
|
|
opts[option].value.c = def_colour;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
2013-05-28 18:01:15 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
2013-05-28 18:01:15 +04:00
|
|
|
/**
|
|
|
|
* Set option defaults for riscos frontend
|
|
|
|
*
|
|
|
|
* @param defaults The option table to update.
|
|
|
|
* @return error status.
|
|
|
|
*
|
2014-06-04 19:44:29 +04:00
|
|
|
* @todo The wimp_COLOUR_... values here map the colour definitions to
|
|
|
|
* parts of the RISC OS desktop palette. In places this is fairly
|
|
|
|
* arbitrary, and could probably do with re-checking.
|
2013-05-28 18:01:15 +04:00
|
|
|
*/
|
|
|
|
static nserror set_defaults(struct nsoption_s *defaults)
|
2012-10-17 17:20:18 +04:00
|
|
|
{
|
|
|
|
/* Set defaults for absent option strings */
|
|
|
|
nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle"));
|
|
|
|
nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies"));
|
|
|
|
nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies"));
|
2013-05-28 18:01:15 +04:00
|
|
|
|
|
|
|
if (nsoption_charp(ca_bundle) == NULL ||
|
|
|
|
nsoption_charp(cookie_file) == NULL ||
|
|
|
|
nsoption_charp(cookie_jar) == NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Failed initialising default options");
|
2013-05-28 18:01:15 +04:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
2012-10-17 17:20:18 +04:00
|
|
|
}
|
2013-05-28 18:01:15 +04:00
|
|
|
|
2015-06-01 13:52:41 +03:00
|
|
|
/* RISC OS platform does not generally benefit from disc cache
|
|
|
|
* so the default should be off.
|
|
|
|
*/
|
|
|
|
nsoption_set_uint(disc_cache_size, 0);
|
|
|
|
|
2016-08-11 10:13:51 +03:00
|
|
|
/* Override core default treeview font size with 12 pt.
|
|
|
|
* TODO: 12 is the normal desktop font size, but users might run
|
|
|
|
* with something different.
|
|
|
|
*/
|
|
|
|
nsoption_set_int(treeview_font_size, 12 * 10);
|
|
|
|
|
2013-05-28 18:01:15 +04:00
|
|
|
/* set default system colours for riscos ui */
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_ActiveBorder, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_CREAM, NSOPTION_sys_colour_ActiveCaption, 0x00dddddd);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_VERY_LIGHT_GREY, NSOPTION_sys_colour_AppWorkspace, 0x00eeeeee);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_VERY_LIGHT_GREY, NSOPTION_sys_colour_Background, 0x00aa0000);/* \TODO -- Check */
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_VERY_LIGHT_GREY, NSOPTION_sys_colour_ButtonFace, 0x00aaaaaa);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_DARK_GREY, NSOPTION_sys_colour_ButtonHighlight, 0x00cccccc);/* \TODO -- Check */
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_MID_DARK_GREY, NSOPTION_sys_colour_ButtonShadow, 0x00bbbbbb);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_ButtonText, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_CaptionText, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_MID_LIGHT_GREY, NSOPTION_sys_colour_GrayText, 0x00777777);/* \TODO -- Check */
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_Highlight, 0x00ee0000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_WHITE, NSOPTION_sys_colour_HighlightText, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_InactiveBorder, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_LIGHT_GREY, NSOPTION_sys_colour_InactiveCaption, 0x00ffffff);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_InactiveCaptionText, 0x00cccccc);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_CREAM, NSOPTION_sys_colour_InfoBackground, 0x00aaaaaa);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_InfoText, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_WHITE, NSOPTION_sys_colour_Menu, 0x00aaaaaa);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_MenuText, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_LIGHT_GREY, NSOPTION_sys_colour_Scrollbar, 0x00aaaaaa);/* \TODO -- Check */
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_MID_DARK_GREY, NSOPTION_sys_colour_ThreeDDarkShadow, 0x00555555);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_VERY_LIGHT_GREY, NSOPTION_sys_colour_ThreeDFace, 0x00dddddd);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_WHITE, NSOPTION_sys_colour_ThreeDHighlight, 0x00aaaaaa);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_WHITE, NSOPTION_sys_colour_ThreeDLightShadow, 0x00999999);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_MID_DARK_GREY, NSOPTION_sys_colour_ThreeDShadow, 0x00777777);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_VERY_LIGHT_GREY, NSOPTION_sys_colour_Window, 0x00aaaaaa);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_WindowFrame, 0x00000000);
|
|
|
|
set_colour_from_wimp(defaults, wimp_COLOUR_BLACK, NSOPTION_sys_colour_WindowText, 0x00000000);
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
2012-10-17 17:20:18 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
2003-08-25 02:39:55 +04:00
|
|
|
|
2006-02-09 03:43:32 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Create intermediate directories for Choices and User Data files
|
|
|
|
*/
|
|
|
|
static void ro_gui_create_dirs(void)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
char *path;
|
2005-06-27 02:25:49 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Choices */
|
|
|
|
path = getenv("NetSurf$ChoicesSave");
|
|
|
|
if (!path)
|
|
|
|
die("Failed to find NetSurf Choices save path");
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
snprintf(buf, sizeof(buf), "%s", path);
|
2014-06-05 15:06:47 +04:00
|
|
|
netsurf_mkdir_all(buf);
|
2005-04-22 01:36:23 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* URL */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", nsoption_charp(url_save));
|
2014-06-05 15:06:47 +04:00
|
|
|
netsurf_mkdir_all(buf);
|
2006-07-16 20:52:28 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Hotlist */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", nsoption_charp(hotlist_save));
|
2014-06-05 15:06:47 +04:00
|
|
|
netsurf_mkdir_all(buf);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Recent */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", nsoption_charp(recent_save));
|
2014-06-05 15:06:47 +04:00
|
|
|
netsurf_mkdir_all(buf);
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Theme */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", nsoption_charp(theme_save));
|
2014-06-05 15:06:47 +04:00
|
|
|
netsurf_mkdir_all(buf);
|
2014-06-04 19:44:29 +04:00
|
|
|
/* and the final directory part (as theme_save is a directory) */
|
|
|
|
xosfile_create_dir(buf, 0);
|
|
|
|
}
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2004-02-27 17:09:15 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Ensures the gui exits cleanly.
|
|
|
|
*/
|
|
|
|
static void ro_gui_cleanup(void)
|
|
|
|
{
|
|
|
|
ro_gui_buffer_close();
|
|
|
|
xhourglass_off();
|
|
|
|
/* Uninstall NetSurf-specific fonts */
|
|
|
|
xos_cli("FontRemove NetSurf:Resources.Fonts.");
|
|
|
|
}
|
2005-03-20 04:55:48 +03:00
|
|
|
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Handles a signal
|
|
|
|
*/
|
|
|
|
static void ro_gui_signal(int sig)
|
|
|
|
{
|
|
|
|
static const os_error error = { 1, "NetSurf has detected a serious "
|
|
|
|
"error and must exit. Please submit a bug report, "
|
|
|
|
"attaching the browser log file." };
|
|
|
|
os_colour old_sand, old_glass;
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
ro_gui_cleanup();
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
xhourglass_on();
|
|
|
|
xhourglass_colours(0x0000ffff, 0x000000ff, &old_sand, &old_glass);
|
|
|
|
nsoption_dump(stderr, NULL);
|
|
|
|
/*rufl_dump_state();*/
|
2003-09-09 23:25:28 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
#ifndef __ELF__
|
|
|
|
/* save WimpSlot and DA to files if NetSurf$CoreDump exists */
|
|
|
|
int used;
|
|
|
|
xos_read_var_val_size("NetSurf$CoreDump", 0, 0, &used, 0, 0);
|
|
|
|
if (used) {
|
|
|
|
int curr_slot;
|
|
|
|
xwimp_slot_size(-1, -1, &curr_slot, 0, 0);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "saving WimpSlot, size 0x%x", curr_slot);
|
2014-06-04 19:44:29 +04:00
|
|
|
xosfile_save("$.NetSurf_Slot", 0x8000, 0,
|
|
|
|
(byte *) 0x8000,
|
|
|
|
(byte *) 0x8000 + curr_slot);
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (__dynamic_num != -1) {
|
|
|
|
int size;
|
|
|
|
byte *base_address;
|
|
|
|
xosdynamicarea_read(__dynamic_num, &size,
|
|
|
|
&base_address, 0, 0, 0, 0, 0);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"saving DA %i, base %p, size 0x%x",
|
|
|
|
__dynamic_num,
|
|
|
|
base_address,
|
|
|
|
size);
|
2014-06-04 19:44:29 +04:00
|
|
|
xosfile_save("$.NetSurf_DA",
|
|
|
|
(bits) base_address, 0,
|
|
|
|
base_address,
|
|
|
|
base_address + size);
|
|
|
|
}
|
2013-09-10 01:19:18 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
#else
|
|
|
|
/* Save WimpSlot and UnixLib managed DAs when UnixEnv$coredump
|
|
|
|
* defines a coredump directory. */
|
2015-02-25 03:32:46 +03:00
|
|
|
const _kernel_oserror *err = __unixlib_write_coredump (NULL);
|
2014-06-04 19:44:29 +04:00
|
|
|
if (err != NULL)
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Coredump failed: %s", err->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
#endif
|
2013-09-10 01:19:18 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
xhourglass_colours(old_sand, old_glass, 0, 0);
|
|
|
|
xhourglass_off();
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
__write_backtrace(sig);
|
2004-07-19 02:21:32 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
xwimp_report_error_by_category(&error,
|
|
|
|
wimp_ERROR_BOX_GIVEN_CATEGORY |
|
|
|
|
wimp_ERROR_BOX_CATEGORY_ERROR <<
|
|
|
|
wimp_ERROR_BOX_CATEGORY_SHIFT,
|
|
|
|
"NetSurf", "!netsurf",
|
|
|
|
(osspriteop_area *) 1, "Quit", 0);
|
|
|
|
xos_cli("Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.Log");
|
2006-10-12 18:00:40 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
_Exit(sig);
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
2006-01-08 04:51:33 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Read a "line" from an Acorn URI file.
|
|
|
|
*
|
|
|
|
* \param fp file pointer to read from
|
|
|
|
* \param b buffer for line, size 400 bytes
|
|
|
|
* \return true on success, false on EOF
|
2006-01-08 04:51:33 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static bool ro_gui_uri_file_parse_line(FILE *fp, char *b)
|
2006-01-08 04:51:33 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
int c;
|
|
|
|
unsigned int i = 0;
|
2006-01-08 04:51:33 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
c = getc(fp);
|
|
|
|
if (c == EOF)
|
|
|
|
return false;
|
2006-01-08 04:51:33 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* skip comment lines */
|
|
|
|
while (c == '#') {
|
|
|
|
do { c = getc(fp); } while (c != EOF && 32 <= c);
|
|
|
|
if (c == EOF)
|
|
|
|
return false;
|
|
|
|
do { c = getc(fp); } while (c != EOF && c < 32);
|
|
|
|
if (c == EOF)
|
|
|
|
return false;
|
|
|
|
}
|
2006-01-08 04:51:33 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* read "line" */
|
|
|
|
do {
|
|
|
|
if (i == 399)
|
|
|
|
return false;
|
|
|
|
b[i++] = c;
|
|
|
|
c = getc(fp);
|
|
|
|
} while (c != EOF && 32 <= c);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* skip line ending control characters */
|
|
|
|
while (c != EOF && c < 32)
|
|
|
|
c = getc(fp);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (c != EOF)
|
|
|
|
ungetc(c, fp);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
b[i] = 0;
|
|
|
|
return true;
|
2006-01-08 04:51:33 +03:00
|
|
|
}
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
|
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Parse an Acorn URI file.
|
2006-09-06 18:44:42 +04:00
|
|
|
*
|
2014-06-04 19:44:29 +04:00
|
|
|
* \param file_name file to read
|
|
|
|
* \param uri_title pointer to receive title data, or NULL for no data
|
|
|
|
* \return URL from file, or 0 on error and error reported
|
2006-09-06 18:44:42 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
|
2006-09-06 18:44:42 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
/* See the "Acorn URI Handler Functional Specification" for the
|
|
|
|
* definition of the URI file format. */
|
|
|
|
char line[400];
|
|
|
|
char *url = NULL;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
*uri_title = NULL;
|
|
|
|
fp = fopen(file_name, "rb");
|
|
|
|
if (!fp) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "fopen(\"%s\", \"rb\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno));
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("LoadError", strerror(errno));
|
2014-06-04 19:44:29 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "URI" */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line) || strcmp(line, "URI") != 0)
|
|
|
|
goto uri_syntax_error;
|
|
|
|
|
|
|
|
/* version */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line) ||
|
|
|
|
strspn(line, "0123456789") != strlen(line))
|
|
|
|
goto uri_syntax_error;
|
|
|
|
|
|
|
|
/* URI */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line))
|
|
|
|
goto uri_syntax_error;
|
|
|
|
|
|
|
|
url = strdup(line);
|
|
|
|
if (!url) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("NoMemory", 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* title */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line))
|
|
|
|
goto uri_free;
|
|
|
|
if (uri_title && line[0] && ((line[0] != '*') || line[1])) {
|
|
|
|
*uri_title = strdup(line);
|
|
|
|
if (!*uri_title) /* non-fatal */
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("NoMemory", 0);
|
2006-09-06 18:44:42 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
|
|
|
uri_free:
|
|
|
|
free(url);
|
|
|
|
|
|
|
|
uri_syntax_error:
|
|
|
|
fclose(fp);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("URIError", 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
return 0;
|
2006-09-06 18:44:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-27 17:09:15 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Parse an ANT URL file.
|
|
|
|
*
|
|
|
|
* \param file_name file to read
|
|
|
|
* \return URL from file, or 0 on error and error reported
|
2004-02-27 17:09:15 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static char *ro_gui_url_file_parse(const char *file_name)
|
2004-02-27 17:09:15 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
char line[400];
|
|
|
|
char *url;
|
|
|
|
FILE *fp;
|
2014-05-26 13:40:54 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
fp = fopen(file_name, "r");
|
|
|
|
if (!fp) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "fopen(\"%s\", \"r\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno));
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("LoadError", strerror(errno));
|
2014-06-04 19:44:29 +04:00
|
|
|
return 0;
|
2004-02-27 17:09:15 +03:00
|
|
|
}
|
2006-03-25 23:30:35 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (!fgets(line, sizeof line, fp)) {
|
|
|
|
if (ferror(fp)) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "fgets: %i: %s", errno,
|
|
|
|
strerror(errno));
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("LoadError", strerror(errno));
|
2014-06-04 19:44:29 +04:00
|
|
|
} else
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("LoadError", messages_get("EmptyError"));
|
2014-06-04 19:44:29 +04:00
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
if (line[strlen(line) - 1] == '\n')
|
|
|
|
line[strlen(line) - 1] = '\0';
|
|
|
|
|
|
|
|
url = strdup(line);
|
|
|
|
if (!url) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("NoMemory", 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return url;
|
2006-01-25 05:43:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Parse an IEURL file.
|
2006-01-25 05:43:07 +03:00
|
|
|
*
|
2014-06-04 19:44:29 +04:00
|
|
|
* \param file_name file to read
|
|
|
|
* \return URL from file, or 0 on error and error reported
|
2006-01-25 05:43:07 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static char *ro_gui_ieurl_file_parse(const char *file_name)
|
2007-07-15 21:20:25 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
char line[400];
|
|
|
|
char *url = 0;
|
|
|
|
FILE *fp;
|
2004-02-27 17:09:15 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
fp = fopen(file_name, "r");
|
|
|
|
if (!fp) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "fopen(\"%s\", \"r\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno));
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("LoadError", strerror(errno));
|
2014-06-04 19:44:29 +04:00
|
|
|
return 0;
|
2004-02-27 17:09:15 +03:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
|
|
|
|
while (fgets(line, sizeof line, fp)) {
|
|
|
|
if (strncmp(line, "URL=", 4) == 0) {
|
|
|
|
if (line[strlen(line) - 1] == '\n')
|
|
|
|
line[strlen(line) - 1] = '\0';
|
|
|
|
url = strdup(line + 4);
|
|
|
|
if (!url) {
|
|
|
|
fclose(fp);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("NoMemory", 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2004-02-27 17:09:15 +03:00
|
|
|
break;
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ferror(fp)) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "fgets: %i: %s", errno, strerror(errno));
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("LoadError", strerror(errno));
|
2014-06-04 19:44:29 +04:00
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
2004-02-27 17:09:15 +03:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
fclose(fp);
|
2004-04-10 01:06:10 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (!url)
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("URIError", 0);
|
2004-05-07 23:14:54 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
return url;
|
2004-05-07 23:14:54 +04:00
|
|
|
}
|
|
|
|
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-05-27 02:43:36 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle Message_DataOpen (double-click on file in the Filer).
|
2014-05-27 02:43:36 +04:00
|
|
|
*
|
2014-06-04 19:44:29 +04:00
|
|
|
* \param message The wimp message to open.
|
2014-05-27 02:43:36 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_msg_dataopen(wimp_message *message)
|
2014-01-26 03:00:22 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
int file_type = message->data.data_xfer.file_type;
|
|
|
|
char *url = 0;
|
|
|
|
os_error *oserror;
|
|
|
|
nsurl *urlns;
|
|
|
|
nserror error;
|
|
|
|
size_t len;
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
switch (file_type) {
|
|
|
|
case 0xb28: /* ANT URL file */
|
|
|
|
url = ro_gui_url_file_parse(message->data.data_xfer.file_name);
|
|
|
|
error = nsurl_create(url, &urlns);
|
|
|
|
free(url);
|
|
|
|
break;
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case 0xfaf: /* HTML file */
|
|
|
|
error = netsurf_path_to_nsurl(message->data.data_xfer.file_name,
|
|
|
|
&urlns);
|
|
|
|
break;
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case 0x1ba: /* IEURL file */
|
|
|
|
url = ro_gui_ieurl_file_parse(message->
|
|
|
|
data.data_xfer.file_name);
|
|
|
|
error = nsurl_create(url, &urlns);
|
|
|
|
free(url);
|
|
|
|
break;
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case 0x2000: /* application */
|
|
|
|
len = strlen(message->data.data_xfer.file_name);
|
|
|
|
if (len < 9 || strcmp(".!NetSurf",
|
|
|
|
message->data.data_xfer.file_name + len - 9))
|
|
|
|
return;
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (nsoption_charp(homepage_url) &&
|
|
|
|
nsoption_charp(homepage_url)[0]) {
|
|
|
|
error = nsurl_create(nsoption_charp(homepage_url),
|
|
|
|
&urlns);
|
|
|
|
} else {
|
|
|
|
error = nsurl_create(NETSURF_HOMEPAGE, &urlns);
|
|
|
|
}
|
|
|
|
break;
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
default:
|
|
|
|
return;
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
|
|
|
oserror = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
|
|
|
if (oserror) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
|
|
|
|
oserror->errnum, oserror->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", oserror->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
return;
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (error != NSERROR_OK) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user(messages_get_errorcode(error), 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
return;
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* create a new window with the file */
|
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
|
|
|
urlns,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(urlns);
|
|
|
|
if (error != NSERROR_OK) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user(messages_get_errorcode(error), 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
2014-05-27 02:43:36 +04:00
|
|
|
}
|
2014-01-26 03:00:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
2014-01-26 03:00:22 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle Message_DataLoad (file dragged in).
|
2014-01-26 03:00:22 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_msg_dataload(wimp_message *message)
|
2014-01-26 03:00:22 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
int file_type = message->data.data_xfer.file_type;
|
|
|
|
char *urltxt = NULL;
|
|
|
|
char *title = NULL;
|
|
|
|
struct gui_window *g;
|
|
|
|
os_error *oserror;
|
|
|
|
nsurl *url;
|
|
|
|
nserror error;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
g = ro_gui_window_lookup(message->data.data_xfer.w);
|
|
|
|
if (g) {
|
|
|
|
if (ro_gui_window_dataload(g, message))
|
|
|
|
return;
|
2014-05-27 02:43:36 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
else {
|
|
|
|
g = ro_gui_toolbar_lookup(message->data.data_xfer.w);
|
|
|
|
if (g && ro_gui_toolbar_dataload(g, message))
|
|
|
|
return;
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
switch (file_type) {
|
|
|
|
case FILETYPE_ACORN_URI:
|
|
|
|
urltxt = ro_gui_uri_file_parse(message->data.data_xfer.file_name,
|
|
|
|
&title);
|
|
|
|
error = nsurl_create(urltxt, &url);
|
|
|
|
free(urltxt);
|
|
|
|
break;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case FILETYPE_ANT_URL:
|
|
|
|
urltxt = ro_gui_url_file_parse(message->data.data_xfer.file_name);
|
|
|
|
error = nsurl_create(urltxt, &url);
|
|
|
|
free(urltxt);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILETYPE_IEURL:
|
|
|
|
urltxt = ro_gui_ieurl_file_parse(message->data.data_xfer.file_name);
|
|
|
|
error = nsurl_create(urltxt, &url);
|
|
|
|
free(urltxt);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILETYPE_HTML:
|
|
|
|
case FILETYPE_JNG:
|
|
|
|
case FILETYPE_CSS:
|
|
|
|
case FILETYPE_MNG:
|
|
|
|
case FILETYPE_GIF:
|
|
|
|
case FILETYPE_BMP:
|
|
|
|
case FILETYPE_ICO:
|
|
|
|
case osfile_TYPE_DRAW:
|
|
|
|
case FILETYPE_PNG:
|
|
|
|
case FILETYPE_JPEG:
|
|
|
|
case osfile_TYPE_SPRITE:
|
|
|
|
case osfile_TYPE_TEXT:
|
|
|
|
case FILETYPE_ARTWORKS:
|
|
|
|
case FILETYPE_SVG:
|
|
|
|
/* display the actual file */
|
|
|
|
error = netsurf_path_to_nsurl(message->data.data_xfer.file_name, &url);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* report error to user */
|
|
|
|
if (error != NSERROR_OK) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user(messages_get_errorcode(error), 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
return;
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
|
|
|
if (g) {
|
|
|
|
error = browser_window_navigate(g->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
BW_NAVIGATE_HISTORY,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
} else {
|
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
nsurl_unref(url);
|
|
|
|
if (error != NSERROR_OK) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user(messages_get_errorcode(error), 0);
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
|
|
|
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
|
|
|
oserror = xwimp_send_message(wimp_USER_MESSAGE, message,
|
|
|
|
message->sender);
|
|
|
|
if (oserror) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x: %s",
|
|
|
|
oserror->errnum, oserror->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", oserror->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-26 03:00:22 +04:00
|
|
|
}
|
2004-05-07 23:14:54 +04:00
|
|
|
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2004-07-29 03:07:52 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Ensure that the filename in a data transfer message is NULL terminated
|
|
|
|
* (some applications, especially BASIC programs use CR)
|
|
|
|
*
|
|
|
|
* \param message message to be corrected
|
2004-07-29 03:07:52 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_msg_terminate_filename(wimp_full_message_data_xfer *message)
|
2004-07-29 03:07:52 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
const char *ep = (char*)message + message->size;
|
|
|
|
char *p = message->file_name;
|
2004-09-27 09:21:00 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if ((size_t)message->size >= sizeof(*message))
|
|
|
|
ep = (char*)message + sizeof(*message) - 1;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
while (p < ep && *p >= ' ') p++;
|
|
|
|
*p = '\0';
|
|
|
|
}
|
2010-10-05 23:14:46 +04:00
|
|
|
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Handle Message_DataSave
|
|
|
|
*/
|
|
|
|
static void ro_msg_datasave(wimp_message *message)
|
|
|
|
{
|
|
|
|
wimp_full_message_data_xfer *dataxfer = (wimp_full_message_data_xfer*)message;
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* remove ghost caret if drag-and-drop protocol was used */
|
|
|
|
// ro_gui_selection_drag_reset();
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
ro_msg_terminate_filename(dataxfer);
|
2010-10-05 23:14:46 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (ro_gui_selection_prepare_paste_datasave(dataxfer))
|
|
|
|
return;
|
2004-09-27 09:21:00 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
switch (dataxfer->file_type) {
|
|
|
|
case FILETYPE_ACORN_URI:
|
|
|
|
case FILETYPE_ANT_URL:
|
|
|
|
case FILETYPE_IEURL:
|
|
|
|
case FILETYPE_HTML:
|
|
|
|
case FILETYPE_JNG:
|
|
|
|
case FILETYPE_CSS:
|
|
|
|
case FILETYPE_MNG:
|
|
|
|
case FILETYPE_GIF:
|
|
|
|
case FILETYPE_BMP:
|
|
|
|
case FILETYPE_ICO:
|
|
|
|
case osfile_TYPE_DRAW:
|
|
|
|
case FILETYPE_PNG:
|
|
|
|
case FILETYPE_JPEG:
|
|
|
|
case osfile_TYPE_SPRITE:
|
|
|
|
case osfile_TYPE_TEXT:
|
|
|
|
case FILETYPE_ARTWORKS:
|
|
|
|
case FILETYPE_SVG: {
|
|
|
|
os_error *error;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
dataxfer->your_ref = dataxfer->my_ref;
|
|
|
|
dataxfer->size = offsetof(wimp_full_message_data_xfer, file_name) + 16;
|
|
|
|
dataxfer->action = message_DATA_SAVE_ACK;
|
|
|
|
dataxfer->est_size = -1;
|
|
|
|
memcpy(dataxfer->file_name, "<Wimp$Scrap>", 13);
|
2004-09-27 09:21:00 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xwimp_send_message: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
break;
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
2004-07-29 03:07:52 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Message_DataSaveAck.
|
2013-05-23 14:50:57 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_msg_datasave_ack(wimp_message *message)
|
2013-05-23 14:50:57 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
ro_msg_terminate_filename((wimp_full_message_data_xfer*)message);
|
2013-05-23 14:50:57 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (ro_print_ack(message))
|
|
|
|
return;
|
2013-05-23 14:50:57 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_DOWNLOAD_SAVE:
|
|
|
|
ro_gui_download_datasave_ack(message);
|
|
|
|
break;
|
2010-03-29 20:59:30 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case GUI_DRAG_SAVE:
|
|
|
|
ro_gui_save_datasave_ack(message);
|
|
|
|
gui_current_drag_type = GUI_DRAG_NONE;
|
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_current_drag_type = GUI_DRAG_NONE;
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2005-02-08 02:00:09 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle PreQuit message
|
|
|
|
*
|
|
|
|
* \param message PreQuit message from Wimp
|
2005-02-08 02:00:09 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_msg_prequit(wimp_message *message)
|
2005-02-22 00:10:48 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
if (!ro_gui_prequit()) {
|
|
|
|
os_error *error;
|
2006-01-06 03:57:01 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* we're objecting to the close down */
|
|
|
|
message->your_ref = message->my_ref;
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
|
|
|
|
message, message->sender);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2008-06-03 07:04:41 +04:00
|
|
|
}
|
2011-10-12 04:50:21 +04:00
|
|
|
}
|
2005-02-08 02:00:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle SaveDesktop message.
|
2004-01-28 21:37:56 +03:00
|
|
|
*
|
2014-06-04 19:44:29 +04:00
|
|
|
* \param message SaveDesktop message from Wimp.
|
2004-01-28 21:37:56 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_msg_save_desktop(wimp_message *message)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
os_error *error;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
error = xosgbpb_writew(message->data.save_desktopw.file,
|
|
|
|
(const byte*)"Run ", 4, NULL);
|
|
|
|
if (!error) {
|
|
|
|
error = xosgbpb_writew(message->data.save_desktopw.file,
|
|
|
|
(const byte*)NETSURF_DIR, strlen(NETSURF_DIR), NULL);
|
|
|
|
if (!error)
|
|
|
|
error = xos_bputw('\n', message->data.save_desktopw.file);
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
2010-03-11 01:47:37 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xosgbpb_writew/xos_bputw: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("SaveError", error->errmess);
|
2010-03-11 01:47:37 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* we must cancel the save by acknowledging the message */
|
|
|
|
message->your_ref = message->my_ref;
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE_ACKNOWLEDGE,
|
|
|
|
message, message->sender);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_send_message: 0x%x:%s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
2014-03-08 18:13:27 +04:00
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle WindowInfo message (part of the iconising protocol)
|
2004-01-28 21:37:56 +03:00
|
|
|
*
|
2014-06-04 19:44:29 +04:00
|
|
|
* \param message WindowInfo message from the Iconiser
|
2004-01-28 21:37:56 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_msg_window_info(wimp_message *message)
|
2004-01-28 21:37:56 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
wimp_full_message_window_info *wi;
|
|
|
|
struct gui_window *g;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* allow the user to turn off thumbnail icons */
|
|
|
|
if (!nsoption_bool(thumbnail_iconise))
|
|
|
|
return;
|
2011-12-20 03:27:10 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
wi = (wimp_full_message_window_info*)message;
|
|
|
|
g = ro_gui_window_lookup(wi->w);
|
2003-10-06 03:30:21 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* ic_<task name> will suffice for our other windows */
|
|
|
|
if (g) {
|
|
|
|
ro_gui_window_iconise(g, wi);
|
|
|
|
ro_gui_dialog_close_persistent(wi->w);
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
|
|
|
}
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Get screen properties following a mode change.
|
2004-01-28 21:37:56 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_gui_get_screen_properties(void)
|
2004-06-09 01:35:28 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
static const ns_os_vdu_var_list vars = {
|
|
|
|
os_MODEVAR_XWIND_LIMIT,
|
|
|
|
{
|
|
|
|
os_MODEVAR_YWIND_LIMIT,
|
|
|
|
os_MODEVAR_XEIG_FACTOR,
|
|
|
|
os_MODEVAR_YEIG_FACTOR,
|
|
|
|
os_VDUVAR_END_LIST
|
|
|
|
}
|
|
|
|
};
|
2004-07-17 17:00:38 +04:00
|
|
|
os_error *error;
|
2014-06-04 19:44:29 +04:00
|
|
|
int vals[4];
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals);
|
2006-09-06 18:44:42 +04:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xos_read_vdu_variables: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2006-09-06 18:44:42 +04:00
|
|
|
return;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
screen_info.width = (vals[0] + 1) << vals[2];
|
|
|
|
screen_info.height = (vals[1] + 1) << vals[3];
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Warn the user if Inet$Resolvers is not set.
|
2004-01-28 21:37:56 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_gui_check_resolvers(void)
|
2004-01-28 21:37:56 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
char *resolvers;
|
|
|
|
resolvers = getenv("Inet$Resolvers");
|
|
|
|
if (resolvers && resolvers[0]) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Inet$Resolvers '%s'", resolvers);
|
2014-06-04 19:44:29 +04:00
|
|
|
} else {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Inet$Resolvers not set or empty");
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("Resolvers", 0);
|
2008-12-26 12:25:30 +03:00
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Initialise the RISC OS specific GUI.
|
|
|
|
*
|
|
|
|
* \param argc The number of command line arguments.
|
|
|
|
* \param argv The string vector of command line arguments.
|
2003-12-11 04:23:57 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static nserror gui_init(int argc, char** argv)
|
2013-01-22 12:51:58 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
struct {
|
|
|
|
void (*sigabrt)(int);
|
|
|
|
void (*sigfpe)(int);
|
|
|
|
void (*sigill)(int);
|
|
|
|
void (*sigint)(int);
|
|
|
|
void (*sigsegv)(int);
|
|
|
|
void (*sigterm)(int);
|
2015-08-15 12:58:56 +03:00
|
|
|
void (*sigoserror)(int);
|
2014-06-04 19:44:29 +04:00
|
|
|
} prev_sigs;
|
|
|
|
char path[40];
|
|
|
|
os_error *error;
|
|
|
|
int length;
|
|
|
|
char *nsdir_temp;
|
|
|
|
byte *base;
|
|
|
|
nsurl *url;
|
|
|
|
nserror ret;
|
|
|
|
bool open_window;
|
|
|
|
|
|
|
|
/* re-enable all FPU exceptions/traps except inexact operations,
|
|
|
|
* which we're not interested in, and underflow which is incorrectly
|
|
|
|
* raised when converting an exact value of 0 from double-precision
|
|
|
|
* to single-precision on FPEmulator v4.09-4.11 (MVFD F0,#0:MVFS F0,F0)
|
|
|
|
* - UnixLib disables all FP exceptions by default */
|
|
|
|
|
|
|
|
_FPU_SETCW(_FPU_IEEE & ~(_FPU_MASK_PM | _FPU_MASK_UM));
|
|
|
|
|
|
|
|
xhourglass_start(1);
|
|
|
|
|
|
|
|
/* read OS version for code that adapts to conform to the OS
|
|
|
|
* (remember that it's preferable to check for specific features
|
|
|
|
* being present) */
|
|
|
|
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
|
|
|
|
|
|
|
|
/* the first release version of the A9home OS is incapable of
|
|
|
|
plotting patterned lines (presumably a fault in the hw acceleration) */
|
|
|
|
if (!xosmodule_lookup("VideoHWSMI", NULL, NULL, &base, NULL, NULL)) {
|
|
|
|
#if 0 // this fault still hasn't been fixed, so disable patterned lines for all versions until it has
|
|
|
|
const char *help = (char*)base + ((int*)base)[5];
|
|
|
|
while (*help > 9) help++;
|
|
|
|
while (*help == 9) help++;
|
|
|
|
if (!memcmp(help, "0.55", 4))
|
|
|
|
#endif
|
|
|
|
ro_plot_patterned_lines = false;
|
2013-01-22 12:51:58 +04:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Create our choices directories */
|
|
|
|
ro_gui_create_dirs();
|
2013-01-22 12:51:58 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Register exit and signal handlers */
|
|
|
|
atexit(ro_gui_cleanup);
|
|
|
|
prev_sigs.sigabrt = signal(SIGABRT, ro_gui_signal);
|
|
|
|
prev_sigs.sigfpe = signal(SIGFPE, ro_gui_signal);
|
|
|
|
prev_sigs.sigill = signal(SIGILL, ro_gui_signal);
|
|
|
|
prev_sigs.sigint = signal(SIGINT, ro_gui_signal);
|
|
|
|
prev_sigs.sigsegv = signal(SIGSEGV, ro_gui_signal);
|
|
|
|
prev_sigs.sigterm = signal(SIGTERM, ro_gui_signal);
|
2015-08-15 12:58:56 +03:00
|
|
|
prev_sigs.sigoserror = signal(SIGOSERROR, ro_gui_signal);
|
2009-01-10 03:18:34 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (prev_sigs.sigabrt == SIG_ERR || prev_sigs.sigfpe == SIG_ERR ||
|
|
|
|
prev_sigs.sigill == SIG_ERR ||
|
|
|
|
prev_sigs.sigint == SIG_ERR ||
|
|
|
|
prev_sigs.sigsegv == SIG_ERR ||
|
2015-08-15 12:58:56 +03:00
|
|
|
prev_sigs.sigterm == SIG_ERR ||
|
|
|
|
prev_sigs.sigoserror == SIG_ERR)
|
2014-06-04 19:44:29 +04:00
|
|
|
die("Failed registering signal handlers");
|
2013-01-22 12:51:58 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Load in UI sprites */
|
|
|
|
gui_sprites = ro_gui_load_sprite_file("NetSurf:Resources.Sprites");
|
|
|
|
if (!gui_sprites)
|
|
|
|
die("Unable to load Sprites.");
|
2013-01-22 12:51:58 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Find NetSurf directory */
|
|
|
|
nsdir_temp = getenv("NetSurf$Dir");
|
|
|
|
if (!nsdir_temp)
|
|
|
|
die("Failed to locate NetSurf directory");
|
|
|
|
NETSURF_DIR = strdup(nsdir_temp);
|
|
|
|
if (!NETSURF_DIR)
|
|
|
|
die("Failed duplicating NetSurf directory string");
|
|
|
|
|
|
|
|
/* Initialise filename allocator */
|
|
|
|
filename_initialise();
|
|
|
|
|
|
|
|
/* Initialise save complete functionality */
|
|
|
|
save_complete_init();
|
|
|
|
|
2017-02-12 13:18:02 +03:00
|
|
|
/* Initialise the font subsystem */
|
|
|
|
nsfont_init();
|
|
|
|
|
2016-12-29 17:51:43 +03:00
|
|
|
/* Load in visited URLs, Cookies, and hostlist */
|
2014-06-04 19:44:29 +04:00
|
|
|
urldb_load(nsoption_charp(url_path));
|
|
|
|
urldb_load_cookies(nsoption_charp(cookie_file));
|
2017-04-25 14:13:07 +03:00
|
|
|
hotlist_init(nsoption_charp(hotlist_path),
|
2017-04-28 14:10:30 +03:00
|
|
|
nsoption_bool(external_hotlists) ?
|
|
|
|
NULL :
|
|
|
|
nsoption_charp(hotlist_save));
|
2014-06-04 19:44:29 +04:00
|
|
|
|
|
|
|
/* Initialise with the wimp */
|
|
|
|
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
|
|
|
|
PTR_WIMP_MESSAGE_LIST(&task_messages), 0,
|
|
|
|
&task_handle);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_initialise: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
die(error->errmess);
|
2003-12-11 04:23:57 +03:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Register message handlers */
|
|
|
|
ro_message_register_route(message_HELP_REQUEST,
|
|
|
|
ro_gui_interactive_help_request);
|
|
|
|
ro_message_register_route(message_DATA_OPEN,
|
|
|
|
ro_msg_dataopen);
|
|
|
|
ro_message_register_route(message_DATA_SAVE,
|
|
|
|
ro_msg_datasave);
|
|
|
|
ro_message_register_route(message_DATA_SAVE_ACK,
|
|
|
|
ro_msg_datasave_ack);
|
|
|
|
ro_message_register_route(message_PRE_QUIT,
|
|
|
|
ro_msg_prequit);
|
|
|
|
ro_message_register_route(message_SAVE_DESKTOP,
|
|
|
|
ro_msg_save_desktop);
|
|
|
|
ro_message_register_route(message_DRAGGING,
|
|
|
|
ro_gui_selection_dragging);
|
|
|
|
ro_message_register_route(message_DRAG_CLAIM,
|
|
|
|
ro_gui_selection_drag_claim);
|
|
|
|
ro_message_register_route(message_WINDOW_INFO,
|
|
|
|
ro_msg_window_info);
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise global information */
|
|
|
|
ro_gui_get_screen_properties();
|
|
|
|
ro_gui_wimp_get_desktop_font();
|
2006-03-25 23:30:35 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Issue a *Desktop to poke AcornURI into life */
|
|
|
|
if (getenv("NetSurf$Start_URI_Handler"))
|
|
|
|
xwimp_start_task("Desktop", 0);
|
2005-09-02 00:29:59 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Open the templates */
|
|
|
|
if ((length = snprintf(path, sizeof(path),
|
|
|
|
"NetSurf:Resources.%s.Templates",
|
|
|
|
nsoption_charp(language))) < 0 || length >= (int)sizeof(path))
|
|
|
|
die("Failed to locate Templates resource.");
|
|
|
|
error = xwimp_open_template(path);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_open_template failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
die(error->errmess);
|
|
|
|
}
|
2004-08-09 10:28:57 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise themes before dialogs */
|
|
|
|
ro_gui_theme_initialise();
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise dialog windows (must be after UI sprites are loaded) */
|
|
|
|
ro_gui_dialog_init();
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise download window */
|
|
|
|
ro_gui_download_init();
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise menus */
|
|
|
|
ro_gui_menu_init();
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise query windows */
|
|
|
|
ro_gui_query_init();
|
2011-02-26 02:26:36 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise toolbars */
|
|
|
|
ro_toolbar_init();
|
2006-07-18 05:51:19 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Initialise url bar module */
|
|
|
|
ro_gui_url_bar_init();
|
|
|
|
|
|
|
|
/* Initialise browser windows */
|
|
|
|
ro_gui_window_initialise();
|
|
|
|
|
|
|
|
/* Done with the templates file */
|
|
|
|
wimp_close_template();
|
|
|
|
|
|
|
|
/* Create Iconbar icon and menus */
|
|
|
|
ro_gui_iconbar_initialise();
|
|
|
|
|
|
|
|
/* Finally, check Inet$Resolvers for sanity */
|
|
|
|
ro_gui_check_resolvers();
|
|
|
|
|
|
|
|
open_window = nsoption_bool(open_browser_at_startup);
|
|
|
|
|
|
|
|
/* parse command-line arguments */
|
|
|
|
if (argc == 2) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "parameters: '%s'", argv[1]);
|
2014-06-04 19:44:29 +04:00
|
|
|
/* this is needed for launching URI files */
|
|
|
|
if (strcasecmp(argv[1], "-nowin") == 0) {
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
ret = nsurl_create(NETSURF_HOMEPAGE, &url);
|
|
|
|
}
|
|
|
|
else if (argc == 3) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "parameters: '%s' '%s'", argv[1],
|
|
|
|
argv[2]);
|
2014-06-04 19:44:29 +04:00
|
|
|
open_window = true;
|
|
|
|
|
|
|
|
/* HTML files */
|
|
|
|
if (strcasecmp(argv[1], "-html") == 0) {
|
|
|
|
ret = netsurf_path_to_nsurl(argv[2], &url);
|
|
|
|
}
|
|
|
|
/* URL files */
|
|
|
|
else if (strcasecmp(argv[1], "-urlf") == 0) {
|
|
|
|
char *urlf = ro_gui_url_file_parse(argv[2]);
|
|
|
|
if (!urlf) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "allocation failed");
|
2014-06-04 19:44:29 +04:00
|
|
|
die("Insufficient memory for URL");
|
2004-04-02 04:41:10 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
ret = nsurl_create(urlf, &url);
|
|
|
|
free(urlf);
|
|
|
|
}
|
|
|
|
/* ANT URL Load */
|
|
|
|
else if (strcasecmp(argv[1], "-url") == 0) {
|
|
|
|
ret = nsurl_create(argv[2], &url);
|
|
|
|
}
|
|
|
|
/* Unknown => exit here. */
|
|
|
|
else {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Unknown parameters: '%s' '%s'",
|
|
|
|
argv[1], argv[2]);
|
2014-06-04 19:44:29 +04:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* get user's homepage (if configured) */
|
|
|
|
else if (nsoption_charp(homepage_url) &&
|
|
|
|
nsoption_charp(homepage_url)[0]) {
|
|
|
|
ret = nsurl_create(nsoption_charp(homepage_url), &url);
|
|
|
|
}
|
|
|
|
/* default homepage */
|
|
|
|
else {
|
|
|
|
ret = nsurl_create(NETSURF_HOMEPAGE, &url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for url creation error */
|
|
|
|
if (ret != NSERROR_OK) {
|
|
|
|
return ret;
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
|
|
|
|
if (open_window) {
|
|
|
|
ret = browser_window_create(BW_CREATE_HISTORY,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
nsurl_unref(url);
|
|
|
|
|
|
|
|
return ret;
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-02 00:29:59 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Determine the default language to use.
|
2005-09-02 00:29:59 +04:00
|
|
|
*
|
2014-06-04 19:44:29 +04:00
|
|
|
* RISC OS has no standard way of determining which language the user prefers.
|
|
|
|
* We have to guess from the 'Country' setting.
|
2005-09-02 00:29:59 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
const char *ro_gui_default_language(void)
|
2005-09-02 00:29:59 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
char path[40];
|
|
|
|
const char *lang;
|
|
|
|
int country;
|
|
|
|
os_error *error;
|
2005-09-02 00:29:59 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* choose a language from the configured country number */
|
|
|
|
error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xosbyte_read failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
country = 1;
|
|
|
|
}
|
|
|
|
switch (country) {
|
|
|
|
case 7: /* Germany */
|
|
|
|
case 30: /* Austria */
|
|
|
|
case 35: /* Switzerland (70% German-speaking) */
|
|
|
|
lang = "de";
|
|
|
|
break;
|
|
|
|
case 6: /* France */
|
|
|
|
case 18: /* Canada2 (French Canada?) */
|
|
|
|
lang = "fr";
|
|
|
|
break;
|
|
|
|
case 34: /* Netherlands */
|
|
|
|
lang = "nl";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lang = "en";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sprintf(path, "NetSurf:Resources.%s", lang);
|
|
|
|
if (is_dir(path))
|
|
|
|
return lang;
|
|
|
|
return "en";
|
2005-09-02 00:29:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-03 03:19:47 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Create a nsurl from a RISC OS pathname.
|
|
|
|
*
|
|
|
|
* Perform the necessary operations on a path to generate a nsurl.
|
|
|
|
*
|
|
|
|
* @param[in] path The RISC OS pathname to convert.
|
2014-11-11 18:46:04 +03:00
|
|
|
* @param[out] url_out pointer to recive the nsurl, The returned url must be
|
2014-06-04 19:44:29 +04:00
|
|
|
* unreferenced by the caller.
|
|
|
|
* @return NSERROR_OK and the url is placed in \a url or error code on faliure.
|
2004-03-03 03:19:47 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static nserror ro_path_to_nsurl(const char *path, struct nsurl **url_out)
|
2002-12-31 01:56:30 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
int spare;
|
|
|
|
char *canonical_path; /* canonicalised RISC OS path */
|
|
|
|
char *unix_path; /* unix path */
|
2016-07-24 23:00:29 +03:00
|
|
|
char *escaped_path;
|
2014-06-04 19:44:29 +04:00
|
|
|
os_error *error;
|
|
|
|
nserror ret;
|
|
|
|
int urllen;
|
|
|
|
char *url; /* resulting url */
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* calculate the canonical risc os path */
|
|
|
|
error = xosfscontrol_canonicalise_path(path, 0, 0, 0, 0, &spare);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xosfscontrol_canonicalise_path failed: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("PathToURL", error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
return NSERROR_NOT_FOUND;
|
2005-04-22 01:36:23 +04:00
|
|
|
}
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
canonical_path = malloc(1 - spare);
|
|
|
|
if (canonical_path == NULL) {
|
|
|
|
free(canonical_path);
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
error = xosfscontrol_canonicalise_path(path, canonical_path, 0, 0, 1 - spare, 0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xosfscontrol_canonicalise_path failed: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("PathToURL", error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
free(canonical_path);
|
|
|
|
return NSERROR_NOT_FOUND;
|
|
|
|
}
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2014-11-18 20:16:26 +03:00
|
|
|
/* create a unix path from the cananocal risc os one */
|
2014-06-04 19:44:29 +04:00
|
|
|
unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0);
|
2005-04-05 02:14:51 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (unix_path == NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "__unixify failed: %s", canonical_path);
|
2014-06-04 19:44:29 +04:00
|
|
|
free(canonical_path);
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
2005-04-05 02:14:51 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
free(canonical_path);
|
2004-12-09 13:30:44 +03:00
|
|
|
|
2016-07-24 23:00:29 +03:00
|
|
|
/* url escape the unix path */
|
|
|
|
ret = url_escape(unix_path, false, "/", &escaped_path);
|
|
|
|
if (ret != NSERROR_OK) {
|
|
|
|
free(unix_path);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
free(unix_path);
|
|
|
|
|
|
|
|
/* convert the escaped unix path into a url */
|
|
|
|
urllen = strlen(escaped_path) + FILE_SCHEME_PREFIX_LEN + 1;
|
2014-06-04 19:44:29 +04:00
|
|
|
url = malloc(urllen);
|
|
|
|
if (url == NULL) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Unable to allocate url");
|
2016-07-24 23:00:29 +03:00
|
|
|
free(escaped_path);
|
2014-06-04 19:44:29 +04:00
|
|
|
return NSERROR_NOMEM;
|
2014-05-27 02:43:36 +04:00
|
|
|
}
|
2004-12-09 13:30:44 +03:00
|
|
|
|
2016-07-24 23:00:29 +03:00
|
|
|
if (*escaped_path == '/') {
|
|
|
|
snprintf(url, urllen, "%s%s",
|
|
|
|
FILE_SCHEME_PREFIX, escaped_path + 1);
|
2014-05-27 02:43:36 +04:00
|
|
|
} else {
|
2016-07-24 23:00:29 +03:00
|
|
|
snprintf(url, urllen, "%s%s",
|
|
|
|
FILE_SCHEME_PREFIX, escaped_path);
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
2016-07-24 23:00:29 +03:00
|
|
|
free(escaped_path);
|
2004-12-09 13:30:44 +03:00
|
|
|
|
2016-07-24 23:00:29 +03:00
|
|
|
ret = nsurl_create(url, url_out);
|
2014-06-04 19:44:29 +04:00
|
|
|
free(url);
|
|
|
|
|
|
|
|
return ret;
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
2004-03-06 01:15:33 +03:00
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Create a path from a nsurl using posix file handling.
|
2004-07-17 17:00:38 +04:00
|
|
|
*
|
2014-11-11 18:46:04 +03:00
|
|
|
* @param[in] url The url to encode.
|
2014-06-04 19:44:29 +04:00
|
|
|
* @param[out] path_out A string containing the result path which should
|
|
|
|
* be freed by the caller.
|
|
|
|
* @return NSERROR_OK and the path is written to \a path or error code
|
|
|
|
* on faliure.
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static nserror ro_nsurl_to_path(struct nsurl *url, char **path_out)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
lwc_string *urlpath;
|
2016-07-24 15:59:30 +03:00
|
|
|
size_t unpath_len;
|
2014-06-04 19:44:29 +04:00
|
|
|
char *unpath;
|
|
|
|
char *path;
|
|
|
|
bool match;
|
|
|
|
lwc_string *scheme;
|
|
|
|
nserror res;
|
|
|
|
char *r;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if ((url == NULL) || (path_out == NULL)) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
2004-06-09 01:35:28 +04:00
|
|
|
}
|
2004-03-05 20:08:28 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
scheme = nsurl_get_component(url, NSURL_SCHEME);
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (lwc_string_caseless_isequal(scheme, corestring_lwc_file,
|
|
|
|
&match) != lwc_error_ok)
|
|
|
|
{
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
lwc_string_unref(scheme);
|
|
|
|
if (match == false) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
urlpath = nsurl_get_component(url, NSURL_PATH);
|
|
|
|
if (urlpath == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-04-03 00:04:00 +04:00
|
|
|
|
2016-06-30 01:06:53 +03:00
|
|
|
res = url_unescape(lwc_string_data(urlpath),
|
|
|
|
lwc_string_length(urlpath),
|
2016-07-24 15:59:30 +03:00
|
|
|
&unpath_len,
|
2016-06-30 01:06:53 +03:00
|
|
|
&unpath);
|
2014-06-04 19:44:29 +04:00
|
|
|
lwc_string_unref(urlpath);
|
|
|
|
if (res != NSERROR_OK) {
|
|
|
|
return res;
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* RISC OS path should not be more than 100 characters longer */
|
2016-07-24 15:59:30 +03:00
|
|
|
path = malloc(unpath_len + 100);
|
2014-06-04 19:44:29 +04:00
|
|
|
if (path == NULL) {
|
|
|
|
free(unpath);
|
|
|
|
return NSERROR_NOMEM;
|
2005-04-08 06:06:46 +04:00
|
|
|
}
|
2005-04-17 21:16:44 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
r = __riscosify(unpath, 0, __RISCOSIFY_NO_SUFFIX,
|
2016-07-24 15:59:30 +03:00
|
|
|
path, unpath_len + 100, 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
free(unpath);
|
|
|
|
if (r == NULL) {
|
|
|
|
free(path);
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
*path_out = path;
|
2014-04-03 00:04:00 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
return NSERROR_OK;
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Ensures output logging stream is correctly configured.
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static bool nslog_stream_configure(FILE *fptr)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
/* set log stream to be non-buffering */
|
|
|
|
setbuf(fptr, NULL);
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
return true;
|
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Close down the gui (RISC OS).
|
2004-07-17 17:00:38 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void gui_quit(void)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
urldb_save_cookies(nsoption_charp(cookie_jar));
|
|
|
|
urldb_save(nsoption_charp(url_save));
|
|
|
|
ro_gui_window_quit();
|
2017-05-29 00:07:33 +03:00
|
|
|
ro_gui_local_history_finalise();
|
2016-12-27 14:45:18 +03:00
|
|
|
ro_gui_global_history_finalise();
|
2016-12-26 16:22:42 +03:00
|
|
|
ro_gui_hotlist_finalise();
|
2016-12-09 17:04:55 +03:00
|
|
|
ro_gui_cookies_finalise();
|
2014-06-04 19:44:29 +04:00
|
|
|
ro_gui_saveas_quit();
|
|
|
|
ro_gui_url_bar_fini();
|
|
|
|
rufl_quit();
|
|
|
|
free(gui_sprites);
|
|
|
|
xwimp_close_down(task_handle);
|
|
|
|
xhourglass_off();
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Handle Close_Window_Request events.
|
|
|
|
*/
|
|
|
|
static void ro_gui_close_window_request(wimp_close *close)
|
|
|
|
{
|
|
|
|
if (ro_gui_alt_pressed())
|
|
|
|
ro_gui_window_close_all();
|
|
|
|
else {
|
|
|
|
if (ro_gui_wimp_event_close_window(close->w))
|
|
|
|
return;
|
|
|
|
ro_gui_dialog_close(close->w);
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Handle key press paste callback.
|
|
|
|
*/
|
|
|
|
static void ro_gui_keypress_cb(void *pw)
|
|
|
|
{
|
|
|
|
wimp_key *key = (wimp_key *) pw;
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (ro_gui_wimp_event_keypress(key) == false) {
|
|
|
|
os_error *error = xwimp_process_key(key->c);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_process_key: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
free(key);
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
|
|
|
|
2003-09-11 01:44:11 +04:00
|
|
|
|
2005-02-03 23:49:43 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle gui keypress.
|
2005-02-03 23:49:43 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_gui_keypress(wimp_key *key)
|
2005-02-03 23:49:43 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
if (key->c == wimp_KEY_ESCAPE &&
|
|
|
|
(gui_current_drag_type == GUI_DRAG_SAVE ||
|
|
|
|
gui_current_drag_type == GUI_DRAG_DOWNLOAD_SAVE)) {
|
2005-02-03 23:49:43 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Allow Escape key to be used for cancelling a drag
|
|
|
|
* save (easier than finding somewhere safe to abort
|
|
|
|
* the drag)
|
|
|
|
*/
|
|
|
|
ro_gui_drag_box_cancel();
|
|
|
|
gui_current_drag_type = GUI_DRAG_NONE;
|
|
|
|
} else if (key->c == 22 /* Ctrl-V */) {
|
|
|
|
wimp_key *copy;
|
2005-02-03 23:49:43 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Must copy the keypress as it's on the stack */
|
|
|
|
copy = malloc(sizeof(wimp_key));
|
|
|
|
if (copy == NULL)
|
|
|
|
return;
|
|
|
|
memcpy(copy, key, sizeof(wimp_key));
|
|
|
|
|
|
|
|
ro_gui_selection_prepare_paste(key->w, ro_gui_keypress_cb, copy);
|
|
|
|
} else if (ro_gui_wimp_event_keypress(key) == false) {
|
|
|
|
os_error *error = xwimp_process_key(key->c);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_process_key: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2005-02-03 23:49:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle the three User_Message events.
|
2005-04-05 02:14:51 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_gui_user_message(wimp_event_no event, wimp_message *message)
|
2005-04-05 02:14:51 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
/* attempt automatic routing */
|
|
|
|
if (ro_message_handle_message(event, message))
|
2013-01-22 12:51:58 +04:00
|
|
|
return;
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
switch (message->action) {
|
|
|
|
case message_DATA_LOAD:
|
|
|
|
ro_msg_terminate_filename((wimp_full_message_data_xfer*)message);
|
2005-04-05 02:14:51 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
|
|
|
|
if (ro_print_current_window)
|
|
|
|
ro_print_dataload_bounce(message);
|
|
|
|
} else if (ro_gui_selection_prepare_paste_dataload(
|
|
|
|
(wimp_full_message_data_xfer *) message) == false) {
|
|
|
|
ro_msg_dataload(message);
|
2005-04-05 02:14:51 +04:00
|
|
|
}
|
2014-06-04 19:44:29 +04:00
|
|
|
break;
|
2005-04-05 02:14:51 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case message_DATA_LOAD_ACK:
|
|
|
|
if (ro_print_current_window)
|
|
|
|
ro_print_cleanup();
|
|
|
|
break;
|
2005-04-05 02:14:51 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case message_MENU_WARNING:
|
|
|
|
ro_gui_menu_warning((wimp_message_menu_warning *)
|
|
|
|
&message->data);
|
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case message_MENUS_DELETED:
|
|
|
|
ro_gui_menu_message_deleted((wimp_message_menus_deleted *)
|
|
|
|
&message->data);
|
|
|
|
break;
|
2005-09-02 00:29:59 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case message_CLAIM_ENTITY:
|
|
|
|
ro_gui_selection_claim_entity((wimp_full_message_claim_entity*)message);
|
|
|
|
break;
|
2004-08-09 10:28:57 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case message_DATA_REQUEST:
|
|
|
|
ro_gui_selection_data_request((wimp_full_message_data_request*)message);
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case message_MODE_CHANGE:
|
|
|
|
ro_gui_get_screen_properties();
|
|
|
|
rufl_invalidate_cache();
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case message_PALETTE_CHANGE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_FONT_CHANGED:
|
|
|
|
ro_gui_wimp_get_desktop_font();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_URI_PROCESS:
|
|
|
|
if (event != wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
ro_uri_message_received(message);
|
|
|
|
break;
|
|
|
|
case message_URI_RETURN_RESULT:
|
|
|
|
ro_uri_bounce(message);
|
|
|
|
break;
|
|
|
|
case message_INET_SUITE_OPEN_URL:
|
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
|
|
|
|
ro_url_bounce(message);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ro_url_message_received(message);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#ifdef WITH_PLUGIN
|
|
|
|
case message_PLUG_IN_OPENING:
|
|
|
|
plugin_opening(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_CLOSED:
|
|
|
|
plugin_closed(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_RESHAPE_REQUEST:
|
|
|
|
plugin_reshape_request(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_FOCUS:
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_URL_ACCESS:
|
|
|
|
plugin_url_access(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_STATUS:
|
|
|
|
plugin_status(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_BUSY:
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_STREAM_NEW:
|
|
|
|
plugin_stream_new(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_STREAM_WRITE:
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_STREAM_WRITTEN:
|
|
|
|
plugin_stream_written(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_STREAM_DESTROY:
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_OPEN:
|
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
plugin_open_msg(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_CLOSE:
|
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
plugin_close_msg(message);
|
|
|
|
break;
|
|
|
|
case message_PLUG_IN_RESHAPE:
|
|
|
|
case message_PLUG_IN_STREAM_AS_FILE:
|
|
|
|
case message_PLUG_IN_NOTIFY:
|
|
|
|
case message_PLUG_IN_ABORT:
|
|
|
|
case message_PLUG_IN_ACTION:
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case message_PRINT_SAVE:
|
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
ro_print_save_bounce(message);
|
|
|
|
break;
|
|
|
|
case message_PRINT_ERROR:
|
|
|
|
ro_print_error(message);
|
|
|
|
break;
|
|
|
|
case message_PRINT_TYPE_ODD:
|
|
|
|
ro_print_type_odd(message);
|
|
|
|
break;
|
|
|
|
case message_HOTLIST_CHANGED:
|
|
|
|
ro_gui_hotlist_add_cleanup();
|
|
|
|
break;
|
|
|
|
case message_QUIT:
|
2014-10-13 03:56:09 +04:00
|
|
|
riscos_done = true;
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Process a Wimp_Poll event.
|
|
|
|
*
|
|
|
|
* \param event wimp event number
|
|
|
|
* \param block parameter block
|
2003-11-08 02:51:13 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
switch (event) {
|
|
|
|
case wimp_NULL_REASON_CODE:
|
|
|
|
ro_gui_throb();
|
|
|
|
ro_mouse_poll();
|
|
|
|
break;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_REDRAW_WINDOW_REQUEST:
|
|
|
|
ro_gui_wimp_event_redraw_window(&block->redraw);
|
|
|
|
break;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_OPEN_WINDOW_REQUEST:
|
|
|
|
ro_gui_open_window_request(&block->open);
|
|
|
|
break;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_CLOSE_WINDOW_REQUEST:
|
|
|
|
ro_gui_close_window_request(&block->close);
|
|
|
|
break;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_POINTER_LEAVING_WINDOW:
|
|
|
|
ro_mouse_pointer_leaving_window(&block->leaving);
|
|
|
|
break;
|
2014-05-27 02:43:36 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_POINTER_ENTERING_WINDOW:
|
|
|
|
ro_gui_wimp_event_pointer_entering_window(&block->entering);
|
|
|
|
break;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_MOUSE_CLICK:
|
|
|
|
ro_gui_wimp_event_mouse_click(&block->pointer);
|
|
|
|
break;
|
2004-11-30 00:47:00 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_USER_DRAG_BOX:
|
|
|
|
ro_mouse_drag_end(&block->dragged);
|
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_KEY_PRESSED:
|
|
|
|
ro_gui_keypress(&(block->key));
|
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_MENU_SELECTION:
|
|
|
|
ro_gui_menu_selection(&(block->selection));
|
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Scroll requests fall back to a generic handler because we
|
|
|
|
* might get these events for any window from a scroll-wheel.
|
|
|
|
*/
|
2005-04-23 06:58:27 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_SCROLL_REQUEST:
|
|
|
|
if (!ro_gui_wimp_event_scroll_window(&(block->scroll)))
|
|
|
|
ro_gui_scroll(&(block->scroll));
|
|
|
|
break;
|
2005-04-23 06:58:27 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
case wimp_USER_MESSAGE:
|
|
|
|
case wimp_USER_MESSAGE_RECORDED:
|
|
|
|
case wimp_USER_MESSAGE_ACKNOWLEDGE:
|
|
|
|
ro_gui_user_message(event, &(block->message));
|
|
|
|
break;
|
2005-04-23 06:58:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-06-26 21:56:42 +04:00
|
|
|
* Poll the RISC OS wimp for events.
|
2005-04-23 06:58:27 +04:00
|
|
|
*/
|
2014-10-13 03:56:09 +04:00
|
|
|
static void riscos_poll(void)
|
2005-04-23 06:58:27 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block block;
|
2014-06-26 21:56:42 +04:00
|
|
|
const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN | wimp_SAVE_FP;
|
2014-06-04 19:44:29 +04:00
|
|
|
os_t track_poll_offset;
|
2005-04-23 06:58:27 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Poll wimp. */
|
|
|
|
xhourglass_off();
|
|
|
|
track_poll_offset = ro_mouse_poll_interval();
|
2014-06-30 19:40:56 +04:00
|
|
|
if (sched_active || (track_poll_offset > 0)) {
|
2014-06-04 19:44:29 +04:00
|
|
|
os_t t = os_read_monotonic_time();
|
2005-04-23 06:58:27 +04:00
|
|
|
|
2014-06-30 19:40:56 +04:00
|
|
|
if (track_poll_offset > 0) {
|
2014-06-04 19:44:29 +04:00
|
|
|
t += track_poll_offset;
|
2014-06-30 19:40:56 +04:00
|
|
|
} else {
|
2014-06-04 19:44:29 +04:00
|
|
|
t += 10;
|
2014-06-30 19:40:56 +04:00
|
|
|
}
|
2006-03-24 06:44:37 +03:00
|
|
|
|
2014-06-30 19:40:56 +04:00
|
|
|
if (sched_active && (sched_time - t) < 0) {
|
2014-06-04 19:44:29 +04:00
|
|
|
t = sched_time;
|
2014-06-30 19:40:56 +04:00
|
|
|
}
|
2006-03-24 06:44:37 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
event = wimp_poll_idle(mask, &block, t, 0);
|
|
|
|
} else {
|
|
|
|
event = wimp_poll(wimp_MASK_NULL | mask, &block, 0);
|
|
|
|
}
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
xhourglass_on();
|
|
|
|
gui_last_poll = clock();
|
|
|
|
ro_gui_handle_event(event, &block);
|
2006-03-24 06:44:37 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Only run scheduled callbacks on a null poll
|
|
|
|
* We cannot do this in the null event handler, as that may be called
|
|
|
|
* from gui_multitask(). Scheduled callbacks must only be run from the
|
|
|
|
* top-level.
|
|
|
|
*/
|
|
|
|
if (event == wimp_NULL_REASON_CODE) {
|
|
|
|
schedule_run();
|
2008-12-26 12:25:30 +03:00
|
|
|
}
|
2006-03-24 06:44:37 +03:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
ro_gui_window_update_boxes();
|
|
|
|
}
|
2006-01-18 03:54:27 +03:00
|
|
|
|
|
|
|
|
2006-02-04 00:20:43 +03:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Handle Open_Window_Request events.
|
2006-02-04 00:20:43 +03:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
void ro_gui_open_window_request(wimp_open *open)
|
2006-02-04 00:20:43 +03:00
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (ro_gui_wimp_event_open_window(open))
|
|
|
|
return;
|
|
|
|
|
|
|
|
error = xwimp_open_window(open);
|
2006-02-04 00:20:43 +03:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2006-02-04 00:20:43 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-11 01:44:11 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* source bounce callback.
|
2003-09-11 01:44:11 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_gui_view_source_bounce(wimp_message *message)
|
2003-09-11 01:44:11 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
char *filename;
|
|
|
|
os_error *error;
|
|
|
|
char command[256];
|
|
|
|
|
|
|
|
/* run the file as text */
|
|
|
|
filename = ((wimp_full_message_data_xfer *)message)->file_name;
|
|
|
|
sprintf(command, "@RunType_FFF %s", filename);
|
|
|
|
error = xwimp_start_task(command, 0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_start_task failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
2003-09-11 01:44:11 +04:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
/**
|
|
|
|
* Send the source of a content to a text editor.
|
|
|
|
*/
|
2016-06-06 10:59:23 +03:00
|
|
|
void ro_gui_view_source(struct hlcache_handle *c)
|
2003-12-11 04:23:57 +03:00
|
|
|
{
|
2005-08-03 21:01:40 +04:00
|
|
|
os_error *error;
|
2014-05-26 13:40:54 +04:00
|
|
|
char *temp_name;
|
2006-04-22 03:49:52 +04:00
|
|
|
wimp_full_message_data_xfer message;
|
2006-07-06 04:07:11 +04:00
|
|
|
int objtype;
|
|
|
|
bool done = false;
|
2005-08-03 21:01:40 +04:00
|
|
|
|
2010-04-07 14:33:46 +04:00
|
|
|
const char *source_data;
|
|
|
|
unsigned long source_size;
|
|
|
|
|
|
|
|
if (!c) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("MiscError", "No document source");
|
2010-04-07 14:33:46 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
source_data = content_get_source_data(c, &source_size);
|
|
|
|
|
|
|
|
if (!source_data) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("MiscError", "No document source");
|
2004-10-18 02:13:35 +04:00
|
|
|
return;
|
|
|
|
}
|
2006-03-25 23:30:35 +03:00
|
|
|
|
2006-01-08 23:09:05 +03:00
|
|
|
/* try to load local files directly. */
|
2014-05-27 02:43:36 +04:00
|
|
|
if (netsurf_nsurl_to_path(hlcache_handle_get_url(c), &temp_name) == NSERROR_OK) {
|
2006-07-06 04:07:11 +04:00
|
|
|
error = xosfile_read_no_path(temp_name, &objtype, 0, 0, 0, 0);
|
|
|
|
if ((!error) && (objtype == osfile_IS_FILE)) {
|
|
|
|
snprintf(message.file_name, 212, "%s", temp_name);
|
|
|
|
message.file_name[211] = '\0';
|
|
|
|
done = true;
|
|
|
|
}
|
2006-01-18 03:54:27 +03:00
|
|
|
free(temp_name);
|
2006-07-06 04:07:11 +04:00
|
|
|
}
|
|
|
|
if (!done) {
|
2006-06-21 02:58:36 +04:00
|
|
|
/* We cannot release the requested filename until after it
|
|
|
|
* has finished being used. As we can't easily find out when
|
|
|
|
* this is, we simply don't bother releasing it and simply
|
|
|
|
* allow it to be re-used next time NetSurf is started. The
|
|
|
|
* memory overhead from doing this is under 1 byte per
|
|
|
|
* filename. */
|
2014-05-26 13:40:54 +04:00
|
|
|
char *r;
|
|
|
|
char full_name[256];
|
2006-06-21 02:58:36 +04:00
|
|
|
const char *filename = filename_request();
|
|
|
|
if (!filename) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("NoMemory", 0);
|
2006-04-22 03:49:52 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-04-18 20:30:28 +04:00
|
|
|
|
2006-06-21 02:58:36 +04:00
|
|
|
snprintf(full_name, 256, "%s/%s", TEMP_FILENAME_PREFIX,
|
|
|
|
filename);
|
2006-06-15 02:46:12 +04:00
|
|
|
full_name[255] = '\0';
|
2006-06-21 02:58:36 +04:00
|
|
|
r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX,
|
|
|
|
message.file_name, 212, 0);
|
2006-04-22 03:49:52 +04:00
|
|
|
if (r == 0) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "__riscosify failed");
|
2006-04-22 03:49:52 +04:00
|
|
|
return;
|
2006-01-08 23:09:05 +03:00
|
|
|
}
|
|
|
|
message.file_name[211] = '\0';
|
2014-04-18 20:30:28 +04:00
|
|
|
|
2006-01-08 23:09:05 +03:00
|
|
|
error = xosfile_save_stamped(message.file_name,
|
2010-04-07 14:33:46 +04:00
|
|
|
ro_content_filetype(c),
|
|
|
|
(byte *) source_data,
|
|
|
|
(byte *) source_data + source_size);
|
2006-01-08 23:09:05 +03:00
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"xosfile_save_stamped failed: 0x%x: %s",
|
|
|
|
error->errnum,
|
|
|
|
error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("MiscError", error->errmess);
|
2006-01-08 23:09:05 +03:00
|
|
|
return;
|
|
|
|
}
|
2005-08-03 21:01:40 +04:00
|
|
|
}
|
2004-10-18 02:13:35 +04:00
|
|
|
|
2006-01-08 23:09:05 +03:00
|
|
|
/* begin the DataOpen protocol */
|
|
|
|
message.your_ref = 0;
|
|
|
|
message.size = 44 + ((strlen(message.file_name) + 4) & (~3u));
|
|
|
|
message.action = message_DATA_OPEN;
|
|
|
|
message.w = 0;
|
|
|
|
message.i = 0;
|
|
|
|
message.pos.x = 0;
|
|
|
|
message.pos.y = 0;
|
|
|
|
message.est_size = 0;
|
|
|
|
message.file_type = 0xfff;
|
2006-06-21 02:58:36 +04:00
|
|
|
ro_message_send_message(wimp_USER_MESSAGE_RECORDED,
|
|
|
|
(wimp_message*)&message, 0,
|
2006-01-08 23:09:05 +03:00
|
|
|
ro_gui_view_source_bounce);
|
|
|
|
}
|
2005-08-05 02:50:49 +04:00
|
|
|
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Broadcast an URL that we can't handle.
|
|
|
|
*/
|
|
|
|
static nserror gui_launch_url(struct nsurl *url)
|
2007-08-20 06:39:49 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
/* Try ant broadcast */
|
|
|
|
ro_url_broadcast(nsurl_access(url));
|
|
|
|
return NSERROR_OK;
|
2003-12-11 04:23:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 06:39:49 +04:00
|
|
|
/**
|
2014-06-04 19:44:29 +04:00
|
|
|
* Choose the language to use.
|
2007-08-20 06:39:49 +04:00
|
|
|
*/
|
2014-06-04 19:44:29 +04:00
|
|
|
static void ro_gui_choose_language(void)
|
2007-08-20 06:39:49 +04:00
|
|
|
{
|
2014-06-04 19:44:29 +04:00
|
|
|
/* if option_language exists and is valid, use that */
|
|
|
|
if (nsoption_charp(language)) {
|
|
|
|
char path[40];
|
|
|
|
if (2 < strlen(nsoption_charp(language)))
|
|
|
|
nsoption_charp(language)[2] = 0;
|
|
|
|
sprintf(path, "NetSurf:Resources.%s", nsoption_charp(language));
|
2007-08-20 06:39:49 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
if (is_dir(path)) {
|
|
|
|
nsoption_setnull_charp(accept_language,
|
|
|
|
strdup(nsoption_charp(language)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsoption_set_charp(language, NULL);
|
2007-08-20 06:39:49 +04:00
|
|
|
}
|
2004-05-13 18:39:43 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
nsoption_set_charp(language, strdup(ro_gui_default_language()));
|
|
|
|
if (nsoption_charp(language) == NULL)
|
|
|
|
die("Out of memory");
|
|
|
|
nsoption_set_charp(accept_language, strdup(nsoption_charp(language)));
|
|
|
|
if (nsoption_charp(accept_language) == NULL)
|
|
|
|
die("Out of memory");
|
2004-05-13 18:39:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/**
|
|
|
|
* Display a warning for a serious problem (eg memory exhaustion).
|
|
|
|
*
|
|
|
|
* \param warning message key for warning message
|
2004-05-07 23:14:54 +04:00
|
|
|
* \param detail additional message, or 0
|
2004-02-25 18:12:58 +03:00
|
|
|
*/
|
2016-04-26 01:19:12 +03:00
|
|
|
nserror ro_warn_user(const char *warning, const char *detail)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "%s %s", warning, detail);
|
2006-02-10 21:10:09 +03:00
|
|
|
|
|
|
|
if (dialog_warning) {
|
2006-02-10 23:44:04 +03:00
|
|
|
char warn_buffer[300];
|
|
|
|
snprintf(warn_buffer, sizeof warn_buffer, "%s %s",
|
2006-02-10 21:10:09 +03:00
|
|
|
messages_get(warning),
|
|
|
|
detail ? detail : "");
|
2006-02-10 23:44:04 +03:00
|
|
|
warn_buffer[sizeof warn_buffer - 1] = 0;
|
2006-02-10 21:10:09 +03:00
|
|
|
ro_gui_set_icon_string(dialog_warning, ICON_WARNING_MESSAGE,
|
2008-08-05 05:23:04 +04:00
|
|
|
warn_buffer, true);
|
2006-02-10 21:10:09 +03:00
|
|
|
xwimp_set_icon_state(dialog_warning, ICON_WARNING_HELP,
|
|
|
|
wimp_ICON_DELETED, wimp_ICON_DELETED);
|
|
|
|
ro_gui_dialog_open(dialog_warning);
|
|
|
|
xos_bell();
|
2016-04-26 01:19:12 +03:00
|
|
|
} else {
|
2006-02-10 21:10:09 +03:00
|
|
|
/* probably haven't initialised (properly), use a
|
|
|
|
non-multitasking error box */
|
2006-02-10 23:44:04 +03:00
|
|
|
os_error error;
|
|
|
|
snprintf(error.errmess, sizeof error.errmess, "%s %s",
|
2006-02-10 21:10:09 +03:00
|
|
|
messages_get(warning),
|
|
|
|
detail ? detail : "");
|
2006-02-10 23:44:04 +03:00
|
|
|
error.errmess[sizeof error.errmess - 1] = 0;
|
|
|
|
xwimp_report_error_by_category(&error,
|
2006-02-10 21:10:09 +03:00
|
|
|
wimp_ERROR_BOX_OK_ICON |
|
|
|
|
wimp_ERROR_BOX_GIVEN_CATEGORY |
|
|
|
|
wimp_ERROR_BOX_CATEGORY_ERROR <<
|
|
|
|
wimp_ERROR_BOX_CATEGORY_SHIFT,
|
|
|
|
"NetSurf", "!netsurf",
|
|
|
|
(osspriteop_area *) 1, 0, 0);
|
|
|
|
}
|
2016-04-26 01:11:55 +03:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
2003-10-06 03:30:21 +04:00
|
|
|
}
|
2004-03-27 03:49:29 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display an error and exit.
|
|
|
|
*
|
|
|
|
* Should only be used during initialisation.
|
|
|
|
*/
|
2006-10-12 18:00:40 +04:00
|
|
|
void die(const char * const error)
|
2004-03-27 03:49:29 +03:00
|
|
|
{
|
2004-08-27 02:58:19 +04:00
|
|
|
os_error warn_error;
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "%s", error);
|
2007-01-01 00:04:14 +03:00
|
|
|
|
2004-08-27 02:58:19 +04:00
|
|
|
warn_error.errnum = 1; /* \todo: reasonable ? */
|
|
|
|
strncpy(warn_error.errmess, messages_get(error),
|
|
|
|
sizeof(warn_error.errmess)-1);
|
|
|
|
warn_error.errmess[sizeof(warn_error.errmess)-1] = '\0';
|
2004-05-07 23:14:54 +04:00
|
|
|
xwimp_report_error_by_category(&warn_error,
|
|
|
|
wimp_ERROR_BOX_OK_ICON |
|
|
|
|
wimp_ERROR_BOX_GIVEN_CATEGORY |
|
|
|
|
wimp_ERROR_BOX_CATEGORY_ERROR <<
|
|
|
|
wimp_ERROR_BOX_CATEGORY_SHIFT,
|
|
|
|
"NetSurf", "!netsurf",
|
|
|
|
(osspriteop_area *) 1, 0, 0);
|
2004-03-27 03:49:29 +03:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2005-04-23 06:58:27 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test whether it's okay to shutdown, prompting the user if not.
|
|
|
|
*
|
|
|
|
* \return true iff it's okay to shutdown immediately
|
|
|
|
*/
|
|
|
|
bool ro_gui_prequit(void)
|
|
|
|
{
|
|
|
|
return ro_gui_download_prequit();
|
|
|
|
}
|
Second merge of Adam Blokus' GSoC work from his branch 'branches/adamblokus/netsurf'.
Merged revisions 4195-4211,4216,4219-4220,4222-4234,4236-4250,4252-4262,4264-4266,4268-4326,4329-4335,4338-4342,4344-4411,4413-4420,4422-4436,4438-4491,4494-4506,4508-4514,4516,4518-4552,4554,4556-4564,4567-4568,4570-4574,4576-4686,4689-4692,4694,4698-4709,4715-4723,4725-4755,4757-4769,4771-4919,4921-4996,4998-5110,5112-5117 via svnmerge from
svn://svn.netsurf-browser.org/branches/adamblokus/netsurf
........
r4736 | adamblokus | 2008-07-26 13:46:54 +0200 (Sat, 26 Jul 2008) | 2 lines
Sorting out some problems with svn.
........
r4737 | adamblokus | 2008-07-26 13:54:36 +0200 (Sat, 26 Jul 2008) | 4 lines
Added export tab to the options dialog.
Added the possibility of changing some print options.
........
r4897 | adamblokus | 2008-08-04 17:59:05 +0200 (Mon, 04 Aug 2008) | 5 lines
Added checking of horizontal clipping.
Added better table loosening.
Changed some minor bugs.
Applied changes in the Export options tab according to the review from tlsa.
........
r4905 | adamblokus | 2008-08-05 01:53:34 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed bug which made it impossible to export pdf's.
........
r4919 | adamblokus | 2008-08-05 16:39:33 +0200 (Tue, 05 Aug 2008) | 2 lines
Fixed some memory leaks which caused Netsurf to break.
........
r4927 | adamblokus | 2008-08-06 02:26:30 +0200 (Wed, 06 Aug 2008) | 4 lines
Fixed bug with filenames which crashed Netsurf.
Turned anti aliasing off for printing.
Fixed some scaling issues.
........
r4928 | adamblokus | 2008-08-06 17:52:44 +0200 (Wed, 06 Aug 2008) | 5 lines
Added new export/print options:
- suppressing images
- turning off backgrounds
- toggled loosening
........
r4950 | adamblokus | 2008-08-07 21:15:21 +0200 (Thu, 07 Aug 2008) | 5 lines
Added new options to PDF export:
- document compression
- document encryption
Added PDF password dialog
........
r4954 | adamblokus | 2008-08-07 22:11:31 +0200 (Thu, 07 Aug 2008) | 2 lines
Added saving print settings.
........
r4956 | adamblokus | 2008-08-07 22:44:48 +0200 (Thu, 07 Aug 2008) | 2 lines
Fixes to PDF encryption
........
r4970 | adamblokus | 2008-08-09 15:26:24 +0200 (Sat, 09 Aug 2008) | 3 lines
Fixed bug in plotting tiled bitmaps.
Fixed bug with too long text decorations.
........
r4977 | adamblokus | 2008-08-09 19:18:56 +0200 (Sat, 09 Aug 2008) | 2 lines
Fixed JPG embedding bug.
........
r4988 | adamblokus | 2008-08-10 16:59:51 +0200 (Sun, 10 Aug 2008) | 3 lines
Added clip checking to pdf plotters. No more "blank" clips.
Made PDF compression a default setting.
........
r4995 | adamblokus | 2008-08-10 20:03:00 +0200 (Sun, 10 Aug 2008) | 2 lines
Fixed Haru crash on font-size==0.
........
r4996 | adamblokus | 2008-08-10 21:04:43 +0200 (Sun, 10 Aug 2008) | 2 lines
Added changing text mode only if necessary.
........
r5045 | adamblokus | 2008-08-11 21:26:26 +0200 (Mon, 11 Aug 2008) | 3 lines
Removing gtk stuff from core code.
Little fix in options.
........
r5048 | adamblokus | 2008-08-11 21:57:45 +0200 (Mon, 11 Aug 2008) | 2 lines
Better font size checking in PDF export.
........
r5050 | adamblokus | 2008-08-11 22:19:56 +0200 (Mon, 11 Aug 2008) | 2 lines
Fixed riscos text scale bug.
........
r5073 | adamblokus | 2008-08-12 17:40:57 +0200 (Tue, 12 Aug 2008) | 2 lines
Added missing tooltips
........
r5092 | adamblokus | 2008-08-13 17:09:25 +0200 (Wed, 13 Aug 2008) | 2 lines
Moved /pdf folder to desktop/save_pdf
........
r5110 | adamblokus | 2008-08-13 22:44:50 +0200 (Wed, 13 Aug 2008) | 2 lines
Added comments.
........
r5113 | adamblokus | 2008-08-13 23:07:35 +0200 (Wed, 13 Aug 2008) | 2 lines
Cosmetic changes
........
r5116 | adamblokus | 2008-08-14 16:10:18 +0200 (Thu, 14 Aug 2008) | 2 lines
Fixed bug with BOX_INLINE_END in tree duplication.
........
r5117 | joty | 2008-08-14 21:47:46 +0200 (Thu, 14 Aug 2008) | 1 line
Improvement for r5116: use local vars when possible; rename global last to box_duplicate_last; check on box_duplicate_main_tree failure.
........
svn path=/trunk/netsurf/; revision=5118
2008-08-15 00:32:10 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
|
2010-03-21 16:32:59 +03:00
|
|
|
/**
|
2014-05-07 19:14:18 +04:00
|
|
|
* Generate a riscos path from one or more component elemnts.
|
|
|
|
*
|
|
|
|
* Constructs a complete path element from passed components. The
|
|
|
|
* second (and subsequent) components have a slash substituted for all
|
|
|
|
* riscos directory separators.
|
2010-03-21 16:32:59 +03:00
|
|
|
*
|
2014-05-07 19:14:18 +04:00
|
|
|
* If a string is allocated it must be freed by the caller.
|
|
|
|
*
|
|
|
|
* @param[in,out] str pointer to string pointer if this is NULL enough
|
|
|
|
* storage will be allocated for the complete path.
|
|
|
|
* @param[in,out] size The size of the space available if \a str not
|
|
|
|
* NULL on input and if not NULL set to the total
|
|
|
|
* output length on output.
|
2014-11-11 18:46:04 +03:00
|
|
|
* @param[in] nelm The number of elements.
|
2014-05-07 19:14:18 +04:00
|
|
|
* @param[in] ap The elements of the path as string pointers.
|
|
|
|
* @return NSERROR_OK and the complete path is written to str
|
|
|
|
* or error code on faliure.
|
2010-03-21 16:32:59 +03:00
|
|
|
*/
|
2014-05-07 19:14:18 +04:00
|
|
|
static nserror riscos_mkpath(char **str, size_t *size, size_t nelm, va_list ap)
|
2010-03-21 16:32:59 +03:00
|
|
|
{
|
2014-05-07 19:14:18 +04:00
|
|
|
const char *elm[16];
|
|
|
|
size_t elm_len[16];
|
|
|
|
size_t elm_idx;
|
|
|
|
char *fname;
|
|
|
|
size_t fname_len = 0;
|
|
|
|
char *curp;
|
|
|
|
size_t idx;
|
|
|
|
|
|
|
|
/* check the parameters are all sensible */
|
|
|
|
if ((nelm == 0) || (nelm > 16)) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if ((*str != NULL) && (size == NULL)) {
|
|
|
|
/* if the caller is providing the buffer they must say
|
|
|
|
* how much space is available.
|
|
|
|
*/
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2010-03-21 16:32:59 +03:00
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
/* calculate how much storage we need for the complete path
|
|
|
|
* with all the elements.
|
|
|
|
*/
|
|
|
|
for (elm_idx = 0; elm_idx < nelm; elm_idx++) {
|
|
|
|
elm[elm_idx] = va_arg(ap, const char *);
|
2014-05-18 01:26:34 +04:00
|
|
|
/* check the argument is not NULL */
|
|
|
|
if (elm[elm_idx] == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-05-07 19:14:18 +04:00
|
|
|
elm_len[elm_idx] = strlen(elm[elm_idx]);
|
|
|
|
fname_len += elm_len[elm_idx];
|
|
|
|
}
|
|
|
|
fname_len += nelm; /* allow for separators and terminator */
|
|
|
|
|
|
|
|
/* ensure there is enough space */
|
|
|
|
fname = *str;
|
|
|
|
if (fname != NULL) {
|
|
|
|
if (fname_len > *size) {
|
|
|
|
return NSERROR_NOSPACE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fname = malloc(fname_len);
|
|
|
|
if (fname == NULL) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
}
|
2010-03-21 16:32:59 +03:00
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
/* copy the elements in with directory separator */
|
|
|
|
curp = fname;
|
2010-03-21 16:32:59 +03:00
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
/* first element is not altered */
|
2014-05-18 02:14:43 +04:00
|
|
|
memmove(curp, elm[0], elm_len[0]);
|
|
|
|
curp += elm_len[0];
|
2014-05-07 19:14:18 +04:00
|
|
|
/* ensure there is a delimiter */
|
|
|
|
if (curp[-1] != DIR_SEP) {
|
|
|
|
*curp = DIR_SEP;
|
|
|
|
curp++;
|
2010-03-21 16:32:59 +03:00
|
|
|
}
|
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
/* subsequent elemnts have slashes substituted with directory
|
|
|
|
* separators.
|
|
|
|
*/
|
|
|
|
for (elm_idx = 1; elm_idx < nelm; elm_idx++) {
|
|
|
|
for (idx = 0; idx < elm_len[elm_idx]; idx++) {
|
|
|
|
if (elm[elm_idx][idx] == DIR_SEP) {
|
|
|
|
*curp = '/';
|
|
|
|
} else {
|
|
|
|
*curp = elm[elm_idx][idx];
|
|
|
|
}
|
|
|
|
curp++;
|
|
|
|
}
|
|
|
|
*curp = DIR_SEP;
|
|
|
|
curp++;
|
|
|
|
}
|
|
|
|
curp[-1] = 0; /* NULL terminate */
|
|
|
|
|
|
|
|
assert((curp - fname) <= (int)fname_len);
|
|
|
|
|
|
|
|
*str = fname;
|
|
|
|
if (size != NULL) {
|
|
|
|
*size = fname_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
2010-03-21 16:32:59 +03:00
|
|
|
|
|
|
|
}
|
2010-07-09 23:45:44 +04:00
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
|
2010-07-09 23:45:44 +04:00
|
|
|
/**
|
2014-05-07 19:14:18 +04:00
|
|
|
* Get the basename of a file using posix path handling.
|
|
|
|
*
|
|
|
|
* This gets the last element of a path and returns it. The returned
|
|
|
|
* element has all forward slashes translated into riscos directory
|
|
|
|
* separators.
|
2010-07-09 23:45:44 +04:00
|
|
|
*
|
2014-05-07 19:14:18 +04:00
|
|
|
* @param[in] path The path to extract the name from.
|
|
|
|
* @param[in,out] str Pointer to string pointer if this is NULL enough
|
|
|
|
* storage will be allocated for the path element.
|
|
|
|
* @param[in,out] size The size of the space available if \a
|
|
|
|
* str not NULL on input and set to the total
|
|
|
|
* output length on output.
|
|
|
|
* @return NSERROR_OK and the complete path is written to str
|
|
|
|
* or error code on faliure.
|
2010-07-09 23:45:44 +04:00
|
|
|
*/
|
2014-05-07 19:14:18 +04:00
|
|
|
static nserror riscos_basename(const char *path, char **str, size_t *size)
|
2010-07-09 23:45:44 +04:00
|
|
|
{
|
2014-05-07 19:14:18 +04:00
|
|
|
const char *leafname;
|
|
|
|
char *fname;
|
|
|
|
char *temp;
|
2010-09-13 22:20:08 +04:00
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
if (path == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
2010-09-13 22:20:08 +04:00
|
|
|
}
|
2010-07-09 23:45:44 +04:00
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
leafname = strrchr(path, DIR_SEP);
|
|
|
|
if (!leafname) {
|
|
|
|
leafname = path;
|
|
|
|
} else {
|
|
|
|
leafname += 1;
|
|
|
|
}
|
2010-07-09 23:45:44 +04:00
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
fname = strdup(leafname);
|
|
|
|
if (fname == NULL) {
|
|
|
|
return NSERROR_NOMEM;
|
2010-09-13 22:20:08 +04:00
|
|
|
}
|
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
/** @todo check this leafname translation is actually required */
|
|
|
|
/* and s/\//\./g */
|
|
|
|
for (temp = fname; *temp != 0; temp++) {
|
|
|
|
if (*temp == '/') {
|
|
|
|
*temp = DIR_SEP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*str = fname;
|
|
|
|
if (size != NULL) {
|
|
|
|
*size = strlen(fname);
|
|
|
|
}
|
|
|
|
return NSERROR_OK;
|
2010-07-09 23:45:44 +04:00
|
|
|
}
|
2014-01-05 20:01:03 +04:00
|
|
|
|
2014-01-15 23:37:05 +04:00
|
|
|
|
2014-06-05 15:06:47 +04:00
|
|
|
/**
|
|
|
|
* Ensure that all directory elements needed to store a filename exist.
|
|
|
|
*
|
|
|
|
* Given a path of x.y.z directories x and x.y will be created.
|
|
|
|
*
|
|
|
|
* @param fname The filename to ensure the path to exists.
|
|
|
|
* @return NSERROR_OK on success or error code on failure.
|
|
|
|
*/
|
|
|
|
static nserror riscos_mkdir_all(const char *fname)
|
|
|
|
{
|
|
|
|
char *dname;
|
|
|
|
char *cur;
|
|
|
|
|
|
|
|
dname = strdup(fname);
|
|
|
|
|
|
|
|
cur = dname;
|
|
|
|
while ((cur = strchr(cur, '.'))) {
|
|
|
|
*cur = '\0';
|
|
|
|
xosfile_create_dir(dname, 0);
|
|
|
|
*cur++ = '.';
|
|
|
|
}
|
|
|
|
|
|
|
|
free(dname);
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Find screen size in OS units.
|
|
|
|
*/
|
|
|
|
void ro_gui_screen_size(int *width, int *height)
|
|
|
|
{
|
|
|
|
*width = screen_info.width;
|
|
|
|
*height = screen_info.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the debug dump of a content to a text editor.
|
|
|
|
*/
|
|
|
|
void ro_gui_dump_browser_window(struct browser_window *bw)
|
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* open file for dump */
|
|
|
|
FILE *stream = fopen("<Wimp$ScrapDir>.WWW.NetSurf.dump", "w");
|
|
|
|
if (!stream) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "fopen: errno %i", errno);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("SaveError", strerror(errno));
|
2014-06-04 19:44:29 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-04 03:36:14 +04:00
|
|
|
browser_window_debug_dump(bw, stream, CONTENT_DEBUG_RENDER);
|
2014-06-04 19:44:29 +04:00
|
|
|
|
|
|
|
fclose(stream);
|
|
|
|
|
|
|
|
/* launch file in editor */
|
|
|
|
error = xwimp_start_task("Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.dump",
|
|
|
|
0);
|
|
|
|
if (error) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "xwimp_start_task failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess);
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user("WimpError", error->errmess);
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-07 19:14:18 +04:00
|
|
|
static struct gui_file_table riscos_file_table = {
|
|
|
|
.mkpath = riscos_mkpath,
|
|
|
|
.basename = riscos_basename,
|
2014-05-27 02:43:36 +04:00
|
|
|
.nsurl_to_path = ro_nsurl_to_path,
|
|
|
|
.path_to_nsurl = ro_path_to_nsurl,
|
2014-06-05 15:06:47 +04:00
|
|
|
.mkdir_all = riscos_mkdir_all,
|
2014-05-07 19:14:18 +04:00
|
|
|
};
|
|
|
|
|
2014-01-23 03:19:57 +04:00
|
|
|
static struct gui_fetch_table riscos_fetch_table = {
|
|
|
|
.filetype = fetch_filetype,
|
|
|
|
|
|
|
|
.get_resource_url = gui_get_resource_url,
|
|
|
|
.mimetype = fetch_mimetype,
|
|
|
|
};
|
|
|
|
|
2016-04-16 00:50:28 +03:00
|
|
|
static struct gui_misc_table riscos_misc_table = {
|
2014-03-08 18:13:27 +04:00
|
|
|
.schedule = riscos_schedule,
|
2016-04-26 01:11:55 +03:00
|
|
|
.warning = ro_warn_user,
|
2014-01-23 03:19:57 +04:00
|
|
|
|
2014-01-15 03:31:54 +04:00
|
|
|
.quit = gui_quit,
|
|
|
|
.launch_url = gui_launch_url,
|
|
|
|
.cert_verify = gui_cert_verify,
|
2014-01-16 04:52:17 +04:00
|
|
|
.login = gui_401login_open,
|
2014-01-15 03:31:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-05 15:06:47 +04:00
|
|
|
static char *get_cachepath(void)
|
|
|
|
{
|
|
|
|
char *cachedir;
|
|
|
|
char *cachepath = NULL;
|
|
|
|
nserror ret;
|
|
|
|
|
|
|
|
cachedir = getenv("Cache$Dir");
|
|
|
|
if ((cachedir == NULL) || (cachedir[0] == 0)) {
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "cachedir was null");
|
2014-06-05 15:06:47 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ret = netsurf_mkpath(&cachepath, NULL, 2, cachedir, "NetSurf");
|
|
|
|
if (ret != NSERROR_OK) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return cachepath;
|
|
|
|
}
|
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
/**
|
|
|
|
* Normal entry point from RISC OS.
|
|
|
|
*/
|
2014-01-15 03:31:54 +04:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2014-06-05 15:06:47 +04:00
|
|
|
char *cachepath;
|
2014-01-15 03:31:54 +04:00
|
|
|
char path[40];
|
|
|
|
int length;
|
|
|
|
os_var_type type;
|
|
|
|
int used = -1; /* slightly better with older OSLib versions */
|
|
|
|
os_error *error;
|
|
|
|
nserror ret;
|
2014-05-10 13:22:10 +04:00
|
|
|
struct netsurf_table riscos_table = {
|
2016-04-16 00:50:28 +03:00
|
|
|
.misc = &riscos_misc_table,
|
2014-01-15 23:37:05 +04:00
|
|
|
.window = riscos_window_table,
|
2014-02-01 14:45:20 +04:00
|
|
|
.clipboard = riscos_clipboard_table,
|
2014-01-15 23:37:05 +04:00
|
|
|
.download = riscos_download_table,
|
2014-01-23 03:19:57 +04:00
|
|
|
.fetch = &riscos_fetch_table,
|
2014-05-07 19:14:18 +04:00
|
|
|
.file = &riscos_file_table,
|
2014-02-02 02:17:36 +04:00
|
|
|
.utf8 = riscos_utf8_table,
|
2014-03-19 02:32:52 +04:00
|
|
|
.search = riscos_search_table,
|
2014-06-05 15:06:47 +04:00
|
|
|
.llcache = filesystem_llcache_table,
|
2015-04-16 01:57:39 +03:00
|
|
|
.bitmap = riscos_bitmap_table,
|
2016-04-24 15:32:07 +03:00
|
|
|
.layout = riscos_layout_table,
|
2014-01-15 23:37:05 +04:00
|
|
|
};
|
2014-01-15 03:31:54 +04:00
|
|
|
|
2014-05-10 13:22:10 +04:00
|
|
|
ret = netsurf_register(&riscos_table);
|
|
|
|
if (ret != NSERROR_OK) {
|
|
|
|
die("NetSurf operation table failed registration");
|
|
|
|
}
|
|
|
|
|
2014-01-15 03:31:54 +04:00
|
|
|
/* Consult NetSurf$Logging environment variable to decide if logging
|
|
|
|
* is required. */
|
|
|
|
error = xos_read_var_val_size("NetSurf$Logging", 0, os_VARTYPE_STRING,
|
|
|
|
&used, NULL, &type);
|
|
|
|
if (error != NULL || type != os_VARTYPE_STRING || used != -2) {
|
|
|
|
verbose_log = true;
|
|
|
|
} else {
|
2014-05-26 13:40:54 +04:00
|
|
|
char logging_env[2];
|
2014-01-15 03:31:54 +04:00
|
|
|
error = xos_read_var_val("NetSurf$Logging", logging_env,
|
|
|
|
sizeof(logging_env), 0, os_VARTYPE_STRING,
|
|
|
|
&used, NULL, &type);
|
|
|
|
if (error != NULL || logging_env[0] != '0') {
|
|
|
|
verbose_log = true;
|
|
|
|
} else {
|
|
|
|
verbose_log = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialise logging. Not fatal if it fails but not much we
|
|
|
|
* can do about it either.
|
|
|
|
*/
|
|
|
|
nslog_init(nslog_stream_configure, &argc, argv);
|
|
|
|
|
|
|
|
/* user options setup */
|
|
|
|
ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
|
|
|
|
if (ret != NSERROR_OK) {
|
|
|
|
die("Options failed to initialise");
|
|
|
|
}
|
|
|
|
nsoption_read("NetSurf:Choices", NULL);
|
|
|
|
nsoption_commandline(&argc, argv, NULL);
|
|
|
|
|
|
|
|
/* Choose the interface language to use */
|
|
|
|
ro_gui_choose_language();
|
|
|
|
|
|
|
|
/* select language-specific Messages */
|
|
|
|
if (((length = snprintf(path,
|
|
|
|
sizeof(path),
|
|
|
|
"NetSurf:Resources.%s.Messages",
|
2014-06-04 19:44:29 +04:00
|
|
|
nsoption_charp(language))) < 0) ||
|
2014-01-15 03:31:54 +04:00
|
|
|
(length >= (int)sizeof(path))) {
|
|
|
|
die("Failed to locate Messages resource.");
|
|
|
|
}
|
|
|
|
|
2015-06-19 18:29:42 +03:00
|
|
|
/* initialise messages */
|
|
|
|
messages_add_from_file(path);
|
|
|
|
|
2014-06-05 15:06:47 +04:00
|
|
|
/* obtain cache path */
|
|
|
|
cachepath = get_cachepath();
|
|
|
|
|
2014-01-15 03:31:54 +04:00
|
|
|
/* common initialisation */
|
2015-06-19 18:29:42 +03:00
|
|
|
ret = netsurf_init(cachepath);
|
2014-06-05 15:06:47 +04:00
|
|
|
free(cachepath);
|
2014-01-15 03:31:54 +04:00
|
|
|
if (ret != NSERROR_OK) {
|
2014-06-05 15:06:47 +04:00
|
|
|
die("NetSurf failed to initialise core");
|
2014-01-15 03:31:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
artworks_init();
|
|
|
|
draw_init();
|
|
|
|
sprite_init();
|
|
|
|
|
|
|
|
/* Load some extra RISC OS specific Messages */
|
2015-06-19 18:29:42 +03:00
|
|
|
messages_add_from_file("NetSurf:Resources.LangNames");
|
2014-01-15 03:31:54 +04:00
|
|
|
|
2014-06-04 19:44:29 +04:00
|
|
|
ret = gui_init(argc, argv);
|
|
|
|
if (ret != NSERROR_OK) {
|
2016-04-26 01:11:55 +03:00
|
|
|
ro_warn_user(messages_get_errorcode(ret), 0);
|
2014-06-04 19:44:29 +04:00
|
|
|
}
|
2014-01-15 03:31:54 +04:00
|
|
|
|
2014-10-13 03:56:09 +04:00
|
|
|
while (!riscos_done) {
|
|
|
|
riscos_poll();
|
|
|
|
}
|
2014-01-15 03:31:54 +04:00
|
|
|
|
|
|
|
netsurf_exit();
|
2016-12-11 19:47:14 +03:00
|
|
|
nsoption_finalise(nsoptions, nsoptions_default);
|
2014-01-15 03:31:54 +04:00
|
|
|
|
2017-09-10 16:22:05 +03:00
|
|
|
/* finalise logging */
|
|
|
|
nslog_finalise();
|
|
|
|
|
2014-01-15 03:31:54 +04:00
|
|
|
return 0;
|
|
|
|
}
|