changeset 2108:02f39b64f36b trunk

[svn] - add support for new extension probing system
author nenolod
date Tue, 12 Dec 2006 18:32:05 -0800
parents 8d2b17ee266e
children 27e0fe4de57e
files ChangeLog audacious/input.c audacious/main.c audacious/main.h
diffstat 4 files changed, 53 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 12 18:22:17 2006 -0800
+++ b/ChangeLog	Tue Dec 12 18:32:05 2006 -0800
@@ -1,3 +1,13 @@
+2006-12-13 02:22:17 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [3219]
+  - add gchar **vfs_extensions to InputPlugin struct, adding support for 
+    the NewVFS extension probing method. The vfs_extensions table defines 
+    a list of supported extensions, and must be NULL terminated.
+  
+  trunk/audacious/plugin.h |   22 +++++++++++++++-------
+  1 file changed, 15 insertions(+), 7 deletions(-)
+
+
 2006-12-12 22:03:08 +0000  Kiyoshi Aman <kiyoshi.aman@gmail.com>
   revision [3217]
   Remove leftover plugin-related bits that don't do anything any more.
--- a/audacious/input.c	Tue Dec 12 18:22:17 2006 -0800
+++ b/audacious/input.c	Tue Dec 12 18:32:05 2006 -0800
@@ -402,6 +402,10 @@
  * Rewritten to use NewVFS probing, semantics are still basically the same.
  *
  * --nenolod, Dec  5 2006
+ *
+ * Adapted to use the NewVFS extension probing system if enabled.
+ *
+ * --nenolod, Dec 12 2006
  */
 InputPlugin *
 input_check_file(const gchar * filename, gboolean show_warning)
@@ -423,27 +427,50 @@
             continue;
 
         vfs_fseek(fd, 0, SEEK_SET);
+        if (cfg.use_extension_probing != TRUE || ip->vfs_extensions == NULL)
+        {
 
-        if (ip->is_our_file_from_vfs != NULL)
-        {
-            ret = ip->is_our_file_from_vfs(filename_proxy, fd);
+            if (ip->is_our_file_from_vfs != NULL)
+            {
+                ret = ip->is_our_file_from_vfs(filename_proxy, fd);
 
-            if (ret > 0)
+                if (ret > 0)
+                {
+                    g_free(filename_proxy);
+                    vfs_fclose(fd);
+                    return ip;
+                }
+            }
+            else if (ip->is_our_file != NULL)
             {
-                g_free(filename_proxy);
-                vfs_fclose(fd);
-                return ip;
+                ret = ip->is_our_file(filename_proxy);
+
+                if (ret > 0)
+                {
+                    g_free(filename_proxy);
+                    vfs_fclose(fd);
+                    return ip;
+                }
             }
         }
-        else if (ip->is_our_file != NULL)
+        else
         {
-            ret = ip->is_our_file(filename_proxy);
+            gint i;
+            gchar *ext = strrchr(filename_proxy, '.');
+
+            if (ext == NULL)
+                continue;
 
-            if (ret > 0)
+            ext++;
+
+            for (i = 0; ip->vfs_extensions[i] != NULL; i++)
             {
-                g_free(filename_proxy);
-                vfs_fclose(fd);
-                return ip;
+                if (!g_strcasecmp(ip->vfs_extensions[i], ext))
+                {
+                    g_free(filename_proxy);
+                    vfs_fclose(fd);
+                    return ip;
+                }
             }
         }
 
--- a/audacious/main.c	Tue Dec 12 18:22:17 2006 -0800
+++ b/audacious/main.c	Tue Dec 12 18:32:05 2006 -0800
@@ -205,6 +205,7 @@
     20,				/* delay until the filepopup comes up */
     FALSE,			/* use filename.jpg for coverart */
     FALSE,			/* use XMMS-style file selection */
+    FALSE,                      /* use extension probing         */
 };
 
 typedef struct bmp_cfg_boolent_t {
@@ -305,6 +306,7 @@
     {"recurse_for_cover", &cfg.recurse_for_cover, TRUE},
     {"use_file_cover", &cfg.use_file_cover, TRUE},
     {"use_xmms_style_fileselector", &cfg.use_xmms_style_fileselector, TRUE},
+    {"use_extension_probing", &cfg.use_extension_probing, TRUE},
 };
 
 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents);
--- a/audacious/main.h	Tue Dec 12 18:22:17 2006 -0800
+++ b/audacious/main.h	Tue Dec 12 18:32:05 2006 -0800
@@ -127,6 +127,7 @@
     gint filepopup_delay;
     gboolean use_file_cover;
     gboolean use_xmms_style_fileselector;
+    gboolean use_extension_probing;
 };
 
 typedef struct _BmpConfig BmpConfig;