=== modified file 'plugins/ipod/__init__.py' --- plugins/ipod/__init__.py 2009-02-20 17:36:26 +0000 +++ plugins/ipod/__init__.py 2009-08-02 09:12:02 +0000 @@ -24,6 +24,7 @@ import gpod import dbus + # iPod device class class iPod( Device ): @@ -68,7 +69,7 @@ Connect (or in this case 'mount' the ipod) """ self.connected = True - self.mountpoint = self.volume.GetProperty( "volume.mount_point" ) + self.mountpoint = str( self.volume.GetProperty( "volume.mount_point" ) ) self.open_db() self.populate_collection() @@ -82,30 +83,43 @@ self.bus = None def get_udis(self, hal): + ret = [] # Based on the code from: https://bugs.launchpad.net/exaile/+bug/135915 self.bus = hal.bus # BAD - ret = [] - dev_udi_list = hal.hal.FindDeviceStringMatch ('portable_audio_player.type', 'ipod') + # dev_udi_list = hal.hal.FindDeviceStringMatch ('portable_audio_player.type', 'ipod') + dev_udi_list = hal.hal.FindDeviceStringMatch ('info.category', 'portable_audio_player') for udi in dev_udi_list: - vol_udi_list = hal.hal.FindDeviceStringMatch ('info.parent', udi) - for vol_udi in vol_udi_list: - vol_obj = hal.bus.get_object ('org.freedesktop.Hal', vol_udi) - vol = dbus.Interface (vol_obj, 'org.freedesktop.Hal.Device') - # The first partition contains ipod firmware, which cannot be mounted - if int( vol.GetProperty('volume.partition.number') ) != 1: - ret.append( vol_udi ) + udiObj = hal.bus.get_object ('org.freedesktop.Hal', udi) + udiInt = dbus.Interface (udiObj, 'org.freedesktop.Hal.Device') + if udiInt.PropertyExists('info.product') and udiInt.GetProperty('info.product').lower() == 'ipod': + volList = hal.hal.FindDeviceStringMatch ('info.parent', udi) + for volUdi in volList: + volObj = hal.bus.get_object ('org.freedesktop.Hal', volUdi) + volInt = dbus.Interface (volObj, 'org.freedesktop.Hal.Device') + # The first partition contains ipod firmware, which cannot be mounted + if volInt.PropertyExists('volume.partition.number') and \ + int( volInt.GetProperty('volume.partition.number') ) != 1: + ret.append(volUdi) return ret def is_type( self, device, capabilities ): + result = 0 parent_udi = device.GetProperty( "info.parent" ) parent_proxy = self.bus.get_object( "org.freedesktop.Hal", parent_udi ) parent_iface = dbus.Interface( parent_proxy, 'org.freedesktop.Hal.Device' ) - parent_protocols = parent_iface.GetProperty( "portable_audio_player.access_method.protocols" ) - return ( "ipod" in parent_protocols ) + try: + parent_protocols = parent_iface.GetProperty( "portable_audio_player.access_method.protocols" ) + if "ipod" in parent_protocols: + result = 10 + except dbus.DBusException: + result = 0 + + return result def device_from_udi( self, hal, udi ): device_proxy = hal.bus.get_object( "org.freedesktop.Hal", udi ) device_iface = dbus.Interface( device_proxy, 'org.freedesktop.Hal.Device' ) + return iPod( device_iface ) ipod_provider = None