[vlc-devel] [PATCH] meta_engine: add art fetching from gvfs.

Francois Cartegnie fcvlcdev at free.fr
Thu Mar 7 20:00:58 CET 2013


Retrieves art from GVFS metadata.
Gnome 2.x, MATE. Unsure if it's still used in Gnome 3.x.
Priority set to 91 (folder module + 1) as it is a user choice.

Francois

---
 configure.ac                   |    4 +
 modules/meta_engine/Modules.am |    1 +
 modules/meta_engine/gvfs.c     |  121 ++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                 |    1 +
 4 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 modules/meta_engine/gvfs.c

diff --git a/configure.ac b/configure.ac
index 127b2e8..ec17570 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3899,6 +3899,10 @@ AS_IF([test "${enable_taglib}" != "no"], [
     AC_MSG_WARN([${TAGLIB_PKG_ERRORS}.])])
 ])
 
+dnl
+dnl gvfs plugin
+dnl
+PKG_ENABLE_MODULES_VLC([GVFS], [gvfsmeta], [glib-2.0 >= 2.28.8 gio-2.0 >= 2.28.8], (gvfs filesystem metadata), [auto])
 
 dnl
 dnl update checking system
diff --git a/modules/meta_engine/Modules.am b/modules/meta_engine/Modules.am
index f9fdcf1..26e88be 100644
--- a/modules/meta_engine/Modules.am
+++ b/modules/meta_engine/Modules.am
@@ -1,5 +1,6 @@
 SOURCES_folder = folder.c
 SOURCES_taglib = taglib.cpp
+SOURCES_gvfsmeta = gvfs.c
 
 libvlc_LTLIBRARIES += \
 	libfolder_plugin.la
diff --git a/modules/meta_engine/gvfs.c b/modules/meta_engine/gvfs.c
new file mode 100644
index 0000000..5779bab
--- /dev/null
+++ b/modules/meta_engine/gvfs.c
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * gfvs.c
+ *****************************************************************************
+ * Copyright (C) 2013 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_art_finder.h>
+#include <vlc_url.h>
+#include <vlc_input_item.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int FindMeta( vlc_object_t * );
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+
+vlc_module_begin ()
+    set_shortname( N_( "gvfsmeta" ) )
+    set_description( N_("Custom icon metadata finder from gvfs") )
+    set_capability( "art finder", 91 )
+    set_callbacks( FindMeta, NULL )
+vlc_module_end ()
+
+/*****************************************************************************
+ *****************************************************************************/
+static int FindMeta( vlc_object_t *p_this )
+{
+    art_finder_t *p_finder = (art_finder_t *) p_this;
+    input_item_t *p_item = p_finder->p_item;
+
+    GError *p_error = NULL;
+    char *psz_uri = NULL;
+
+    char *psz_dir = input_item_GetURI( p_item );
+    if( !psz_dir )
+        return VLC_EGENERIC;
+
+    if ( !*psz_dir || strncmp( psz_dir, "file://", 7 ) )
+    {
+        free( psz_dir );
+        return VLC_EGENERIC;
+    }
+
+    g_type_init ();
+
+    GFile *p_file = g_file_new_for_uri( psz_dir );
+
+    if ( p_file != NULL )
+    {
+        GFileQueryInfoFlags flags = 0;
+        GFileInfo *p_info = g_file_query_info( p_file, "metadata::custom-icon", flags, NULL, &p_error );
+
+        if ( p_info != NULL )
+        {
+            char **pp_attributes = g_file_info_list_attributes( p_info, NULL );
+
+            if ( pp_attributes[0] )
+            {
+                char *psz_icon = g_file_info_get_attribute_as_string( p_info, pp_attributes[0] );
+                if ( psz_icon )
+                {
+                    if ( asprintf( &psz_uri, "%s/%s", psz_dir, psz_icon ) >= 0 )
+                        input_item_SetArtURL( p_item, psz_uri );
+                    free( psz_icon );
+                }
+            }
+
+            g_strfreev( pp_attributes );
+
+            g_object_unref( p_info );
+        }
+
+        g_object_unref( p_file );
+    }
+
+    free( psz_dir );
+
+    if ( p_error )
+    {
+        msg_Err( p_this, "%s", p_error->message );
+        g_error_free( p_error );
+    }
+
+    if( psz_uri ) /* Was found and set */
+    {
+        free( psz_uri );
+        return VLC_SUCCESS;
+    }
+
+    return VLC_EGENERIC;
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9f520b1..3f68e0f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -938,6 +938,7 @@ modules/lua/vlc.h
 modules/media_library/sql_media_library.c
 modules/meta_engine/folder.c
 modules/meta_engine/taglib.cpp
+modules/meta_engine/gvfs.c
 modules/misc/audioscrobbler.c
 modules/misc/dhparams.h
 modules/misc/gnutls.c
-- 
1.7.9




More information about the vlc-devel mailing list