8#include "imobiledevice.h"
10#include <QCoreApplication>
13#include "imobile_debug.h"
16#include "imobileportablemediaplayer.h"
18#include <libimobiledevice/libimobiledevice.h>
19#include <libimobiledevice/lockdown.h>
21using namespace Solid::Backends::IMobile;
23IMobileDevice::IMobileDevice(
const QString &udi)
27 const QString deviceId = udi.
mid(udiPrefix().length() + 1);
31 if (ret != IDEVICE_E_SUCCESS) {
32 qCWarning(IMOBILE) <<
"Failed to create device instance for" << deviceId << ret;
36 auto deviceCleanup = qScopeGuard([device] {
40 lockdownd_client_t lockdowndClient =
nullptr;
41 auto lockdownRet = lockdownd_client_new(device, &lockdowndClient,
"kde_solid_imobile");
42 if (lockdownRet != LOCKDOWN_E_SUCCESS || !lockdowndClient) {
43 qCWarning(IMOBILE) <<
"Failed to create lockdownd client for" << deviceId;
47 auto lockdowndClientCleanup = qScopeGuard([lockdowndClient] {
48 lockdownd_client_free(lockdowndClient);
52 lockdownRet = lockdownd_get_device_name(lockdowndClient, &name);
53 if (lockdownRet != LOCKDOWN_E_SUCCESS) {
54 qCWarning(IMOBILE) <<
"Failed to get device name for" << deviceId << lockdownRet;
60 plist_t deviceClassEntry =
nullptr;
61 lockdownRet = lockdownd_get_value(lockdowndClient,
nullptr ,
"DeviceClass", &deviceClassEntry);
62 if (lockdownRet != LOCKDOWN_E_SUCCESS) {
63 qCWarning(IMOBILE) <<
"Failed to get device class for" << deviceId << lockdownRet;
65 char *deviceClass =
nullptr;
66 plist_get_string_val(deviceClassEntry, &deviceClass);
74IMobileDevice::~IMobileDevice()
78QString IMobileDevice::udi()
const
83QString IMobileDevice::parentUdi()
const
88QString IMobileDevice::vendor()
const
93QString IMobileDevice::product()
const
102QString IMobileDevice::icon()
const
105 return QStringLiteral(
"multimedia-player-apple-ipod-touch");
107 return QStringLiteral(
"computer-apple-ipad");
109 return QStringLiteral(
"phone-apple-iphone");
118QString IMobileDevice::description()
const
129 case Solid::DeviceInterface::PortableMediaPlayer:
139 if (!queryDeviceInterface(type)) {
144 case Solid::DeviceInterface::PortableMediaPlayer:
145 return new PortableMediaPlayer(
this);
153#include "moc_imobiledevice.cpp"
Type
This enum type defines the type of device interface that a Device can have.
This class allows applications to deal with devices available in the underlying system.
QString name(GameStandardAction id)
const char * constData() const const
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString fromUtf8(QByteArrayView str)
QString mid(qsizetype position, qsizetype n) const const
QByteArray toUtf8() const const