[rhythmbox] mpid: provide access to device serial numbers
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] mpid: provide access to device serial numbers
- Date: Sat, 12 Dec 2009 01:12:19 +0000 (UTC)
commit dd6c8fe6163bd05c689f893c8c125bef4eb16881
Author: Jonathan Matthew <jonathan d14n org>
Date: Sat Dec 12 11:11:44 2009 +1000
mpid: provide access to device serial numbers
lib/libmediaplayerid/mediaplayerid.h | 1 +
lib/libmediaplayerid/mpid-device.c | 11 +++++++++++
lib/libmediaplayerid/mpid-hal.c | 8 ++++++++
lib/libmediaplayerid/mpid-udev.c | 3 ++-
4 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/lib/libmediaplayerid/mediaplayerid.h b/lib/libmediaplayerid/mediaplayerid.h
index 66905d2..4e6c9e1 100644
--- a/lib/libmediaplayerid/mediaplayerid.h
+++ b/lib/libmediaplayerid/mediaplayerid.h
@@ -80,6 +80,7 @@ struct _MPIDDevice
char *model;
char *vendor;
char *fs_uuid;
+ char *serial;
char *drive_type;
gboolean requires_eject;
diff --git a/lib/libmediaplayerid/mpid-device.c b/lib/libmediaplayerid/mpid-device.c
index 7b0df29..79c31ad 100644
--- a/lib/libmediaplayerid/mpid-device.c
+++ b/lib/libmediaplayerid/mpid-device.c
@@ -36,6 +36,7 @@ enum
PROP_MODEL,
PROP_VENDOR,
PROP_FS_UUID,
+ PROP_SERIAL,
PROP_DRIVE_TYPE,
PROP_REQUIRES_EJECT,
PROP_ACCESS_PROTOCOLS,
@@ -212,6 +213,9 @@ mpid_device_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case PROP_FS_UUID:
g_value_set_string (value, device->fs_uuid);
break;
+ case PROP_SERIAL:
+ g_value_set_string (value, device->serial);
+ break;
case PROP_DRIVE_TYPE:
g_value_set_string (value, device->drive_type);
break;
@@ -351,6 +355,13 @@ mpid_device_class_init (MPIDDeviceClass *klass)
NULL,
G_PARAM_READABLE));
g_object_class_install_property (object_class,
+ PROP_SERIAL,
+ g_param_spec_string ("serial",
+ "device serial ID",
+ "device serial ID",
+ NULL,
+ G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
PROP_DRIVE_TYPE,
g_param_spec_string ("drive-type",
"drive type",
diff --git a/lib/libmediaplayerid/mpid-hal.c b/lib/libmediaplayerid/mpid-hal.c
index 16bd850..3996892 100644
--- a/lib/libmediaplayerid/mpid-hal.c
+++ b/lib/libmediaplayerid/mpid-hal.c
@@ -112,6 +112,14 @@ find_portable_audio_player_udi (LibHalContext *context, MPIDDevice *device, cons
while (!libhal_device_query_capability (context, udi, "portable_audio_player", &error) && !dbus_error_is_set (&error)) {
char *new_udi;
+ /* look for the device serial along the way */
+ if (device->serial == NULL) {
+ char *parent_udi = libhal_device_get_property_string (context, udi, "info.parent", &error);
+ device->serial = libhal_device_get_property_string (context, parent_udi, "storage.serial", &error);
+ free_dbus_error ("finding device serial", &error);
+ g_free (parent_udi);
+ }
+
new_udi = libhal_device_get_property_string (context, udi, "info.parent", &error);
if (dbus_error_is_set (&error))
break;
diff --git a/lib/libmediaplayerid/mpid-udev.c b/lib/libmediaplayerid/mpid-udev.c
index aee4efa..5e6fcd9 100644
--- a/lib/libmediaplayerid/mpid-udev.c
+++ b/lib/libmediaplayerid/mpid-udev.c
@@ -45,10 +45,11 @@ mpid_device_db_lookup (MPIDDevice *device)
udevice = g_udev_client_query_by_device_file (client, devpath);
if (udevice != NULL) {
- /* get vendor and model names and the UUID */
+ /* get vendor and model names, UUID, and serial */
device->model = g_strdup (g_udev_device_get_property (udevice, "ID_MODEL"));
device->vendor = g_strdup (g_udev_device_get_property (udevice, "ID_VENDOR"));
device->fs_uuid = g_strdup (g_udev_device_get_property (udevice, "ID_FS_UUID"));
+ device->serial = g_strdup (g_udev_device_get_property (udevice, "ID_SERIAL"));
/* get media player information */
device_file = g_udev_device_get_property (udevice, "ID_MEDIA_PLAYER");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]