summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--!NetSurf/!Run,feb8
-rw-r--r--!NetSurf/Resources/de/Messages11
-rw-r--r--!NetSurf/Resources/en/Messages11
-rw-r--r--!NetSurf/Resources/fr/Messages11
-rw-r--r--!NetSurf/Resources/nl/Messages11
-rw-r--r--content/fetch.c26
-rw-r--r--desktop/options.c13
-rw-r--r--desktop/options.h3
-rw-r--r--gtk/gtk_gui.c16
-rw-r--r--gtk/gtk_treeview.c5
-rw-r--r--riscos/dialog.c30
-rw-r--r--riscos/global_history.c24
-rw-r--r--riscos/gui.c174
-rw-r--r--riscos/hotlist.c17
-rw-r--r--riscos/menus.c10
-rw-r--r--riscos/options.h28
-rw-r--r--riscos/theme.c9
-rw-r--r--riscos/theme.h12
-rw-r--r--riscos/theme_install.c6
19 files changed, 245 insertions, 180 deletions
diff --git a/!NetSurf/!Run,feb b/!NetSurf/!Run,feb
index c259f818f..cf809c4b4 100644
--- a/!NetSurf/!Run,feb
+++ b/!NetSurf/!Run,feb
@@ -1,4 +1,4 @@
-| Run file for NetSurf. ( $Revision: 1.44 $ )
+| Run file for NetSurf. ( $Revision: 1.45 $ )
|
| This file ensures that the system resources required by NetSurf are
| present. Additionally, it forces setting of system variables related
@@ -9,6 +9,12 @@ Set NetSurf$ForceVars 1
<Obey$Dir>.!Boot
UnSet NetSurf$ForceVars
+| Resource Locations
+| The following are read-only locations
+SetMacro NetSurf$Path Choices:WWW.NetSurf.,<NetSurf$Dir>.
+| The following are write-only locations
+SetMacro NetSurf$ChoicesSave <Choices$Write>.WWW.NetSurf.Choices
+
| We need RISC OS 3
RMEnsure UtilityModule 3.00 Error NetSurf needs RISC OS 3 or later
diff --git a/!NetSurf/Resources/de/Messages b/!NetSurf/Resources/de/Messages
index cb509a7f3..3c62f3b44 100644
--- a/!NetSurf/Resources/de/Messages
+++ b/!NetSurf/Resources/de/Messages
@@ -340,17 +340,6 @@ Encoding2:from <meta>
EncodingUnk:Unknown
-# Cookies
-# =======
-#
-# Cookies related tokens.
-#
-# At present, this section simply stores the location of
-# the cookie file. This should not be changed.
-#
-cookiefile:Choices:WWW.NetSurf.Cookies
-cookiejar:<Choices$Write>.WWW.NetSurf.Cookies
-
# Errors
# ======
#
diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages
index 8c6b6dcae..ef84d79dd 100644
--- a/!NetSurf/Resources/en/Messages
+++ b/!NetSurf/Resources/en/Messages
@@ -340,17 +340,6 @@ Encoding2:from <meta>
EncodingUnk:Unknown
-# Cookies
-# =======
-#
-# Cookies related tokens.
-#
-# At present, this section simply stores the location of
-# the cookie file. This should not be changed.
-#
-cookiefile:Choices:WWW.NetSurf.Cookies
-cookiejar:<Choices$Write>.WWW.NetSurf.Cookies
-
# Errors
# ======
#
diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages
index 581c137da..75b83a73a 100644
--- a/!NetSurf/Resources/fr/Messages
+++ b/!NetSurf/Resources/fr/Messages
@@ -340,17 +340,6 @@ Encoding2:de <meta>
EncodingUnk:Inconnu
-# Cookies
-# =======
-#
-# Cookies related tokens.
-#
-# At present, this section simply stores the location of
-# the cookie file. This should not be changed.
-#
-cookiefile:Choices:WWW.NetSurf.Cookies
-cookiejar:<Choices$Write>.WWW.NetSurf.Cookies
-
# Errors
# ======
#
diff --git a/!NetSurf/Resources/nl/Messages b/!NetSurf/Resources/nl/Messages
index 59b7ac15e..60e23980e 100644
--- a/!NetSurf/Resources/nl/Messages
+++ b/!NetSurf/Resources/nl/Messages
@@ -341,17 +341,6 @@ Encoding2:from <meta>
EncodingUnk:Unknown
-# Cookies
-# =======
-#
-# Cookies related tokens.
-#
-# At present, this section simply stores the location of
-# the cookie file. This should not be changed.
-#
-cookiefile:Choices:WWW.NetSurf.Cookies
-cookiejar:<Choices$Write>.WWW.NetSurf.Cookies
-
# Errors
# ======
#
diff --git a/content/fetch.c b/content/fetch.c
index e5878cf0d..9fa792f2c 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -38,9 +38,6 @@
#ifdef WITH_POST
#include "netsurf/render/form.h"
#endif
-#ifdef riscos
-#include "netsurf/riscos/gui.h"
-#endif
#define NDEBUG
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
@@ -101,10 +98,6 @@ static bool fetch_process_headers(struct fetch *f);
static struct curl_httppost *fetch_post_convert(struct form_successful_control *control);
#endif
-#ifdef riscos
-static char * ca_bundle; /**< SSL certificate bundle filename. */
-#endif
-
/**
* Initialise the fetcher.
@@ -126,13 +119,6 @@ void fetch_init(void)
die("Failed to initialise the fetch module "
"(curl_multi_init failed).");
-#ifdef riscos
- ca_bundle = malloc(strlen(NETSURF_DIR) + 40);
- if (!ca_bundle)
- die("NoMemory");
- sprintf(ca_bundle, "%s.Resources.ca-bundle", NETSURF_DIR);
-#endif
-
/* Create a curl easy handle with the options that are common to all
fetches. */
fetch_blank_curl = curl_easy_init();
@@ -157,9 +143,9 @@ void fetch_init(void)
SETOPT(CURLOPT_LOW_SPEED_TIME, 60L);
SETOPT(CURLOPT_NOSIGNAL, 1L);
SETOPT(CURLOPT_CONNECTTIMEOUT, 60L);
-#ifdef riscos
- SETOPT(CURLOPT_CAINFO, ca_bundle);
-#endif
+
+ if (option_ca_bundle)
+ SETOPT(CURLOPT_CAINFO, option_ca_bundle);
if (!option_ssl_verify_certificates) {
/* disable verification of SSL certificates.
@@ -421,8 +407,10 @@ CURLcode fetch_set_options(struct fetch *f)
SETOPT(CURLOPT_HTTPGET, 1L);
}
if (f->cookies) {
- SETOPT(CURLOPT_COOKIEFILE, messages_get("cookiefile"));
- SETOPT(CURLOPT_COOKIEJAR, messages_get("cookiejar"));
+ if (option_cookie_file)
+ SETOPT(CURLOPT_COOKIEFILE, option_cookie_file);
+ if (option_cookie_jar)
+ SETOPT(CURLOPT_COOKIEJAR, option_cookie_jar);
} else {
SETOPT(CURLOPT_COOKIEFILE, 0);
SETOPT(CURLOPT_COOKIEJAR, 0);
diff --git a/desktop/options.c b/desktop/options.c
index da68be4d4..5ae615703 100644
--- a/desktop/options.c
+++ b/desktop/options.c
@@ -72,6 +72,12 @@ bool option_animate_images = true;
int option_expire_url = 28;
/** Default font family */
int option_font_default = CSS_FONT_FAMILY_SANS_SERIF;
+/** ca-bundle location */
+char *option_ca_bundle = 0;
+/** Cookie file location */
+char *option_cookie_file = 0;
+/** Cookie jar loaction */
+char *option_cookie_jar = 0;
EXTRA_OPTION_DEFINE
@@ -97,8 +103,11 @@ struct {
{ "minimum_gif_delay", OPTION_INTEGER, &option_minimum_gif_delay },
{ "send_referer", OPTION_BOOL, &option_send_referer },
{ "animate_images", OPTION_BOOL, &option_animate_images },
- { "expire_url", OPTION_INTEGER, &option_expire_url },
- { "font_default", OPTION_INTEGER, &option_font_default },
+ { "expire_url", OPTION_INTEGER, &option_expire_url },
+ { "font_default", OPTION_INTEGER, &option_font_default },
+ { "ca_bundle", OPTION_STRING, &option_ca_bundle },
+ { "cookie_file", OPTION_STRING, &option_cookie_file },
+ { "cookie_jar", OPTION_STRING, &option_cookie_jar },
EXTRA_OPTION_TABLE
};
diff --git a/desktop/options.h b/desktop/options.h
index 50f3a261a..f31be7c45 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -47,6 +47,9 @@ extern bool option_send_referer;
extern bool option_animate_images;
extern int option_expire_url;
extern int option_font_default; /* a css_font_family */
+extern char *option_ca_bundle;
+extern char *option_cookie_file;
+extern char *option_cookie_jar;
void options_read(const char *path);
void options_write(const char *path);
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index 3c512fddc..b5eaf767b 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -16,6 +16,7 @@
#include <gtk/gtk.h>
#include "netsurf/content/content.h"
#include "netsurf/content/fetch.h"
+#include "netsurf/content/url_store.h"
#include "netsurf/desktop/401login.h"
#include "netsurf/desktop/browser.h"
#include "netsurf/desktop/gui.h"
@@ -54,6 +55,17 @@ void gui_init(int argc, char** argv)
snprintf(buf, sizeof buf, "%s/.netsurf/Choices", home);
options_read(buf);
+ if (!option_cookie_file) {
+ snprintf(buf, sizeof buf, "%s/.netsurf/Cookies");
+ option_cookie_file = strdup(buf);
+ }
+ if (!option_cookie_jar) {
+ snprintf(buf, sizeof buf, "%s/.netsurf/Cookies");
+ option_cookie_jar = strdup(buf);
+ }
+ if (!option_cookie_file || !option_cookie_jar)
+ die("Failed initialising cookie options");
+
snprintf(buf, sizeof buf, "%s/.netsurf/messages", home);
messages_load(buf);
@@ -62,6 +74,8 @@ void gui_init(int argc, char** argv)
default_stylesheet_url = strdup(buf);
snprintf(buf, sizeof buf, "file:///%s/.netsurf/AdBlock.css", home);
adblock_stylesheet_url = strdup(buf);
+ if (!default_stylesheet_url || !adblock_stylesheet_url)
+ die("Failed duplicating stylesheet strings");
}
@@ -213,7 +227,7 @@ void schedule(int t, void (*callback)(void *p), void *p) {}
void schedule_remove(void (*callback)(void *p), void *p) {}
void schedule_run(void) {}
-void global_history_add(struct gui_window *g) {}
+void global_history_add(struct url_content *data) {}
utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
char **result)
diff --git a/gtk/gtk_treeview.c b/gtk/gtk_treeview.c
index c7d04362f..6b9280c5d 100644
--- a/gtk/gtk_treeview.c
+++ b/gtk/gtk_treeview.c
@@ -38,13 +38,12 @@ void tree_redraw_area(struct tree *tree, int x, int y, int width, int height) {
/**
* Draws a line.
*
- * \param tree the tree to draw a line for
* \param x the x co-ordinate
* \param x the y co-ordinate
* \param x the width of the line
* \param x the height of the line
*/
-void tree_draw_line(struct tree *tree, int x, int y, int width, int height) {
+void tree_draw_line(int x, int y, int width, int height) {
}
@@ -83,7 +82,7 @@ void tree_recalculate_node_element(struct node_element *element) {
*
* \param node the node to update
*/
-void tree_update_URL_node(struct node *node) {
+void tree_update_URL_node(struct node *node, struct url_content *data) {
}
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 700067a0c..74238b57e 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -84,15 +84,15 @@ void ro_gui_dialog_init(void)
/* configure window */
ro_gui_configure_initialise();
-
+
/* 401 login window */
#ifdef WITH_AUTH
ro_gui_401login_init();
#endif
-
+
/* hotlist window */
ro_gui_hotlist_initialise();
-
+
/* global history window */
ro_gui_global_history_initialise();
@@ -104,7 +104,7 @@ void ro_gui_dialog_init(void)
ICON_THEME_INSTALL_INSTALL,
ro_gui_theme_install_apply);
ro_gui_wimp_event_set_help_prefix(dialog_theme_install, "HelpThemeInst");
-
+
/* debug window */
dialog_debug = ro_gui_dialog_create("debug");
ro_gui_wimp_event_set_help_prefix(dialog_debug, "HelpDebug");
@@ -113,7 +113,7 @@ void ro_gui_dialog_init(void)
#ifdef WITH_SEARCH
ro_gui_search_init();
#endif
-
+
/* print */
#ifdef WITH_PRINT
ro_gui_print_init();
@@ -141,7 +141,7 @@ void ro_gui_dialog_init(void)
ro_gui_wimp_event_register_ok(dialog_folder, ICON_FOLDER_OK,
ro_gui_hotlist_dialog_apply);
ro_gui_wimp_event_set_help_prefix(dialog_folder, "HelpHotFolder");
-
+
/* hotlist entry editing */
dialog_entry = ro_gui_dialog_create("new_entry");
ro_gui_wimp_event_register_text_field(dialog_entry, ICON_ENTRY_NAME);
@@ -161,7 +161,7 @@ void ro_gui_dialog_init(void)
ro_gui_wimp_event_register_ok(dialog_saveas, ICON_SAVE_OK,
ro_gui_save_ok);
ro_gui_wimp_event_set_help_prefix(dialog_saveas, "HelpSaveAs");
-
+
/* url suggestion */
dialog_url_complete = ro_gui_dialog_create("url_suggest");
ro_gui_wimp_event_register_mouse_click(dialog_url_complete,
@@ -169,7 +169,7 @@ void ro_gui_dialog_init(void)
ro_gui_wimp_event_register_redraw_window(dialog_url_complete,
ro_gui_url_complete_redraw);
ro_gui_wimp_event_set_help_prefix(dialog_url_complete, "HelpAutoURL");
-
+
/* open URL */
dialog_openurl = ro_gui_dialog_create("open_url");
ro_gui_wimp_event_register_menu_gright(dialog_openurl, ICON_OPENURL_URL,
@@ -178,7 +178,7 @@ void ro_gui_dialog_init(void)
ro_gui_wimp_event_register_ok(dialog_openurl, ICON_OPENURL_OPEN,
ro_gui_dialog_openurl_apply);
ro_gui_wimp_event_set_help_prefix(dialog_openurl, "HelpOpenURL");
-
+
/* scale view */
dialog_zoom = ro_gui_dialog_create("zoom");
ro_gui_wimp_event_register_numeric_field(dialog_zoom, ICON_ZOOM_VALUE,
@@ -368,7 +368,7 @@ void ro_gui_dialog_close(wimp_w close)
}
}
}
-
+
error = xwimp_close_window(close);
if (error) {
LOG(("xwimp_close_window: 0x%x: %s",
@@ -381,7 +381,7 @@ void ro_gui_dialog_close(wimp_w close)
/**
* Moves a window to the top of the stack.
- *
+ *
* If the window is currently closed then:
*
* * The window is opened in the centre of the screen (at the supplied size)
@@ -619,13 +619,7 @@ void ro_gui_dialog_close_persistent(wimp_w parent) {
void ro_gui_save_options(void)
{
- /* NCOS doesnt have the fancy Universal Boot vars; so select
- * the path to the choices file based on the build options */
-#ifndef NCOS
- options_write("<Choices$Write>.WWW.NetSurf.Choices");
-#else
- options_write("<User$Path>.Choices.NetSurf.Choices");
-#endif
+ options_write("<NetSurf$ChoicesSave>");
}
diff --git a/riscos/global_history.c b/riscos/global_history.c
index f3a3d0144..cf1f3ab09 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -23,6 +23,7 @@
#include "netsurf/riscos/global_history.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/menus.h"
+#include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/treeview.h"
#include "netsurf/riscos/wimp.h"
@@ -35,10 +36,6 @@
#define MAXIMUM_URL_LENGTH 1024
#define MAXIMUM_BASE_NODES 16
-#define GLOBAL_HISTORY_RECENT_READ "Choices:WWW.NetSurf.Recent"
-#define GLOBAL_HISTORY_RECENT_WRITE "<Choices$Write>.WWW.NetSurf.Recent"
-
-
static struct node *global_history_base_node[MAXIMUM_BASE_NODES];
static int global_history_base_node_time[MAXIMUM_BASE_NODES];
static int global_history_base_node_count = 0;
@@ -54,7 +51,6 @@ static void ro_gui_global_history_initialise_node(const char *title,
time_t base, int days_back);
static struct node *ro_gui_global_history_find(const char *url);
-
/* The history window, toolbar and plot origins
*/
static wimp_w global_history_window;
@@ -112,10 +108,10 @@ void ro_gui_global_history_initialise(void) {
global_history_window);
/* load recent URLs */
- fp = fopen(GLOBAL_HISTORY_RECENT_READ, "r");
+ fp = fopen(option_recent_path, "r");
if (!fp)
LOG(("Failed to open file '%s' for reading",
- GLOBAL_HISTORY_RECENT_READ));
+ option_recent_path));
else {
while (fgets(s, MAXIMUM_URL_LENGTH, fp)) {
if (s[strlen(s) - 1] == '\n')
@@ -132,7 +128,7 @@ void ro_gui_global_history_initialise(void) {
url_count++;
if (url_count == 0)
return;
-
+
/* place pointers to the URL data in a single block of memory so
* they can be quickly sorted */
url_block = (struct url_content **)malloc(
@@ -147,17 +143,17 @@ void ro_gui_global_history_initialise(void) {
for (url = hostname->url; url; url = url->next)
url_block[i++] = &url->data;
assert(i == url_count);
-
+
/* sort information by the last_visit information */
qsort(url_block, url_count, sizeof(struct url_content *),
url_store_compare_last_visit);
-
+
/* add URLs to the global history */
global_history_init = true;
for (i = 0; i < url_count; i++)
global_history_add(url_block[i]);
-
- global_history_init = false;
+
+ global_history_init = false;
free(url_block);
}
@@ -234,10 +230,10 @@ void ro_gui_global_history_save(void) {
int i;
/* save recent URLs */
- fp = fopen(GLOBAL_HISTORY_RECENT_WRITE, "w");
+ fp = fopen(option_recent_save, "w");
if (!fp)
LOG(("Failed to open file '%s' for writing",
- GLOBAL_HISTORY_RECENT_WRITE));
+ option_recent_save));
else {
for (i = global_history_recent_count - 1; i >= 0; i--)
if (strlen(global_history_recent_url[i]) <
diff --git a/riscos/gui.c b/riscos/gui.c
index 0c74bb915..163fa68df 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -128,6 +128,15 @@ const char * NETSURF_DIR;
char *default_stylesheet_url;
char *adblock_stylesheet_url;
+#ifndef ncos
+static const char *task_name = "NetSurf";
+#define CHOICES_PREFIX "<Choices$Write>.WWW.NetSurf."
+#else
+static const char *task_name = "NCNetSurf";
+#define CHOICES_PREFIX "<User$Path>.Choices.NetSurf."
+#endif
+
+
/** The pointer is over a window which is tracking mouse movement. */
static bool gui_track = false;
/** Handle of window which the pointer is over. */
@@ -204,10 +213,9 @@ static wimp_MESSAGE_LIST(38) task_messages = { {
0
} };
+static void ro_gui_create_dirs(void);
static void ro_gui_choose_language(void);
-#ifndef ncos
static void ro_gui_icon_bar_create(void);
-#endif
static void ro_gui_signal(int sig);
static void ro_gui_cleanup(void);
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
@@ -254,8 +262,9 @@ void gui_init(int argc, char** argv)
xhourglass_start(1);
- /* read OS version for code that adapts to conform to the OS (remember
- that it's preferable to check for specific features being present) */
+ /* read OS version for code that adapts to conform to the OS
+ * (remember that it's preferable to check for specific features
+ * being present) */
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
atexit(ro_gui_cleanup);
@@ -273,28 +282,14 @@ void gui_init(int argc, char** argv)
prev_sigs.sigterm == SIG_ERR)
die("Failed registering signal handlers");
- /* create our choices directories */
-#ifndef ncos
- xosfile_create_dir("<Choices$Write>.WWW", 0);
- xosfile_create_dir("<Choices$Write>.WWW.NetSurf", 0);
- xosfile_create_dir("<Choices$Write>.WWW.NetSurf.Themes", 0);
-#else
- xosfile_create_dir("<User$Path>.Choices.NetSurf", 0);
- xosfile_create_dir("<User$Path>.Choices.NetSurf.Choices", 0);
- xosfile_create_dir("<User$Path>.Choices.NetSurf.Choices.Themes", 0);
-#endif
ro_filename_initialise();
#ifdef WITH_SAVE_COMPLETE
save_complete_init();
#endif
- /* We don't have the universal boot sequence on NCOS */
-#ifndef ncos
- options_read("Choices:WWW.NetSurf.Choices");
-#else
- options_read("<User$Path>.Choices.NetSurf.Choices");
-#endif
+ options_read("NetSurf:Choices");
+
/* set defaults for absent strings */
if (!option_theme)
option_theme = strdup("Aletheia");
@@ -304,38 +299,72 @@ void gui_init(int argc, char** argv)
option_toolbar_hotlist = strdup("401|23");
if (!option_toolbar_history)
option_toolbar_history = strdup("01|23");
+ 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");
+
+ 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 ||
+ !option_theme_save)
+ die("Failed initialising string options");
- gui_sprites = ro_gui_load_sprite_file("<NetSurf$Dir>.Resources.Sprites");
+ /* create our choices directories */
+ ro_gui_create_dirs();
+
+ gui_sprites = ro_gui_load_sprite_file("NetSurf:Resources.Sprites");
if (!gui_sprites)
die("Unable to load Sprites.");
ro_gui_choose_language();
bitmap_initialise_memory();
- url_store_load("Choices:WWW.NetSurf.URL");
+ url_store_load(option_url_path);
nsdir_temp = getenv("NetSurf$Dir");
if (!nsdir_temp)
die("Failed to locate NetSurf directory");
NETSURF_DIR = strdup(nsdir_temp);
+ if (!NETSURF_DIR)
+ die("Failed duplicating NetSurf directory string");
if ((length = snprintf(path, sizeof(path),
- "<NetSurf$Dir>.Resources.%s.Messages",
+ "NetSurf:Resources.%s.Messages",
option_language)) < 0 || length >= (int)sizeof(path))
die("Failed to locate Messages resource.");
messages_load(path);
- messages_load("<NetSurf$Dir>.Resources.LangNames");
+ messages_load("NetSurf:Resources.LangNames");
- default_stylesheet_url = strdup("file:/<NetSurf$Dir>/Resources/CSS");
- adblock_stylesheet_url = strdup("file:/<NetSurf$Dir>/Resources/AdBlock");
-#ifndef ncos
- error = xwimp_initialise(wimp_VERSION_RO38, "NetSurf",
- (const wimp_message_list *) &task_messages, 0,
- &task_handle);
-#else
- error = xwimp_initialise(wimp_VERSION_RO38, "NCNetSurf",
+ default_stylesheet_url = strdup("file:/NetSurf:/Resources/CSS");
+ adblock_stylesheet_url = strdup("file:/NetSurf:/Resources/AdBlock");
+ if (!default_stylesheet_url || !adblock_stylesheet_url)
+ die("Failed initialising string constants.");
+
+ error = xwimp_initialise(wimp_VERSION_RO38, task_name,
(const wimp_message_list *) &task_messages, 0,
&task_handle);
-#endif
if (error) {
LOG(("xwimp_initialise: 0x%x: %s",
error->errnum, error->errmess));
@@ -351,7 +380,7 @@ void gui_init(int argc, char** argv)
/* Open the templates
*/
if ((length = snprintf(path, sizeof(path),
- "<NetSurf$Dir>.Resources.%s.Templates",
+ "NetSurf:Resources.%s.Templates",
option_language)) < 0 || length >= (int)sizeof(path))
die("Failed to locate Templates resource.");
error = xwimp_open_template(path);
@@ -370,12 +399,75 @@ void gui_init(int argc, char** argv)
ro_gui_tree_initialise(); /* must be done after sprite loading */
-#ifndef ncos
ro_gui_icon_bar_create();
-#endif
ro_gui_check_resolvers();
}
+/**
+ * Create intermediate directories for Choices and User Data files
+ */
+void ro_gui_create_dirs(void)
+{
+ char *path;
+ char buf[256];
+
+ /* Choices */
+ path = getenv("NetSurf$ChoicesSave");
+ if (!path)
+ die("Failed to find NetSurf Choices save path");
+
+ snprintf(buf, sizeof(buf), "%s", path);
+ path = buf;
+
+ /* Given a path x.y.z, this will try to create x, x.y */
+ while ((path = strchr(path, '.'))) {
+ *path = '\0';
+ xosfile_create_dir(buf, 0);
+ *path++ = '.';
+ }
+
+ /* URL */
+ snprintf(buf, sizeof(buf), "%s", option_url_save);
+ path = buf;
+
+ while ((path = strchr(path, '.'))) {
+ *path = '\0';
+ xosfile_create_dir(buf, 0);
+ *path++ = '.';
+ }
+
+ /* Hotlist */
+ snprintf(buf, sizeof(buf), "%s", option_hotlist_save);
+ path = buf;
+
+ while ((path = strchr(path, '.'))) {
+ *path = '\0';
+ xosfile_create_dir(buf, 0);
+ *path++ = '.';
+ }
+
+ /* Recent */
+ snprintf(buf, sizeof(buf), "%s", option_recent_save);
+ path = buf;
+
+ while ((path = strchr(path, '.'))) {
+ *path = '\0';
+ xosfile_create_dir(buf, 0);
+ *path++ = '.';
+ }
+
+ /* Theme */
+ snprintf(buf, sizeof(buf), "%s", option_theme_save);
+ path = buf;
+
+ while ((path = strchr(path, '.'))) {
+ *path = '\0';
+ xosfile_create_dir(buf, 0);
+ *path++ = '.';
+ }
+ /* and the final directory part (as theme_save is a directory) */
+ xosfile_create_dir(buf, 0);
+}
/**
* Determine the language to use.
@@ -395,7 +487,7 @@ void ro_gui_choose_language(void)
if (option_language) {
if (2 < strlen(option_language))
option_language[2] = 0;
- sprintf(path, "<NetSurf$Dir>.Resources.%s", option_language);
+ sprintf(path, "NetSurf:Resources.%s", option_language);
if (is_dir(path)) {
if (!option_accept_language)
option_accept_language = strdup(option_language);
@@ -429,7 +521,7 @@ void ro_gui_choose_language(void)
lang = "en";
break;
}
- sprintf(path, "<NetSurf$Dir>.Resources.%s", lang);
+ sprintf(path, "NetSurf:Resources.%s", lang);
if (is_dir(path))
option_language = strdup(lang);
else
@@ -440,13 +532,13 @@ void ro_gui_choose_language(void)
}
-#ifndef ncos
/**
* Create an iconbar icon.
*/
void ro_gui_icon_bar_create(void)
{
+#ifndef ncos
wimp_icon_create icon = {
wimp_ICON_BAR_RIGHT,
{ { 0, 0, 68, 68 },
@@ -456,8 +548,8 @@ void ro_gui_icon_bar_create(void)
wimp_create_icon(&icon);
ro_gui_wimp_event_register_mouse_click(wimp_ICON_BAR,
ro_gui_icon_bar_click);
-}
#endif
+}
/**
@@ -566,7 +658,7 @@ void gui_init2(int argc, char** argv)
void gui_quit(void)
{
bitmap_quit();
- url_store_save("<Choices$Write>.WWW.NetSurf.URL");
+ url_store_save(option_url_save);
ro_gui_window_quit();
ro_gui_global_history_save();
ro_gui_hotlist_save();
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index f0c762ecb..914b095a2 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -20,6 +20,7 @@
#include "netsurf/desktop/tree.h"
#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/menus.h"
+#include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h"
#include "netsurf/riscos/treeview.h"
#include "netsurf/riscos/wimp.h"
@@ -65,7 +66,7 @@ void ro_gui_hotlist_initialise(void) {
/* Either load or create a hotlist
*/
- fp = fopen("Choices:WWW.NetSurf.Hotlist", "r");
+ fp = fopen(option_hotlist_path, "r");
if (!fp) {
hotlist_tree = calloc(sizeof(struct tree), 1);
if (!hotlist_tree) {
@@ -112,7 +113,7 @@ void ro_gui_hotlist_initialise(void) {
tree_initialise(hotlist_tree);
} else {
fclose(fp);
- hotlist_tree = options_load_tree("Choices:WWW.NetSurf.Hotlist");
+ hotlist_tree = options_load_tree(option_hotlist_path);
}
if (!hotlist_tree) return;
hotlist_tree->handle = (int)hotlist_window;
@@ -142,9 +143,9 @@ void ro_gui_hotlist_save(void) {
/* Save to our file
*/
- options_save_tree(hotlist_tree, "<Choices$Write>.WWW.NetSurf.Hotlist",
+ options_save_tree(hotlist_tree, option_hotlist_save,
"NetSurf hotlist");
- error = xosfile_set_type("<Choices$Write>.WWW.NetSurf.Hotlist", 0xfaf);
+ error = xosfile_set_type(option_hotlist_save, 0xfaf);
if (error)
LOG(("xosfile_set_type: 0x%x: %s",
error->errnum, error->errmess));
@@ -214,7 +215,7 @@ void ro_gui_hotlist_visited(struct content *content, struct tree *tree,
void ro_gui_hotlist_prepare_folder_dialog(struct node *node) {
const char *name;
const char *title;
-
+
dialog_folder_node = node;
if (node) {
title = messages_get("EditFolder");
@@ -222,7 +223,7 @@ void ro_gui_hotlist_prepare_folder_dialog(struct node *node) {
} else {
title = messages_get("NewFolder");
name = messages_get("Folder");
- }
+ }
ro_gui_set_window_title(dialog_folder, title);
ro_gui_set_icon_string(dialog_folder, ICON_FOLDER_NAME, name);
ro_gui_wimp_event_memorise(dialog_folder);
@@ -277,7 +278,7 @@ bool ro_gui_hotlist_dialog_apply(wimp_w w) {
if (strlen(icon) == 0) {
warn_user("NoURLError", 0);
return false;
- }
+ }
res = url_normalize(icon, &url);
title = strip(ro_gui_get_icon_string(w, ICON_ENTRY_NAME));
node = dialog_entry_node;
@@ -314,7 +315,7 @@ bool ro_gui_hotlist_dialog_apply(wimp_w w) {
data->title = strdup(title);
node = dialog_entry_node = tree_create_URL_node(
hotlist_tree->root, data, title);
-
+
} else {
node = dialog_folder_node = tree_create_folder_node(
hotlist_tree->root, title);
diff --git a/riscos/menus.c b/riscos/menus.c
index 8c3ea401f..59e41e230 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -520,7 +520,7 @@ void ro_gui_popup_menu(wimp_menu *menu, wimp_w w, wimp_i i) {
warn_user("MenuError", error->errmess);
return;
}
-
+
ro_gui_menu_create(menu,
state.visible.x0 + icon_state.icon.extent.x1 + 64,
state.visible.y1 + icon_state.icon.extent.y1 -
@@ -559,7 +559,7 @@ void ro_gui_menu_closed(bool cleanup) {
the text doesn't remain highlighted */
if (ro_gui_menu_search_window_menu)
ro_gui_search_end(dialog_search);
-
+
if (tree)
ro_gui_tree_menu_closed(tree);
}
@@ -605,7 +605,7 @@ void ro_gui_menu_selection(wimp_selection *selection) {
if (!current_menu)
return
assert(current_menu_window);
-
+
/* get the menu entry and associated action */
menu_entry = &current_menu->entries[selection->items[0]];
for (i = 1; selection->items[i] != -1; i++)
@@ -932,7 +932,7 @@ void ro_gui_menu_prepare_languages(bool accept, const char *lang)
for (entry = menu->entries; entry; entry = entry->next) {
if (!accept) {
snprintf(path_buf, sizeof path_buf,
- "<NetSurf$Dir>.Resources.%.2s",
+ "NetSurf:Resources.%.2s",
entry->entry_key + offset);
entry->menu_entry->icon_flags |= is_dir(path_buf) ?
@@ -1249,7 +1249,7 @@ void ro_gui_menu_define_menu_add(struct menu_definition *definition,
*/
void ro_gui_menu_init_structure(wimp_menu *menu, int entries) {
int i;
-
+
menu->title_fg = wimp_COLOUR_BLACK;
menu->title_bg = wimp_COLOUR_LIGHT_GREY;
menu->work_fg = wimp_COLOUR_BLACK;
diff --git a/riscos/options.h b/riscos/options.h
index 1c153c088..2a39aeb08 100644
--- a/riscos/options.h
+++ b/riscos/options.h
@@ -57,6 +57,14 @@ extern bool option_url_suggestion;
extern int option_image_memory_direct; /* -1 means auto-detect */
extern int option_image_memory_compressed; /* -1 means auto-detect */
extern bool option_strip_extensions;
+extern char *option_url_path;
+extern char *option_url_save;
+extern char *option_hotlist_path;
+extern char *option_hotlist_save;
+extern char *option_recent_path;
+extern char *option_recent_save;
+extern char *option_theme_path;
+extern char *option_theme_save;
#define EXTRA_OPTION_DEFINE \
bool option_use_mouse_gestures = false;\
@@ -98,7 +106,15 @@ bool option_block_popups = false; \
bool option_url_suggestion = true; \
int option_image_memory_direct = -1; \
int option_image_memory_compressed = -1; \
-bool option_strip_extensions = true;
+bool option_strip_extensions = true; \
+char *option_url_path = 0; \
+char *option_url_save = 0; \
+char *option_hotlist_path = 0; \
+char *option_hotlist_save = 0; \
+char *option_recent_path = 0; \
+char *option_recent_save = 0; \
+char *option_theme_path = 0; \
+char *option_theme_save = 0;
#define EXTRA_OPTION_TABLE \
{ "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\
@@ -140,6 +156,14 @@ bool option_strip_extensions = true;
{ "url_suggestion", OPTION_BOOL, &option_url_suggestion }, \
{ "image_memory_direct", OPTION_INTEGER, &option_image_memory_direct }, \
{ "image_memory_compressed",OPTION_INTEGER, &option_image_memory_compressed }, \
-{ "strip_extensions", OPTION_BOOL, &option_strip_extensions }
+{ "strip_extensions", OPTION_BOOL, &option_strip_extensions }, \
+{ "url_path", OPTION_STRING, &option_url_path }, \
+{ "url_save", OPTION_STRING, &option_url_save }, \
+{ "hotlist_path", OPTION_STRING, &option_hotlist_path }, \
+{ "hotlist_save", OPTION_STRING, &option_hotlist_save }, \
+{ "recent_path", OPTION_STRING, &option_recent_path }, \
+{ "recent_save", OPTION_STRING, &option_recent_save }, \
+{ "theme_path", OPTION_STRING, &option_theme_path }, \
+{ "theme_save", OPTION_STRING, &option_theme_save }
#endif
diff --git a/riscos/theme.c b/riscos/theme.c
index 4495316ae..82cddd064 100644
--- a/riscos/theme.c
+++ b/riscos/theme.c
@@ -174,7 +174,6 @@ struct theme_descriptor *ro_gui_theme_find(const char *leafname) {
struct theme_descriptor *ro_gui_theme_get_available(void) {
struct theme_descriptor *current;
struct theme_descriptor *test;
- char pathname[256];
/* close any descriptors we've got so far
* _except_ the current theme */
@@ -184,15 +183,11 @@ struct theme_descriptor *ro_gui_theme_get_available(void) {
if (strcmp(theme_current->name, "Aletheia") != 0) {
/* add our default 'Aletheia' theme */
- snprintf(pathname, 256, "%s.Resources", NETSURF_DIR);
- pathname[255] = '\0';
- ro_gui_theme_add_descriptor(pathname, "Aletheia");
+ ro_gui_theme_add_descriptor("NetSurf:Resources", "Aletheia");
}
/* scan our choices directory */
- snprintf(pathname, 256, "%s%s", THEME_PATH_R, THEME_LEAFNAME);
- pathname[255] = '\0';
- ro_gui_theme_get_available_in_dir(pathname);
+ ro_gui_theme_get_available_in_dir(option_theme_path);
/* sort alphabetically in a very rubbish way */
if ((theme_descriptors) && (theme_descriptors->next)) {
diff --git a/riscos/theme.h b/riscos/theme.h
index 1cf99dbc1..4c21d0296 100644
--- a/riscos/theme.h
+++ b/riscos/theme.h
@@ -14,18 +14,6 @@
#ifndef _NETSURF_RISCOS_THEME_H_
#define _NETSURF_RISCOS_THEME_H_
-
-#ifndef NCOS
-#define THEME_LEAFNAME "WWW.NetSurf.Themes"
-#define THEME_PATH_W "<Choices$Write>."
-#define THEME_PATH_R "Choices:"
-#else
-#define THEME_LEAFNAME "NetSurf.Choices.Themes"
-#define THEME_PATH_W "<User$Path>.Choices."
-#define THEME_PATH_R THEME_PATH_W
-#endif
-
-
typedef enum {
THEME_BROWSER_TOOLBAR,
THEME_HOTLIST_TOOLBAR,
diff --git a/riscos/theme_install.c b/riscos/theme_install.c
index 37ad83ff7..22b722aea 100644
--- a/riscos/theme_install.c
+++ b/riscos/theme_install.c
@@ -172,8 +172,8 @@ bool ro_gui_theme_install_apply(wimp_w w)
}
/* simply overwrite previous theme versions */
- snprintf(theme_save, sizeof theme_save, "%s%s.%s",
- THEME_PATH_W, THEME_LEAFNAME, theme_file);
+ snprintf(theme_save, sizeof theme_save, "%s.%s",
+ option_theme_save, theme_file);
theme_save[sizeof theme_save - 1] = '\0';
error = xosfile_save_stamped(theme_save, 0xffd,
@@ -187,7 +187,7 @@ bool ro_gui_theme_install_apply(wimp_w w)
free(theme_file);
return false;
}
-
+
/* apply the new theme */
ro_gui_theme_get_available();
theme_install = ro_gui_theme_find(theme_file);