sound-juicer r2287 - in trunk: . libjuicer
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: sound-juicer r2287 - in trunk: . libjuicer
- Date: Thu, 4 Sep 2008 16:51:41 +0000 (UTC)
Author: hadess
Date: Thu Sep 4 16:51:41 2008
New Revision: 2287
URL: http://svn.gnome.org/viewvc/sound-juicer?rev=2287&view=rev
Log:
2008-09-04 Bastien Nocera <hadess hadess net>
* configure.in: Make libcdio an optional library again,
it would conflict with the GPL + exception license
* libjuicer/Makefile.am:
* libjuicer/sj-metadata-getter.c (lookup_cd):
* libjuicer/sj-metadata-gvfs.c (device_to_cdda_uri),
(gvfs_list_albums), (sj_metadata_gvfs_get_property),
(sj_metadata_gvfs_set_property), (sj_metadata_gvfs_finalize),
(sj_metadata_gvfs_init), (metadata_iface_init),
(sj_metadata_gvfs_class_init), (sj_metadata_gvfs_new):
* libjuicer/sj-metadata-gvfs.h: Add a gvfs based metadata
reader, for fallback support
Added:
trunk/libjuicer/sj-metadata-gvfs.c
trunk/libjuicer/sj-metadata-gvfs.h
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/libjuicer/Makefile.am
trunk/libjuicer/sj-metadata-getter.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Sep 4 16:51:41 2008
@@ -69,18 +69,22 @@
AC_SUBST(MEDIA_PROFILES_CFLAGS)
AC_SUBST(MEDIA_PROFILES_LIBS)
-# Find libcdio
-PKG_CHECK_MODULES([CDIO],[libcdio >= 0.70])
+# Find optional libcdio
+PKG_CHECK_MODULES([CDIO],[libcdio >= 0.70], [have_cdio=yes], [have_cdio=no])
AC_SUBST([CDIO_CFLAGS])
AC_SUBST([CDIO_LIBS])
+AM_CONDITIONAL([HAVE_LIBCDIO], [test "$have_cdio" = "yes"])
+if test "$have_cdio" = "yes" ; then
+ AC_DEFINE([HAVE_LIBCDIO], 1, [Whether libcdio is available])
+fi
-# Find MusicBrainz
+# Find optional MusicBrainz3 and required Musicbrainz2
PKG_CHECK_MODULES(MUSICBRAINZ3, libmusicbrainz3, [have_mb3=yes], [have_mb3=no])
AC_SUBST(MUSICBRAINZ3_CFLAGS)
AC_SUBST(MUSICBRAINZ3_LIBS)
-AM_CONDITIONAL([HAVE_MB3], [test "$have_mb3" = "yes"])
+AM_CONDITIONAL([HAVE_MUSICBRAINZ3], [test "$have_mb3" = "yes"])
if test "$have_mb3" = "yes" ; then
- AC_DEFINE([HAVE_MB3], 1, [Whether libmusicbrainz3 is available])
+ AC_DEFINE([HAVE_MUSIZBRAINZ3], 1, [Whether libmusicbrainz3 is available])
fi
PKG_CHECK_MODULES(MUSICBRAINZ, libmusicbrainz >= 2.1.3)
@@ -92,6 +96,11 @@
AC_CHECK_FUNCS(mb_SetProxyCreds)
LIBS="$oldlibs"
+# Find gio for the metadata extractor
+PKG_CHECK_MODULES(GIO, gio-2.0)
+AC_SUBST(GIO_CFLAGS)
+AC_SUBST(GIO_LIBS)
+
# Find how and where to put the GConf schemas
AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
if test "$GCONFTOOL" = "no"; then
Modified: trunk/libjuicer/Makefile.am
==============================================================================
--- trunk/libjuicer/Makefile.am (original)
+++ trunk/libjuicer/Makefile.am Thu Sep 4 16:51:41 2008
@@ -12,8 +12,8 @@
sj-metadata.c \
sj-metadata-musicbrainz.h \
sj-metadata-musicbrainz.c \
- sj-metadata-cdtext.h \
- sj-metadata-cdtext.c \
+ sj-metadata-gvfs.h \
+ sj-metadata-gvfs.c \
sj-metadata-getter.c \
sj-metadata-getter.h \
sj-util.h sj-util.c
@@ -46,12 +46,18 @@
-export-dynamic \
$(AM_LDFLAGS)
-if HAVE_MB3
+if HAVE_MUSICBRAINZ3
libjuicer_la_SOURCES += \
sj-metadata-musicbrainz3.h \
sj-metadata-musicbrainz3.c
endif
+if HAVE_LIBCDIO
+libjuicer_la_SOURCES += \
+ sj-metadata-cdtext.h \
+ sj-metadata-cdtext.c
+endif
+
#
# Build the GValue marshals
#
Modified: trunk/libjuicer/sj-metadata-getter.c
==============================================================================
--- trunk/libjuicer/sj-metadata-getter.c (original)
+++ trunk/libjuicer/sj-metadata-getter.c Thu Sep 4 16:51:41 2008
@@ -25,11 +25,14 @@
#include "sj-metadata-getter.h"
#include "sj-metadata-marshal.h"
#include "sj-metadata.h"
-#ifdef HAVE_MB3
+#ifdef HAVE_MUSICBRAINZ3
#include "sj-metadata-musicbrainz3.h"
-#endif /* HAVE_MB3 */
+#endif /* HAVE_MUSICBRAINZ3 */
#include "sj-metadata-musicbrainz.h"
+#ifdef HAVE_LIBCDIO
#include "sj-metadata-cdtext.h"
+#endif /* HAVE_LIBCDIO */
+#include "sj-metadata-gvfs.h"
#include "sj-error.h"
enum {
@@ -173,11 +176,14 @@
GError *error = NULL;
gboolean found = FALSE;
GType types[] = {
-#ifdef HAVE_MB3
+#ifdef HAVE_MUSICBRAINZ3
SJ_TYPE_METADATA_MUSICBRAINZ3,
-#endif /* HAVE_MB3 */
+#endif /* HAVE_MUSICBRAINZ3 */
SJ_TYPE_METADATA_MUSICBRAINZ,
+#ifdef HAVE_LIBCDIO
SJ_TYPE_METADATA_CDTEXT,
+#endif /* HAVE_LIBCDIO */
+ SJ_TYPE_METADATA_GVFS
};
priv = GETTER_PRIVATE (mdg);
Added: trunk/libjuicer/sj-metadata-gvfs.c
==============================================================================
--- (empty file)
+++ trunk/libjuicer/sj-metadata-gvfs.c Thu Sep 4 16:51:41 2008
@@ -0,0 +1,259 @@
+/*
+ * sj-metadata-gvfs.c
+ * Copyright (C) 2005 Ross Burton <ross burtonini com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <glib/gerror.h>
+#include <glib/glist.h>
+#include <glib/gstrfuncs.h>
+#include <glib/gmessages.h>
+#include <gio/gio.h>
+
+#include "sj-metadata-gvfs.h"
+#include "sj-structures.h"
+#include "sj-error.h"
+
+struct SjMetadataGvfsPrivate {
+ char *cdrom;
+ char *uri;
+ GList *albums;
+};
+
+#define GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), SJ_TYPE_METADATA_GVFS, SjMetadataGvfsPrivate))
+
+enum {
+ PROP_0,
+ PROP_DEVICE,
+ PROP_PROXY_HOST,
+ PROP_PROXY_PORT,
+};
+
+static void metadata_iface_init (gpointer g_iface, gpointer iface_data);
+
+G_DEFINE_TYPE_WITH_CODE (SjMetadataGvfs, sj_metadata_gvfs,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (SJ_TYPE_METADATA, metadata_iface_init));
+
+
+/**
+ * Private methods
+ */
+
+static char *
+device_to_cdda_uri (const char *device)
+{
+ if (g_str_has_prefix (device, "/dev/") == FALSE)
+ return NULL;
+ return g_strdup_printf ("cdda://%s", device + strlen ("/dev/"));
+}
+
+static GList *
+gvfs_list_albums (SjMetadata *metadata, char **url, GError **error)
+{
+ SjMetadataGvfsPrivate *priv;
+ AlbumDetails *album;
+ GError *my_error = NULL;
+ GFile *file;
+ GFileInfo *info;
+ GFileEnumerator *e;
+ guint i = 0;
+
+ g_return_val_if_fail (SJ_IS_METADATA_GVFS (metadata), NULL);
+
+ priv = SJ_METADATA_GVFS (metadata)->priv;
+
+ if (priv->uri == NULL) {
+ g_set_error (error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, _("Cannot access CD"));
+ priv->albums = NULL;
+ return NULL;
+ }
+
+ file = g_file_new_for_uri (priv->uri);
+
+ info = g_file_query_info (file, "xattr::org.gnome.audio",
+ G_FILE_QUERY_INFO_NONE, NULL, &my_error);
+ if (info == NULL)
+ goto bail;
+
+ album = g_new0(AlbumDetails, 1);
+
+ /* Get the album metadata */
+ if (g_file_info_get_attribute_string (info, "xattr::org.gnome.audio.title") != NULL) {
+ album->metadata_source = SOURCE_CDTEXT;
+ album->title = g_strdup (g_file_info_get_attribute_string (info, "xattr::org.gnome.audio.title"));
+ } else {
+ album->metadata_source = SOURCE_FALLBACK;
+ album->title = g_strdup (_("Unknown Title"));
+ }
+ album->artist = g_strdup (g_file_info_get_attribute_string (info, "xattr::org.gnome.audio.artist"));
+ if (album->artist == NULL)
+ album->artist = g_strdup (_("Unknown Artist"));
+ album->genre = g_strdup (g_file_info_get_attribute_string (info, "xattr::org.gnome.audio.genre"));
+
+ g_object_unref (info);
+
+ /* Get tracks metadata */
+ e = g_file_enumerate_children (file, "xattr::org.gnome.audio",
+ G_FILE_QUERY_INFO_NONE, NULL, &my_error);
+ if (e == NULL)
+ goto bail;
+
+ for (info = g_file_enumerator_next_file (e, NULL, NULL) ;
+ info != NULL ;
+ info = g_file_enumerator_next_file (e, NULL, NULL)) {
+ TrackDetails *track;
+
+ track = g_new0 (TrackDetails, 1);
+ track->number = i++;
+ track->title = g_strdup (g_file_info_get_attribute_string (info, "xattr::org.gnome.audio.title"));
+ if (track->title == NULL)
+ track->title = g_strdup_printf (_("Track %d"), i);
+ track->artist = g_strdup (g_file_info_get_attribute_string (info, "xattr::org.gnome.audio.artist"));
+ if (track->artist == NULL)
+ track->artist = g_strdup (_("Unknown Artist"));
+ track->duration = g_file_info_get_attribute_uint64 (info, "xattr::org.gnome.audio.duration");
+ album->number++;
+ g_object_unref (info);
+ }
+ g_object_unref (e);
+
+ priv->albums = g_list_append (NULL, album);
+
+ return priv->albums;
+
+bail:
+
+ g_object_unref (file);
+ g_set_error (error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, _("Cannot access CD: %s"), my_error->message);
+ g_error_free (my_error);
+ g_list_foreach (priv->albums, (GFunc)album_details_free, NULL);
+ g_list_free (priv->albums);
+ priv->albums = NULL;
+ return NULL;
+}
+
+
+/**
+ * GObject methods
+ */
+
+static void
+sj_metadata_gvfs_get_property (GObject *object, guint property_id,
+ GValue *value, GParamSpec *pspec)
+{
+ SjMetadataGvfsPrivate *priv = SJ_METADATA_GVFS (object)->priv;
+ g_assert (priv);
+
+ switch (property_id) {
+ case PROP_DEVICE:
+ g_value_set_string (value, priv->cdrom);
+ break;
+ case PROP_PROXY_HOST:
+ /* Do nothing */
+ g_value_set_string (value, "");
+ break;
+ case PROP_PROXY_PORT:
+ /* Do nothing */
+ g_value_set_int (value, 0);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+sj_metadata_gvfs_set_property (GObject *object, guint property_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ SjMetadataGvfsPrivate *priv = SJ_METADATA_GVFS (object)->priv;
+ g_assert (priv);
+
+ switch (property_id) {
+ case PROP_DEVICE:
+ if (priv->cdrom)
+ g_free (priv->cdrom);
+ priv->cdrom = g_value_dup_string (value);
+ priv->uri = device_to_cdda_uri (priv->cdrom);
+ break;
+ case PROP_PROXY_HOST:
+ case PROP_PROXY_PORT:
+ /* Do nothing */
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+sj_metadata_gvfs_finalize (GObject *object)
+{
+ SjMetadataGvfsPrivate *priv = SJ_METADATA_GVFS (object)->priv;
+ g_free (priv->cdrom);
+ g_free (priv->uri);
+ g_list_foreach (priv->albums, (GFunc)album_details_free, NULL);
+ g_list_free (priv->albums);
+}
+
+static void
+sj_metadata_gvfs_init (SjMetadataGvfs *gvfs)
+{
+ gvfs->priv = GET_PRIVATE (gvfs);
+}
+
+static void
+metadata_iface_init (gpointer g_iface, gpointer iface_data)
+{
+ SjMetadataClass *klass = (SjMetadataClass*)g_iface;
+
+ klass->list_albums = gvfs_list_albums;
+}
+
+static void
+sj_metadata_gvfs_class_init (SjMetadataGvfsClass *class)
+{
+ GObjectClass *object_class = (GObjectClass*) class;
+
+ g_type_class_add_private (class, sizeof (SjMetadataGvfsPrivate));
+
+ object_class->get_property = sj_metadata_gvfs_get_property;
+ object_class->set_property = sj_metadata_gvfs_set_property;
+ object_class->finalize = sj_metadata_gvfs_finalize;
+
+ g_object_class_override_property (object_class, PROP_DEVICE, "device");
+ g_object_class_override_property (object_class, PROP_PROXY_HOST, "proxy-host");
+ g_object_class_override_property (object_class, PROP_PROXY_PORT, "proxy-port");
+}
+
+
+/*
+ * Public methods
+ */
+
+GObject *
+sj_metadata_gvfs_new (void)
+{
+ return g_object_new (sj_metadata_gvfs_get_type (), NULL);
+}
Added: trunk/libjuicer/sj-metadata-gvfs.h
==============================================================================
--- (empty file)
+++ trunk/libjuicer/sj-metadata-gvfs.h Thu Sep 4 16:51:41 2008
@@ -0,0 +1,57 @@
+/*
+ * sj-metadata-gvfs.h
+ * Copyright (C) 2008 Bastien Nocera <hadess hadess net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef SJ_METADATA_GVFS_H
+#define SJ_METADATA_GVFS_H
+
+#include <glib-object.h>
+#include "sj-metadata.h"
+
+G_BEGIN_DECLS
+
+#define SJ_TYPE_METADATA_GVFS (sj_metadata_gvfs_get_type ())
+#define SJ_METADATA_GVFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SJ_TYPE_METADATA_GVFS, SjMetadataGvfs))
+#define SJ_METADATA_GVFS_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), SJ_TYPE_METADATA_GVFS, SjMetadataGvfsClass))
+#define SJ_IS_METADATA_GVFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SJ_TYPE_METADATA_GVFS))
+#define SJ_IS_METADATA_GVFS_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), SJ_TYPE_METADATA_GVFS))
+#define SJ_METADATA_GVFS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SJ_TYPE_METADATA_GVFS, SjMetadataGvfsClass))
+
+typedef struct _SjMetadataGvfs SjMetadataGvfs;
+typedef struct _SjMetadataGvfsClass SjMetadataGvfsClass;
+typedef struct SjMetadataGvfsPrivate SjMetadataGvfsPrivate;
+
+struct _SjMetadataGvfs
+{
+ GObject parent;
+ SjMetadataGvfsPrivate *priv;
+};
+
+struct _SjMetadataGvfsClass
+{
+ GObjectClass parent;
+};
+
+GType sj_metadata_gvfs_get_type (void);
+
+GObject *sj_metadata_gvfs_new (void);
+
+G_END_DECLS
+
+#endif /* SJ_METADATA_GVFS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]