QString iLister::MakeFriendlyName(const QString& id) { QString name = LockAndGetDeviceInfo(id, &DeviceInfo::name); if (!name.isEmpty()) { return name; } QString model_id = LockAndGetDeviceInfo(id, &DeviceInfo::product_type); if (model_id.startsWith("iPhone")) { QString version = model_id.right(3); QChar major = version[0]; QChar minor = version[2]; if (major == '1' && minor == '1') { return "iPhone"; } if (major == '1' && minor == '2') { return "iPhone 3G"; } if (major == '2' && minor == '1') { return "iPhone 3GS"; } if (major == '3' && minor == '1') { return "iPhone 4"; } } else if (model_id.startsWith("iPod")) { return "iPod Touch"; } else if (model_id.startsWith("iPad")) { return "iPad"; } return model_id; }
QVariantList DeviceKitLister::DeviceIcons(const QString &id) { QString path = LockAndGetDeviceInfo(id, &DeviceData::device_mount_paths)[0]; return QVariantList() << GuessIconForPath(path) << GuessIconForModel(DeviceManufacturer(id), DeviceModel(id)) << LockAndGetDeviceInfo(id, &DeviceData::device_presentation_icon_name); }
void DeviceKitLister::UnmountDevice(const QString& id) { QString path = LockAndGetDeviceInfo(id, &DeviceData::dbus_path); OrgFreedesktopUDisksDeviceInterface device( OrgFreedesktopUDisksInterface::staticInterfaceName(), path, QDBusConnection::systemBus()); if (!device.isValid()) { qLog(Warning) << "Error connecting to the device interface on" << path; return; } // Get the device's parent drive QString drive_path = device.partitionSlave().path(); OrgFreedesktopUDisksDeviceInterface drive( OrgFreedesktopUDisksInterface::staticInterfaceName(), drive_path, QDBusConnection::systemBus()); if (!drive.isValid()) { qLog(Warning) << "Error connecting to the drive interface on" << drive_path; return; } // Unmount the filesystem QDBusPendingReply<> reply = device.FilesystemUnmount(QStringList()); reply.waitForFinished(); // Eject the drive drive.DriveEject(QStringList()); // Don't bother waiting for the eject to finish }
QVariantList WmdmLister::DeviceIcons(const QString& id) { QPixmap pixmap = LockAndGetDeviceInfo(id, &DeviceInfo::icon_); if (pixmap.isNull()) return QVariantList(); return QVariantList() << pixmap; }
QList<QUrl> iLister::MakeDeviceUrls(const QString& id) { QList<QUrl> ret; QString uuid = LockAndGetDeviceInfo(id, &DeviceInfo::uuid); if (uuid.isEmpty()) return ret; ret << QUrl("afc://" + uuid + "/"); return ret; }
QList<QUrl> WmdmLister::MakeDeviceUrls(const QString& id) { QList<QUrl> ret; QString mount_point = LockAndGetDeviceInfo(id, &DeviceInfo::mount_point_); if (!mount_point.isEmpty()) { ret << MakeUrlFromLocalPath(mount_point); } QUrl wmdm_url; wmdm_url.setScheme("wmdm"); wmdm_url.setPath(id); ret << wmdm_url; return ret; }
QVariantMap iLister::DeviceHardwareInfo(const QString& id) { QVariantMap ret; ret[tr("Color")] = LockAndGetDeviceInfo(id, &DeviceInfo::colour); ret["IMEI"] = LockAndGetDeviceInfo(id, &DeviceInfo::imei); ret[tr("Password Protected")] = LockAndGetDeviceInfo(id, &DeviceInfo::password_protected); ret[tr("Timezone")] = LockAndGetDeviceInfo(id, &DeviceInfo::timezone); ret[tr("WiFi MAC Address")] = LockAndGetDeviceInfo(id, &DeviceInfo::wifi_mac); ret[tr("Bluetooth MAC Address")] = LockAndGetDeviceInfo(id, &DeviceInfo::bt_mac); return ret; }
QString WmdmLister::DeviceModel(const QString& id) { return LockAndGetDeviceInfo(id, &DeviceInfo::name_); }
QString DeviceKitLister::DeviceManufacturer(const QString &id) { return LockAndGetDeviceInfo(id, &DeviceData::drive_vendor); }
QList<QUrl> DeviceKitLister::MakeDeviceUrls(const QString& id) { QString mount_point = LockAndGetDeviceInfo( id, &DeviceData::device_mount_paths)[0]; return QList<QUrl>() << MakeUrlFromLocalPath(mount_point); }
QString WmdmLister::DeviceCanonicalName(const QString& id) { return LockAndGetDeviceInfo(id, &DeviceInfo::canonical_name_); }
quint64 DeviceKitLister::DeviceCapacity(const QString &id) { return LockAndGetDeviceInfo(id, &DeviceData::device_size); }
quint64 DeviceKitLister::DeviceFreeSpace(const QString &id) { return LockAndGetDeviceInfo(id, &DeviceData::free_space); }
quint64 GioLister::DeviceFreeSpace(const QString &id) { return LockAndGetDeviceInfo(id, &DeviceInfo::filesystem_free); }
QString DeviceKitLister::DeviceModel(const QString &id) { return LockAndGetDeviceInfo(id, &DeviceData::drive_model); }
quint64 GioLister::DeviceCapacity(const QString &id) { return LockAndGetDeviceInfo(id, &DeviceInfo::filesystem_size); }
QString WmdmLister::DeviceManufacturer(const QString& id) { return LockAndGetDeviceInfo(id, &DeviceInfo::manufacturer_); }
quint64 iLister::DeviceFreeSpace(const QString& id) { return LockAndGetDeviceInfo(id, &DeviceInfo::free_bytes); }
quint64 iLister::DeviceCapacity(const QString& id) { return LockAndGetDeviceInfo(id, &DeviceInfo::total_bytes); }
QString iLister::DeviceModel(const QString& id) { return LockAndGetDeviceInfo(id, &DeviceInfo::product_type); }