[grilo-plugins/0.1.x] local-metadata: Support all GIO supported schemes



commit 8eeb305c64b8b5a591e714ac8df5e8848c21c98c
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Apr 11 16:45:22 2012 +0100

    local-metadata: Support all GIO supported schemes
    
    And not just file:///
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673916

 src/metadata/local-metadata/grl-local-metadata.c |   26 +++++++++++++++++++--
 1 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/src/metadata/local-metadata/grl-local-metadata.c b/src/metadata/local-metadata/grl-local-metadata.c
index 5b75d6a..99d51ed 100644
--- a/src/metadata/local-metadata/grl-local-metadata.c
+++ b/src/metadata/local-metadata/grl-local-metadata.c
@@ -771,6 +771,27 @@ resolve_album_art (GrlMetadataSource *source,
 }
 
 static gboolean
+is_supported_scheme (const char *scheme)
+{
+  GVfs *vfs;
+  const gchar * const * schemes;
+  guint i;
+
+  if (scheme == NULL)
+    return FALSE;
+
+  vfs = g_vfs_get_default ();
+  schemes = g_vfs_get_supported_uri_schemes (vfs);
+
+  for (i = 0; schemes[i] != NULL; i++) {
+    if (g_str_equal (schemes[i], scheme))
+      return TRUE;
+  }
+
+  return FALSE;
+}
+
+static gboolean
 has_compatible_media_url (GrlMedia *media)
 {
   gboolean ret = FALSE;
@@ -780,10 +801,9 @@ has_compatible_media_url (GrlMedia *media)
   url = grl_media_get_url (media);
   scheme = g_uri_parse_scheme (url);
 
-  ret = 0 == g_strcmp0 (scheme, "file");
+  ret = is_supported_scheme (scheme);
 
-  if (scheme)
-    g_free (scheme);
+  g_free (scheme);
 
   return ret;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]