Hi, Attached to this mail is a patch against CVS HEAD which makes rhythmbox use libgpod to parse the iPod content. libgpod ( http://www.gtkpod.org/libgpod.html ) is a library based on gtkpod code which will be used by gtkpod in future releases. Using it in rhythmbox has the advantage of less code to maintain, but it adds an additional external dependency, that's why I'm sending this mail before committing this patch, to know if people have issue with that new dep. Incidentally, the patch should make rhythmbox display (read-only) ipod playlists. Christophe
? =
? burner.Diff
? burner.diff
? burner.diuff
? conf11657.file
? playbin.diff
? playlist.diff
? queue-set.diff
? rb-ipod-source-libgpod.diff
? rb-ipod-source.c
? rhythmbox-audioscrobbler-libsoup-new-files.tar.bz2
? rhythmbox-gpod.diff
? treeview.diff
? data/glade/audioscrobbler-prefs.glade
? lib/md5.c
? lib/md5.h
? remote/dbus/rb-remote-dbus.loT
? shell/rb-audioscrobbler.c
? shell/rb-audioscrobbler.h
? sources/rb-audioscrobbler.c
Index: configure.ac
===================================================================
RCS file: /cvs/gnome/rhythmbox/configure.ac,v
retrieving revision 1.170
diff -u -r1.170 configure.ac
--- configure.ac 15 Sep 2005 12:10:48 -0000 1.170
+++ configure.ac 18 Sep 2005 18:07:00 -0000
@@ -71,6 +71,7 @@
if test x$enable_hal05 != xyes; then
PKG_CHECK_MODULES(HAL, hal >= 0.2.92 hal < 0.5 gnome-vfs-2.0 >= 2.7.4, enable_hal02=yes, enable_hal02=no)
fi
+ PKG_CHECK_MODULES(IPOD, libgpod-1.0)
if test x$enable_hal05 == xyes || test x$enable_hal02 == xyes; then
enable_hal=yes
else
@@ -88,6 +89,10 @@
AC_DEFINE(HAVE_HAL_0_2, 1, [Define if you have HAL 0.2 or later])
fi
fi
+ AC_SUBST(HAL_CFLAGS)
+ AC_SUBST(HAL_LIBS)
+ AC_SUBST(IPOD_CFLAGS)
+ AC_SUBST(IPOD_LIBS)
fi
AM_CONDITIONAL(USE_IPOD, test x"$enable_ipod" = xyes)
Index: shell/Makefile.am
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/Makefile.am,v
retrieving revision 1.58
diff -u -r1.58 Makefile.am
--- shell/Makefile.am 15 Sep 2005 05:41:14 -0000 1.58
+++ shell/Makefile.am 18 Sep 2005 18:07:00 -0000
@@ -100,6 +100,11 @@
endif
+if USE_IPOD
+rhythmbox_LDADD += $(IPOD_LIBS)
+endif
+
+
# i hate link order problems
rhythmbox_LDADD += $(top_builddir)/remote/librbremote.la
Index: sources/Makefile.am
===================================================================
RCS file: /cvs/gnome/rhythmbox/sources/Makefile.am,v
retrieving revision 1.24
diff -u -r1.24 Makefile.am
--- sources/Makefile.am 11 Sep 2005 03:05:11 -0000 1.24
+++ sources/Makefile.am 18 Sep 2005 18:07:00 -0000
@@ -1,5 +1,4 @@
## arch-tag: Automake rules for source object library
-
noinst_LTLIBRARIES = libsources.la libsourcesimpl.la
libsources_la_SOURCES = rb-source.c rb-source.h
@@ -47,9 +46,8 @@
if USE_IPOD
libsourcesimpl_la_SOURCES += \
rb-ipod-source.c \
- rb-ipod-source.h \
- itunesdb.c \
- itunesdb.h
+ rb-ipod-source.h
+INCLUDES += -I$(top_srcdir)/sources/ipod $(IPOD_CFLAGS)
endif
if USE_CD_BURNER
Index: sources/rb-ipod-source.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/sources/rb-ipod-source.c,v
retrieving revision 1.21
diff -u -r1.21 rb-ipod-source.c
--- sources/rb-ipod-source.c 11 Sep 2005 03:05:11 -0000 1.21
+++ sources/rb-ipod-source.c 18 Sep 2005 18:07:00 -0000
@@ -28,7 +28,6 @@
#include <gtk/gtktreeview.h>
#include <gtk/gtkicontheme.h>
#include <string.h>
-#include "itunesdb.h"
#include "rhythmdb.h"
#include <libgnome/gnome-i18n.h>
#ifdef HAVE_HAL
@@ -37,8 +36,10 @@
#endif
#include <libgnomevfs/gnome-vfs-volume.h>
#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <gpod/itdb.h>
#include "eel-gconf-extensions.h"
#include "rb-ipod-source.h"
+#include "rb-playlist-source.h"
#include "rb-stock-icons.h"
#include "rb-debug.h"
#include "rb-util.h"
@@ -48,9 +49,14 @@
GObjectConstructParam *construct_properties);
static void rb_ipod_source_dispose (GObject *object);
+static GObject *rb_ipod_source_constructor (GType type, guint n_construct_properties,
+ GObjectConstructParam *construct_properties);
+static void rb_ipod_source_dispose (GObject *object);
+
static gboolean impl_show_popup (RBSource *source);
static void rb_ipod_load_songs (RBiPodSource *source);
static gchar *rb_ipod_get_mount_path (GnomeVFSVolume *volume);
+static void impl_delete_thyself (RBSource *source);
#ifdef HAVE_HAL
static gboolean hal_udi_is_ipod (const char *udi);
@@ -58,7 +64,7 @@
typedef struct
{
- iPodParser *parser;
+ Itdb_iTunesDB *ipod_db;
gchar *ipod_mount_path;
} RBiPodSourcePrivate;
@@ -78,6 +84,7 @@
object_class->dispose = rb_ipod_source_dispose;
source_class->impl_show_popup = impl_show_popup;
+ source_class->impl_delete_thyself = impl_delete_thyself;
g_type_class_add_private (klass, sizeof (RBiPodSourcePrivate));
}
@@ -109,10 +116,10 @@
{
RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (object);
- if (priv->parser != NULL) {
- ipod_parser_destroy (priv->parser);
- priv->parser = NULL;
- }
+ if (priv->ipod_db != NULL) {
+ itdb_free (priv->ipod_db);
+ priv->ipod_db = NULL;
+ }
if (priv->ipod_mount_path) {
g_free (priv->ipod_mount_path);
@@ -159,52 +166,110 @@
g_value_unset (&value);
}
-#define MAX_SONGS_LOADED_AT_ONCE 250
-static gboolean
-load_ipod_db_idle_cb (RBiPodSource *source)
+static char *
+ipod_path_to_uri (const char *mount_point, const char *ipod_path)
+{
+ char *rel_pc_path;
+ char *full_pc_path;
+ char *uri;
+
+ rel_pc_path = g_strdup (ipod_path);
+ itdb_filename_ipod2fs (rel_pc_path);
+ full_pc_path = g_build_filename (mount_point, rel_pc_path, NULL);
+ g_free (rel_pc_path);
+ uri = g_filename_to_uri (full_pc_path, NULL, NULL);
+ g_free (full_pc_path);
+ return uri;
+}
+
+static void
+add_rb_playlist (RBiPodSource *source, Itdb_Playlist *playlist)
{
- RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
- RhythmDBEntry *entry;
RBShell *shell;
- RhythmDB *db;
- int i;
- RhythmDBEntryType entry_type;
+ RBSource *playlist_source;
+ GList *it;
+ RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
+
+ g_object_get (G_OBJECT (source), "shell", &shell, NULL);
- g_object_get (G_OBJECT (source), "shell", &shell, NULL);
- g_object_get (G_OBJECT (shell), "db", &db, NULL);
+ playlist_source = RB_SOURCE (g_object_new (RB_TYPE_PLAYLIST_SOURCE,
+ "name", playlist->name,
+ "shell", shell,
+ "visibility", TRUE,
+ "is-local", FALSE,
+ NULL));
+
+ for (it = playlist->members; it != NULL; it = it->next) {
+ Itdb_Track *song;
+ char *filename;
+
+ song = (Itdb_Track *)it->data;
+ filename = ipod_path_to_uri (priv->ipod_mount_path,
+ song->ipod_path);
+ rb_playlist_source_add_location (RB_PLAYLIST_SOURCE (playlist_source),
+ filename);
+ g_free (filename);
+ }
+
+ rb_shell_append_source (shell, playlist_source, RB_SOURCE (source));
g_object_unref (G_OBJECT (shell));
- g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
+}
- g_assert (db != NULL);
- g_assert (priv->parser != NULL);
- for (i = 0; i < MAX_SONGS_LOADED_AT_ONCE; i++) {
- gchar *pc_path, *pc_vfs_path;
- gchar *mount_path;
- iPodItem *item;
- iPodSong *song;
-
- item = ipod_get_next_item (priv->parser);
- if ((item == NULL) || (item->type != IPOD_ITEM_SONG)) {
- ipod_item_destroy (item);
- ipod_parser_destroy (priv->parser);
- priv->parser = NULL;
- g_object_unref (G_OBJECT (db));
- return FALSE;
+static void
+load_ipod_playlists (RBiPodSource *source)
+{
+ RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
+ GList *it;
+
+ for (it = priv->ipod_db->playlists; it != NULL; it = it->next) {
+ Itdb_Playlist *playlist;
+
+ playlist = (Itdb_Playlist *)it->data;
+ if (playlist->type == ITDB_PL_TYPE_MPL) {
+ continue;
}
- song = (iPodSong *)item->data;
-
- /* Set URI */
- mount_path = priv->ipod_mount_path;
- pc_path = itunesdb_get_track_name_on_ipod (mount_path, song);
- pc_vfs_path = g_strdup_printf ("file://%s", pc_path);
- g_free (pc_path);
- entry = rhythmdb_entry_new (RHYTHMDB (db),
- entry_type,
- pc_vfs_path);
- g_free (pc_vfs_path);
+ if (playlist->is_spl) {
+ continue;
+ }
+
+ add_rb_playlist (source, playlist);
+ }
+}
+
+static gboolean
+load_ipod_db_idle_cb (RBiPodSource *source)
+{
+ RBShell *shell;
+ RhythmDB *db;
+ GList *it;
+ RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
+
+ g_object_get (G_OBJECT (source), "shell", &shell, NULL);
+ g_object_get (G_OBJECT (shell), "db", &db, NULL);
+ g_object_unref (G_OBJECT (shell));
+
+ g_assert (db != NULL);
+ for (it = priv->ipod_db->tracks; it != NULL; it = it->next) {
+ Itdb_Track *song;
+ RhythmDBEntry *entry;
+ RhythmDBEntryType entry_type;
+ char *pc_path;
+
+ song = (Itdb_Track *)it->data;
+
+ /* Set URI */
+ g_object_get (G_OBJECT (source), "entry-type", &entry_type,
+ NULL);
+
+ pc_path = ipod_path_to_uri (priv->ipod_mount_path,
+ song->ipod_path);
+ entry = rhythmdb_entry_new (RHYTHMDB (db), entry_type,
+ pc_path);
+ g_free (pc_path);
+
rb_debug ("Adding %s from iPod", pc_path);
/* Set track number */
@@ -262,8 +327,7 @@
g_value_unset (&value);
}
- /* Set title */
-
+ /* Set title */
entry_set_string_prop (RHYTHMDB (db), entry,
RHYTHMDB_PROP_TITLE, song->title);
@@ -278,13 +342,13 @@
RHYTHMDB_PROP_GENRE, song->genre);
rhythmdb_commit (RHYTHMDB (db));
-
-
- ipod_item_destroy (item);
+
}
+ load_ipod_playlists (source);
+
g_object_unref (G_OBJECT (db));
- return TRUE;
+ return FALSE;
}
static void
@@ -295,10 +359,11 @@
g_object_get (G_OBJECT (source), "volume", &volume, NULL);
priv->ipod_mount_path = rb_ipod_get_mount_path (volume);
- g_object_unref (G_OBJECT (volume));
- priv->parser = ipod_parser_new (priv->ipod_mount_path);
- g_idle_add ((GSourceFunc)load_ipod_db_idle_cb, source);
+ priv->ipod_db = itdb_parse (priv->ipod_mount_path, NULL);
+ if (priv->ipod_db != NULL) {
+ g_idle_add ((GSourceFunc)load_ipod_db_idle_cb, source);
+ }
}
static gchar *
@@ -458,4 +523,15 @@
{
_rb_source_show_popup (RB_SOURCE (source), "/iPodSourcePopup");
return TRUE;
+}
+
+static void
+impl_delete_thyself (RBSource *source)
+{
+ RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
+
+ itdb_free (priv->ipod_db);
+ priv->ipod_db = NULL;
+
+ RB_SOURCE_CLASS (rb_ipod_source_parent_class)->impl_delete_thyself (source);
}
Attachment:
signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=