Commit cba92761 authored by Dominik Haumann's avatar Dominik Haumann

Better support for mtp devices

This patch removes the call of LIBMTP_Check_Specific_Device(), since
it is generally not adviced to use it at all, see [1]. Instead, it
should only be used in case LIBMTP_Detect_Raw_Devices() fails.
Looking into other mtp implementations (gvfs, smtpfs) revelas, that
LIBMTP_Check_Specific_Device() is not used at all. Therefore,
this patch brings the kio-mtp implementation more in line with
other implmentations.

It was confirmed [2] that with this patch some Windows Phones (e.g.
Lumia 630) get properly detected and work as expected.

  [1] https://sourceforge.net/p/libmtp/mailman/message/34948820/
  [2] https://www.reddit.com/r/kde/comments/4aggg0

REVIEW: 127386
parent 7dac649e
......@@ -107,22 +107,23 @@ DeviceCache::~DeviceCache()
void DeviceCache::checkDevice(Solid::Device solidDevice)
{
Solid::GenericInterface *iface = solidDevice.as<Solid::GenericInterface>();
QMap<QString, QVariant> properties = iface->allProperties();
int solidBusNum = properties.value(QLatin1String("BUSNUM")).toInt();
int solidDevNum = properties.value(QLatin1String("DEVNUM")).toInt();
if (!udiCache.contains(solidDevice.udi())) {
qCDebug(LOG_KIO_MTP) << "new device, getting raw devices";
int isMtpDevice = LIBMTP_Check_Specific_Device(solidBusNum, solidDevNum);
Solid::GenericInterface *iface = solidDevice.as<Solid::GenericInterface>();
if (!iface) {
qCDebug( LOG_KIO_MTP ) << "Solid device " << solidDevice.udi() << " has NOT a Solid::GenericInterface";
return;
}
if (isMtpDevice == 1 && !udiCache.contains(solidDevice.udi())) {
qCDebug(LOG_KIO_MTP) << "new device, getting raw devices";
const QMap<QString, QVariant> &properties = iface->allProperties();
const uint32_t solidBusNum = properties.value ( QLatin1String ( "BUSNUM" ) ).toUInt();
const uint32_t solidDevNum = properties.value ( QLatin1String ( "DEVNUM" ) ).toUInt();
LIBMTP_raw_device_t *rawdevices = 0;
int numrawdevices;
LIBMTP_error_number_t err;
QMap<QString, LIBMTP_raw_device_t *> devices;
err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
switch (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment