[banshee/1.5.1-fixes: 25/56] Look for android in DAP product/name/id



commit a4f458a4d814a5e31863e316a91fda97d3dd9b3c
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Nov 6 16:22:45 2009 -0800

    Look for android in DAP product/name/id
    
    Hopefully will let us support Android devices generically, without
    having to have vendor/product ids for every new device.

 .../Banshee.Dap.MassStorage/DeviceMapper.cs        |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/DeviceMapper.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/DeviceMapper.cs
index 1818988..043e877 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/DeviceMapper.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/DeviceMapper.cs
@@ -37,10 +37,12 @@ namespace Banshee.Dap.MassStorage
     {
         public static MassStorageDevice Map (MassStorageSource source)
         {
+            var u = source.UsbDevice;
+
             foreach (VendorProductDeviceNode node in AddinManager.GetExtensionNodes (
                 "/Banshee/Dap/MassStorage/Device")) {
-                short vendor_id = (short)source.UsbDevice.VendorId;
-                short product_id = (short)source.UsbDevice.ProductId;
+                short vendor_id = (short)u.VendorId;
+                short product_id = (short)u.ProductId;
                 
                 if (node.Matches (vendor_id, product_id)) {
                     CustomMassStorageDevice device = (CustomMassStorageDevice)node.CreateInstance (); 
@@ -51,6 +53,17 @@ namespace Banshee.Dap.MassStorage
                     return device;
                 }
             }
+
+            // Look for 'Android' in the product/name/uuid/serial of the device to identify
+            // other Android devices
+            foreach (var str in new string [] { u.Product, u.Name, u.Uuid, u.Serial }) {
+                if (str != null && str.ToLower ().Contains ("android")) {
+                    return new AndroidDevice () {
+                        VendorProductInfo = new VendorProductInfo (u.Vendor, u.Name ?? u.Product, (short)u.VendorId, (short)u.ProductId),
+                        Source = source
+                    };
+                }
+            }
             
             return new MassStorageDevice (source);
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]