aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-07-10 21:33:49 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-07-10 21:33:49 +0800
commitd446a326bb0243e014e3d4e8e6152b6a6f9b7e28 (patch)
treefccfd27fab44f27b2d8f24c53bac8ddcefcde398 /src/bookmarks/ephy-bookmarks.c
parent268d6be0929222404146c78a5656ee0739af262a (diff)
downloadgsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.gz
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.bz2
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.lz
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.xz
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.tar.zst
gsoc2013-epiphany-d446a326bb0243e014e3d4e8e6152b6a6f9b7e28.zip
Some minor changes in rdf format (thanks to Edd Dumbill), and use
2003-07-10 Marco Pesenti Gritti <marco@it.gnome.org> * src/bookmarks/ephy-bookmarks-export.c: (add_topics_list), (ephy_bookmarks_export_rdf): Some minor changes in rdf format (thanks to Edd Dumbill), and use namespaces in the code. * src/bookmarks/ephy-bookmarks-import.c: (bookmark_add), (ephy_bookmarks_import_xbel), (parse_rdf_subjects), (parse_rdf_item), (ephy_bookmarks_import_rdf): * src/bookmarks/ephy-bookmarks-import.h: Add an rdf importer. * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_load), (ephy_bookmarks_save), (ephy_bookmarks_init), (ephy_bookmarks_finalize): Update db to 1.0, import bookmarks from the rdf first time. WARNING Backup your bookmarks.rdf file before using this and let me know if you get any problems. (esp if you had a < 0.7.3 epiphany version).
Diffstat (limited to 'src/bookmarks/ephy-bookmarks.c')
-rw-r--r--src/bookmarks/ephy-bookmarks.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index bb6db5bd7..757b2f3b3 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -31,12 +31,13 @@
#include "ephy-node-common.h"
#include "ephy-toolbars-model.h"
#include "ephy-bookmarks-export.h"
+#include "ephy-bookmarks-import.h"
#include <string.h>
#include <bonobo/bonobo-i18n.h>
#include <libgnomevfs/gnome-vfs-utils.h>
-#define EPHY_BOOKMARKS_XML_VERSION "0.1"
+#define EPHY_BOOKMARKS_XML_VERSION "1.0"
#define BOOKMARKS_SAVE_DELAY (3 * 1000)
#define MAX_FAVORITES_NUM 10
@@ -47,6 +48,7 @@ struct EphyBookmarksPrivate
gboolean dirty;
guint save_timeout_id;
char *xml_file;
+ char *rdf_file;
EphyNodeDb *db;
EphyNode *bookmarks;
EphyNode *keywords;
@@ -313,6 +315,7 @@ ephy_bookmarks_load (EphyBookmarks *eb)
xmlDocPtr doc;
xmlNodePtr root, child;
char *tmp;
+ gboolean result = TRUE;
if (g_file_test (eb->priv->xml_file, G_FILE_TEST_EXISTS) == FALSE)
return FALSE;
@@ -323,7 +326,12 @@ ephy_bookmarks_load (EphyBookmarks *eb)
root = xmlDocGetRootElement (doc);
tmp = xmlGetProp (root, "version");
- g_assert (tmp != NULL && strcmp (tmp, EPHY_BOOKMARKS_XML_VERSION) == 0);
+ if (tmp != NULL && strcmp (tmp, EPHY_BOOKMARKS_XML_VERSION) != 0)
+ {
+ g_warning ("Old bookmarks database format detected");
+ child = NULL;
+ result = FALSE;
+ }
g_free (tmp);
for (child = root->children; child != NULL; child = child->next)
@@ -335,7 +343,7 @@ ephy_bookmarks_load (EphyBookmarks *eb)
xmlFreeDoc (doc);
- return TRUE;
+ return result;
}
static void
@@ -343,9 +351,9 @@ ephy_bookmarks_save (EphyBookmarks *eb)
{
xmlDocPtr doc;
xmlNodePtr root;
+ xmlNodePtr comment;
GPtrArray *children;
int i;
- char *rdf_file;
LOG ("Saving bookmarks")
@@ -357,6 +365,9 @@ ephy_bookmarks_save (EphyBookmarks *eb)
xmlSetProp (root, "version", EPHY_BOOKMARKS_XML_VERSION);
xmlDocSetRootElement (doc, root);
+ comment = xmlNewDocComment (doc, "Do not rely on this file, it's only for internal use. Use bookmarks.rdf instead.");
+ xmlAddChild (root, comment);
+
children = ephy_node_get_children (eb->priv->keywords);
for (i = 0; i < children->len; i++)
{
@@ -388,11 +399,7 @@ ephy_bookmarks_save (EphyBookmarks *eb)
xmlFreeDoc(doc);
/* Export bookmarks in rdf */
- rdf_file = g_build_filename (ephy_dot_dir (),
- "bookmarks.rdf",
- NULL);
- ephy_bookmarks_export_rdf (eb, rdf_file);
- g_free (rdf_file);
+ ephy_bookmarks_export_rdf (eb, eb->priv->rdf_file);
}
static gboolean
@@ -667,7 +674,10 @@ ephy_bookmarks_init (EphyBookmarks *eb)
eb->priv->dirty = FALSE;
eb->priv->save_timeout_id = 0;
eb->priv->xml_file = g_build_filename (ephy_dot_dir (),
- "bookmarks.xml",
+ "ephy-bookmarks.xml",
+ NULL);
+ eb->priv->rdf_file = g_build_filename (ephy_dot_dir (),
+ "bookmarks.rdf",
NULL);
/* Bookmarks */
@@ -739,7 +749,13 @@ ephy_bookmarks_init (EphyBookmarks *eb)
g_value_unset (&value);
ephy_node_add_child (eb->priv->keywords, eb->priv->notcategorized);
- eb->priv->init_defaults = !ephy_bookmarks_load (eb);
+ if (!ephy_bookmarks_load (eb))
+ {
+ if (!ephy_bookmarks_import_rdf (eb, eb->priv->rdf_file))
+ {
+ eb->priv->init_defaults = !ephy_bookmarks_load (eb);
+ }
+ }
ephy_bookmarks_emit_data_changed (eb);
@@ -778,6 +794,9 @@ ephy_bookmarks_finalize (GObject *object)
(gpointer *)&eb->priv->toolbars_model);
}
+ g_free (eb->priv->xml_file);
+ g_free (eb->priv->rdf_file);
+
g_free (eb->priv);
LOG ("Bookmarks finalized")