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
|
|
|
*/
|
|
|
|
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <assert.h>
|
2004-07-17 17:00:38 +04:00
|
|
|
#include <errno.h>
|
2005-06-27 02:25:49 +04:00
|
|
|
#include <fpu_control.h>
|
2005-02-08 02:00:09 +03:00
|
|
|
#include <signal.h>
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <stdbool.h>
|
2003-08-27 02:37:32 +04:00
|
|
|
#include <stddef.h>
|
2003-07-15 18:37:34 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2005-06-27 02:25:49 +04:00
|
|
|
#include <features.h>
|
2003-11-08 02:51:13 +03:00
|
|
|
#include <unixlib/local.h>
|
2007-07-15 21:20:25 +04:00
|
|
|
#include <curl/curl.h>
|
2008-07-27 02:29:15 +04:00
|
|
|
#include "oslib/font.h"
|
|
|
|
#include "oslib/help.h"
|
|
|
|
#include "oslib/hourglass.h"
|
|
|
|
#include "oslib/inetsuite.h"
|
|
|
|
#include "oslib/os.h"
|
|
|
|
#include "oslib/osbyte.h"
|
|
|
|
#include "oslib/osfile.h"
|
|
|
|
#include "oslib/osfscontrol.h"
|
|
|
|
#include "oslib/osgbpb.h"
|
|
|
|
#include "oslib/osmodule.h"
|
|
|
|
#include "oslib/osspriteop.h"
|
|
|
|
#include "oslib/pdriver.h"
|
|
|
|
#include "oslib/plugin.h"
|
|
|
|
#include "oslib/wimp.h"
|
|
|
|
#include "oslib/wimpspriteop.h"
|
|
|
|
#include "oslib/uri.h"
|
|
|
|
#include "rufl.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#include "content/content.h"
|
2010-04-07 14:33:46 +04:00
|
|
|
#include "content/hlcache.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "content/urldb.h"
|
2011-02-24 01:27:55 +03:00
|
|
|
#include "content/fetchers/resource.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "desktop/cookies.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/gui.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "desktop/history_global_core.h"
|
|
|
|
#include "desktop/hotlist.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/netsurf.h"
|
|
|
|
#include "desktop/options.h"
|
2009-12-18 02:55:02 +03:00
|
|
|
#include "desktop/save_complete.h"
|
2011-09-18 15:50:34 +04:00
|
|
|
#include "desktop/sslcert.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "desktop/tree.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "desktop/tree_url_node.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "render/box.h"
|
|
|
|
#include "render/font.h"
|
|
|
|
#include "render/html.h"
|
2011-05-09 13:57:40 +04:00
|
|
|
#include "riscos/content-handlers/artworks.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/bitmap.h"
|
|
|
|
#include "riscos/buffer.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "riscos/cookies.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/dialog.h"
|
2011-05-09 13:57:40 +04:00
|
|
|
#include "riscos/content-handlers/draw.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/global_history.h"
|
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/help.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "riscos/hotlist.h"
|
2011-02-21 02:16:33 +03:00
|
|
|
#include "riscos/iconbar.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/menus.h"
|
|
|
|
#include "riscos/message.h"
|
|
|
|
#include "riscos/options.h"
|
|
|
|
#include "riscos/print.h"
|
|
|
|
#include "riscos/query.h"
|
|
|
|
#include "riscos/save.h"
|
2010-10-05 23:14:46 +04:00
|
|
|
#include "riscos/sslcert.h"
|
2011-05-09 13:57:40 +04:00
|
|
|
#include "riscos/content-handlers/sprite.h"
|
2011-02-26 02:26:36 +03:00
|
|
|
#include "riscos/system_colour.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/textselection.h"
|
|
|
|
#include "riscos/theme.h"
|
2011-02-21 02:16:33 +03:00
|
|
|
#include "riscos/toolbar.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/treeview.h"
|
|
|
|
#include "riscos/uri.h"
|
|
|
|
#include "riscos/url_protocol.h"
|
|
|
|
#include "riscos/url_complete.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
2009-03-28 22:10:29 +03:00
|
|
|
#include "riscos/wimputils.h"
|
2011-02-21 02:16:33 +03:00
|
|
|
#include "riscos/window.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/filename.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/url.h"
|
|
|
|
#include "utils/utils.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef FILETYPE_ACORN_URI
|
|
|
|
#define FILETYPE_ACORN_URI 0xf91
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_ANT_URL
|
|
|
|
#define FILETYPE_ANT_URL 0xb28
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_IEURL
|
|
|
|
#define FILETYPE_IEURL 0x1ba
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_HTML
|
|
|
|
#define FILETYPE_HTML 0xfaf
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_JNG
|
|
|
|
#define FILETYPE_JNG 0xf78
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_CSS
|
|
|
|
#define FILETYPE_CSS 0xf79
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_MNG
|
|
|
|
#define FILETYPE_MNG 0xf83
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_GIF
|
|
|
|
#define FILETYPE_GIF 0x695
|
|
|
|
#endif
|
2006-02-25 21:51:51 +03:00
|
|
|
#ifndef FILETYPE_BMP
|
|
|
|
#define FILETYPE_BMP 0x69c
|
|
|
|
#endif
|
2006-02-26 05:25:19 +03:00
|
|
|
#ifndef FILETYPE_ICO
|
|
|
|
#define FILETYPE_ICO 0x132
|
|
|
|
#endif
|
2005-04-05 02:14:51 +04:00
|
|
|
#ifndef FILETYPE_PNG
|
|
|
|
#define FILETYPE_PNG 0xb60
|
|
|
|
#endif
|
|
|
|
#ifndef FILETYPE_JPEG
|
|
|
|
#define FILETYPE_JPEG 0xc85
|
|
|
|
#endif
|
2005-12-10 17:31:33 +03:00
|
|
|
#ifndef FILETYPE_ARTWORKS
|
|
|
|
#define FILETYPE_ARTWORKS 0xd94
|
|
|
|
#endif
|
2007-07-13 12:25:34 +04:00
|
|
|
#ifndef FILETYPE_SVG
|
|
|
|
#define FILETYPE_SVG 0xaad
|
|
|
|
#endif
|
2005-04-05 02:14:51 +04:00
|
|
|
|
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."
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/** The pointer is over a window which is tracking mouse movement. */
|
|
|
|
static bool gui_track = false;
|
|
|
|
/** Handle of window which the pointer is over. */
|
|
|
|
static wimp_w gui_track_wimp_w;
|
|
|
|
/** Browser window which the pointer is over, or 0 if none. */
|
2006-09-02 19:52:41 +04:00
|
|
|
struct gui_window *gui_track_gui_window;
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
gui_drag_type gui_current_drag_type;
|
2004-04-02 04:41:10 +04:00
|
|
|
wimp_t task_handle; /**< RISC OS wimp task handle. */
|
2004-03-30 15:45:48 +04:00
|
|
|
static clock_t gui_last_poll; /**< Time of last wimp_poll. */
|
2004-12-09 13:30:44 +03:00
|
|
|
osspriteop_area *gui_sprites; /**< Sprite area containing pointer and hotlist sprites */
|
2004-05-08 22:12:36 +04:00
|
|
|
|
2006-01-06 03:57:01 +03:00
|
|
|
/** Previously registered signal handlers */
|
|
|
|
static struct {
|
|
|
|
void (*sigabrt)(int);
|
|
|
|
void (*sigfpe)(int);
|
|
|
|
void (*sigill)(int);
|
|
|
|
void (*sigint)(int);
|
|
|
|
void (*sigsegv)(int);
|
|
|
|
void (*sigterm)(int);
|
|
|
|
} prev_sigs;
|
|
|
|
|
2003-11-08 02:51:13 +03: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,
|
|
|
|
0
|
|
|
|
}
|
|
|
|
};
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2006-02-04 00:20:43 +03:00
|
|
|
static struct
|
|
|
|
{
|
|
|
|
int width; /* in OS units */
|
|
|
|
int height;
|
|
|
|
} screen_info;
|
|
|
|
|
2006-01-08 04:51:33 +03:00
|
|
|
static void ro_gui_create_dirs(void);
|
2006-09-06 18:44:42 +04:00
|
|
|
static void ro_gui_create_dir(char *path);
|
2004-02-27 17:09:15 +03:00
|
|
|
static void ro_gui_choose_language(void);
|
2005-02-22 00:10:48 +03:00
|
|
|
static void ro_gui_signal(int sig);
|
|
|
|
static void ro_gui_cleanup(void);
|
2004-01-28 21:37:56 +03:00
|
|
|
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
|
|
|
|
static void ro_gui_null_reason_code(void);
|
|
|
|
static void ro_gui_close_window_request(wimp_close *close);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_gui_pointer_leaving_window(wimp_leaving *leaving);
|
|
|
|
static void ro_gui_pointer_entering_window(wimp_entering *entering);
|
2004-05-07 23:14:54 +04:00
|
|
|
static void ro_gui_check_resolvers(void);
|
2004-02-26 03:44:42 +03:00
|
|
|
static void ro_gui_drag_end(wimp_dragged *drag);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_gui_keypress(wimp_key *key);
|
2004-01-28 21:37:56 +03:00
|
|
|
static void ro_gui_user_message(wimp_event_no event, wimp_message *message);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_msg_dataload(wimp_message *block);
|
2005-04-08 06:06:46 +04:00
|
|
|
static char *ro_gui_uri_file_parse(const char *file_name, char **uri_title);
|
2004-07-17 17:00:38 +04:00
|
|
|
static bool ro_gui_uri_file_parse_line(FILE *fp, char *b);
|
|
|
|
static char *ro_gui_url_file_parse(const char *file_name);
|
2005-02-03 23:49:43 +03:00
|
|
|
static char *ro_gui_ieurl_file_parse(const char *file_name);
|
2005-09-02 00:29:59 +04:00
|
|
|
static void ro_msg_terminate_filename(wimp_full_message_data_xfer *message);
|
2005-04-05 02:14:51 +04:00
|
|
|
static void ro_msg_datasave(wimp_message *message);
|
2004-07-17 17:00:38 +04:00
|
|
|
static void ro_msg_datasave_ack(wimp_message *message);
|
2006-01-09 03:12:09 +03:00
|
|
|
static void ro_msg_dataopen(wimp_message *message);
|
2006-02-04 00:20:43 +03:00
|
|
|
static void ro_gui_get_screen_properties(void);
|
2005-04-23 06:58:27 +04:00
|
|
|
static void ro_msg_prequit(wimp_message *message);
|
|
|
|
static void ro_msg_save_desktop(wimp_message *message);
|
2006-03-24 06:44:37 +03:00
|
|
|
static void ro_msg_window_info(wimp_message *message);
|
2006-01-09 03:12:09 +03:00
|
|
|
static void ro_gui_view_source_bounce(wimp_message *message);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
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 */
|
|
|
|
if (strcmp(path, "adblock.css") == 0)
|
|
|
|
path = "AdBlock";
|
|
|
|
else if (strcmp(path, "default.css") == 0)
|
|
|
|
path = "CSS";
|
|
|
|
else if (strcmp(path, "quirks.css") == 0)
|
|
|
|
path = "Quirks";
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/**
|
|
|
|
* Initialise the gui (RISC OS specific part).
|
|
|
|
*/
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2010-03-30 00:03:44 +04:00
|
|
|
static void gui_init(int argc, char** argv)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-02-27 17:09:15 +03:00
|
|
|
char path[40];
|
|
|
|
os_error *error;
|
2004-06-09 01:35:28 +04:00
|
|
|
int length;
|
2005-03-20 04:55:48 +03:00
|
|
|
char *nsdir_temp;
|
2006-07-16 20:52:28 +04:00
|
|
|
byte *base;
|
2003-08-25 02:39:55 +04:00
|
|
|
|
2005-06-27 03:23:55 +04:00
|
|
|
/* re-enable all FPU exceptions/traps except inexact operations,
|
2006-02-09 03:43:32 +03:00
|
|
|
* 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));
|
2005-06-27 02:25:49 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
xhourglass_start(1);
|
|
|
|
|
2006-01-08 04:51:33 +03:00
|
|
|
/* read OS version for code that adapts to conform to the OS
|
|
|
|
* (remember that it's preferable to check for specific features
|
|
|
|
* being present) */
|
2005-04-22 01:36:23 +04:00
|
|
|
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
|
|
|
|
|
2006-07-16 20:52:28 +04:00
|
|
|
/* 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)) {
|
2006-08-22 07:33:05 +04:00
|
|
|
#if 0 // this fault still hasn't been fixed, so disable patterned lines for all versions until it has
|
2006-07-16 20:52:28 +04:00
|
|
|
const char *help = (char*)base + ((int*)base)[5];
|
|
|
|
while (*help > 9) help++;
|
|
|
|
while (*help == 9) help++;
|
|
|
|
if (!memcmp(help, "0.55", 4))
|
2006-08-22 07:33:05 +04:00
|
|
|
#endif
|
2006-10-12 18:00:40 +04:00
|
|
|
ro_plot_patterned_lines = false;
|
2006-07-16 20:52:28 +04:00
|
|
|
}
|
|
|
|
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Set defaults for absent option strings */
|
2005-02-08 02:00:09 +03:00
|
|
|
if (!option_theme)
|
2005-03-21 17:48:26 +03:00
|
|
|
option_theme = strdup("Aletheia");
|
|
|
|
if (!option_toolbar_browser)
|
2005-03-21 18:27:31 +03:00
|
|
|
option_toolbar_browser = strdup("0123|58|9");
|
2005-03-21 17:48:26 +03:00
|
|
|
if (!option_toolbar_hotlist)
|
2006-07-13 16:46:02 +04:00
|
|
|
option_toolbar_hotlist = strdup("40|12|3");
|
2005-03-21 17:48:26 +03:00
|
|
|
if (!option_toolbar_history)
|
2006-07-13 16:46:02 +04:00
|
|
|
option_toolbar_history = strdup("0|12|3");
|
|
|
|
if (!option_toolbar_cookies)
|
|
|
|
option_toolbar_cookies = strdup("0|12");
|
2006-01-08 04:51:33 +03:00
|
|
|
if (!option_ca_bundle)
|
|
|
|
option_ca_bundle = strdup("NetSurf:Resources.ca-bundle");
|
|
|
|
if (!option_cookie_file)
|
|
|
|
option_cookie_file = strdup("NetSurf:Cookies");
|
|
|
|
if (!option_cookie_jar)
|
|
|
|
option_cookie_jar = strdup(CHOICES_PREFIX "Cookies");
|
|
|
|
if (!option_url_path)
|
|
|
|
option_url_path = strdup("NetSurf:URL");
|
|
|
|
if (!option_url_save)
|
|
|
|
option_url_save = strdup(CHOICES_PREFIX "URL");
|
|
|
|
if (!option_hotlist_path)
|
|
|
|
option_hotlist_path = strdup("NetSurf:Hotlist");
|
|
|
|
if (!option_hotlist_save)
|
|
|
|
option_hotlist_save = strdup(CHOICES_PREFIX "Hotlist");
|
|
|
|
if (!option_recent_path)
|
|
|
|
option_recent_path = strdup("NetSurf:Recent");
|
|
|
|
if (!option_recent_save)
|
|
|
|
option_recent_save = strdup(CHOICES_PREFIX "Recent");
|
|
|
|
if (!option_theme_path)
|
|
|
|
option_theme_path = strdup("NetSurf:Themes");
|
|
|
|
if (!option_theme_save)
|
|
|
|
option_theme_save = strdup(CHOICES_PREFIX "Themes");
|
2011-02-21 02:16:33 +03:00
|
|
|
|
2011-01-20 17:05:13 +03:00
|
|
|
tree_set_icon_dir(strdup("NetSurf:Resources.Icons"));
|
2006-01-08 04:51:33 +03:00
|
|
|
|
|
|
|
if (!option_theme || ! option_toolbar_browser ||
|
|
|
|
!option_toolbar_hotlist || !option_toolbar_history ||
|
|
|
|
!option_ca_bundle || !option_cookie_file ||
|
|
|
|
!option_cookie_jar || !option_url_path ||
|
|
|
|
!option_url_save || !option_hotlist_path ||
|
|
|
|
!option_hotlist_save || !option_recent_path ||
|
|
|
|
!option_recent_save || !option_theme_path ||
|
2011-01-20 17:05:13 +03:00
|
|
|
!option_theme_save)
|
2006-01-08 04:51:33 +03:00
|
|
|
die("Failed initialising string options");
|
2005-02-08 02:00:09 +03:00
|
|
|
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Create our choices directories */
|
2006-01-08 04:51:33 +03:00
|
|
|
ro_gui_create_dirs();
|
|
|
|
|
2006-10-12 18:00:40 +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);
|
|
|
|
|
|
|
|
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 ||
|
|
|
|
prev_sigs.sigterm == SIG_ERR)
|
|
|
|
die("Failed registering signal handlers");
|
|
|
|
|
|
|
|
/* Load in UI sprites */
|
2006-01-08 04:51:33 +03:00
|
|
|
gui_sprites = ro_gui_load_sprite_file("NetSurf:Resources.Sprites");
|
2006-01-02 08:21:57 +03:00
|
|
|
if (!gui_sprites)
|
|
|
|
die("Unable to load Sprites.");
|
2004-02-27 17:09:15 +03:00
|
|
|
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Find NetSurf directory */
|
2005-03-20 04:55:48 +03:00
|
|
|
nsdir_temp = getenv("NetSurf$Dir");
|
|
|
|
if (!nsdir_temp)
|
|
|
|
die("Failed to locate NetSurf directory");
|
|
|
|
NETSURF_DIR = strdup(nsdir_temp);
|
2006-01-08 04:51:33 +03:00
|
|
|
if (!NETSURF_DIR)
|
|
|
|
die("Failed duplicating NetSurf directory string");
|
2005-03-20 04:55:48 +03:00
|
|
|
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Initialise filename allocator */
|
|
|
|
filename_initialise();
|
|
|
|
|
|
|
|
/* Initialise save complete functionality */
|
|
|
|
save_complete_init();
|
|
|
|
|
|
|
|
/* Initialise bitmap memory pool */
|
|
|
|
bitmap_initialise_memory();
|
|
|
|
|
|
|
|
/* Load in visited URLs and Cookies */
|
|
|
|
urldb_load(option_url_path);
|
|
|
|
urldb_load_cookies(option_cookie_file);
|
|
|
|
|
|
|
|
/* Initialise with the wimp */
|
2006-01-08 04:51:33 +03:00
|
|
|
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
|
2009-03-28 22:10:29 +03:00
|
|
|
PTR_WIMP_MESSAGE_LIST(&task_messages), 0,
|
2004-07-19 02:21:32 +04:00
|
|
|
&task_handle);
|
2004-05-08 22:12:36 +04:00
|
|
|
if (error) {
|
2005-02-22 00:10:48 +03:00
|
|
|
LOG(("xwimp_initialise: 0x%x: %s",
|
2004-03-08 03:03:58 +03:00
|
|
|
error->errnum, error->errmess));
|
2004-05-08 22:12:36 +04:00
|
|
|
die(error->errmess);
|
|
|
|
}
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Register message handlers */
|
2006-01-09 03:12:09 +03:00
|
|
|
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);
|
2006-02-16 02:09:55 +03:00
|
|
|
ro_message_register_route(message_DRAGGING,
|
|
|
|
ro_gui_selection_dragging);
|
|
|
|
ro_message_register_route(message_DRAG_CLAIM,
|
|
|
|
ro_gui_selection_drag_claim);
|
2006-03-24 06:44:37 +03:00
|
|
|
ro_message_register_route(message_WINDOW_INFO,
|
|
|
|
ro_msg_window_info);
|
2003-09-09 23:25:28 +04:00
|
|
|
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Initialise the font subsystem */
|
2005-02-23 02:36:14 +03:00
|
|
|
nsfont_init();
|
2006-10-12 18:00:40 +04:00
|
|
|
|
|
|
|
/* Initialise global information */
|
2006-02-04 00:20:43 +03:00
|
|
|
ro_gui_get_screen_properties();
|
2006-07-18 05:51:19 +04:00
|
|
|
ro_gui_wimp_get_desktop_font();
|
2004-09-14 03:56:18 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/* Issue a *Desktop to poke AcornURI into life */
|
|
|
|
if (getenv("NetSurf$Start_URI_Handler"))
|
|
|
|
xwimp_start_task("Desktop", 0);
|
2003-09-05 18:35:36 +04:00
|
|
|
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Open the templates */
|
2004-06-09 01:35:28 +04:00
|
|
|
if ((length = snprintf(path, sizeof(path),
|
2006-01-08 04:51:33 +03:00
|
|
|
"NetSurf:Resources.%s.Templates",
|
2004-06-11 02:39:56 +04:00
|
|
|
option_language)) < 0 || length >= (int)sizeof(path))
|
2004-06-09 01:35:28 +04:00
|
|
|
die("Failed to locate Templates resource.");
|
2004-02-27 17:09:15 +03:00
|
|
|
error = xwimp_open_template(path);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_template failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-03-27 03:49:29 +03:00
|
|
|
die(error->errmess);
|
2003-12-30 01:50:43 +03:00
|
|
|
}
|
2006-10-12 18:00:40 +04:00
|
|
|
|
|
|
|
/* Initialise themes before dialogs */
|
|
|
|
ro_gui_theme_initialise();
|
|
|
|
/* Initialise dialog windows (must be after UI sprites are loaded) */
|
|
|
|
ro_gui_dialog_init();
|
|
|
|
/* Initialise download window */
|
2003-11-08 02:51:13 +03:00
|
|
|
ro_gui_download_init();
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Initialise menus */
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_init();
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Initialise query windows */
|
2005-04-23 06:58:27 +04:00
|
|
|
ro_gui_query_init();
|
2006-10-12 18:00:40 +04:00
|
|
|
/* Initialise the history subsystem */
|
2003-11-15 03:26:42 +03:00
|
|
|
ro_gui_history_init();
|
2011-02-21 02:16:33 +03:00
|
|
|
/* Initialise toolbars */
|
|
|
|
ro_toolbar_init();
|
|
|
|
/* Initialise browser windows */
|
|
|
|
ro_gui_window_initialise();
|
2006-10-12 18:00:40 +04:00
|
|
|
|
|
|
|
/* Done with the templates file */
|
2003-11-08 02:51:13 +03:00
|
|
|
wimp_close_template();
|
2004-07-19 02:21:32 +04:00
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
/* Create Iconbar icon and menus */
|
|
|
|
ro_gui_iconbar_initialise();
|
2006-10-12 18:00:40 +04:00
|
|
|
|
|
|
|
/* Finally, check Inet$Resolvers for sanity */
|
2004-05-07 23:14:54 +04:00
|
|
|
ro_gui_check_resolvers();
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2006-01-08 04:51:33 +03:00
|
|
|
/**
|
|
|
|
* Create intermediate directories for Choices and User Data files
|
|
|
|
*/
|
|
|
|
void ro_gui_create_dirs(void)
|
|
|
|
{
|
|
|
|
char buf[256];
|
2006-09-06 18:44:42 +04:00
|
|
|
char *path;
|
2006-01-08 04:51:33 +03:00
|
|
|
|
|
|
|
/* Choices */
|
|
|
|
path = getenv("NetSurf$ChoicesSave");
|
|
|
|
if (!path)
|
|
|
|
die("Failed to find NetSurf Choices save path");
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s", path);
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_create_dir(buf);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
|
|
|
/* URL */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", option_url_save);
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_create_dir(buf);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
|
|
|
/* Hotlist */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", option_hotlist_save);
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_create_dir(buf);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
|
|
|
/* Recent */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", option_recent_save);
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_create_dir(buf);
|
2006-01-08 04:51:33 +03:00
|
|
|
|
|
|
|
/* Theme */
|
|
|
|
snprintf(buf, sizeof(buf), "%s", option_theme_save);
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_create_dir(buf);
|
2006-01-08 04:51:33 +03:00
|
|
|
/* and the final directory part (as theme_save is a directory) */
|
|
|
|
xosfile_create_dir(buf, 0);
|
|
|
|
}
|
2005-02-23 02:36:14 +03:00
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create directory structure for a path
|
|
|
|
*
|
|
|
|
* Given a path of x.y.z directories x and x.y will be created
|
|
|
|
*
|
|
|
|
* \param path the directory path to create
|
|
|
|
*/
|
|
|
|
void ro_gui_create_dir(char *path)
|
|
|
|
{
|
|
|
|
char *cur = path;
|
|
|
|
while ((cur = strchr(cur, '.'))) {
|
|
|
|
*cur = '\0';
|
|
|
|
xosfile_create_dir(path, 0);
|
|
|
|
*cur++ = '.';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-27 17:09:15 +03:00
|
|
|
/**
|
2006-01-25 05:43:07 +03:00
|
|
|
* Choose the language to use.
|
2004-02-27 17:09:15 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_choose_language(void)
|
|
|
|
{
|
|
|
|
char path[40];
|
|
|
|
|
|
|
|
/* if option_language exists and is valid, use that */
|
|
|
|
if (option_language) {
|
|
|
|
if (2 < strlen(option_language))
|
|
|
|
option_language[2] = 0;
|
2006-01-08 04:51:33 +03:00
|
|
|
sprintf(path, "NetSurf:Resources.%s", option_language);
|
2004-03-08 03:03:58 +03:00
|
|
|
if (is_dir(path)) {
|
|
|
|
if (!option_accept_language)
|
|
|
|
option_accept_language = strdup(option_language);
|
2004-02-27 17:09:15 +03:00
|
|
|
return;
|
2004-03-08 03:03:58 +03:00
|
|
|
}
|
2004-02-27 17:09:15 +03:00
|
|
|
free(option_language);
|
|
|
|
option_language = 0;
|
|
|
|
}
|
2006-03-25 23:30:35 +03:00
|
|
|
|
2006-01-25 05:43:07 +03:00
|
|
|
option_language = strdup(ro_gui_default_language());
|
2007-07-15 21:20:25 +04:00
|
|
|
if (!option_language)
|
|
|
|
die("Out of memory");
|
2006-01-25 05:43:07 +03:00
|
|
|
option_accept_language = strdup(option_language);
|
2007-07-15 21:20:25 +04:00
|
|
|
if (!option_accept_language)
|
|
|
|
die("Out of memory");
|
2006-01-25 05:43:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine the default language to use.
|
|
|
|
*
|
|
|
|
* RISC OS has no standard way of determining which language the user prefers.
|
|
|
|
* We have to guess from the 'Country' setting.
|
|
|
|
*/
|
2007-07-15 21:20:25 +04:00
|
|
|
|
|
|
|
const char *ro_gui_default_language(void)
|
|
|
|
{
|
2006-01-25 05:43:07 +03:00
|
|
|
char path[40];
|
|
|
|
const char *lang;
|
|
|
|
int country;
|
|
|
|
os_error *error;
|
2004-02-27 17:09:15 +03:00
|
|
|
|
|
|
|
/* choose a language from the configured country number */
|
|
|
|
error = xosbyte_read(osbyte_VAR_COUNTRY_NUMBER, &country);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosbyte_read failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
country = 1;
|
|
|
|
}
|
|
|
|
switch (country) {
|
2004-09-25 03:52:40 +04:00
|
|
|
case 7: /* Germany */
|
2005-06-22 04:21:36 +04:00
|
|
|
case 30: /* Austria */
|
|
|
|
case 35: /* Switzerland (70% German-speaking) */
|
2004-09-25 03:52:40 +04:00
|
|
|
lang = "de";
|
|
|
|
break;
|
2004-02-27 17:09:15 +03:00
|
|
|
case 6: /* France */
|
|
|
|
case 18: /* Canada2 (French Canada?) */
|
|
|
|
lang = "fr";
|
|
|
|
break;
|
2005-06-22 03:56:40 +04:00
|
|
|
case 34: /* Netherlands */
|
|
|
|
lang = "nl";
|
|
|
|
break;
|
2004-02-27 17:09:15 +03:00
|
|
|
default:
|
|
|
|
lang = "en";
|
|
|
|
break;
|
|
|
|
}
|
2006-01-08 04:51:33 +03:00
|
|
|
sprintf(path, "NetSurf:Resources.%s", lang);
|
2004-02-27 17:09:15 +03:00
|
|
|
if (is_dir(path))
|
2006-01-25 05:43:07 +03:00
|
|
|
return lang;
|
|
|
|
return "en";
|
2004-02-27 17:09:15 +03:00
|
|
|
}
|
|
|
|
|
2004-04-10 01:06:10 +04:00
|
|
|
|
2004-05-07 23:14:54 +04:00
|
|
|
/**
|
|
|
|
* Warn the user if Inet$Resolvers is not set.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_check_resolvers(void)
|
|
|
|
{
|
2004-06-10 01:04:45 +04:00
|
|
|
char *resolvers;
|
|
|
|
resolvers = getenv("Inet$Resolvers");
|
2004-06-18 21:03:22 +04:00
|
|
|
if (resolvers && resolvers[0]) {
|
2004-06-10 01:04:45 +04:00
|
|
|
LOG(("Inet$Resolvers '%s'", resolvers));
|
|
|
|
} else {
|
2004-06-18 21:03:22 +04:00
|
|
|
LOG(("Inet$Resolvers not set or empty"));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("Resolvers", 0);
|
2004-06-10 01:04:45 +04:00
|
|
|
}
|
2004-05-07 23:14:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-29 03:07:52 +04:00
|
|
|
/**
|
|
|
|
* Last-minute gui init, after all other modules have initialised.
|
|
|
|
*/
|
|
|
|
|
2010-03-29 20:59:30 +04:00
|
|
|
static void gui_init2(int argc, char** argv)
|
2004-07-29 03:07:52 +04:00
|
|
|
{
|
2004-09-27 09:21:00 +04:00
|
|
|
char *url = 0;
|
|
|
|
bool open_window = option_open_browser_at_startup;
|
|
|
|
|
2010-10-05 23:14:46 +04:00
|
|
|
/* Complete initialisation of the treeview modules. */
|
|
|
|
|
|
|
|
/* certificate verification window */
|
|
|
|
ro_gui_cert_postinitialise();
|
|
|
|
|
|
|
|
/* hotlist window */
|
|
|
|
ro_gui_hotlist_postinitialise();
|
|
|
|
|
|
|
|
/* global history window */
|
|
|
|
ro_gui_global_history_postinitialise();
|
|
|
|
|
|
|
|
/* cookies window */
|
|
|
|
ro_gui_cookies_postinitialise();
|
|
|
|
|
|
|
|
|
2004-09-27 09:21:00 +04:00
|
|
|
/* parse command-line arguments */
|
|
|
|
if (argc == 2) {
|
|
|
|
LOG(("parameters: '%s'", argv[1]));
|
|
|
|
/* this is needed for launching URI files */
|
|
|
|
if (strcasecmp(argv[1], "-nowin") == 0)
|
|
|
|
open_window = false;
|
|
|
|
}
|
|
|
|
else if (argc == 3) {
|
|
|
|
LOG(("parameters: '%s' '%s'", argv[1], argv[2]));
|
|
|
|
open_window = true;
|
|
|
|
|
|
|
|
/* HTML files */
|
|
|
|
if (strcasecmp(argv[1], "-html") == 0) {
|
2006-01-18 03:54:27 +03:00
|
|
|
url = path_to_url(argv[2]);
|
2004-09-27 09:21:00 +04:00
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* URL files */
|
|
|
|
else if (strcasecmp(argv[1], "-urlf") == 0) {
|
|
|
|
url = ro_gui_url_file_parse(argv[2]);
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* ANT URL Load */
|
|
|
|
else if (strcasecmp(argv[1], "-url") == 0) {
|
|
|
|
url = strdup(argv[2]);
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Unknown => exit here. */
|
|
|
|
else {
|
|
|
|
LOG(("Unknown parameters: '%s' '%s'",
|
|
|
|
argv[1], argv[2]));
|
|
|
|
return;
|
2004-07-29 03:07:52 +04:00
|
|
|
}
|
|
|
|
}
|
2004-09-27 09:21:00 +04:00
|
|
|
/* get user's homepage (if configured) */
|
|
|
|
else if (option_homepage_url && option_homepage_url[0]) {
|
|
|
|
url = calloc(strlen(option_homepage_url) + 5, sizeof(char));
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
|
|
|
sprintf(url, "%s", option_homepage_url);
|
|
|
|
}
|
|
|
|
/* default homepage */
|
|
|
|
else {
|
|
|
|
url = calloc(80, sizeof(char));
|
|
|
|
if (!url) {
|
|
|
|
LOG(("malloc failed"));
|
|
|
|
die("Insufficient memory for URL");
|
|
|
|
}
|
2008-01-20 02:42:26 +03:00
|
|
|
snprintf(url, 80, "file:///<NetSurf$Dir>/Docs/welcome/index_%s",
|
2004-09-27 09:21:00 +04:00
|
|
|
option_language);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (open_window)
|
2008-08-24 14:31:38 +04:00
|
|
|
browser_window_create(url, NULL, 0, true, false);
|
2004-09-27 09:21:00 +04:00
|
|
|
|
|
|
|
free(url);
|
2004-07-29 03:07:52 +04:00
|
|
|
}
|
|
|
|
|
2010-03-29 20:59:30 +04:00
|
|
|
/** Normal entry point from OS */
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2010-04-12 02:40:41 +04:00
|
|
|
char path[40];
|
|
|
|
int length;
|
|
|
|
|
2010-03-29 20:59:30 +04:00
|
|
|
setbuf(stderr, NULL);
|
|
|
|
|
2010-04-12 02:40:41 +04:00
|
|
|
netsurf_init(&argc, &argv, "NetSurf:Choices", NULL);
|
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
artworks_init();
|
|
|
|
draw_init();
|
|
|
|
sprite_init();
|
|
|
|
|
2010-03-30 00:03:44 +04:00
|
|
|
/* Choose the interface language to use */
|
|
|
|
ro_gui_choose_language();
|
|
|
|
|
|
|
|
/* Load in our language-specific Messages */
|
|
|
|
if ((length = snprintf(path, sizeof(path),
|
|
|
|
"NetSurf:Resources.%s.Messages",
|
|
|
|
option_language)) < 0 || length >= (int)sizeof(path))
|
|
|
|
die("Failed to locate Messages resource.");
|
|
|
|
messages_load(path);
|
|
|
|
messages_load("NetSurf:Resources.LangNames");
|
|
|
|
|
|
|
|
gui_init(argc, argv);
|
2010-03-29 20:59:30 +04:00
|
|
|
|
|
|
|
gui_init2(argc, argv);
|
|
|
|
|
|
|
|
netsurf_main_loop();
|
|
|
|
|
|
|
|
netsurf_exit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-29 03:07:52 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/**
|
|
|
|
* Close down the gui (RISC OS).
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_quit(void)
|
|
|
|
{
|
2005-06-23 21:24:23 +04:00
|
|
|
bitmap_quit();
|
2006-06-20 01:49:25 +04:00
|
|
|
urldb_save_cookies(option_cookie_jar);
|
2006-04-10 03:21:13 +04:00
|
|
|
urldb_save(option_url_save);
|
2004-07-30 20:16:07 +04:00
|
|
|
ro_gui_window_quit();
|
2010-10-05 23:14:46 +04:00
|
|
|
history_global_cleanup();
|
|
|
|
cookies_cleanup();
|
|
|
|
hotlist_cleanup(option_hotlist_save);
|
2011-09-18 15:50:34 +04:00
|
|
|
sslcert_cleanup();
|
2005-07-16 09:54:45 +04:00
|
|
|
ro_gui_saveas_quit();
|
2005-02-20 16:19:19 +03:00
|
|
|
rufl_quit();
|
2004-06-30 03:13:40 +04:00
|
|
|
free(gui_sprites);
|
2004-07-30 20:16:07 +04:00
|
|
|
xwimp_close_down(task_handle);
|
2004-01-28 21:37:56 +03:00
|
|
|
xhourglass_off();
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2005-02-08 02:00:09 +03:00
|
|
|
/**
|
|
|
|
* Handles a signal
|
|
|
|
*/
|
2005-02-22 00:10:48 +03:00
|
|
|
|
|
|
|
void ro_gui_signal(int sig)
|
|
|
|
{
|
2006-01-06 03:57:01 +03:00
|
|
|
void (*prev_handler)(int);
|
2007-01-01 00:04:14 +03:00
|
|
|
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." };
|
2006-01-06 03:57:01 +03:00
|
|
|
|
2005-02-20 16:19:19 +03:00
|
|
|
ro_gui_cleanup();
|
2006-01-06 03:57:01 +03:00
|
|
|
|
|
|
|
/* Get previous handler of this signal */
|
|
|
|
switch (sig) {
|
|
|
|
case SIGABRT:
|
|
|
|
prev_handler = prev_sigs.sigabrt;
|
|
|
|
break;
|
|
|
|
case SIGFPE:
|
|
|
|
prev_handler = prev_sigs.sigfpe;
|
|
|
|
break;
|
|
|
|
case SIGILL:
|
|
|
|
prev_handler = prev_sigs.sigill;
|
|
|
|
break;
|
|
|
|
case SIGINT:
|
|
|
|
prev_handler = prev_sigs.sigint;
|
|
|
|
break;
|
|
|
|
case SIGSEGV:
|
|
|
|
prev_handler = prev_sigs.sigsegv;
|
|
|
|
break;
|
|
|
|
case SIGTERM:
|
|
|
|
prev_handler = prev_sigs.sigterm;
|
|
|
|
break;
|
|
|
|
default:
|
2007-01-02 03:13:02 +03:00
|
|
|
/* Unexpected signal - force to default so we exit
|
|
|
|
* cleanly */
|
|
|
|
prev_handler = SIG_DFL;
|
|
|
|
break;
|
2006-01-06 03:57:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (prev_handler != SIG_IGN && prev_handler != SIG_DFL) {
|
|
|
|
/* User-registered handler, so call it direct */
|
|
|
|
prev_handler(sig);
|
|
|
|
} else if (prev_handler == SIG_DFL) {
|
2007-01-02 03:13:02 +03:00
|
|
|
/* Previous handler would be the default. However, if we
|
|
|
|
* get here, it's going to be fatal, anyway, so bail,
|
|
|
|
* after writing context to the log and informing the
|
|
|
|
* user */
|
|
|
|
|
|
|
|
os_colour old_sand, old_glass;
|
|
|
|
|
|
|
|
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");
|
|
|
|
xhourglass_on();
|
|
|
|
xhourglass_colours(0x0000ffff, 0x000000ff,
|
|
|
|
&old_sand, &old_glass);
|
2011-02-21 00:04:53 +03:00
|
|
|
options_dump(stderr);
|
2007-01-02 03:13:02 +03:00
|
|
|
/*rufl_dump_state();*/
|
|
|
|
|
2009-01-31 16:50:17 +03:00
|
|
|
#ifndef __ELF__
|
2008-06-07 23:00:46 +04:00
|
|
|
/* save WimpSlot and DA to files if NetSurf$CoreDump exists */
|
2008-06-03 07:04:41 +04:00
|
|
|
int used;
|
|
|
|
xos_read_var_val_size("NetSurf$CoreDump", 0, 0, &used, 0, 0);
|
|
|
|
if (used) {
|
2008-06-07 23:00:46 +04:00
|
|
|
int curr_slot;
|
|
|
|
xwimp_slot_size(-1, -1, &curr_slot, 0, 0);
|
|
|
|
LOG(("saving WimpSlot, size 0x%x", curr_slot));
|
|
|
|
xosfile_save("$.NetSurf_Slot", 0x8000, 0,
|
|
|
|
(byte *) 0x8000,
|
|
|
|
(byte *) 0x8000 + curr_slot);
|
|
|
|
|
2008-06-03 07:04:41 +04:00
|
|
|
if (__dynamic_num != -1) {
|
|
|
|
int size;
|
|
|
|
byte *base_address;
|
|
|
|
xosdynamicarea_read(__dynamic_num, &size,
|
|
|
|
&base_address, 0, 0, 0, 0, 0);
|
2008-06-07 23:00:46 +04:00
|
|
|
LOG(("saving DA %i, base %p, size 0x%x",
|
|
|
|
__dynamic_num,
|
2008-06-03 07:04:41 +04:00
|
|
|
base_address, size));
|
2008-06-07 23:00:46 +04:00
|
|
|
xosfile_save("$.NetSurf_DA",
|
2008-06-03 07:04:41 +04:00
|
|
|
(bits) base_address, 0,
|
|
|
|
base_address,
|
|
|
|
base_address + size);
|
|
|
|
}
|
|
|
|
}
|
2009-01-31 16:50:17 +03:00
|
|
|
#else
|
|
|
|
/* Save WimpSlot and UnixLib managed DAs when UnixEnv$coredump
|
|
|
|
* defines a coredump directory. */
|
|
|
|
_kernel_oserror *err = __unixlib_write_coredump (NULL);
|
|
|
|
if (err != NULL)
|
|
|
|
LOG(("Coredump failed: %s", err->errmess));
|
|
|
|
#endif
|
2008-06-03 07:04:41 +04:00
|
|
|
|
2008-07-30 04:55:55 +04:00
|
|
|
xhourglass_colours(old_sand, old_glass, 0, 0);
|
|
|
|
xhourglass_off();
|
|
|
|
|
|
|
|
__write_backtrace(sig);
|
|
|
|
|
2007-01-02 03:13:02 +03:00
|
|
|
abort();
|
2006-01-06 03:57:01 +03:00
|
|
|
}
|
|
|
|
/* If we reach here, previous handler was either SIG_IGN or
|
|
|
|
* the user-defined handler returned. In either case, we have
|
|
|
|
* nothing to do */
|
2005-02-08 02:00:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures the gui exits cleanly.
|
|
|
|
*/
|
2005-02-22 00:10:48 +03:00
|
|
|
|
|
|
|
void ro_gui_cleanup(void)
|
|
|
|
{
|
2005-02-08 02:00:09 +03:00
|
|
|
ro_gui_buffer_close();
|
|
|
|
xhourglass_off();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Poll the OS for events (RISC OS).
|
|
|
|
*
|
|
|
|
* \param active return as soon as possible
|
|
|
|
*/
|
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
void gui_poll(bool active)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2004-01-28 21:37:56 +03:00
|
|
|
wimp_event_no event;
|
|
|
|
wimp_block block;
|
2008-06-06 17:58:56 +04:00
|
|
|
const wimp_poll_flags mask = wimp_MASK_LOSE | wimp_MASK_GAIN |
|
|
|
|
wimp_SAVE_FP;
|
2004-01-28 21:37:56 +03:00
|
|
|
|
|
|
|
/* Poll wimp. */
|
|
|
|
xhourglass_off();
|
|
|
|
if (active) {
|
|
|
|
event = wimp_poll(mask, &block, 0);
|
2007-08-07 07:55:18 +04:00
|
|
|
} else if (sched_active || gui_track || browser_reformat_pending ||
|
2005-06-23 21:24:23 +04:00
|
|
|
bitmap_maintenance) {
|
2005-04-15 09:54:44 +04:00
|
|
|
os_t t = os_read_monotonic_time();
|
|
|
|
|
|
|
|
if (gui_track)
|
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_SELECTION:
|
|
|
|
case GUI_DRAG_SCROLL:
|
|
|
|
t += 4; /* for smoother update */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
t += 10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
t += 10;
|
|
|
|
|
|
|
|
if (sched_active && (sched_time - t) < 0)
|
2004-03-28 04:29:29 +04:00
|
|
|
t = sched_time;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2004-03-28 04:29:29 +04:00
|
|
|
event = wimp_poll_idle(mask, &block, t, 0);
|
2004-01-28 21:37:56 +03:00
|
|
|
} else {
|
|
|
|
event = wimp_poll(wimp_MASK_NULL | mask, &block, 0);
|
|
|
|
}
|
2010-03-11 01:47:37 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
xhourglass_on();
|
2004-03-30 15:45:48 +04:00
|
|
|
gui_last_poll = clock();
|
2004-01-28 21:37:56 +03:00
|
|
|
ro_gui_handle_event(event, &block);
|
2010-03-11 01:47:37 +03:00
|
|
|
|
2010-10-25 03:17:21 +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
|
2010-03-11 01:47:37 +03:00
|
|
|
* top-level.
|
|
|
|
*/
|
|
|
|
if (event == wimp_NULL_REASON_CODE)
|
|
|
|
schedule_run();
|
|
|
|
|
2008-12-26 12:25:30 +03:00
|
|
|
ro_gui_window_update_boxes();
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
if (browser_reformat_pending && event == wimp_NULL_REASON_CODE)
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_window_process_reformats();
|
2005-06-23 21:24:23 +04:00
|
|
|
else if (bitmap_maintenance_priority ||
|
|
|
|
(bitmap_maintenance && event == wimp_NULL_REASON_CODE))
|
|
|
|
bitmap_maintain();
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Process a Wimp_Poll event.
|
|
|
|
*
|
|
|
|
* \param event wimp event number
|
|
|
|
* \param block parameter block
|
|
|
|
*/
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
void ro_gui_handle_event(wimp_event_no event, wimp_block *block)
|
|
|
|
{
|
|
|
|
switch (event) {
|
|
|
|
case wimp_NULL_REASON_CODE:
|
|
|
|
ro_gui_null_reason_code();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wimp_REDRAW_WINDOW_REQUEST:
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_wimp_event_redraw_window(&block->redraw);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_OPEN_WINDOW_REQUEST:
|
|
|
|
ro_gui_open_window_request(&block->open);
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_CLOSE_WINDOW_REQUEST:
|
|
|
|
ro_gui_close_window_request(&block->close);
|
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_POINTER_LEAVING_WINDOW:
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_pointer_leaving_window(&block->leaving);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_POINTER_ENTERING_WINDOW:
|
2004-07-17 17:00:38 +04:00
|
|
|
ro_gui_pointer_entering_window(&block->entering);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
2003-12-21 05:27:22 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_MOUSE_CLICK:
|
2006-09-06 18:44:42 +04:00
|
|
|
ro_gui_wimp_event_mouse_click(&block->pointer);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_USER_DRAG_BOX:
|
|
|
|
ro_gui_drag_end(&(block->dragged));
|
|
|
|
break;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_KEY_PRESSED:
|
|
|
|
ro_gui_keypress(&(block->key));
|
|
|
|
break;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_MENU_SELECTION:
|
|
|
|
ro_gui_menu_selection(&(block->selection));
|
|
|
|
break;
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_SCROLL_REQUEST:
|
|
|
|
ro_gui_scroll_request(&(block->scroll));
|
|
|
|
break;
|
2003-10-06 03:30:21 +04:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case wimp_USER_MESSAGE:
|
|
|
|
case wimp_USER_MESSAGE_RECORDED:
|
|
|
|
case wimp_USER_MESSAGE_ACKNOWLEDGE:
|
|
|
|
ro_gui_user_message(event, &(block->message));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-07-30 17:06:22 +04:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle Null_Reason_Code events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_null_reason_code(void)
|
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
wimp_pointer pointer;
|
|
|
|
os_error *error;
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
ro_gui_throb();
|
2004-07-17 17:00:38 +04:00
|
|
|
|
|
|
|
if (!gui_track)
|
|
|
|
return;
|
|
|
|
|
|
|
|
error = xwimp_get_pointer_info(&pointer);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_get_pointer_info: 0x%x: %s",
|
2005-04-15 09:54:44 +04:00
|
|
|
error->errnum, error->errmess));
|
2004-07-17 17:00:38 +04:00
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
2004-02-26 03:44:42 +03:00
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
|
|
|
|
/* pointer is allowed to wander outside the initiating window
|
|
|
|
for certain drag types */
|
|
|
|
|
|
|
|
case GUI_DRAG_SELECTION:
|
|
|
|
case GUI_DRAG_SCROLL:
|
2006-09-02 19:52:41 +04:00
|
|
|
case GUI_DRAG_FRAME:
|
2005-04-15 09:54:44 +04:00
|
|
|
assert(gui_track_gui_window);
|
|
|
|
ro_gui_window_mouse_at(gui_track_gui_window, &pointer);
|
|
|
|
break;
|
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
// case GUI_DRAG_SAVE:
|
|
|
|
// ro_gui_selection_send_dragging(&pointer);
|
|
|
|
// break;
|
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
default:
|
2010-12-19 21:16:14 +03:00
|
|
|
if (ro_gui_global_history_check_window(gui_track_wimp_w) ||
|
|
|
|
ro_gui_hotlist_check_window(gui_track_wimp_w) ||
|
|
|
|
ro_gui_cookies_check_window(gui_track_wimp_w))
|
2010-12-19 21:22:09 +03:00
|
|
|
ro_treeview_mouse_at(&pointer);
|
2005-04-15 09:54:44 +04:00
|
|
|
if (gui_track_wimp_w == history_window)
|
|
|
|
ro_gui_history_mouse_at(&pointer);
|
|
|
|
if (gui_track_wimp_w == dialog_url_complete)
|
2006-01-01 16:58:31 +03:00
|
|
|
ro_gui_url_complete_mouse_at(&pointer);
|
2005-04-15 09:54:44 +04:00
|
|
|
else if (gui_track_gui_window)
|
2008-06-06 17:58:56 +04:00
|
|
|
ro_gui_window_mouse_at(gui_track_gui_window,
|
|
|
|
&pointer);
|
2005-04-15 09:54:44 +04:00
|
|
|
break;
|
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Open_Window_Request events.
|
|
|
|
*/
|
|
|
|
|
2004-06-09 01:35:28 +04:00
|
|
|
void ro_gui_open_window_request(wimp_open *open)
|
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
os_error *error;
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2005-12-31 07:38:27 +03:00
|
|
|
if (ro_gui_wimp_event_open_window(open))
|
|
|
|
return;
|
|
|
|
|
2006-09-06 18:44:42 +04:00
|
|
|
error = xwimp_open_window(open);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_open_window: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
2004-05-05 02:23:44 +04:00
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle Close_Window_Request events.
|
|
|
|
*/
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
void ro_gui_close_window_request(wimp_close *close)
|
|
|
|
{
|
2008-12-26 12:25:30 +03:00
|
|
|
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);
|
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Handle Pointer_Leaving_Window events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_pointer_leaving_window(wimp_leaving *leaving)
|
|
|
|
{
|
2006-09-06 18:44:42 +04:00
|
|
|
if (gui_track_wimp_w == history_window)
|
|
|
|
ro_gui_dialog_close(dialog_tooltip);
|
2004-07-17 17:00:38 +04:00
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_SELECTION:
|
|
|
|
case GUI_DRAG_SCROLL:
|
2006-02-16 02:09:55 +03:00
|
|
|
case GUI_DRAG_SAVE:
|
2006-09-02 19:52:41 +04:00
|
|
|
case GUI_DRAG_FRAME:
|
2005-04-15 09:54:44 +04:00
|
|
|
/* ignore Pointer_Leaving_Window event that the Wimp mysteriously
|
2006-02-16 02:09:55 +03:00
|
|
|
issues when a Wimp_DragBox drag operation is started */
|
2005-04-15 09:54:44 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2006-12-03 21:17:56 +03:00
|
|
|
if (gui_track_gui_window)
|
|
|
|
gui_window_set_pointer(gui_track_gui_window, GUI_POINTER_DEFAULT);
|
|
|
|
gui_track_wimp_w = 0;
|
|
|
|
gui_track_gui_window = NULL;
|
2005-04-15 09:54:44 +04:00
|
|
|
gui_track = false;
|
|
|
|
break;
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Pointer_Entering_Window events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_pointer_entering_window(wimp_entering *entering)
|
|
|
|
{
|
2006-09-02 19:52:41 +04:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_SELECTION:
|
|
|
|
case GUI_DRAG_SCROLL:
|
|
|
|
case GUI_DRAG_SAVE:
|
|
|
|
case GUI_DRAG_FRAME:
|
|
|
|
/* ignore entering new windows/frames */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gui_track_wimp_w = entering->w;
|
|
|
|
gui_track_gui_window = ro_gui_window_lookup(entering->w);
|
2010-10-05 23:14:46 +04:00
|
|
|
gui_track = gui_track_gui_window ||
|
|
|
|
gui_track_wimp_w == history_window ||
|
|
|
|
gui_track_wimp_w == dialog_url_complete ||
|
2010-12-19 21:16:14 +03:00
|
|
|
ro_gui_hotlist_check_window(gui_track_wimp_w) ||
|
|
|
|
ro_gui_global_history_check_window(gui_track_wimp_w) ||
|
|
|
|
ro_gui_cookies_check_window(gui_track_wimp_w);
|
2006-09-02 19:52:41 +04:00
|
|
|
break;
|
|
|
|
}
|
2004-07-17 17:00:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
/**
|
|
|
|
* Handle User_Drag_Box events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_drag_end(wimp_dragged *drag)
|
|
|
|
{
|
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_SELECTION:
|
2006-12-03 21:17:56 +03:00
|
|
|
assert(gui_track_gui_window);
|
2005-04-15 09:54:44 +04:00
|
|
|
ro_gui_selection_drag_end(gui_track_gui_window, drag);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_DRAG_SCROLL:
|
2006-12-03 21:17:56 +03:00
|
|
|
assert(gui_track_gui_window);
|
2005-04-15 09:54:44 +04:00
|
|
|
ro_gui_window_scroll_end(gui_track_gui_window, drag);
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_DRAG_DOWNLOAD_SAVE:
|
2004-06-28 03:24:11 +04:00
|
|
|
ro_gui_download_drag_end(drag);
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_DRAG_SAVE:
|
|
|
|
ro_gui_save_drag_end(drag);
|
|
|
|
break;
|
2004-05-05 02:23:44 +04:00
|
|
|
|
|
|
|
case GUI_DRAG_STATUS_RESIZE:
|
2004-07-03 21:30:28 +04:00
|
|
|
break;
|
|
|
|
|
2010-12-19 13:45:13 +03:00
|
|
|
case GUI_DRAG_TREEVIEW:
|
|
|
|
ro_treeview_drag_end(drag);
|
2004-05-05 02:23:44 +04:00
|
|
|
break;
|
2005-03-20 22:28:50 +03:00
|
|
|
|
2011-02-21 02:16:33 +03:00
|
|
|
case GUI_DRAG_BUTTONBAR:
|
|
|
|
ro_gui_button_bar_drag_end(drag);
|
2005-03-20 22:28:50 +03:00
|
|
|
break;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
case GUI_DRAG_FRAME:
|
2006-12-03 21:17:56 +03:00
|
|
|
assert(gui_track_gui_window);
|
2006-09-02 19:52:41 +04:00
|
|
|
ro_gui_window_frame_resize_end(gui_track_gui_window, drag);
|
|
|
|
break;
|
|
|
|
|
2005-04-15 09:54:44 +04:00
|
|
|
default:
|
|
|
|
assert(gui_current_drag_type == GUI_DRAG_NONE);
|
|
|
|
break;
|
2004-02-26 03:44:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
/**
|
|
|
|
* Handle Key_Pressed events.
|
|
|
|
*/
|
2004-01-28 21:37:56 +03:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
void ro_gui_keypress(wimp_key *key)
|
2002-10-15 14:41:12 +04:00
|
|
|
{
|
2009-01-10 03:18:34 +03:00
|
|
|
if (key->c == wimp_KEY_ESCAPE &&
|
|
|
|
(gui_current_drag_type == GUI_DRAG_SAVE ||
|
|
|
|
gui_current_drag_type == GUI_DRAG_DOWNLOAD_SAVE)) {
|
|
|
|
|
|
|
|
/* 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 (!ro_gui_wimp_event_keypress(key)) {
|
|
|
|
os_error *error = xwimp_process_key(key->c);
|
2004-07-17 17:00:38 +04:00
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_process_key: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
}
|
2002-10-15 14:41:12 +04:00
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
/**
|
|
|
|
* Handle the three User_Message events.
|
|
|
|
*/
|
|
|
|
void ro_gui_user_message(wimp_event_no event, wimp_message *message)
|
|
|
|
{
|
2006-04-22 03:49:52 +04:00
|
|
|
/* attempt automatic routing */
|
|
|
|
if (ro_message_handle_message(event, message))
|
|
|
|
return;
|
2006-03-25 23:30:35 +03:00
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
switch (message->action) {
|
|
|
|
case message_DATA_LOAD:
|
2005-09-02 00:29:59 +04:00
|
|
|
ro_msg_terminate_filename((wimp_full_message_data_xfer*)message);
|
|
|
|
|
2004-08-09 10:28:57 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
|
2008-08-03 00:07:44 +04:00
|
|
|
if (ro_print_current_window)
|
|
|
|
ro_print_dataload_bounce(message);
|
2004-08-09 10:28:57 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ro_msg_dataload(message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_DATA_LOAD_ACK:
|
2008-08-03 00:07:44 +04:00
|
|
|
if (ro_print_current_window)
|
|
|
|
ro_print_cleanup();
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
case message_MENU_WARNING:
|
|
|
|
ro_gui_menu_warning((wimp_message_menu_warning *)
|
|
|
|
&message->data);
|
|
|
|
break;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
2004-07-04 22:44:51 +04:00
|
|
|
case message_MENUS_DELETED:
|
2011-02-21 02:16:33 +03:00
|
|
|
ro_gui_menu_closed();
|
2004-07-04 22:44:51 +04:00
|
|
|
break;
|
2005-04-15 09:54:44 +04:00
|
|
|
|
|
|
|
case message_CLAIM_ENTITY:
|
|
|
|
ro_gui_selection_claim_entity((wimp_full_message_claim_entity*)message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_DATA_REQUEST:
|
|
|
|
ro_gui_selection_data_request((wimp_full_message_data_request*)message);
|
|
|
|
break;
|
|
|
|
|
2006-07-18 05:51:19 +04:00
|
|
|
case message_MODE_CHANGE:
|
|
|
|
ro_gui_get_screen_properties();
|
|
|
|
rufl_invalidate_cache();
|
2011-02-26 02:26:36 +03:00
|
|
|
ro_gui_system_colour_update();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case message_PALETTE_CHANGE:
|
|
|
|
ro_gui_system_colour_update();
|
2006-07-18 05:51:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case message_FONT_CHANGED:
|
|
|
|
ro_gui_wimp_get_desktop_font();
|
|
|
|
break;
|
|
|
|
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_URI_PROCESS:
|
2004-04-02 04:41:10 +04:00
|
|
|
if (event != wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
ro_uri_message_received(message);
|
|
|
|
break;
|
|
|
|
case message_URI_RETURN_RESULT:
|
2004-06-29 03:57:26 +04:00
|
|
|
ro_uri_bounce(message);
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
|
|
|
case message_INET_SUITE_OPEN_URL:
|
2004-04-02 04:41:10 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE) {
|
|
|
|
ro_url_bounce(message);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ro_url_message_received(message);
|
|
|
|
}
|
2004-01-28 21:37:56 +03:00
|
|
|
break;
|
|
|
|
#ifdef WITH_PLUGIN
|
|
|
|
case message_PLUG_IN_OPENING:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_opening(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_CLOSED:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_closed(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_RESHAPE_REQUEST:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_reshape_request(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_FOCUS:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_URL_ACCESS:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_url_access(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STATUS:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_status(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_BUSY:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_NEW:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_stream_new(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_WRITE:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_WRITTEN:
|
2004-08-13 04:55:59 +04:00
|
|
|
plugin_stream_written(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_STREAM_DESTROY:
|
2004-08-13 04:55:59 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_OPEN:
|
2004-08-13 04:55:59 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
plugin_open_msg(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
case message_PLUG_IN_CLOSE:
|
2004-08-13 04:55:59 +04:00
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
|
|
|
plugin_close_msg(message);
|
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
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
|
2004-08-09 10:28:57 +04:00
|
|
|
case message_PRINT_SAVE:
|
|
|
|
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
|
2008-08-03 00:07:44 +04:00
|
|
|
ro_print_save_bounce(message);
|
2004-08-09 10:28:57 +04:00
|
|
|
break;
|
|
|
|
case message_PRINT_ERROR:
|
2008-08-03 00:07:44 +04:00
|
|
|
ro_print_error(message);
|
2004-08-09 10:28:57 +04:00
|
|
|
break;
|
|
|
|
case message_PRINT_TYPE_ODD:
|
2008-08-03 00:07:44 +04:00
|
|
|
ro_print_type_odd(message);
|
2004-08-09 10:28:57 +04:00
|
|
|
break;
|
2004-01-28 21:37:56 +03:00
|
|
|
|
|
|
|
case message_QUIT:
|
|
|
|
netsurf_quit = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-02 00:29:59 +04:00
|
|
|
/**
|
|
|
|
* Ensure that the filename in a data transfer message is NUL terminated
|
|
|
|
* (some applications, especially BASIC programs use CR)
|
|
|
|
*
|
|
|
|
* \param message message to be corrected
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_terminate_filename(wimp_full_message_data_xfer *message)
|
|
|
|
{
|
|
|
|
const char *ep = (char*)message + message->size;
|
|
|
|
char *p = message->file_name;
|
|
|
|
|
|
|
|
if ((size_t)message->size >= sizeof(*message))
|
|
|
|
ep = (char*)message + sizeof(*message) - 1;
|
|
|
|
|
|
|
|
while (p < ep && *p >= ' ') p++;
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-03 03:19:47 +03:00
|
|
|
/**
|
|
|
|
* Handle Message_DataLoad (file dragged in).
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_dataload(wimp_message *message)
|
2002-12-31 01:56:30 +03:00
|
|
|
{
|
2004-07-17 17:00:38 +04:00
|
|
|
int file_type = message->data.data_xfer.file_type;
|
2005-04-08 06:06:46 +04:00
|
|
|
int tree_file_type = file_type;
|
2004-03-05 02:15:17 +03:00
|
|
|
char *url = 0;
|
2005-04-08 06:06:46 +04:00
|
|
|
char *title = NULL;
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window *g;
|
|
|
|
os_error *error;
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
g = ro_gui_window_lookup(message->data.data_xfer.w);
|
2005-04-22 01:36:23 +04:00
|
|
|
if (g) {
|
|
|
|
if (ro_gui_window_dataload(g, message))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g = ro_gui_toolbar_lookup(message->data.data_xfer.w);
|
|
|
|
if (g && ro_gui_toolbar_dataload(g, message))
|
|
|
|
return;
|
|
|
|
}
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
switch (file_type) {
|
|
|
|
case FILETYPE_ACORN_URI:
|
2005-04-08 06:06:46 +04:00
|
|
|
url = ro_gui_uri_file_parse(message->data.data_xfer.file_name,
|
|
|
|
&title);
|
|
|
|
tree_file_type = 0xfaf;
|
2005-04-05 02:14:51 +04:00
|
|
|
break;
|
|
|
|
case FILETYPE_ANT_URL:
|
|
|
|
url = ro_gui_url_file_parse(message->data.data_xfer.file_name);
|
2005-04-08 06:06:46 +04:00
|
|
|
tree_file_type = 0xfaf;
|
2005-04-05 02:14:51 +04:00
|
|
|
break;
|
|
|
|
case FILETYPE_IEURL:
|
|
|
|
url = ro_gui_ieurl_file_parse(message->data.data_xfer.file_name);
|
2005-04-08 06:06:46 +04:00
|
|
|
tree_file_type = 0xfaf;
|
2005-04-05 02:14:51 +04:00
|
|
|
break;
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
case FILETYPE_HTML:
|
|
|
|
case FILETYPE_JNG:
|
|
|
|
case FILETYPE_CSS:
|
|
|
|
case FILETYPE_MNG:
|
|
|
|
case FILETYPE_GIF:
|
2006-02-25 21:51:51 +03:00
|
|
|
case FILETYPE_BMP:
|
2006-02-26 05:25:19 +03:00
|
|
|
case FILETYPE_ICO:
|
2005-04-05 02:14:51 +04:00
|
|
|
case osfile_TYPE_DRAW:
|
|
|
|
case FILETYPE_PNG:
|
|
|
|
case FILETYPE_JPEG:
|
|
|
|
case osfile_TYPE_SPRITE:
|
|
|
|
case osfile_TYPE_TEXT:
|
2005-12-10 17:31:33 +03:00
|
|
|
case FILETYPE_ARTWORKS:
|
2007-07-13 12:25:34 +04:00
|
|
|
case FILETYPE_SVG:
|
2005-04-05 02:14:51 +04:00
|
|
|
/* display the actual file */
|
2006-01-18 03:54:27 +03:00
|
|
|
url = path_to_url(message->data.data_xfer.file_name);
|
2005-04-05 02:14:51 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2004-12-09 13:30:44 +03:00
|
|
|
|
|
|
|
if (!url)
|
2005-02-03 23:49:43 +03:00
|
|
|
/* error has already been reported by one of the
|
2004-12-09 13:30:44 +03:00
|
|
|
* functions called above */
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (g) {
|
2006-04-22 22:24:18 +04:00
|
|
|
browser_window_go(g->bw, url, 0, true);
|
2010-10-05 23:14:46 +04:00
|
|
|
// } else if (ro_gui_hotlist_check_window(message->data.data_xfer.w)) {
|
|
|
|
// /* Drop URL into hotlist */
|
|
|
|
// ro_gui_hotlist_url_drop(message, url);
|
2004-12-09 13:30:44 +03:00
|
|
|
} else {
|
2008-08-24 14:31:38 +04:00
|
|
|
browser_window_create(url, 0, 0, true, false);
|
2004-12-09 13:30:44 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
2004-03-06 01:15:33 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
free(url);
|
|
|
|
}
|
2004-03-06 01:15:33 +03:00
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Parse an Acorn URI file.
|
|
|
|
*
|
|
|
|
* \param file_name file to read
|
2005-04-08 06:06:46 +04:00
|
|
|
* \param uri_title pointer to receive title data, or NULL for no data
|
2004-07-17 17:00:38 +04:00
|
|
|
* \return URL from file, or 0 on error and error reported
|
|
|
|
*/
|
|
|
|
|
2005-04-08 06:06:46 +04:00
|
|
|
char *ro_gui_uri_file_parse(const char *file_name, char **uri_title)
|
2004-07-17 17:00:38 +04:00
|
|
|
{
|
|
|
|
/* See the "Acorn URI Handler Functional Specification" for the
|
|
|
|
* definition of the URI file format. */
|
|
|
|
char line[400];
|
2005-04-08 06:06:46 +04:00
|
|
|
char *url = NULL;
|
2004-07-17 17:00:38 +04:00
|
|
|
FILE *fp;
|
|
|
|
|
2005-04-10 02:31:26 +04:00
|
|
|
*uri_title = NULL;
|
2004-07-17 17:00:38 +04:00
|
|
|
fp = fopen(file_name, "rb");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("fopen(\"%s\", \"rb\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
return 0;
|
2004-06-09 01:35:28 +04:00
|
|
|
}
|
2004-03-05 20:08:28 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* "URI" */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line) || strcmp(line, "URI") != 0)
|
|
|
|
goto uri_syntax_error;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* version */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line) ||
|
|
|
|
strspn(line, "0123456789") != strlen(line))
|
|
|
|
goto uri_syntax_error;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* URI */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line))
|
|
|
|
goto uri_syntax_error;
|
|
|
|
url = strdup(line);
|
|
|
|
if (!url) {
|
|
|
|
warn_user("NoMemory", 0);
|
2005-04-10 02:31:26 +04:00
|
|
|
fclose(fp);
|
2004-07-17 17:00:38 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2005-04-08 06:06:46 +04:00
|
|
|
/* title */
|
|
|
|
if (!ro_gui_uri_file_parse_line(fp, line))
|
|
|
|
goto uri_syntax_error;
|
|
|
|
if (uri_title && line[0] && ((line[0] != '*') || line[1])) {
|
|
|
|
*uri_title = strdup(line);
|
|
|
|
if (!*uri_title) /* non-fatal */
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
2005-04-17 21:16:44 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
return url;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
uri_syntax_error:
|
|
|
|
fclose(fp);
|
|
|
|
warn_user("URIError", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2004-07-17 17:00:38 +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
|
|
|
|
*/
|
2004-04-03 03:59:53 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
bool ro_gui_uri_file_parse_line(FILE *fp, char *b)
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
c = getc(fp);
|
|
|
|
if (c == EOF)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* 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;
|
2004-03-03 03:19:47 +03:00
|
|
|
}
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* read "line" */
|
|
|
|
do {
|
|
|
|
if (i == 399)
|
|
|
|
return false;
|
|
|
|
b[i++] = c;
|
|
|
|
c = getc(fp);
|
|
|
|
} while (c != EOF && 32 <= c);
|
2004-04-03 03:59:53 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/* skip line ending control characters */
|
|
|
|
while (c != EOF && c < 32)
|
|
|
|
c = getc(fp);
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (c != EOF)
|
|
|
|
ungetc(c, fp);
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
b[i] = 0;
|
|
|
|
return true;
|
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/**
|
|
|
|
* Parse an ANT URL file.
|
|
|
|
*
|
|
|
|
* \param file_name file to read
|
|
|
|
* \return URL from file, or 0 on error and error reported
|
|
|
|
*/
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
char *ro_gui_url_file_parse(const char *file_name)
|
|
|
|
{
|
|
|
|
char line[400];
|
|
|
|
char *url;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
fp = fopen(file_name, "r");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("fopen(\"%s\", \"r\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (!fgets(line, sizeof line, fp)) {
|
|
|
|
if (ferror(fp)) {
|
|
|
|
LOG(("fgets: %i: %s",
|
|
|
|
errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
} else
|
|
|
|
warn_user("LoadError", messages_get("EmptyError"));
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
fclose(fp);
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
if (line[strlen(line) - 1] == '\n')
|
|
|
|
line[strlen(line) - 1] = '\0';
|
2002-12-31 01:56:30 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
url = strdup(line);
|
|
|
|
if (!url) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return 0;
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
2003-01-06 03:04:43 +03:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
return url;
|
2002-12-31 01:56:30 +03:00
|
|
|
}
|
|
|
|
|
2003-09-11 01:44:11 +04:00
|
|
|
|
2005-02-03 23:49:43 +03:00
|
|
|
/**
|
|
|
|
* Parse an IEURL file.
|
|
|
|
*
|
|
|
|
* \param file_name file to read
|
|
|
|
* \return URL from file, or 0 on error and error reported
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *ro_gui_ieurl_file_parse(const char *file_name)
|
|
|
|
{
|
|
|
|
char line[400];
|
|
|
|
char *url = 0;
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
fp = fopen(file_name, "r");
|
|
|
|
if (!fp) {
|
|
|
|
LOG(("fopen(\"%s\", \"r\"): %i: %s",
|
|
|
|
file_name, errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ferror(fp)) {
|
|
|
|
LOG(("fgets: %i: %s",
|
|
|
|
errno, strerror(errno)));
|
|
|
|
warn_user("LoadError", strerror(errno));
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
if (!url)
|
|
|
|
warn_user("URIError", 0);
|
|
|
|
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-05 02:14:51 +04:00
|
|
|
/**
|
|
|
|
* Handle Message_DataSave
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_datasave(wimp_message *message)
|
|
|
|
{
|
|
|
|
wimp_full_message_data_xfer *dataxfer = (wimp_full_message_data_xfer*)message;
|
|
|
|
|
2006-02-16 02:09:55 +03:00
|
|
|
/* remove ghost caret if drag-and-drop protocol was used */
|
|
|
|
// ro_gui_selection_drag_reset();
|
|
|
|
|
2005-09-02 00:29:59 +04:00
|
|
|
ro_msg_terminate_filename(dataxfer);
|
|
|
|
|
2005-04-05 02:14:51 +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:
|
2006-02-25 21:51:51 +03:00
|
|
|
case FILETYPE_BMP:
|
2006-02-26 05:25:19 +03:00
|
|
|
case FILETYPE_ICO:
|
2005-04-05 02:14:51 +04:00
|
|
|
case osfile_TYPE_DRAW:
|
|
|
|
case FILETYPE_PNG:
|
|
|
|
case FILETYPE_JPEG:
|
|
|
|
case osfile_TYPE_SPRITE:
|
2005-12-10 17:31:33 +03:00
|
|
|
case osfile_TYPE_TEXT:
|
2007-07-13 12:25:34 +04:00
|
|
|
case FILETYPE_ARTWORKS:
|
|
|
|
case FILETYPE_SVG: {
|
2005-04-05 02:14:51 +04:00
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, (wimp_message*)dataxfer, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s", error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
/**
|
|
|
|
* Handle Message_DataSaveAck.
|
|
|
|
*/
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
void ro_msg_datasave_ack(wimp_message *message)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2005-09-02 00:29:59 +04:00
|
|
|
ro_msg_terminate_filename((wimp_full_message_data_xfer*)message);
|
|
|
|
|
2008-08-03 00:07:44 +04:00
|
|
|
if (ro_print_ack(message))
|
2004-08-09 10:28:57 +04:00
|
|
|
return;
|
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
switch (gui_current_drag_type) {
|
|
|
|
case GUI_DRAG_DOWNLOAD_SAVE:
|
2004-06-28 03:24:11 +04:00
|
|
|
ro_gui_download_datasave_ack(message);
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
case GUI_DRAG_SAVE:
|
|
|
|
ro_gui_save_datasave_ack(message);
|
2006-02-16 02:09:55 +03:00
|
|
|
gui_current_drag_type = GUI_DRAG_NONE;
|
2004-02-26 03:44:42 +03:00
|
|
|
break;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-02-26 03:44:42 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle Message_DataOpen (double-click on file in the Filer).
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_dataopen(wimp_message *message)
|
|
|
|
{
|
2004-11-30 00:47:00 +03:00
|
|
|
int file_type = message->data.data_xfer.file_type;
|
2004-03-05 02:15:17 +03:00
|
|
|
char *url = 0;
|
2004-11-30 00:47:00 +03:00
|
|
|
size_t len;
|
|
|
|
os_error *error;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-11-30 00:47:00 +03:00
|
|
|
if (file_type == 0xb28) /* ANT URL file */
|
|
|
|
url = ro_gui_url_file_parse(message->data.data_xfer.file_name);
|
|
|
|
else if (file_type == 0xfaf) /* HTML file */
|
2006-01-18 03:54:27 +03:00
|
|
|
url = path_to_url(message->data.data_xfer.file_name);
|
2005-02-03 23:49:43 +03:00
|
|
|
else if (file_type == 0x1ba) /* IEURL file */
|
|
|
|
url = ro_gui_ieurl_file_parse(message->
|
|
|
|
data.data_xfer.file_name);
|
2004-11-30 00:47:00 +03:00
|
|
|
else if (file_type == 0x2000) { /* application */
|
|
|
|
len = strlen(message->data.data_xfer.file_name);
|
|
|
|
if (len < 9 || strcmp(".!NetSurf",
|
|
|
|
message->data.data_xfer.file_name + len - 9))
|
|
|
|
return;
|
|
|
|
if (option_homepage_url && option_homepage_url[0]) {
|
|
|
|
url = strdup(option_homepage_url);
|
|
|
|
} else {
|
|
|
|
url = malloc(80);
|
|
|
|
if (url)
|
|
|
|
snprintf(url, 80,
|
2008-01-20 02:42:26 +03:00
|
|
|
"file:///<NetSurf$Dir>/Docs/welcome/index_%s",
|
2004-11-30 00:47:00 +03:00
|
|
|
option_language);
|
2004-06-09 01:35:28 +04:00
|
|
|
}
|
2004-11-30 00:47:00 +03:00
|
|
|
if (!url)
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else
|
|
|
|
return;
|
2004-03-05 02:15:17 +03:00
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/* send DataLoadAck */
|
|
|
|
message->action = message_DATA_LOAD_ACK;
|
|
|
|
message->your_ref = message->my_ref;
|
2004-11-30 00:47:00 +03:00
|
|
|
error = xwimp_send_message(wimp_USER_MESSAGE, message, message->sender);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!url)
|
2005-02-03 23:49:43 +03:00
|
|
|
/* error has already been reported by one of the
|
2004-11-30 00:47:00 +03:00
|
|
|
* functions called above */
|
|
|
|
return;
|
2003-11-08 02:51:13 +03:00
|
|
|
|
|
|
|
/* create a new window with the file */
|
2008-08-24 14:31:38 +04:00
|
|
|
browser_window_create(url, NULL, 0, true, false);
|
2004-11-30 00:47:00 +03:00
|
|
|
|
|
|
|
free(url);
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-23 06:58:27 +04:00
|
|
|
/**
|
|
|
|
* Handle PreQuit message
|
|
|
|
*
|
|
|
|
* \param message PreQuit message from Wimp
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_prequit(wimp_message *message)
|
|
|
|
{
|
|
|
|
if (!ro_gui_prequit()) {
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* 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) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle SaveDesktop message
|
|
|
|
*
|
|
|
|
* \param message SaveDesktop message from Wimp
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_save_desktop(wimp_message *message)
|
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosgbpb_writew/xos_bputw: 0x%x:%s", error->errnum, error->errmess));
|
|
|
|
warn_user("SaveError", error->errmess);
|
|
|
|
|
|
|
|
/* 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) {
|
|
|
|
LOG(("xwimp_send_message: 0x%x:%s", error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-24 06:44:37 +03:00
|
|
|
/**
|
|
|
|
* Handle WindowInfo message (part of the iconising protocol)
|
|
|
|
*
|
|
|
|
* \param message WindowInfo message from the Iconiser
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_msg_window_info(wimp_message *message)
|
|
|
|
{
|
|
|
|
wimp_full_message_window_info *wi;
|
|
|
|
struct gui_window *g;
|
|
|
|
|
2006-07-03 05:03:07 +04:00
|
|
|
/* allow the user to turn off thumbnail icons */
|
|
|
|
if (!option_thumbnail_iconise)
|
|
|
|
return;
|
2006-07-14 01:57:35 +04:00
|
|
|
|
2006-03-24 06:44:37 +03:00
|
|
|
wi = (wimp_full_message_window_info*)message;
|
|
|
|
g = ro_gui_window_lookup(wi->w);
|
|
|
|
|
|
|
|
/* ic_<task name> will suffice for our other windows */
|
2008-12-26 12:25:30 +03:00
|
|
|
if (g) {
|
|
|
|
ro_gui_window_iconise(g, wi);
|
|
|
|
ro_gui_dialog_close_persistent(wi->w);
|
|
|
|
}
|
2006-03-24 06:44:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
/**
|
|
|
|
* Convert a RISC OS pathname to a file: URL.
|
2004-03-03 03:19:47 +03:00
|
|
|
*
|
|
|
|
* \param path RISC OS pathname
|
|
|
|
* \return URL, allocated on heap, or 0 on failure
|
2003-11-08 02:51:13 +03:00
|
|
|
*/
|
|
|
|
|
2006-01-18 03:54:27 +03:00
|
|
|
char *path_to_url(const char *path)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-03-03 03:19:47 +03:00
|
|
|
int spare;
|
2010-04-17 03:56:53 +04:00
|
|
|
char *canonical_path; /* canonicalised RISC OS path */
|
|
|
|
char *unix_path; /* unix path */
|
|
|
|
char *escurl;
|
2004-03-03 03:19:47 +03:00
|
|
|
os_error *error;
|
2008-04-02 04:43:51 +04:00
|
|
|
url_func_result url_err;
|
2010-04-17 03:56:53 +04:00
|
|
|
int urllen;
|
|
|
|
char *url; /* resulting url */
|
2004-03-03 03:19:47 +03:00
|
|
|
|
2010-04-17 03:56:53 +04:00
|
|
|
/* calculate the canonical risc os path */
|
2004-03-03 03:19:47 +03:00
|
|
|
error = xosfscontrol_canonicalise_path(path, 0, 0, 0, 0, &spare);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xosfscontrol_canonicalise_path failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("PathToURL", error->errmess);
|
2008-04-02 04:43:51 +04:00
|
|
|
return NULL;
|
2004-03-03 03:19:47 +03:00
|
|
|
}
|
|
|
|
|
2010-04-17 03:56:53 +04:00
|
|
|
canonical_path = malloc(1 - spare);
|
|
|
|
if (canonical_path == NULL) {
|
2004-03-03 03:19:47 +03:00
|
|
|
LOG(("malloc failed"));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("NoMemory", 0);
|
2010-04-17 03:56:53 +04:00
|
|
|
free(canonical_path);
|
2008-04-02 04:43:51 +04:00
|
|
|
return NULL;
|
2004-03-03 03:19:47 +03:00
|
|
|
}
|
|
|
|
|
2010-04-17 03:56:53 +04:00
|
|
|
error = xosfscontrol_canonicalise_path(path, canonical_path, 0, 0, 1 - spare, 0);
|
2004-03-03 03:19:47 +03:00
|
|
|
if (error) {
|
|
|
|
LOG(("xosfscontrol_canonicalise_path failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
2004-05-07 23:14:54 +04:00
|
|
|
warn_user("PathToURL", error->errmess);
|
2010-04-17 03:56:53 +04:00
|
|
|
free(canonical_path);
|
2008-04-02 04:43:51 +04:00
|
|
|
return NULL;
|
2004-03-03 03:19:47 +03:00
|
|
|
}
|
|
|
|
|
2010-04-17 03:56:53 +04:00
|
|
|
/* create a unix path from teh cananocal risc os one */
|
|
|
|
unix_path = __unixify(canonical_path, __RISCOSIFY_NO_REVERSE_SUFFIX, NULL, 0, 0);
|
2010-10-25 03:17:21 +04:00
|
|
|
|
2010-04-17 13:16:42 +04:00
|
|
|
if (unix_path == NULL) {
|
2010-04-17 03:56:53 +04:00
|
|
|
LOG(("__unixify failed: %s", canonical_path));
|
|
|
|
free(canonical_path);
|
2008-04-02 04:43:51 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-04-17 03:56:53 +04:00
|
|
|
free(canonical_path);
|
|
|
|
|
|
|
|
/* convert the unix path into a url */
|
|
|
|
urllen = strlen(unix_path) + FILE_SCHEME_PREFIX_LEN + 1;
|
|
|
|
url = malloc(urllen);
|
|
|
|
if (url == NULL) {
|
|
|
|
LOG(("Unable to allocate url"));
|
|
|
|
free(unix_path);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*unix_path == '/') {
|
|
|
|
snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, unix_path + 1);
|
|
|
|
} else {
|
|
|
|
snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, unix_path);
|
|
|
|
}
|
2010-10-25 03:17:21 +04:00
|
|
|
free(unix_path);
|
2008-04-02 04:43:51 +04:00
|
|
|
|
|
|
|
/* We don't want '/' to be escaped. */
|
2010-03-31 17:59:57 +04:00
|
|
|
url_err = url_escape(url, FILE_SCHEME_PREFIX_LEN, false, "/", &escurl);
|
2008-04-02 04:43:51 +04:00
|
|
|
free(url); url = NULL;
|
|
|
|
if (url_err != URL_FUNC_OK) {
|
|
|
|
LOG(("url_escape failed: %s", url));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return escurl;
|
2003-11-08 02:51:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-18 03:54:27 +03:00
|
|
|
/**
|
|
|
|
* Convert a file: URL to a RISC OS pathname.
|
|
|
|
*
|
|
|
|
* \param url a file: URL
|
|
|
|
* \return RISC OS pathname, allocated on heap, or 0 on failure
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *url_to_path(const char *url)
|
|
|
|
{
|
2010-09-11 22:47:36 +04:00
|
|
|
char *path;
|
2010-09-12 00:51:08 +04:00
|
|
|
char *filename;
|
2010-09-11 22:47:36 +04:00
|
|
|
char *respath;
|
|
|
|
url_func_result res; /* result from url routines */
|
|
|
|
char *r;
|
2006-01-18 03:54:27 +03:00
|
|
|
|
2010-09-11 22:47:36 +04:00
|
|
|
res = url_path(url, &path);
|
|
|
|
if (res != URL_FUNC_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
2006-01-18 03:54:27 +03:00
|
|
|
return NULL;
|
2010-09-11 22:47:36 +04:00
|
|
|
}
|
2006-01-18 03:54:27 +03:00
|
|
|
|
2010-09-11 22:47:36 +04:00
|
|
|
res = url_unescape(path, &respath);
|
|
|
|
free(path);
|
|
|
|
if (res != URL_FUNC_OK) {
|
2006-01-18 03:54:27 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-11 22:47:36 +04:00
|
|
|
/* RISC OS path should not be more than 100 characters longer */
|
|
|
|
filename = malloc(strlen(respath) + 100);
|
2006-01-18 03:54:27 +03:00
|
|
|
if (!filename) {
|
2010-09-11 22:47:36 +04:00
|
|
|
free(respath);
|
2006-01-18 03:54:27 +03:00
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-09-11 22:47:36 +04:00
|
|
|
|
|
|
|
r = __riscosify(respath, 0, __RISCOSIFY_NO_SUFFIX,
|
|
|
|
filename, strlen(respath) + 100, 0);
|
|
|
|
|
|
|
|
free(respath);
|
2006-01-18 03:54:27 +03:00
|
|
|
if (r == 0) {
|
2010-09-11 22:47:36 +04:00
|
|
|
free(filename);
|
2006-01-18 03:54:27 +03:00
|
|
|
LOG(("__riscosify failed"));
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-09-11 22:47:36 +04:00
|
|
|
|
2006-01-18 03:54:27 +03:00
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-04 00:20:43 +03:00
|
|
|
/**
|
|
|
|
* Get screen properties following a mode change.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_get_screen_properties(void)
|
|
|
|
{
|
2009-03-28 22:10:29 +03: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
|
|
|
|
}
|
2006-02-04 00:20:43 +03:00
|
|
|
};
|
|
|
|
os_error *error;
|
|
|
|
int vals[4];
|
|
|
|
|
2009-03-28 22:10:29 +03:00
|
|
|
error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals);
|
2006-02-04 00:20:43 +03:00
|
|
|
if (error) {
|
|
|
|
LOG(("xos_read_vdu_variables: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("MiscError", error->errmess);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
screen_info.width = (vals[0] + 1) << vals[2];
|
|
|
|
screen_info.height = (vals[1] + 1) << vals[3];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-11 01:44:11 +04:00
|
|
|
/**
|
|
|
|
* Find screen size in OS units.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ro_gui_screen_size(int *width, int *height)
|
|
|
|
{
|
2006-02-04 00:20:43 +03:00
|
|
|
*width = screen_info.width;
|
|
|
|
*height = screen_info.height;
|
2003-09-11 01:44:11 +04:00
|
|
|
}
|
|
|
|
|
2003-11-08 02:51:13 +03:00
|
|
|
|
2004-05-14 23:59:09 +04:00
|
|
|
/**
|
|
|
|
* Opens a language sensitive help page
|
|
|
|
*
|
|
|
|
* \param page the page to open
|
|
|
|
*/
|
2004-05-25 14:42:28 +04:00
|
|
|
void ro_gui_open_help_page(const char *page)
|
2003-09-26 20:52:53 +04:00
|
|
|
{
|
2004-02-27 17:09:15 +03:00
|
|
|
char url[80];
|
2004-06-09 01:35:28 +04:00
|
|
|
int length;
|
|
|
|
|
|
|
|
if ((length = snprintf(url, sizeof url,
|
2006-04-12 12:09:27 +04:00
|
|
|
"file:///<NetSurf$Dir>/Docs/%s_%s",
|
2011-03-16 15:22:02 +03:00
|
|
|
page, option_language)) >= 0 &&
|
|
|
|
length < (int)sizeof(url))
|
2008-08-24 14:31:38 +04:00
|
|
|
browser_window_create(url, NULL, 0, true, false);
|
2003-09-26 20:52:53 +04:00
|
|
|
}
|
|
|
|
|
2007-08-20 06:39:49 +04:00
|
|
|
|
2003-12-11 04:23:57 +03:00
|
|
|
/**
|
|
|
|
* Send the source of a content to a text editor.
|
|
|
|
*/
|
2004-02-26 03:44:42 +03:00
|
|
|
|
2010-04-07 14:33:46 +04:00
|
|
|
void ro_gui_view_source(hlcache_handle *c)
|
2003-12-11 04:23:57 +03:00
|
|
|
{
|
2005-08-03 21:01:40 +04:00
|
|
|
os_error *error;
|
2006-04-22 03:49:52 +04:00
|
|
|
char full_name[256];
|
|
|
|
char *temp_name, *r;
|
|
|
|
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) {
|
|
|
|
warn_user("MiscError", "No document source");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
source_data = content_get_source_data(c, &source_size);
|
|
|
|
|
|
|
|
if (!source_data) {
|
2004-10-18 02:13:35 +04:00
|
|
|
warn_user("MiscError", "No document source");
|
|
|
|
return;
|
|
|
|
}
|
2006-03-25 23:30:35 +03:00
|
|
|
|
2006-01-08 23:09:05 +03:00
|
|
|
/* try to load local files directly. */
|
2011-10-03 20:30:08 +04:00
|
|
|
temp_name = url_to_path(nsurl_access(content_get_url(c)));
|
2006-01-18 03:54:27 +03:00
|
|
|
if (temp_name) {
|
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. */
|
|
|
|
const char *filename = filename_request();
|
|
|
|
if (!filename) {
|
2006-04-22 03:49:52 +04:00
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return;
|
|
|
|
}
|
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) {
|
|
|
|
LOG(("__riscosify failed"));
|
|
|
|
return;
|
2006-01-08 23:09:05 +03:00
|
|
|
}
|
|
|
|
message.file_name[211] = '\0';
|
|
|
|
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) {
|
|
|
|
LOG(("xosfile_save_stamped failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("MiscError", error->errmess);
|
|
|
|
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
|
|
|
|
|
|
|
|
2007-08-20 06:39:49 +04:00
|
|
|
void ro_gui_view_source_bounce(wimp_message *message)
|
|
|
|
{
|
2006-01-08 23:09:05 +03: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);
|
2005-08-03 21:01:40 +04:00
|
|
|
if (error) {
|
2006-01-08 23:09:05 +03:00
|
|
|
LOG(("xwimp_start_task failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
2005-08-03 21:01:40 +04:00
|
|
|
}
|
2003-12-11 04:23:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 06:39:49 +04:00
|
|
|
/**
|
|
|
|
* Send the debug dump of a content to a text editor.
|
|
|
|
*/
|
|
|
|
|
2010-04-07 14:55:39 +04:00
|
|
|
void ro_gui_dump_content(hlcache_handle *c)
|
2007-08-20 06:39:49 +04:00
|
|
|
{
|
|
|
|
os_error *error;
|
|
|
|
|
|
|
|
/* open file for dump */
|
|
|
|
FILE *stream = fopen("<Wimp$ScrapDir>.WWW.NetSurf.dump", "w");
|
|
|
|
if (!stream) {
|
|
|
|
LOG(("fopen: errno %i", errno));
|
|
|
|
warn_user("SaveError", strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* output debug information to file */
|
2010-04-07 14:55:39 +04:00
|
|
|
switch (content_get_type(c)) {
|
2007-08-20 06:39:49 +04:00
|
|
|
case CONTENT_HTML:
|
2010-04-07 14:55:39 +04:00
|
|
|
box_dump(stream, html_get_box_tree(c), 0);
|
2007-08-20 06:39:49 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(stream);
|
|
|
|
|
|
|
|
/* launch file in editor */
|
|
|
|
error = xwimp_start_task("Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.dump",
|
|
|
|
0);
|
|
|
|
if (error) {
|
|
|
|
LOG(("xwimp_start_task failed: 0x%x: %s",
|
|
|
|
error->errnum, error->errmess));
|
|
|
|
warn_user("WimpError", error->errmess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-13 18:39:43 +04:00
|
|
|
/**
|
|
|
|
* Broadcast an URL that we can't handle.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void gui_launch_url(const char *url)
|
|
|
|
{
|
|
|
|
/* Try ant broadcast first */
|
|
|
|
ro_url_broadcast(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
2003-10-06 03:30:21 +04:00
|
|
|
|
2004-05-07 23:14:54 +04:00
|
|
|
void warn_user(const char *warning, const char *detail)
|
2003-11-08 02:51:13 +03:00
|
|
|
{
|
2004-05-07 23:14:54 +04:00
|
|
|
LOG(("%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();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* 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);
|
|
|
|
}
|
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;
|
|
|
|
|
2007-01-01 00:04:14 +03:00
|
|
|
LOG(("%s", error));
|
|
|
|
|
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
|
|
|
|
|
|
|
void PDF_Password(char **owner_pass, char **user_pass, char *path)
|
|
|
|
{
|
|
|
|
/*TODO:this waits to be written, until then no PDF encryption*/
|
|
|
|
*owner_pass = NULL;
|
|
|
|
}
|
2010-03-21 16:32:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the filename part of a full path
|
|
|
|
*
|
|
|
|
* \param path full path and filename
|
|
|
|
* \return filename (will be freed with free())
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *filename_from_path(char *path)
|
|
|
|
{
|
|
|
|
char *leafname;
|
|
|
|
char *temp;
|
|
|
|
int leaflen;
|
|
|
|
|
|
|
|
temp = strrchr(path, '.');
|
|
|
|
if (!temp)
|
|
|
|
temp = path; /* already leafname */
|
|
|
|
else
|
|
|
|
temp += 1;
|
|
|
|
|
|
|
|
leaflen = strlen(temp);
|
|
|
|
|
|
|
|
leafname = malloc(leaflen + 1);
|
|
|
|
if (!leafname) {
|
|
|
|
LOG(("malloc failed"));
|
2010-04-07 15:05:24 +04:00
|
|
|
return NULL;
|
2010-03-21 16:32:59 +03:00
|
|
|
}
|
|
|
|
memcpy(leafname, temp, leaflen + 1);
|
|
|
|
|
|
|
|
/* and s/\//\./g */
|
|
|
|
for (temp = leafname; *temp; temp++)
|
|
|
|
if (*temp == '/')
|
|
|
|
*temp = '.';
|
|
|
|
|
|
|
|
return leafname;
|
|
|
|
}
|
2010-07-09 23:45:44 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a path component/filename to an existing path
|
|
|
|
*
|
2010-09-13 22:20:08 +04:00
|
|
|
* \param path buffer containing platform-native format path + free space
|
2010-07-09 23:45:44 +04:00
|
|
|
* \param length length of buffer "path"
|
2010-09-13 22:20:08 +04:00
|
|
|
* \param newpart string containing unix-format path component to add to path
|
2010-07-09 23:45:44 +04:00
|
|
|
* \return true on success
|
|
|
|
*/
|
|
|
|
|
2010-07-10 01:36:55 +04:00
|
|
|
bool path_add_part(char *path, int length, const char *newpart)
|
2010-07-09 23:45:44 +04:00
|
|
|
{
|
2010-09-13 22:20:08 +04:00
|
|
|
size_t path_len = strlen(path);
|
|
|
|
|
|
|
|
/* Append directory separator, if there isn't one */
|
|
|
|
if (path[path_len - 1] != '.') {
|
2010-07-09 23:45:44 +04:00
|
|
|
strncat(path, ".", length);
|
2010-09-13 22:20:08 +04:00
|
|
|
path_len += 1;
|
|
|
|
}
|
2010-07-09 23:45:44 +04:00
|
|
|
|
|
|
|
strncat(path, newpart, length);
|
|
|
|
|
2010-09-13 22:20:08 +04:00
|
|
|
/* Newpart is either a directory name, or a file leafname
|
|
|
|
* Either way, we must replace all dots with forward slashes */
|
|
|
|
for (path = path + path_len; *path; path++) {
|
|
|
|
if (*path == '.')
|
|
|
|
*path = '/';
|
|
|
|
}
|
|
|
|
|
2010-07-09 23:45:44 +04:00
|
|
|
return true;
|
|
|
|
}
|