aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks-import.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-03-03 05:30:04 +0800
committerChristian Persch <chpe@src.gnome.org>2006-03-03 05:30:04 +0800
commitfdb9695a63e0d25e9adffeb485962ee62e67f310 (patch)
tree08b1288995fccfe1e25c65595c3c2ac2b7d7ebad /src/bookmarks/ephy-bookmarks-import.c
parent8dc95a5c584d8fdb99afec102702bd8801b95266 (diff)
downloadgsoc2013-epiphany-fdb9695a63e0d25e9adffeb485962ee62e67f310.tar.gz
gsoc2013-epiphany-fdb9695a63e0d25e9adffeb485962ee62e67f310.tar.zst
gsoc2013-epiphany-fdb9695a63e0d25e9adffeb485962ee62e67f310.zip
If we can't detect the mime type, fall back to checking the file
2006-03-02 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmarks-import.c: (ephy_bookmarks_import): If we can't detect the mime type, fall back to checking the file extension. Bug #331468. * src/ephy-main.c: (main): Don't pass NULL to realpath if PATH_MAX is defined. Bug #333051.
Diffstat (limited to 'src/bookmarks/ephy-bookmarks-import.c')
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 098a96d9d..651fa2fa8 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -69,44 +69,60 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
const char *filename)
{
const char *type;
+ char *basename;
gboolean success = FALSE;
if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE;
+ g_return_val_if_fail (filename != NULL, FALSE);
+
type = gnome_vfs_get_file_mime_type (filename, NULL, FALSE);
LOG ("Importing bookmarks of type %s", type ? type : "(null)");
- if (type == NULL)
- {
- g_warning ("Couldn't determine the type of the bookmarks file %s!\n", filename);
- }
- else if (strcmp (type, "application/x-mozilla-bookmarks") == 0)
+ if (type != NULL && (strcmp (type, "application/rdf+xml") == 0 ||
+ strcmp (type, "text/rdf") == 0))
{
- success = ephy_bookmarks_import_mozilla (bookmarks, filename);
+ success = ephy_bookmarks_import_rdf (bookmarks, filename);
}
- else if (strcmp (type, "application/x-xbel") == 0)
+ else if ((type != NULL && strcmp (type, "application/x-xbel") == 0) ||
+ strstr (filename, GALEON_BOOKMARKS_DIR) != NULL ||
+ strstr (filename, KDE_BOOKMARKS_DIR) != NULL)
{
success = ephy_bookmarks_import_xbel (bookmarks, filename);
}
- else if (strcmp (type, "application/rdf+xml") == 0 ||
- strcmp (type, "text/rdf") == 0)
- {
- success = ephy_bookmarks_import_rdf (bookmarks, filename);
- }
- else if (strstr (filename, MOZILLA_BOOKMARKS_DIR) != NULL ||
+ else if ((type != NULL && strcmp (type, "application/x-mozilla-bookmarks") == 0) ||
+ strstr (filename, MOZILLA_BOOKMARKS_DIR) != NULL ||
strstr (filename, FIREFOX_BOOKMARKS_DIR_0) != NULL ||
strstr (filename, FIREFOX_BOOKMARKS_DIR_1) != NULL ||
strstr (filename, FIREFOX_BOOKMARKS_DIR_2) != NULL)
{
success = ephy_bookmarks_import_mozilla (bookmarks, filename);
}
- else if (strstr (filename, GALEON_BOOKMARKS_DIR) != NULL ||
- strstr (filename, KDE_BOOKMARKS_DIR) != NULL)
+ else if (type == NULL)
{
- success = ephy_bookmarks_import_xbel (bookmarks, filename);
+ basename = g_path_get_basename (filename);
+
+ if (g_str_has_suffix (basename, ".rdf"))
+ {
+ success = ephy_bookmarks_import_rdf (bookmarks, filename);
+ }
+ else if (g_str_has_suffix (basename, ".xbel"))
+ {
+ success = ephy_bookmarks_import_xbel (bookmarks, filename);
+ }
+ else if (g_str_has_suffix (basename, ".html"))
+ {
+ success = ephy_bookmarks_import_mozilla (bookmarks, filename);
+ }
+ else
+ {
+ /* else FIXME: put up some UI to warn user about unrecognised format? */
+ g_warning ("Couldn't determine the type of the bookmarks file %s!\n", filename);
+ }
+
+ g_free (basename);
}
- /* else FIXME: put up some UI to warn user about unrecognised format? */
return success;
}