[banshee] [Hardware.Gio] Implement support for IUsbdevice.ResolveRootUsbDevice
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Hardware.Gio] Implement support for IUsbdevice.ResolveRootUsbDevice
- Date: Fri, 13 Aug 2010 22:51:56 +0000 (UTC)
commit d61618da902846524e4cf9323b405553c5d73f58
Author: Alan McGovern <alan mcgovern gmail com>
Date: Sat Jul 24 16:21:06 2010 +0100
[Hardware.Gio] Implement support for IUsbdevice.ResolveRootUsbDevice
Add support for returning an IUsbDevice for a given IDevice.
.../Banshee.Gio/Banshee.Hardware.Gio/Device.cs | 2 +-
.../Banshee.Gio/Banshee.Hardware.Gio/UsbDevice.cs | 24 +++++++++++++++++++-
2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Device.cs b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Device.cs
index 0095a20..8170bb6 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Device.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/Device.cs
@@ -81,7 +81,7 @@ namespace Banshee.Hardware.Gio
public IUsbDevice ResolveRootUsbDevice ()
{
- return null;
+ return UsbDevice.ResolveRootDevice (this);
}
public bool PropertyExists (string key)
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/UsbDevice.cs b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/UsbDevice.cs
index bcbc7af..316dd4a 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/UsbDevice.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/UsbDevice.cs
@@ -41,11 +41,33 @@ namespace Banshee.Hardware.Gio
const string UdevVendorId = "ID_VENDOR_ID";
const string UdevProductId = "ID_MODEL_ID";
- public IUsbDevice ResolveRootUsbDevice ()
+ internal static IUsbDevice ResolveRootDevice (IDevice device)
{
+ // First check if the supplied device is an IUsbDevice itself
+ var result = Resolve (device);
+ if (result != null) {
+ return result;
+ }
+
+ // Now walk up the device tree to see if we can find one.
+ IRawDevice raw = device as IRawDevice;
+ if (raw != null) {
+ var parent = raw.Device.UdevMetadata.Parent;
+ while (parent != null) {
+ if (parent.PropertyExists (UdevUsbBusNumber) && parent.PropertyExists (UdevUsbDeviceNumber)) {
+ return new UsbDevice (new RawUsbDevice (raw.Device.Manager, raw.Device.GioMetadata, parent));
+ }
+ parent = parent.Parent;
+ }
+ }
return null;
}
+ public IUsbDevice ResolveRootUsbDevice ()
+ {
+ return this;
+ }
+
public static int GetBusNumber (IUsbDevice device)
{
var raw = device as IRawDevice;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]