summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-04-09 23:21:13 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-04-09 23:21:13 +0000
commitc09eb457df1962f5b014214874b2beffd69141a4 (patch)
treea7c30e8b57b1d8bdeb87127c8f1ba16e91bf3971 /riscos
parente5e1b982d55636b409b194cf0488ebafe9c6d519 (diff)
downloadnetsurf-c09eb457df1962f5b014214874b2beffd69141a4.tar.gz
netsurf-c09eb457df1962f5b014214874b2beffd69141a4.tar.bz2
Unify information databases
svn path=/trunk/netsurf/; revision=2519
Diffstat (limited to 'riscos')
-rw-r--r--riscos/401login.c8
-rw-r--r--riscos/global_history.c166
-rw-r--r--riscos/global_history.h2
-rw-r--r--riscos/gui.c15
-rw-r--r--riscos/hotlist.c71
-rw-r--r--riscos/menus.c7
-rw-r--r--riscos/sslcert.c7
-rw-r--r--riscos/thumbnail.c4
-rw-r--r--riscos/treeview.c65
-rw-r--r--riscos/url_complete.c274
-rw-r--r--riscos/window.c6
11 files changed, 370 insertions, 255 deletions
diff --git a/riscos/401login.c b/riscos/401login.c
index ecc99e4f7..92bfe0f1a 100644
--- a/riscos/401login.c
+++ b/riscos/401login.c
@@ -12,8 +12,8 @@
#include <string.h>
#include "oslib/wimp.h"
#include "netsurf/utils/config.h"
-#include "netsurf/content/authdb.h"
#include "netsurf/content/content.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/browser.h"
#include "netsurf/desktop/401login.h"
#include "netsurf/desktop/gui.h"
@@ -187,11 +187,7 @@ bool ro_gui_401login_apply(wimp_w w)
sprintf(auth, "%s:%s", session->uname, session->pwd);
- if (!authdb_insert(session->url, session->realm, auth)) {
- LOG(("failed"));
- free(auth);
- return false;
- }
+ urldb_set_auth_details(session->url, session->realm, auth);
free(auth);
diff --git a/riscos/global_history.c b/riscos/global_history.c
index cf1f3ab09..984df358c 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -17,7 +17,7 @@
#include <time.h>
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
-#include "netsurf/content/url_store.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/tree.h"
#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/global_history.h"
@@ -50,20 +50,19 @@ static void ro_gui_global_history_initialise_nodes(void);
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);
+static bool global_history_iterate_callback(const char *url);
-/* The history window, toolbar and plot origins
-*/
+/* The history window, toolbar and plot origins */
static wimp_w global_history_window;
struct tree *global_history_tree;
-void ro_gui_global_history_initialise(void) {
+/**
+ * Initialise global history tree
+ */
+void ro_gui_global_history_initialise(void)
+{
char s[MAXIMUM_URL_LENGTH];
FILE *fp;
- struct hostname_data *hostname;
- struct url_data *url;
- int url_count = 0;
- struct url_content **url_block;
- int i = 0;
/* create our window */
global_history_window = ro_gui_dialog_create("tree");
@@ -76,8 +75,7 @@ void ro_gui_global_history_initialise(void) {
ro_gui_wimp_event_register_mouse_click(global_history_window,
ro_gui_global_history_click);
- /* Create an empty tree
- */
+ /* Create an empty tree */
global_history_tree = calloc(sizeof(struct tree), 1);
if (!global_history_tree) {
warn_user("NoMemory", 0);
@@ -99,8 +97,7 @@ void ro_gui_global_history_initialise(void) {
ro_gui_wimp_event_register_keypress(global_history_window,
ro_gui_tree_keypress);
- /* Create our toolbar
- */
+ /* Create our toolbar */
global_history_tree->toolbar = ro_gui_theme_create_toolbar(NULL,
THEME_HISTORY_TOOLBAR);
if (global_history_tree->toolbar)
@@ -121,47 +118,29 @@ void ro_gui_global_history_initialise(void) {
fclose(fp);
}
- /* count the number of URLs to add */
- for (hostname = url_store_hostnames; hostname;
- hostname = hostname->next)
- for (url = hostname->url; url; url = url->next)
- 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(
- url_count * sizeof(struct url_content *));
- if (!url_block) {
- warn_user("NoMemory", 0);
- LOG(("Insufficient memory for malloc()"));
- return;
- }
- for (hostname = url_store_hostnames; hostname;
- hostname = hostname->next)
- 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]);
-
+ urldb_iterate_entries(global_history_iterate_callback);
global_history_init = false;
- free(url_block);
}
+/**
+ * Callback for urldb_iterate_entries
+ *
+ * \param url The URL
+ * \return true to continue iteration, false otherwise
+ */
+bool global_history_iterate_callback(const char *url)
+{
+ global_history_add(url);
+
+ return true;
+}
/**
* Initialises the base nodes
*/
-static void ro_gui_global_history_initialise_nodes(void) {
+void ro_gui_global_history_initialise_nodes(void)
+{
struct tm *full_time;
time_t t;
int weekday;
@@ -196,8 +175,12 @@ static void ro_gui_global_history_initialise_nodes(void) {
t, -weekday - 21);
}
-static void ro_gui_global_history_initialise_node(const char *title,
- time_t base, int days_back) {
+/**
+ * Create and initialise a node
+ */
+void ro_gui_global_history_initialise_node(const char *title,
+ time_t base, int days_back)
+{
struct tm *full_time;
char buffer[64];
struct node *node;
@@ -225,7 +208,8 @@ static void ro_gui_global_history_initialise_node(const char *title,
/**
* Saves the global history's recent URL data.
*/
-void ro_gui_global_history_save(void) {
+void ro_gui_global_history_save(void)
+{
FILE *fp;
int i;
@@ -249,8 +233,10 @@ void ro_gui_global_history_save(void) {
* Respond to a mouse click
*
* \param pointer the pointer state
+ * \return true to indicate click handled
*/
-bool ro_gui_global_history_click(wimp_pointer *pointer) {
+bool ro_gui_global_history_click(wimp_pointer *pointer)
+{
ro_gui_tree_click(pointer, global_history_tree);
if (pointer->buttons == wimp_CLICK_MENU)
ro_gui_menu_create(global_history_menu, pointer->pos.x,
@@ -268,23 +254,32 @@ bool ro_gui_global_history_click(wimp_pointer *pointer) {
* \param y the x co-ordinate to give help for
* \return the message code index
*/
-int ro_gui_global_history_help(int x, int y) {
+int ro_gui_global_history_help(int x, int y)
+{
return -1;
}
/**
* Adds to the global history
+ *
+ * \param url The URL to add
*/
-void global_history_add(struct url_content *data) {
+void global_history_add(const char *url)
+{
int i, j;
+ const struct url_data *data;
struct node *parent = NULL;
struct node *link;
struct node *node;
bool before = false;
int visit_date;
- assert(data);
+ assert(url);
+
+ data = urldb_get_url_data(url);
+ if (!data)
+ return;
visit_date = data->last_visit;
@@ -316,28 +311,27 @@ void global_history_add(struct url_content *data) {
if (!parent)
return;
- /* find any previous occurance */
- if (!global_history_init) {
- node = ro_gui_global_history_find(data->url);
- if (node) {
- /* \todo: calculate old/new positions and redraw
- * only the relevant portion */
+ /* find any previous occurance */
+ if (!global_history_init) {
+ node = ro_gui_global_history_find(url);
+ if (node) {
+ /* \todo: calculate old/new positions and redraw
+ * only the relevant portion */
tree_redraw_area(global_history_tree,
0, 0, 16384, 16384);
- tree_update_URL_node(node, data);
- tree_delink_node(node);
- tree_link_node(parent, node, false);
+ tree_update_URL_node(node, url, data);
+ tree_delink_node(node);
+ tree_link_node(parent, node, false);
tree_handle_node_changed(global_history_tree,
node, false, true);
/* ro_gui_tree_scroll_visible(hotlist_tree,
&node->data);
-*/ return;
- }
+*/ return;
+ }
}
- /* Add the node at the bottom
- */
- node = tree_create_URL_node_shared(parent, data);
+ /* Add the node at the bottom */
+ node = tree_create_URL_node_shared(parent, url, data);
if ((!global_history_init) && (node)) {
tree_redraw_area(global_history_tree,
node->box.x - NODE_INSTEP,
@@ -347,8 +341,14 @@ void global_history_add(struct url_content *data) {
}
}
-
-struct node *ro_gui_global_history_find(const char *url) {
+/**
+ * Find an entry in the global history
+ *
+ * \param url The URL to find
+ * \return Pointer to node, or NULL if not found
+ */
+struct node *ro_gui_global_history_find(const char *url)
+{
int i;
struct node *node;
struct node_element *element;
@@ -359,7 +359,7 @@ struct node *ro_gui_global_history_find(const char *url) {
node; node = node->next) {
element = tree_find_element(node,
TREE_ELEMENT_URL);
- if ((element) && (url == element->text))
+ if ((element) && !strcmp(url, element->text))
return node;
}
}
@@ -369,38 +369,35 @@ struct node *ro_gui_global_history_find(const char *url) {
/**
- * Adds a URL to the recently used list
+ * Adds an URL to the recently used list
*
- * \param url the URL to add
+ * \param url the URL to add (copied)
*/
-void global_history_add_recent(const char *url) {
- struct url_content *data;
+void global_history_add_recent(const char *url)
+{
int i;
int j = -1;
char *current;
- /* by using the url_store, we get a central char* of the string that
- * isn't going anywhere unless we tell it to */
- data = url_store_find(url);
- if (!data)
- return;
-
/* try to find a string already there */
for (i = 0; i < global_history_recent_count; i++)
- if (global_history_recent_url[i] == data->url)
+ if (global_history_recent_url[i] &&
+ !strcmp(global_history_recent_url[i], url))
j = i;
/* already at head of list */
if (j == 0)
return;
- /* add to head of list */
if (j < 0) {
+ /* add to head of list */
+ free(global_history_recent_url[
+ GLOBAL_HISTORY_RECENT_URLS - 1]);
memmove(&global_history_recent_url[1],
&global_history_recent_url[0],
(GLOBAL_HISTORY_RECENT_URLS - 1) *
sizeof(char *));
- global_history_recent_url[0] = data->url;
+ global_history_recent_url[0] = strdup(url);
global_history_recent_count++;
if (global_history_recent_count > GLOBAL_HISTORY_RECENT_URLS)
global_history_recent_count =
@@ -424,7 +421,8 @@ void global_history_add_recent(const char *url) {
* \param count set to the current number of entries in the URL array on exit
* \return the current URL array
*/
-char **global_history_get_recent(int *count) {
+char **global_history_get_recent(int *count)
+{
*count = global_history_recent_count;
return global_history_recent_url;
}
diff --git a/riscos/global_history.h b/riscos/global_history.h
index e9576ecd9..5aab7b2b4 100644
--- a/riscos/global_history.h
+++ b/riscos/global_history.h
@@ -12,8 +12,6 @@
#ifndef _NETSURF_RISCOS_GLOBALHISTORY_H_
#define _NETSURF_RISCOS_GLOBALHISTORY_H_
-#include "netsurf/content/url_store.h"
-
#define GLOBAL_HISTORY_RECENT_URLS 16
void ro_gui_global_history_initialise(void);
diff --git a/riscos/gui.c b/riscos/gui.c
index b5b7564dd..26cadd79f 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -39,7 +39,7 @@
#include "rufl.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
-#include "netsurf/content/url_store.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/desktop/netsurf.h"
#include "netsurf/desktop/options.h"
@@ -366,7 +366,7 @@ void gui_init(int argc, char** argv)
ro_gui_choose_language();
bitmap_initialise_memory();
- url_store_load(option_url_path);
+ urldb_load(option_url_path);
nsdir_temp = getenv("NetSurf$Dir");
if (!nsdir_temp)
@@ -717,7 +717,7 @@ void gui_init2(int argc, char** argv)
void gui_quit(void)
{
bitmap_quit();
- url_store_save(option_url_save);
+ urldb_save(option_url_save);
ro_gui_window_quit();
ro_gui_global_history_save();
ro_gui_hotlist_save();
@@ -1467,7 +1467,7 @@ void ro_msg_dataload(wimp_message *message)
os_error *error;
int x, y;
bool before;
- struct url_content *data;
+ const struct url_data *data;
g = ro_gui_window_lookup(message->data.data_xfer.w);
if (g) {
@@ -1525,14 +1525,17 @@ void ro_msg_dataload(wimp_message *message)
browser_window_go(g->bw, url, 0);
} else if ((hotlist_tree) && ((wimp_w)hotlist_tree->handle ==
message->data.data_xfer.w)) {
- data = url_store_find(url);
+ data = urldb_get_url_data(url);
+ if (!data)
+ urldb_add_url(url);
+ data = urldb_get_url_data(url);
if (data) {
ro_gui_tree_get_tree_coordinates(hotlist_tree,
message->data.data_xfer.pos.x,
message->data.data_xfer.pos.y,
&x, &y);
link = tree_get_link_details(hotlist_tree, x, y, &before);
- node = tree_create_URL_node(NULL, data, title);
+ node = tree_create_URL_node(NULL, url, data, title);
tree_link_node(link, node, before);
tree_handle_node_changed(hotlist_tree, node, false, true);
tree_redraw_area(hotlist_tree, node->box.x - NODE_INSTEP, 0,
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 914b095a2..fa67098c1 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -17,6 +17,7 @@
#include "oslib/osfile.h"
#include "oslib/wimp.h"
#include "netsurf/content/content.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/tree.h"
#include "netsurf/riscos/dialog.h"
#include "netsurf/riscos/menus.h"
@@ -48,10 +49,24 @@ struct tree *hotlist_tree;
struct node *dialog_folder_node;
struct node *dialog_entry_node;
+static const struct {
+ const char *url;
+ const char *msg_key;
+} default_entries[] = {
+ { "http://netsurf.sourceforge.net/", "HotlistHomepage" },
+ { "http://netsurf.sourceforge.net/builds/", "HotlistTestBuild" },
+ { "http://netsurf.sourceforge.net/docs", "HotlistDocumentation" },
+ { "http://sourceforge.net/tracker/?atid=464312&group_id=51719",
+ "HotlistBugTracker" },
+ { "http://sourceforge.net/tracker/?atid=464315&group_id=51719",
+ "HotlistFeatureRequest" }
+};
+#define ENTRIES_COUNT (sizeof(default_entries) / sizeof(default_entries[0]))
+
void ro_gui_hotlist_initialise(void) {
FILE *fp;
struct node *node;
- struct url_content *data;
+ const struct url_data *data;
/* create our window */
hotlist_window = ro_gui_dialog_create("tree");
@@ -68,6 +83,8 @@ void ro_gui_hotlist_initialise(void) {
*/
fp = fopen(option_hotlist_path, "r");
if (!fp) {
+ int i;
+
hotlist_tree = calloc(sizeof(struct tree), 1);
if (!hotlist_tree) {
warn_user("NoMemory", 0);
@@ -83,32 +100,18 @@ void ro_gui_hotlist_initialise(void) {
node = tree_create_folder_node(hotlist_tree->root, "NetSurf");
if (!node)
node = hotlist_tree->root;
- data = url_store_find("http://netsurf.sourceforge.net/");
- if (data) {
- tree_create_URL_node(node, data,
- messages_get("HotlistHomepage"));
- }
- data = url_store_find("http://netsurf.sourceforge.net/builds/");
- if (data) {
- tree_create_URL_node(node, data,
- messages_get("HotlistTestBuild"));
- }
- data = url_store_find("http://netsurf.sourceforge.net/docs");
- if (data) {
- tree_create_URL_node(node, data,
- messages_get("HotlistDocumentation"));
- }
- data = url_store_find("http://sourceforge.net/tracker/"
- "?atid=464312&group_id=51719");
- if (data) {
- tree_create_URL_node(node, data,
- messages_get("HotlistBugTracker"));
- }
- data = url_store_find("http://sourceforge.net/tracker/"
- "?atid=464315&group_id=51719");
- if (data) {
- tree_create_URL_node(node, data,
- messages_get("HotlistFeatureRequest"));
+
+ for (i = 0; i != ENTRIES_COUNT; i++) {
+ data = urldb_get_url_data(default_entries[i].url);
+ if (!data)
+ urldb_add_url(default_entries[i].url);
+
+ data = urldb_get_url_data(default_entries[i].url);
+ if (data) {
+ tree_create_URL_node(node,
+ default_entries[i].url, data,
+ messages_get(default_entries[i].msg_key));
+ }
}
tree_initialise(hotlist_tree);
} else {
@@ -196,7 +199,7 @@ void ro_gui_hotlist_visited(struct content *content, struct tree *tree,
element = tree_find_element(node, TREE_ELEMENT_URL);
if ((element) && (!strcmp(element->text,
content->url))) {
- tree_update_URL_node(node, NULL);
+ tree_update_URL_node(node, content->url, NULL);
tree_handle_node_changed(tree, node, true,
false);
}
@@ -270,7 +273,7 @@ bool ro_gui_hotlist_dialog_apply(wimp_w w) {
char *icon;
char *url = NULL;
url_func_result res = URL_FUNC_OK;
- struct url_content *data;
+ const struct url_data *data;
/* get our data */
if (w == dialog_entry) {
@@ -305,16 +308,20 @@ bool ro_gui_hotlist_dialog_apply(wimp_w w) {
/* update/insert our data */
if (!node) {
if (url) {
- data = url_store_find(url);
+ data = urldb_get_url_data(url);
+ if (!data)
+ urldb_add_url(url);
+
+ data = urldb_get_url_data(url);
if (!data) {
free(url);
free(title);
return false;
}
if (!data->title)
- data->title = strdup(title);
+ urldb_set_url_title(url, title);
node = dialog_entry_node = tree_create_URL_node(
- hotlist_tree->root, data, title);
+ hotlist_tree->root, url, data, title);
} else {
node = dialog_folder_node = tree_create_folder_node(
diff --git a/riscos/menus.c b/riscos/menus.c
index 12f6221ad..f44f88a27 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -20,6 +20,7 @@
#include "oslib/osgbpb.h"
#include "oslib/territory.h"
#include "oslib/wimp.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/desktop/history_core.h"
#include "netsurf/render/box.h"
@@ -1368,7 +1369,7 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
struct node *node;
os_error *error;
char url[80];
- struct url_content *data;
+ const struct url_data *data;
ro_gui_menu_get_window_details(owner, &g, &bw, &c, &t, &tree);
@@ -1408,9 +1409,9 @@ bool ro_gui_menu_handle_action(wimp_w owner, menu_action action,
case HOTLIST_ADD_URL:
if ((!hotlist_tree) || (!c) || (!c->url))
return false;
- data = url_store_find(c->url);
+ data = urldb_get_url_data(c->url);
if (data) {
- node = tree_create_URL_node(hotlist_tree->root, data, NULL);
+ node = tree_create_URL_node(hotlist_tree->root, c->url, data, NULL);
if (node) {
tree_redraw_area(hotlist_tree,
node->box.x - NODE_INSTEP, 0,
diff --git a/riscos/sslcert.c b/riscos/sslcert.c
index 74a9ffdcd..678b78a0e 100644
--- a/riscos/sslcert.c
+++ b/riscos/sslcert.c
@@ -18,9 +18,9 @@
#include <stdio.h>
#include <string.h>
#include "oslib/wimp.h"
-#include "netsurf/content/certdb.h"
#include "netsurf/content/content.h"
#include "netsurf/content/fetch.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/browser.h"
#include "netsurf/desktop/gui.h"
#include "netsurf/riscos/dialog.h"
@@ -169,10 +169,7 @@ bool ro_gui_cert_apply(wimp_w w)
assert(session);
- if (!certdb_insert(session->url)) {
- LOG(("certdb_insert failed"));
- return false;
- }
+ urldb_set_cert_permissions(session->url, true);
browser_window_go(session->bw, session->url, 0);
diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c
index 2cb357ac5..e242864c2 100644
--- a/riscos/thumbnail.c
+++ b/riscos/thumbnail.c
@@ -21,7 +21,7 @@
#include "oslib/osfile.h"
#include "oslib/osspriteop.h"
#include "netsurf/content/content.h"
-#include "netsurf/content/url_store.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/plotters.h"
#include "netsurf/image/bitmap.h"
#include "netsurf/render/font.h"
@@ -138,7 +138,7 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
/* register the thumbnail with the URL */
if (url)
- url_store_add_thumbnail(url, bitmap);
+ urldb_set_thumbnail(url, bitmap);
bitmap_modified(bitmap);
return true;
}
diff --git a/riscos/treeview.c b/riscos/treeview.c
index e1f6f536a..d91771907 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -20,7 +20,7 @@
#include "oslib/osbyte.h"
#include "oslib/osspriteop.h"
#include "oslib/wimp.h"
-#include "netsurf/content/url_store.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/desktop/browser.h"
#include "netsurf/desktop/tree.h"
#include "netsurf/riscos/bitmap.h"
@@ -204,14 +204,14 @@ void tree_draw_node_element(struct tree *tree, struct node_element *element) {
int temp;
int toolbar_height = 0;
struct node_element *url_element;
- struct bitmap *bitmap = NULL;
+ const struct bitmap *bitmap = NULL;
struct node_update *update;
char *frame;
assert(tree);
assert(element);
assert(element->parent);
-
+
if (tree->toolbar)
toolbar_height = ro_gui_theme_toolbar_height(tree->toolbar);
@@ -294,11 +294,11 @@ void tree_draw_node_element(struct tree *tree, struct node_element *element) {
case NODE_ELEMENT_THUMBNAIL:
url_element = tree_find_element(element->parent, TREE_ELEMENT_URL);
if (url_element)
- bitmap = url_store_get_thumbnail(url_element->text);
+ bitmap = urldb_get_thumbnail(url_element->text);
if (bitmap) {
- frame = bitmap_get_buffer(bitmap);
- if (!frame)
- url_store_add_thumbnail(url_element->text, NULL);
+ frame = bitmap_get_buffer(bitmap);
+ if (!frame)
+ urldb_set_thumbnail(url_element->text, NULL);
if ((!frame) || (element->box.width == 0)) {
update = calloc(sizeof(struct node_update), 1);
if (!update)
@@ -348,7 +348,7 @@ void tree_draw_node_element(struct tree *tree, struct node_element *element) {
void tree_handle_node_changed_callback(void *p) {
struct node_update *update = p;
-
+
tree_handle_node_changed(update->tree, update->node, true, false);
free(update);
}
@@ -420,7 +420,7 @@ void tree_recalculate_node_element(struct node_element *element) {
int sprite_width;
int sprite_height;
osspriteop_flags flags;
- struct bitmap *bitmap = NULL;
+ const struct bitmap *bitmap = NULL;
struct node_element *url_element;
assert(element);
@@ -467,7 +467,7 @@ void tree_recalculate_node_element(struct node_element *element) {
case NODE_ELEMENT_THUMBNAIL:
url_element = tree_find_element(element->parent, TREE_ELEMENT_URL);
if (url_element)
- bitmap = url_store_get_thumbnail(url_element->text);
+ bitmap = urldb_get_thumbnail(url_element->text);
if (bitmap) {
/* if ((bitmap->width == 0) && (bitmap->height == 0))
frame = bitmap_get_buffer(bitmap);
@@ -523,32 +523,37 @@ void tree_set_node_sprite_folder(struct node *node) {
* The internal node dimensions are not updated.
*
* \param node the node to update
+ * \param url the URL
* \param data the data the node is linked to, or NULL for unlinked data
*/
-void tree_update_URL_node(struct node *node, struct url_content *data) {
+void tree_update_URL_node(struct node *node,
+ const char *url, const struct url_data *data) {
struct node_element *element;
char buffer[256];
-
+
assert(node);
-
+
element = tree_find_element(node, TREE_ELEMENT_URL);
if (!element)
return;
if (data) {
- /* node is linked, update */
- assert(!node->editable);
- if (data->title)
- node->data.text = data->title;
- else
- node->data.text = data->url;
+ /* node is linked, update */
+ assert(!node->editable);
+ if (!data->title)
+ urldb_set_url_title(url, url);
+
+ if (!data->title)
+ return;
+
+ node->data.text = data->title;
} else {
- /* node is not link, find data */
- assert(node->editable);
- data = url_store_find(element->text);
+ /* node is not linked, find data */
+ assert(node->editable);
+ data = urldb_get_url_data(element->text);
if (!data)
return;
}
-
+
if (element) {
sprintf(buffer, "small_%.3x", ro_content_filetype_from_type(data->type));
if (ro_gui_wimp_sprite_exists(buffer))
@@ -615,7 +620,7 @@ void ro_gui_tree_redraw(wimp_draw *redraw) {
struct tree *tree;
osbool more;
int clip_x0, clip_x1, clip_y0, clip_y1, origin_x, origin_y;
-
+
tree = (struct tree *)ro_gui_wimp_event_get_user_data(redraw->w);
assert(tree);
@@ -785,7 +790,7 @@ bool ro_gui_tree_click(wimp_pointer *pointer, struct tree *tree) {
element = &last->data;
if (last->expanded)
for (; element->next; element = element->next);
- ro_gui_tree_scroll_visible(tree, element);
+ ro_gui_tree_scroll_visible(tree, element);
ro_gui_tree_scroll_visible(tree, &node->data);
return true;
}
@@ -926,7 +931,7 @@ bool ro_gui_tree_toolbar_click(wimp_pointer* pointer) {
struct tree *tree =
(struct tree *)ro_gui_wimp_event_get_user_data(toolbar->parent_handle);
assert(tree);
-
+
ro_gui_tree_stop_edit(tree);
if (pointer->buttons == wimp_CLICK_MENU) {
@@ -937,7 +942,7 @@ bool ro_gui_tree_toolbar_click(wimp_pointer* pointer) {
if (tree->toolbar->editor) {
ro_gui_theme_toolbar_editor_click(tree->toolbar, pointer);
- return true;
+ return true;
}
switch (pointer->i) {
@@ -1156,9 +1161,9 @@ void ro_gui_tree_open(wimp_open *open) {
int width;
int height;
int toolbar_height = 0;
-
+
tree = (struct tree *)ro_gui_wimp_event_get_user_data(open->w);
-
+
if (!tree)
return;
if (tree->toolbar)
@@ -1264,7 +1269,7 @@ void ro_gui_tree_selection_drag_end(wimp_dragged *drag) {
os_error *error;
int x0, y0, x1, y1;
int toolbar_height = 0;
-
+
if (ro_gui_tree_current_drag_tree->toolbar)
toolbar_height = ro_gui_theme_toolbar_height(
ro_gui_tree_current_drag_tree->toolbar);
diff --git a/riscos/url_complete.c b/riscos/url_complete.c
index 88b2ad8e5..c31e0150d 100644
--- a/riscos/url_complete.c
+++ b/riscos/url_complete.c
@@ -15,7 +15,7 @@
#include <stdlib.h>
#include <string.h>
#include "oslib/wimp.h"
-#include "netsurf/content/url_store.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/utils/log.h"
#include "netsurf/riscos/global_history.h"
#include "netsurf/riscos/gui.h"
@@ -27,7 +27,7 @@
#define MAXIMUM_VISIBLE_LINES 7
-static struct url_content **url_complete_matches = NULL;
+static char **url_complete_matches = NULL;
static int url_complete_matches_allocated = 0;
static int url_complete_matches_available = 0;
static char *url_complete_matched_string = NULL;
@@ -36,8 +36,9 @@ static int url_complete_keypress_selection = -1;
static wimp_w url_complete_parent = 0;
static bool url_complete_matches_reset = false;
static char *url_complete_original_url = NULL;
+static bool url_complete_memory_exhausted = false;
-static struct url_content *url_complete_redraw[MAXIMUM_VISIBLE_LINES];
+static char *url_complete_redraw[MAXIMUM_VISIBLE_LINES];
static char url_complete_icon_null[] = "\0";
static char url_complete_icon_sprite[12];
static wimp_icon url_complete_icon;
@@ -45,21 +46,26 @@ static wimp_icon url_complete_sprite;
static int mouse_x;
static int mouse_y;
+static bool url_complete_callback(const char *url);
+
/**
* Should be called when the caret is placed into a URL completion icon.
*
* \param g the gui_window to initialise URL completion for
*/
-void ro_gui_url_complete_start(struct gui_window *g) {
- char *url;
-
+void ro_gui_url_complete_start(struct gui_window *g)
+{
+ char *url;
+
if ((!g->toolbar) || (!g->toolbar->display_url) ||
(g->window == url_complete_parent))
return;
ro_gui_url_complete_close(NULL, 0);
- url = ro_gui_get_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL);
- url_complete_matched_string = url_store_match_string(url);
+ url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
+ ICON_TOOLBAR_URL);
+
+ url_complete_matched_string = strdup(url);
if (url_complete_matched_string)
url_complete_parent = g->window;
}
@@ -70,14 +76,13 @@ void ro_gui_url_complete_start(struct gui_window *g) {
*
* \param g the gui_window to update
* \param key the key pressed
+ * \return true to indicate keypress handled, false otherwise
*/
-bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
+bool ro_gui_url_complete_keypress(struct gui_window *g, int key)
+{
wimp_window_state state;
- struct url_content **array_extend;
- struct url_data *reference = NULL;
char *match_url;
char *url;
- struct url_content *output;
int i, lines;
int old_selection;
bool ignore_changes = false;
@@ -86,7 +91,8 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
bool currently_open;
/* we must have a toolbar/url bar */
- if ((!g->toolbar) || (!g->toolbar->display_url) || (!option_url_suggestion)) {
+ if ((!g->toolbar) || (!g->toolbar->display_url) ||
+ (!option_url_suggestion)) {
ro_gui_url_complete_close(NULL, 0);
return false;
}
@@ -107,12 +113,13 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
url_complete_matched_string = NULL;
}
}
-
+
/* get the text to match */
url_complete_parent = g->window;
- url = ro_gui_get_icon_string(g->toolbar->toolbar_handle, ICON_TOOLBAR_URL);
- match_url = url_store_match_string(url);
+ url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
+ ICON_TOOLBAR_URL);
+ match_url = strdup(url);
if (!match_url) {
ro_gui_url_complete_close(NULL, 0);
return false;
@@ -121,7 +128,8 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
/* check if we should ignore text changes */
if ((url_complete_keypress_selection >= 0) && (url_complete_matches))
ignore_changes = !strcmp(url,
- url_complete_matches[url_complete_keypress_selection]->url);
+ url_complete_matches[
+ url_complete_keypress_selection]);
/* if the text to match has changed then update it */
if (!ignore_changes && ((!url_complete_matched_string) ||
@@ -133,11 +141,13 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
lines = url_complete_matches_available;
if (url_complete_matches)
for (i = 0; i < MAXIMUM_VISIBLE_LINES; i++)
- url_complete_redraw[i] = url_complete_matches[i];
+ url_complete_redraw[i] =
+ url_complete_matches[i];
/* our selection gets wiped */
error = xwimp_force_redraw(dialog_url_complete,
- 0, -(url_complete_matches_selection + 1) * 44,
+ 0,
+ -(url_complete_matches_selection + 1) * 44,
65536, -url_complete_matches_selection * 44);
if (error) {
LOG(("xwimp_force_redraw: 0x%x: %s",
@@ -150,7 +160,14 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
free(url_complete_matched_string);
url_complete_matched_string = match_url;
url_complete_original_url = NULL;
- url_complete_matches_available = 0;
+ if (url_complete_matches) {
+ for (; url_complete_matches_available > 0;
+ url_complete_matches_available--)
+ free(url_complete_matches[
+ url_complete_matches_available - 1]);
+ } else {
+ url_complete_matches_available = 0;
+ }
url_complete_matches_selection = -1;
url_complete_keypress_selection = -1;
@@ -164,25 +181,12 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
url_complete_matches_allocated = 64;
}
- /* get all our matches */
- while ((output = url_store_match(match_url, &reference))) {
- url_complete_matches_available++;
- if (url_complete_matches_available >
- url_complete_matches_allocated) {
-
- array_extend = (struct url_content **)realloc(
- url_complete_matches,
- (url_complete_matches_allocated + 64) *
- sizeof(struct url_content *));
- if (!array_extend) {
- ro_gui_url_complete_close(NULL, 0);
- return false;
- }
- url_complete_matches = array_extend;
- url_complete_matches_allocated += 64;
- }
- url_complete_matches[url_complete_matches_available - 1] =
- output;
+ /* find matches */
+ url_complete_memory_exhausted = false;
+ urldb_iterate_partial(match_url, url_complete_callback);
+ if (url_complete_memory_exhausted) {
+ ro_gui_url_complete_close(NULL, 0);
+ return false;
}
/* update the window */
@@ -203,17 +207,19 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
if (lines > url_complete_matches_available)
lines = url_complete_matches_available;
for (i = 0; i < lines; i++) {
- if (url_complete_redraw[i] != url_complete_matches[i]) {
+ if (url_complete_redraw[i] !=
+ url_complete_matches[i]) {
error = xwimp_force_redraw(dialog_url_complete,
0, -(i + 1) * 44, 65536, -i * 44);
if (error) {
LOG(("xwimp_force_redraw: 0x%x: %s",
- error->errnum, error->errmess));
- warn_user("WimpError", error->errmess);
+ error->errnum,
+ error->errmess));
+ warn_user("WimpError",
+ error->errmess);
}
}
}
-
} else {
free(match_url);
}
@@ -221,7 +227,9 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
/* handle keypresses */
if (!currently_open)
return false;
+
old_selection = url_complete_matches_selection;
+
switch (key) {
case wimp_KEY_UP:
url_complete_matches_selection--;
@@ -230,10 +238,12 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
url_complete_matches_selection++;
break;
case wimp_KEY_PAGE_UP:
- url_complete_matches_selection -= MAXIMUM_VISIBLE_LINES;
+ url_complete_matches_selection -=
+ MAXIMUM_VISIBLE_LINES;
break;
case wimp_KEY_PAGE_DOWN:
- url_complete_matches_selection += MAXIMUM_VISIBLE_LINES;
+ url_complete_matches_selection +=
+ MAXIMUM_VISIBLE_LINES;
break;
case wimp_KEY_CONTROL | wimp_KEY_UP:
url_complete_matches_selection = 0;
@@ -242,8 +252,11 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
url_complete_matches_selection = 65536;
break;
}
- if (url_complete_matches_selection > url_complete_matches_available - 1)
- url_complete_matches_selection = url_complete_matches_available - 1;
+
+ if (url_complete_matches_selection >
+ url_complete_matches_available - 1)
+ url_complete_matches_selection =
+ url_complete_matches_available - 1;
else if (url_complete_matches_selection < -1)
url_complete_matches_selection = -1;
@@ -251,12 +264,14 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
return false;
error = xwimp_force_redraw(dialog_url_complete,
- 0, -(old_selection + 1) * 44, 65536, -old_selection * 44);
+ 0, -(old_selection + 1) * 44,
+ 65536, -old_selection * 44);
if (error) {
LOG(("xwimp_force_redraw: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
+
error = xwimp_force_redraw(dialog_url_complete,
0, -(url_complete_matches_selection + 1) * 44,
65536, -url_complete_matches_selection * 44);
@@ -265,6 +280,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
+
if (old_selection == -1) {
free(url_complete_original_url);
url_complete_original_url = malloc(strlen(url) + 1);
@@ -272,6 +288,7 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
return false;
strcpy(url_complete_original_url, url);
}
+
if (url_complete_matches_selection == -1) {
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL,
@@ -279,7 +296,8 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
} else {
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL,
- url_complete_matches[url_complete_matches_selection]->url);
+ url_complete_matches[
+ url_complete_matches_selection]);
}
url_complete_keypress_selection = url_complete_matches_selection;
@@ -292,11 +310,15 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
warn_user("WimpError", error->errmess);
return true;
}
+
if (state.yscroll < -(url_complete_matches_selection * 44))
state.yscroll = -(url_complete_matches_selection * 44);
height = state.visible.y1 - state.visible.y0;
- if (state.yscroll - height > -((url_complete_matches_selection + 1) * 44))
- state.yscroll = -((url_complete_matches_selection + 1) * 44) + height;
+ if (state.yscroll - height >
+ -((url_complete_matches_selection + 1) * 44))
+ state.yscroll =
+ -((url_complete_matches_selection + 1) * 44) + height;
+
error = xwimp_open_window((wimp_open *)(&state));
if (error) {
LOG(("xwimp_open_window: 0x%x: %s",
@@ -308,6 +330,43 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
return true;
}
+/**
+ * Callback function for urldb_iterate_partial
+ *
+ * \param url URL which matches
+ * \return true to continue iteration, false otherwise
+ */
+bool url_complete_callback(const char *url)
+{
+ char **array_extend;
+ char *temp;
+
+ url_complete_matches_available++;
+
+ if (url_complete_matches_available >
+ url_complete_matches_allocated) {
+
+ array_extend = (char **)realloc(url_complete_matches,
+ (url_complete_matches_allocated + 64) *
+ sizeof(struct url_content *));
+ if (!array_extend) {
+ url_complete_memory_exhausted = true;
+ return false;
+ }
+ url_complete_matches = array_extend;
+ url_complete_matches_allocated += 64;
+ }
+
+ temp = strdup(url);
+ if (!temp) {
+ url_complete_memory_exhausted = true;
+ return false;
+ }
+
+ url_complete_matches[url_complete_matches_available - 1] = temp;
+
+ return true;
+}
/**
* Move and resize the url completion window to match the toolbar.
@@ -315,7 +374,8 @@ bool ro_gui_url_complete_keypress(struct gui_window *g, int key) {
* \param g the gui_window to update
* \param open the wimp_open request (updated on exit)
*/
-void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
+void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open)
+{
os_box extent = { 0, 0, 0, 0 };
wimp_icon_state url_state;
wimp_window_state toolbar_state;
@@ -327,8 +387,9 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
/* only react to our window */
if (open->w != url_complete_parent)
return;
- /* if there is no toolbar, or there is no URL bar shown, or there are
- * no URL matches, close it */
+
+ /* if there is no toolbar, or there is no URL bar shown,
+ * or there are no URL matches, close it */
if ((!g->toolbar) || (!g->toolbar->display_url) ||
(!url_complete_matches) ||
(url_complete_matches_available == 0)) {
@@ -345,6 +406,7 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
warn_user("WimpError", error->errmess);
return;
}
+
if (url_complete_matches_reset)
state.yscroll = 0;
@@ -357,6 +419,7 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
warn_user("WimpError", error->errmess);
return;
}
+
url_state.w = g->toolbar->toolbar_handle;
url_state.i = ICON_TOOLBAR_SURROUND;
error = xwimp_get_icon_state(&url_state);
@@ -366,6 +429,7 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
warn_user("WimpError", error->errmess);
return;
}
+
lines = url_complete_matches_available;
extent.y0 = -(lines * 44);
extent.x1 = 65536;
@@ -376,6 +440,7 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
warn_user("WimpError", error->errmess);
return;
}
+
state.next = open->next;
state.flags &= ~wimp_WINDOW_VSCROLL;
state.flags &= ~(4095 << 16); /* clear bits 16-27 */
@@ -385,7 +450,8 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
state.flags |= wimp_WINDOW_VSCROLL;
}
state.visible.x0 = open->visible.x0 + 2 + url_state.icon.extent.x0;
- state.visible.x1 = open->visible.x0 - 2 + url_state.icon.extent.x1 - scroll_v;
+ state.visible.x1 = open->visible.x0 - 2 +
+ url_state.icon.extent.x1 - scroll_v;
state.visible.y1 = open->visible.y1 - url_state.icon.extent.y1 + 2;
state.visible.y0 = state.visible.y1 - (lines * 44);
if (state.visible.x1 + scroll_v > toolbar_state.visible.x1)
@@ -398,7 +464,8 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
warn_user("WimpError", error->errmess);
}
} else {
- error = xwimp_open_window_nested_with_flags(&state, (wimp_w)-1, 0);
+ error = xwimp_open_window_nested_with_flags(&state,
+ (wimp_w)-1, 0);
if (error) {
LOG(("xwimp_open_window: 0x%x: %s",
error->errnum, error->errmess));
@@ -417,16 +484,24 @@ void ro_gui_url_complete_resize(struct gui_window *g, wimp_open *open) {
* \param i the icon the user clicked on to prompt the close
* \return whether the window was closed
*/
-bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i) {
+bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i)
+{
os_error *error;
bool currently_open;
- if ((g && (i == ICON_TOOLBAR_URL) && (g->window == url_complete_parent)))
+ if ((g && (i == ICON_TOOLBAR_URL) &&
+ (g->window == url_complete_parent)))
return false;
currently_open = ((url_complete_parent) &&
(url_complete_matches_available > 0));
+ if (url_complete_matches) {
+ for (; url_complete_matches_available > 0;
+ url_complete_matches_available--)
+ free(url_complete_matches[
+ url_complete_matches_available - 1]);
+ }
free(url_complete_matches);
free(url_complete_matched_string);
free(url_complete_original_url);
@@ -445,6 +520,7 @@ bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i) {
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
+
return currently_open;
}
@@ -453,13 +529,15 @@ bool ro_gui_url_complete_close(struct gui_window *g, wimp_i i) {
* Redraws a section of the URL completion window
*
* \param redraw the area to redraw
- * \param tree the tree to redraw
*/
-void ro_gui_url_complete_redraw(wimp_draw *redraw) {
+void ro_gui_url_complete_redraw(wimp_draw *redraw)
+{
osbool more;
os_error *error;
int clip_y0, clip_y1, origin_y;
int first_line, last_line, line;
+ const struct url_data *data;
+ int type;
/* initialise our icon */
url_complete_icon.flags = wimp_ICON_INDIRECTED | wimp_ICON_VCENTRED |
@@ -468,23 +546,26 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) {
(wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT);
url_complete_icon.extent.x0 = 50;
url_complete_icon.extent.x1 = 16384;
- url_complete_icon.data.indirected_text.validation = url_complete_icon_null;
+ url_complete_icon.data.indirected_text.validation =
+ url_complete_icon_null;
url_complete_sprite.flags = wimp_ICON_TEXT | wimp_ICON_SPRITE |
wimp_ICON_INDIRECTED | wimp_ICON_FILLED |
wimp_ICON_HCENTRED | wimp_ICON_VCENTRED;
url_complete_sprite.extent.x0 = 0;
url_complete_sprite.extent.x1 = 50;
- url_complete_sprite.data.indirected_text.text = url_complete_icon_null;
- url_complete_sprite.data.indirected_text.validation = url_complete_icon_sprite;
+ url_complete_sprite.data.indirected_text.text =
+ url_complete_icon_null;
+ url_complete_sprite.data.indirected_text.validation =
+ url_complete_icon_sprite;
url_complete_sprite.data.indirected_text.size = 1;
/* no matches? no redraw */
if (!url_complete_matches) {
- LOG(("Attempt to redraw with no matches made"));
+ LOG(("Attempt to redraw with no matches made"));
ro_gui_user_redraw(redraw, false, NULL);
return;
}
-
+
/* redraw */
more = wimp_redraw_window(redraw);
while (more) {
@@ -497,32 +578,47 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) {
for (line = first_line; line < last_line; line++) {
if (line == url_complete_matches_selection)
- url_complete_icon.flags |= wimp_ICON_SELECTED;
+ url_complete_icon.flags |=
+ wimp_ICON_SELECTED;
else
- url_complete_icon.flags &= ~wimp_ICON_SELECTED;
+ url_complete_icon.flags &=
+ ~wimp_ICON_SELECTED;
url_complete_icon.extent.y1 = -line * 44;
url_complete_icon.extent.y0 = -(line + 1) * 44;
url_complete_icon.data.indirected_text.text =
- url_complete_matches[line]->url;
+ url_complete_matches[line];
url_complete_icon.data.indirected_text.size =
- strlen(url_complete_matches[line]->url);
+ strlen(url_complete_matches[line]);
+
error = xwimp_plot_icon(&url_complete_icon);
if (error) {
LOG(("xwimp_plot_icon: 0x%x: %s",
- error->errnum, error->errmess));
+ error->errnum,
+ error->errmess));
warn_user("WimpError", error->errmess);
}
+
+ data = urldb_get_url_data(url_complete_matches[line]);
+ if (data)
+ type = ro_content_filetype_from_type(
+ data->type);
+ else
+ type = 0;
+
sprintf(url_complete_icon_sprite, "Ssmall_%.3x",
- ro_content_filetype_from_type(
- url_complete_matches[line]->type));
- if (!ro_gui_wimp_sprite_exists(url_complete_icon_sprite + 1))
- sprintf(url_complete_icon_sprite, "Ssmall_xxx");
+ type);
+
+ if (!ro_gui_wimp_sprite_exists(
+ url_complete_icon_sprite + 1))
+ sprintf(url_complete_icon_sprite,
+ "Ssmall_xxx");
url_complete_sprite.extent.y1 = -line * 44;
url_complete_sprite.extent.y0 = -(line + 1) * 44;
error = xwimp_plot_icon(&url_complete_sprite);
if (error) {
LOG(("xwimp_plot_icon: 0x%x: %s",
- error->errnum, error->errmess));
+ error->errnum,
+ error->errmess));
warn_user("WimpError", error->errmess);
}
}
@@ -536,7 +632,8 @@ void ro_gui_url_complete_redraw(wimp_draw *redraw) {
*
* \param pointer the pointer state
*/
-void ro_gui_url_complete_mouse_at(wimp_pointer *pointer) {
+void ro_gui_url_complete_mouse_at(wimp_pointer *pointer)
+{
wimp_mouse_state current;
current = pointer->buttons;
@@ -552,7 +649,8 @@ void ro_gui_url_complete_mouse_at(wimp_pointer *pointer) {
* \param pointer the pointer state
* \return whether the click was handled
*/
-bool ro_gui_url_complete_click(wimp_pointer *pointer) {
+bool ro_gui_url_complete_click(wimp_pointer *pointer)
+{
wimp_window_state state;
os_error *error;
int selection, old_selection;
@@ -562,6 +660,7 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) {
if ((mouse_x == pointer->pos.x) && (mouse_y == pointer->pos.y) &&
(!pointer->buttons))
return false;
+
mouse_x = pointer->pos.x;
mouse_y = pointer->pos.y;
@@ -573,13 +672,15 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) {
warn_user("WimpError", error->errmess);
return false;
}
+
selection = (state.visible.y1 - pointer->pos.y - state.yscroll) / 44;
if (selection != url_complete_matches_selection) {
if (url_complete_matches_selection == -1) {
g = ro_gui_window_lookup(url_complete_parent);
if (!g)
return false;
- url = ro_gui_get_icon_string(g->toolbar->toolbar_handle,
+ url = ro_gui_get_icon_string(
+ g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL);
free(url_complete_original_url);
url_complete_original_url = malloc(strlen(url) + 1);
@@ -590,7 +691,8 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) {
old_selection = url_complete_matches_selection;
url_complete_matches_selection = selection;
error = xwimp_force_redraw(dialog_url_complete,
- 0, -(old_selection + 1) * 44, 65536, -old_selection * 44);
+ 0, -(old_selection + 1) * 44,
+ 65536, -old_selection * 44);
if (error) {
LOG(("xwimp_force_redraw: 0x%x: %s",
error->errnum, error->errmess));
@@ -607,7 +709,7 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) {
}
if (!pointer->buttons)
return true;
-
+
/* find owning window */
g = ro_gui_window_lookup(url_complete_parent);
if (!g)
@@ -617,18 +719,22 @@ bool ro_gui_url_complete_click(wimp_pointer *pointer) {
if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL,
- url_complete_matches[url_complete_matches_selection]->url);
+ url_complete_matches[
+ url_complete_matches_selection]);
browser_window_go(g->bw,
- url_complete_matches[url_complete_matches_selection]->url,
+ url_complete_matches[
+ url_complete_matches_selection],
0);
- global_history_add_recent(url_complete_matches[url_complete_matches_selection]->url);
+ global_history_add_recent(url_complete_matches[
+ url_complete_matches_selection]);
ro_gui_url_complete_close(NULL, 0);
/* Adjust just sets the text */
} else if (pointer->buttons == wimp_CLICK_ADJUST) {
ro_gui_set_icon_string(g->toolbar->toolbar_handle,
ICON_TOOLBAR_URL,
- url_complete_matches[url_complete_matches_selection]->url);
+ url_complete_matches[
+ url_complete_matches_selection]);
ro_gui_url_complete_keypress(g, 0);
}
return true;
diff --git a/riscos/window.c b/riscos/window.c
index cb66962df..cf9238bd5 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -30,7 +30,7 @@
#include "oslib/wimpspriteop.h"
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
-#include "netsurf/content/url_store.h"
+#include "netsurf/content/urldb.h"
#include "netsurf/css/css.h"
#include "netsurf/desktop/browser.h"
#include "netsurf/desktop/plotters.h"
@@ -2015,6 +2015,10 @@ bool ro_gui_window_keypress(struct gui_window *g, int key, bool toolbar)
}
return true;
+ case wimp_KEY_CONTROL + wimp_KEY_F9:
+ urldb_dump();
+ return true;
+
case wimp_KEY_CONTROL + wimp_KEY_SHIFT + wimp_KEY_F9:
talloc_report_full(0, stderr);
return true;