From: Christian Dywan Date: Sat, 5 Dec 2009 22:43:12 +0000 (+0100) Subject: Support RDF bookmarks, and add Epiphany to Import bookmarks X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca6174ba6c39b69d03bf1aa1802487125107d7b4;p=midori Support RDF bookmarks, and add Epiphany to Import bookmarks --- diff --git a/midori/midori-array.c b/midori/midori-array.c index e6f7d3b9..275faba4 100644 --- a/midori/midori-array.c +++ b/midori/midori-array.c @@ -183,34 +183,78 @@ katze_array_from_xmlDocPtr (KatzeArray* array, xmlDocPtr doc) { xmlNodePtr cur; - xmlChar* version; - gchar* value; KatzeItem* item; cur = xmlDocGetRootElement (doc); - version = xmlGetProp (cur, (xmlChar*)"version"); - if (xmlStrcmp (version, (xmlChar*)"1.0")) - g_warning ("XBEL version is not 1.0."); - xmlFree (version); - - value = (gchar*)xmlGetProp (cur, (xmlChar*)"title"); - katze_item_set_name (KATZE_ITEM (array), value); - g_free (value); - - value = (gchar*)xmlGetProp (cur, (xmlChar*)"desc"); - katze_item_set_text (KATZE_ITEM (array), value); - g_free (value); if ((cur = xmlDocGetRootElement (doc)) == NULL) { /* Empty document */ return FALSE; } - if (!katze_str_equal ((gchar*)cur->name, "xbel")) + if (katze_str_equal ((gchar*)cur->name, "xbel")) + { + /* XBEL 1.0 */ + gchar* value; + + value = (gchar*)xmlGetProp (cur, (xmlChar*)"version"); + if (!katze_str_equal (value, "1.0")) + g_warning ("XBEL version is not 1.0."); + g_free (value); + + value = (gchar*)xmlGetProp (cur, (xmlChar*)"title"); + katze_item_set_name (KATZE_ITEM (array), value); + g_free (value); + + value = (gchar*)xmlGetProp (cur, (xmlChar*)"desc"); + katze_item_set_text (KATZE_ITEM (array), value); + g_free (value); + } + else if (katze_str_equal ((gchar*)cur->name, "RDF")) + { + /* Minimal RSS 1.0 support, enough to read bookmarks */ + cur = cur->xmlChildrenNode; + while (cur) + { + item = NULL; + if (katze_str_equal ((gchar*)cur->name, "item")) + { + xmlNodePtr cur_item; + + item = katze_item_new (); + + cur_item = cur->xmlChildrenNode; + while (cur_item) + { + if (katze_str_equal ((gchar*)cur_item->name, "title")) + item->name = g_strstrip ((gchar*)xmlNodeGetContent (cur_item)); + else if (katze_str_equal ((gchar*)cur_item->name, "link")) + item->uri = g_strstrip ((gchar*)xmlNodeGetContent (cur_item)); + else if (katze_str_equal ((gchar*)cur_item->name, "subject")) + { + gchar* value = g_strstrip ((gchar*)xmlNodeGetContent (cur_item)); + /* FIXME: Create a folder according to the tag */ + g_free (value); + } + cur_item = cur_item->next; + } + } + else if (katze_str_equal ((gchar*)cur->name, "channel")) + /* Ignored */; + else if (!katze_str_equal ((gchar*)cur->name, "text")) + g_warning ("Unexpected attribute: %s", (gchar*)cur->name); + if (item) + katze_array_add_item (array, item); + cur = cur->next; + } + return TRUE; + } + else { /* Wrong document kind */ return FALSE; } + cur = cur->xmlChildrenNode; while (cur) { @@ -233,6 +277,8 @@ katze_array_from_xmlDocPtr (KatzeArray* array, xmlNodePtr node = cur->xmlChildrenNode; katze_item_set_text (KATZE_ITEM (array), (gchar*)node->content); } + else if (!katze_str_equal ((gchar*)cur->name, "text")) + g_warning ("Unexpected attribute: %s", (gchar*)cur->name); if (item) katze_array_add_item (array, item); cur = cur->next; diff --git a/midori/midori-browser.c b/midori/midori-browser.c index ee25e30b..0fda96ba 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -4133,6 +4133,7 @@ _action_bookmarks_import_activate (GtkAction* action, { ".kazehakase/bookmarks.xml", N_("Kazehakase"), "kazehakase-icon" }, { ".opera/bookmarks.adr", N_("Opera"), "opera" }, { ".kde/share/apps/konqueror/bookmarks.xml", N_("Konqueror"), "konqueror" }, + { ".gnome2/epiphany/bookmarks.rdf", N_("Epiphany"), "epiphany" }, }; GtkWidget* dialog;