rhythmbox r6283 - in trunk: . lib plugins/generic-player plugins/ipod
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: rhythmbox r6283 - in trunk: . lib plugins/generic-player plugins/ipod
- Date: Sat, 11 Apr 2009 12:22:08 +0000 (UTC)
Author: hadess
Date: Sat Apr 11 12:22:08 2009
New Revision: 6283
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6283&view=rev
Log:
2009-04-11 Bastien Nocera <hadess hadess net>
* lib/Makefile.am:
* lib/rb-util.c (rb_gvolume_get_udi):
* lib/rb-util.h: Add rb_gvolume_get_udi utility function to
get a UDI from a GVolume, even if the gvfs volume monitor doesn't
use HAL, or export the UDI information (eg. the DeviceKit-disks
gvfs monitor)
* plugins/generic-player/rb-generic-player-source.c
(get_hal_udi_for_player):
* plugins/generic-player/rb-nokia770-source.c (volume_is_nokia770),
(rb_nokia770_is_mount_player):
* plugins/generic-player/rb-psp-source.c (volume_is_psp),
(rb_psp_is_mount_player):
* plugins/ipod/rb-ipod-helpers.c (volume_is_ipod),
(rb_ipod_helpers_is_ipod): Use rb_gvolume_get_udi() to get the UDI
of the devices
(Closes: #578514)
Modified:
trunk/ChangeLog
trunk/lib/Makefile.am
trunk/lib/rb-util.c
trunk/lib/rb-util.h
trunk/plugins/generic-player/rb-generic-player-source.c
trunk/plugins/generic-player/rb-nokia770-source.c
trunk/plugins/generic-player/rb-psp-source.c
trunk/plugins/ipod/rb-ipod-helpers.c
Modified: trunk/lib/Makefile.am
==============================================================================
--- trunk/lib/Makefile.am (original)
+++ trunk/lib/Makefile.am Sat Apr 11 12:22:08 2009
@@ -49,9 +49,10 @@
-I$(top_srcdir) \
-I$(top_srcdir)/widgets \
$(SOUP_CFLAGS) \
+ $(HAL_CFLAGS) \
$(RHYTHMBOX_CFLAGS)
-librb_la_LIBADD = $(SOUP_LIBS) -lSM -lICE
+librb_la_LIBADD = $(SOUP_LIBS) $(HAL_LIBS) -lSM -lICE
BUILT_SOURCES=
Modified: trunk/lib/rb-util.c
==============================================================================
--- trunk/lib/rb-util.c (original)
+++ trunk/lib/rb-util.c Sat Apr 11 12:22:08 2009
@@ -38,6 +38,11 @@
#include <gobject/gvaluecollector.h>
#include <gio/gio.h>
+#ifdef HAVE_HAL
+#include <libhal.h>
+#include <dbus/dbus.h>
+#endif
+
#include "rb-util.h"
#include "rb-debug.h"
@@ -991,3 +996,41 @@
return gdk_pixbuf_scale_simple (pixbuf, d_width, d_height, GDK_INTERP_BILINEAR);
}
+#ifdef HAVE_HAL
+char *
+rb_gvolume_get_udi (GVolume *volume, gpointer ctx)
+{
+ char *udi, *dev, **udis;
+ int num_udis;
+
+ g_return_val_if_fail (volume != NULL, NULL);
+ g_return_val_if_fail (G_IS_VOLUME (volume), NULL);
+ g_return_val_if_fail (ctx != NULL, NULL);
+
+ udi = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
+ if (udi != NULL)
+ return udi;
+
+ dev = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ udis = libhal_manager_find_device_string_match ((LibHalContext *) ctx,
+ "block.device", dev,
+ &num_udis, NULL);
+
+ if (udis == NULL || num_udis < 1) {
+ libhal_free_string_array (udis);
+ return NULL;
+ }
+
+ udi = g_strdup (udis[0]);
+ libhal_free_string_array (udis);
+
+ return udi;
+}
+#else
+char *
+rb_gvolume_get_udi (GVolume *volume, gpointer ctx)
+{
+ return NULL;
+}
+#endif /* HAVE_HAL */
+
Modified: trunk/lib/rb-util.h
==============================================================================
--- trunk/lib/rb-util.h (original)
+++ trunk/lib/rb-util.h Sat Apr 11 12:22:08 2009
@@ -100,6 +100,8 @@
GdkPixbuf *rb_scale_pixbuf_to_size (GdkPixbuf *pixbuf,
GtkIconSize size);
+char *rb_gvolume_get_udi (GVolume *volume, gpointer ctx);
+
G_END_DECLS
#endif /* __RB_UTIL_H */
Modified: trunk/plugins/generic-player/rb-generic-player-source.c
==============================================================================
--- trunk/plugins/generic-player/rb-generic-player-source.c (original)
+++ trunk/plugins/generic-player/rb-generic-player-source.c Sat Apr 11 12:22:08 2009
@@ -1468,7 +1468,7 @@
return NULL;
}
- udi = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
+ udi = rb_gvolume_get_udi (volume, ctx);
if (udi == NULL) {
g_object_unref (volume);
Modified: trunk/plugins/generic-player/rb-nokia770-source.c
==============================================================================
--- trunk/plugins/generic-player/rb-nokia770-source.c (original)
+++ trunk/plugins/generic-player/rb-nokia770-source.c Sat Apr 11 12:22:08 2009
@@ -136,14 +136,12 @@
}
-#ifdef HAVE_HAL
-
static gboolean
-hal_udi_is_nokia770 (const char *udi)
+volume_is_nokia770 (GVolume *volume)
{
LibHalContext *ctx;
DBusConnection *conn;
- char *parent_udi;
+ char *parent_udi, *udi;
char *parent_name;
gboolean result;
DBusError error;
@@ -153,6 +151,7 @@
dbus_error_init (&error);
conn = NULL;
+ udi = NULL;
parent_udi = NULL;
parent_name = NULL;
@@ -169,6 +168,10 @@
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,
@@ -206,6 +209,7 @@
}
end:
+ g_free (udi);
g_free (parent_name);
g_free (parent_udi);
@@ -225,24 +229,19 @@
return result;
}
-#endif
gboolean
rb_nokia770_is_mount_player (GMount *mount)
{
- gboolean result = FALSE;
- gchar *str;
+ gboolean result;
GVolume *volume;
volume = g_mount_get_volume (mount);
- if (volume != NULL) {
- str = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
- if (str != NULL) {
- result = hal_udi_is_nokia770 (str);
- g_free (str);
- }
- g_object_unref (volume);
- }
+ if (volume == NULL)
+ return FALSE;
+
+ result = volume_is_nokia770 (volume);
+ g_object_unref (volume);
return result;
}
Modified: trunk/plugins/generic-player/rb-psp-source.c
==============================================================================
--- trunk/plugins/generic-player/rb-psp-source.c (original)
+++ trunk/plugins/generic-player/rb-psp-source.c Sat Apr 11 12:22:08 2009
@@ -272,11 +272,11 @@
}
static gboolean
-hal_udi_is_psp (const char *udi)
+volume_is_psp (GVolume *volume)
{
LibHalContext *ctx;
DBusConnection *conn;
- char *parent_udi;
+ char *parent_udi, *udi;
char *parent_name;
gboolean result;
DBusError error;
@@ -285,6 +285,7 @@
result = FALSE;
dbus_error_init (&error);
+ udi = NULL;
parent_udi = NULL;
parent_name = NULL;
@@ -302,6 +303,10 @@
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);
@@ -318,6 +323,7 @@
}
end:
+ g_free (udi);
g_free (parent_udi);
g_free (parent_name);
@@ -342,19 +348,15 @@
rb_psp_is_mount_player (GMount *mount)
{
GVolume *volume;
- gboolean result = FALSE;
+ gboolean result;
volume = g_mount_get_volume (mount);
- if (volume != NULL) {
- char *str;
+ if (volume == NULL)
+ return FALSE;
+
+ result = volume_is_psp (volume);
+ g_object_unref (volume);
- str = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
- if (str != NULL) {
- result = hal_udi_is_psp (str);
- g_free (str);
- }
- g_object_unref (volume);
- }
return result;
}
Modified: trunk/plugins/ipod/rb-ipod-helpers.c
==============================================================================
--- trunk/plugins/ipod/rb-ipod-helpers.c (original)
+++ trunk/plugins/ipod/rb-ipod-helpers.c Sat Apr 11 12:22:08 2009
@@ -44,6 +44,7 @@
#endif
#include "rb-ipod-helpers.h"
+#include "rb-util.h"
#include "rb-debug.h"
#include "rb-dialog.h"
@@ -402,11 +403,11 @@
#ifdef HAVE_HAL
static gboolean
-hal_udi_is_ipod (const char *udi)
+volume_is_ipod (GVolume *volume)
{
LibHalContext *ctx;
DBusConnection *conn;
- char *parent_udi;
+ char *parent_udi, *udi;
char **methods_list;
guint i;
gboolean result;
@@ -416,6 +417,7 @@
result = FALSE;
dbus_error_init (&error);
+ udi = NULL;
conn = NULL;
parent_udi = NULL;
methods_list = NULL;
@@ -436,6 +438,10 @@
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);
@@ -453,6 +459,7 @@
}
end:
+ g_free (udi);
g_free (parent_udi);
libhal_free_string_array (methods_list);
@@ -476,24 +483,16 @@
gboolean
rb_ipod_helpers_is_ipod (GMount *mount)
{
- gchar *udi;
- gboolean result;
+ gboolean result;
GVolume *volume;
volume = g_mount_get_volume (mount);
if (volume == NULL)
return FALSE;
- udi = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
+ result = volume_is_ipod (volume);
g_object_unref (volume);
- if (udi == NULL) {
- return FALSE;
- }
-
- result = hal_udi_is_ipod (udi);
- g_free (udi);
-
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]