From 32db7e04d0c3bd255b2e8aa7dbd7c2b884b35614 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Thu, 9 Dec 2004 10:30:44 +0000 Subject: [project @ 2004-12-09 10:30:43 by rjw] Re-implementation of hotlist via general tree code. Animations can be stopped once more. Purged a few xcalloc() calls. svn path=/import/netsurf/; revision=1394 --- desktop/options.c | 376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 376 insertions(+) (limited to 'desktop/options.c') diff --git a/desktop/options.c b/desktop/options.c index a777f6d12..3ad212a14 100644 --- a/desktop/options.c +++ b/desktop/options.c @@ -5,6 +5,7 @@ * Copyright 2003 Phil Mellor * Copyright 2003 John M Bell * Copyright 2004 James Bursa + * Copyright 2004 Richard Wilson */ /** \file @@ -14,11 +15,16 @@ * value is "0" or "1". */ +#include #include #include #include +#include "libxml/HTMLparser.h" +#include "libxml/HTMLtree.h" #include "netsurf/desktop/options.h" +#include "netsurf/desktop/tree.h" #include "netsurf/utils/log.h" +#include "netsurf/utils/messages.h" #include "netsurf/utils/utils.h" #ifdef riscos @@ -57,6 +63,9 @@ bool option_block_ads = false; int option_minimum_gif_delay = 10; /** Whether to send the referer HTTP header */ bool option_send_referer = true; +/** Whether to animate images */ +bool option_animate_images = true; + EXTRA_OPTION_DEFINE @@ -80,12 +89,21 @@ struct { { "block_advertisements", OPTION_BOOL, &option_block_ads }, { "minimum_gif_delay", OPTION_INTEGER, &option_minimum_gif_delay }, { "send_referer", OPTION_BOOL, &option_send_referer }, + { "animate_images", OPTION_BOOL, &option_animate_images }, \ EXTRA_OPTION_TABLE }; #define option_table_entries (sizeof option_table / sizeof option_table[0]) +static void options_load_hotlist_directory(xmlNode *ul, struct node *directory); +static void options_load_hotlist_entry(xmlNode *li, struct node *directory); +xmlNode *options_find_hotlist_element(xmlNode *node, const char *name); +bool options_save_hotlist_directory(struct node *directory, xmlNode *node); +bool options_save_hotlist_entry(struct node *entry, xmlNode *node); +bool options_save_hotlist_entry_comment(xmlNode *node, const char *name, int value); + + /** * Read options from a file. * @@ -201,3 +219,361 @@ void options_write(const char *path) fclose(fp); } + + +/** + * Loads a hotlist as a tree from a specified file. + * + * \param filename name of file to read + * \return the hotlist file represented as a tree, or NULL on failure + */ +struct tree *options_load_hotlist(const char *filename) { + xmlDoc *doc; + xmlNode *html, *body, *ul; + struct tree *tree; + + doc = htmlParseFile(filename, "iso-8859-1"); + if (!doc) { + warn_user("HotlistLoadError", messages_get("ParsingFail")); + return NULL; + } + + html = options_find_hotlist_element((xmlNode *) doc, "html"); + body = options_find_hotlist_element(html, "body"); + ul = options_find_hotlist_element(body, "ul"); + if (!ul) { + xmlFreeDoc(doc); + warn_user("HotlistLoadError", + "(......