diff options
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-favicon-cache.c | 45 | ||||
-rw-r--r-- | embed/ephy-history.c | 52 |
2 files changed, 22 insertions, 75 deletions
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c index 0ba259132..6c443773f 100644 --- a/embed/ephy-favicon-cache.c +++ b/embed/ephy-favicon-cache.c @@ -19,7 +19,6 @@ * $Id$ */ -#include <libxml/tree.h> #include <libgnomevfs/gnome-vfs-ops.h> #include <string.h> #include <time.h> @@ -85,8 +84,8 @@ ephy_favicon_cache_get_type (void) }; ephy_favicon_cache_type = g_type_register_static (G_TYPE_OBJECT, - "EphyFaviconCache", - &our_info, 0); + "EphyFaviconCache", + &our_info, 0); } return ephy_favicon_cache_type; @@ -200,38 +199,6 @@ remove_obsolete_icons (EphyFaviconCache *eb) } static void -ephy_favicon_cache_save (EphyFaviconCache *eb) -{ - xmlDocPtr doc; - xmlNodePtr root; - GPtrArray *children; - int i; - - /* save nodes to xml */ - xmlIndentTreeOutput = TRUE; - doc = xmlNewDoc ("1.0"); - - root = xmlNewDocNode (doc, NULL, "ephy_favicons_cache", NULL); - xmlSetProp (root, "version", EPHY_FAVICON_CACHE_XML_VERSION); - xmlDocSetRootElement (doc, root); - - children = ephy_node_get_children (eb->priv->icons); - for (i = 0; i < children->len; i++) - { - EphyNode *kid; - - kid = g_ptr_array_index (children, i); - - ephy_node_save_to_xml (kid, root); - } - ephy_node_thaw (eb->priv->icons); - - ephy_file_save_xml (eb->priv->xml_file, doc); - - xmlFreeDoc (doc); -} - -static void ephy_favicon_cache_init (EphyFaviconCache *cache) { EphyNodeDb *db; @@ -321,7 +288,13 @@ ephy_favicon_cache_finalize (GObject *object) cleanup_downloads_hash (cache); remove_obsolete_icons (cache); - ephy_favicon_cache_save (cache); + + ephy_node_db_write_to_xml_safe + (cache->priv->db, cache->priv->xml_file, + EPHY_FAVICON_CACHE_XML_ROOT, + EPHY_FAVICON_CACHE_XML_VERSION, + NULL, + cache->priv->icons, 0, NULL); g_free (cache->priv->xml_file); g_free (cache->priv->directory); diff --git a/embed/ephy-history.c b/embed/ephy-history.c index 871212755..8afbead0e 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -25,6 +25,7 @@ #include "ephy-history.h" #include "ephy-file-helpers.h" #include "ephy-debug.h" +#include "ephy-node-db.h" #include "ephy-node-common.h" #include <time.h> @@ -36,7 +37,7 @@ #define EPHY_HISTORY_XML_VERSION "1.0" /* how often to save the history, in milliseconds */ -#define HISTORY_SAVE_INTERVAL (60 * 5 * 1000) +#define HISTORY_SAVE_INTERVAL (5 * 60 * 1000) /* if you change this remember to change also the user interface description */ #define HISTORY_PAGE_OBSOLETE_DAYS 10 @@ -176,12 +177,7 @@ remove_obsolete_pages (EphyHistory *eb) static void ephy_history_save (EphyHistory *eb) { - xmlDocPtr doc; - xmlNodePtr root; - GPtrArray *children; - int i; - - LOG ("Saving history") + int ret; /* only save if there are changes */ if (eb->priv->dirty == FALSE) @@ -189,44 +185,22 @@ ephy_history_save (EphyHistory *eb) return; } - /* save nodes to xml */ - xmlIndentTreeOutput = TRUE; - doc = xmlNewDoc ("1.0"); - - root = xmlNewDocNode (doc, NULL, "ephy_history", NULL); - xmlSetProp (root, "version", EPHY_HISTORY_XML_VERSION); - xmlDocSetRootElement (doc, root); - - children = ephy_node_get_children (eb->priv->hosts); - for (i = 0; i < children->len; i++) - { - EphyNode *kid; - - kid = g_ptr_array_index (children, i); - if (kid == eb->priv->pages) continue; - - ephy_node_save_to_xml (kid, root); - } - ephy_node_thaw (eb->priv->hosts); - - children = ephy_node_get_children (eb->priv->pages); - for (i = 0; i < children->len; i++) - { - EphyNode *kid; + LOG ("Saving history db") - kid = g_ptr_array_index (children, i); + ret = ephy_node_db_write_to_xml_safe + (eb->priv->db, eb->priv->xml_file, + EPHY_HISTORY_XML_ROOT, + EPHY_HISTORY_XML_VERSION, + NULL, /* comment */ + eb->priv->hosts, 0, + eb->priv->pages, 0, + NULL); - ephy_node_save_to_xml (kid, root); - } - ephy_node_thaw (eb->priv->pages); - - if (ephy_file_save_xml (eb->priv->xml_file, doc)) + if (ret >=0) { /* save was successful */ eb->priv->dirty = FALSE; } - - xmlFreeDoc(doc); } static void |