[rhythmbox] ipod: use libmediaplayerid for device detection
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] ipod: use libmediaplayerid for device detection
- Date: Tue, 4 Aug 2009 13:44:29 +0000 (UTC)
commit 45ba8a9199fe04ec9ac187c34608ba6823af1f5f
Author: Jonathan Matthew <jonathan d14n org>
Date: Tue Aug 4 23:38:28 2009 +1000
ipod: use libmediaplayerid for device detection
plugins/ipod/Makefile.am | 2 -
plugins/ipod/rb-ipod-helpers.c | 165 ++++++++++------------------------------
plugins/ipod/rb-ipod-helpers.h | 4 +-
plugins/ipod/rb-ipod-plugin.c | 2 +-
plugins/ipod/rb-ipod-source.c | 2 +-
sources/Makefile.am | 1 -
6 files changed, 45 insertions(+), 131 deletions(-)
---
diff --git a/plugins/ipod/Makefile.am b/plugins/ipod/Makefile.am
index 84c0392..1f29644 100644
--- a/plugins/ipod/Makefile.am
+++ b/plugins/ipod/Makefile.am
@@ -16,7 +16,6 @@ libipod_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
libipod_la_LIBTOOLFLAGS = --tag=disable-static
libipod_la_LIBADD = \
$(top_builddir)/shell/librhythmbox-core.la \
- $(HAL_LIBS) \
$(IPOD_LIBS)
INCLUDES = \
@@ -37,7 +36,6 @@ INCLUDES = \
-DSHARE_DIR=\"$(pkgdatadir)\" \
-DDATADIR=\""$(datadir)"\" \
$(RHYTHMBOX_CFLAGS) \
- $(HAL_CFLAGS) \
$(IPOD_CFLAGS) \
-D_XOPEN_SOURCE -D_BSD_SOURCE
diff --git a/plugins/ipod/rb-ipod-helpers.c b/plugins/ipod/rb-ipod-helpers.c
index 382edc2..caf769c 100644
--- a/plugins/ipod/rb-ipod-helpers.c
+++ b/plugins/ipod/rb-ipod-helpers.c
@@ -405,143 +405,57 @@ rb_ipod_helpers_mount_has_ipod_db (GMount *mount)
return result;
}
-#ifdef HAVE_HAL
-static gboolean
-volume_is_ipod (GVolume *volume)
-{
- LibHalContext *ctx;
- DBusConnection *conn;
- char *parent_udi, *udi;
- char **methods_list;
- guint i;
- gboolean result;
- DBusError error;
- gboolean inited = FALSE;
-
- result = FALSE;
- dbus_error_init (&error);
-
- udi = NULL;
- conn = NULL;
- parent_udi = NULL;
- methods_list = NULL;
-
- ctx = libhal_ctx_new ();
- if (ctx == NULL) {
- /* FIXME: should we return an error somehow so that we can
- * fall back to a check for iTunesDB presence instead ?
- */
- rb_debug ("cannot connect to HAL");
- goto end;
- }
- conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
- if (conn == NULL || dbus_error_is_set (&error))
- goto end;
-
- libhal_ctx_set_dbus_connection (ctx, conn);
- if (!libhal_ctx_init (ctx, &error) || dbus_error_is_set (&error))
- goto end;
-
- udi = rb_gvolume_get_udi (volume, ctx);
- if (udi == NULL)
- goto end;
-
- inited = TRUE;
- parent_udi = libhal_device_get_property_string (ctx, udi,
- "info.parent", &error);
- if (parent_udi == NULL || dbus_error_is_set (&error))
- goto end;
- methods_list = libhal_device_get_property_strlist (ctx, parent_udi,
- "portable_audio_player.access_method.protocols", &error);
- if (methods_list == NULL || dbus_error_is_set (&error))
- goto end;
- for (i = 0; methods_list[i] != NULL; i++) {
- if (strcmp ("ipod", methods_list[i]) == 0) {
- result = TRUE;
- break;
- }
- }
-
-end:
- g_free (udi);
- g_free (parent_udi);
- libhal_free_string_array (methods_list);
-
- if (dbus_error_is_set (&error)) {
- rb_debug ("Error: %s\n", error.message);
- dbus_error_free (&error);
- dbus_error_init (&error);
- }
-
- if (ctx) {
- if (inited)
- libhal_ctx_shutdown (ctx, &error);
- libhal_ctx_free(ctx);
- }
-
- dbus_error_free (&error);
-
- return result;
-}
-
-gboolean
-rb_ipod_helpers_is_ipod (GMount *mount)
-{
- gboolean result;
- GVolume *volume;
- GFile *root;
-
- root = g_mount_get_root (mount);
- if (root != NULL) {
- if (g_file_has_uri_scheme (root, "afc") != FALSE) {
- g_object_unref (root);
- return TRUE;
- }
- g_object_unref (root);
- }
-
- volume = g_mount_get_volume (mount);
- if (volume == NULL)
- return FALSE;
-
- result = volume_is_ipod (volume);
- g_object_unref (volume);
-
- return result;
-}
-
-#else
-
gboolean
-rb_ipod_helpers_is_ipod (GMount *mount)
+rb_ipod_helpers_is_ipod (GMount *mount, MPIDDevice *device_info)
{
GFile *root;
- gchar *mount_point;
gboolean result = FALSE;
+ char **protocols;
- root = g_mount_get_root (mount);
- if (root != NULL) {
- gchar *device_dir;
-
- mount_point = g_file_get_path (root);
- if (mount_point != NULL) {
- device_dir = itdb_get_device_dir (mount_point);
- if (device_dir != NULL) {
- result = g_file_test (device_dir,
- G_FILE_TEST_IS_DIR);
- g_free (device_dir);
+ /* if we have specific information about the device, use it.
+ * otherwise, check if the device has an ipod device directory on it.
+ */
+ g_object_get (device_info, "access-protocols", &protocols, NULL);
+ if (protocols != NULL && g_strv_length (protocols) > 0) {
+ int i;
+
+ for (i = 0; protocols[i] != NULL; i++) {
+ if (g_str_equal (protocols[i], "ipod")) {
+ result = TRUE;
+ break;
}
}
-
- g_free (mount_point);
- g_object_unref (root);
+ } else {
+ root = g_mount_get_root (mount);
+ if (root != NULL) {
+ gchar *device_dir;
+
+ if (g_file_has_uri_scheme (root, "afc") != FALSE) {
+ result = TRUE;
+ } else {
+ gchar *mount_point;
+ mount_point = g_file_get_path (root);
+ if (mount_point != NULL) {
+ device_dir = itdb_get_device_dir (mount_point);
+ if (device_dir != NULL) {
+ result = g_file_test (device_dir,
+ G_FILE_TEST_IS_DIR);
+ g_free (device_dir);
+ }
+ }
+
+ g_free (mount_point);
+ }
+ g_object_unref (root);
+ }
}
+ g_strfreev (protocols);
return result;
}
#endif
-
-gboolean rb_ipod_helpers_needs_init (GMount *mount)
+gboolean
+rb_ipod_helpers_needs_init (GMount *mount)
{
/* This function is a useless one-liner for now, but it should check
* for the existence of the firsttime file on the ipod to tell if
@@ -549,3 +463,4 @@ gboolean rb_ipod_helpers_needs_init (GMount *mount)
*/
return (!rb_ipod_helpers_mount_has_ipod_db (mount));
}
+
diff --git a/plugins/ipod/rb-ipod-helpers.h b/plugins/ipod/rb-ipod-helpers.h
index f32c63b..418ed54 100644
--- a/plugins/ipod/rb-ipod-helpers.h
+++ b/plugins/ipod/rb-ipod-helpers.h
@@ -31,6 +31,8 @@
#include <glib.h>
#include <rb-source.h>
+#include "mediaplayerid.h"
+
G_BEGIN_DECLS
gboolean rb_ipod_helpers_show_first_time_dialog (GMount *mount,
const char *builder_file);
@@ -38,7 +40,7 @@ gboolean rb_ipod_helpers_show_first_time_dialog (GMount *mount,
guint64 rb_ipod_helpers_get_capacity (const char *mountpoint);
guint64 rb_ipod_helpers_get_free_space (const char *mountpoint);
char *rb_ipod_helpers_get_device (RBSource *source);
-gboolean rb_ipod_helpers_is_ipod (GMount *mount);
+gboolean rb_ipod_helpers_is_ipod (GMount *mount, MPIDDevice *device_info);
gboolean rb_ipod_helpers_needs_init (GMount *mount);
G_END_DECLS
diff --git a/plugins/ipod/rb-ipod-plugin.c b/plugins/ipod/rb-ipod-plugin.c
index 1dd505c..215243b 100644
--- a/plugins/ipod/rb-ipod-plugin.c
+++ b/plugins/ipod/rb-ipod-plugin.c
@@ -233,7 +233,7 @@ static RBSource *
create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *device_info, RBIpodPlugin *plugin)
{
RBSource *src;
- if (!rb_ipod_helpers_is_ipod (mount)) {
+ if (!rb_ipod_helpers_is_ipod (mount, device_info)) {
return NULL;
}
diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c
index 8afe1a4..c647a13 100644
--- a/plugins/ipod/rb-ipod-source.c
+++ b/plugins/ipod/rb-ipod-source.c
@@ -1543,7 +1543,7 @@ impl_get_mime_types (RBRemovableMediaSource *source)
{
GList *ret = NULL;
- /* FIXME: we should really query HAL for this */
+ /* FIXME: we should really query MPID for this */
ret = g_list_prepend (ret, g_strdup ("audio/aac"));
ret = g_list_prepend (ret, g_strdup ("audio/mpeg"));
diff --git a/sources/Makefile.am b/sources/Makefile.am
index dfe6c5f..cd50ea2 100644
--- a/sources/Makefile.am
+++ b/sources/Makefile.am
@@ -64,7 +64,6 @@ INCLUDES = \
-DSHARE_DIR=\"$(pkgdatadir)\" \
-DDATADIR=\""$(datadir)"\" \
$(TOTEM_PLPARSER_CFLAGS) \
- $(HAL_CFLAGS) \
$(RHYTHMBOX_CFLAGS) \
$(NO_STRICT_ALIASING_CFLAGS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]