Merge branch 'master' into filebrowsing
Conflicts: libkdeconnect/dbusinterfaces.cpp
This commit is contained in:
commit
781c41da5b
5 changed files with 46 additions and 30 deletions
|
@ -123,22 +123,17 @@ void Daemon::forceOnNetworkChange()
|
|||
}
|
||||
}
|
||||
|
||||
QStringList Daemon::visibleDevices()
|
||||
QStringList Daemon::devices(bool onlyReachable, bool onlyVisible)
|
||||
{
|
||||
QStringList ret;
|
||||
Q_FOREACH(Device* device, mDevices) {
|
||||
if (device->isReachable()) {
|
||||
if (onlyReachable && !device->isReachable()) continue;
|
||||
if (onlyVisible && !device->isPaired()) continue;
|
||||
ret.append(device->id());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList Daemon::devices()
|
||||
{
|
||||
return mDevices.keys();
|
||||
}
|
||||
|
||||
void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl)
|
||||
{
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@ public Q_SLOTS:
|
|||
Q_SCRIPTABLE void forceOnNetworkChange();
|
||||
|
||||
//Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
|
||||
Q_SCRIPTABLE QStringList devices(); //All known devices
|
||||
Q_SCRIPTABLE QStringList visibleDevices(); //Only visible devices
|
||||
Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyVisible = false);
|
||||
|
||||
Q_SIGNALS:
|
||||
Q_SCRIPTABLE void deviceAdded(const QString& id);
|
||||
|
|
|
@ -27,34 +27,62 @@ DaemonDbusInterface::DaemonDbusInterface(QObject* parent)
|
|||
|
||||
}
|
||||
|
||||
DaemonDbusInterface::~DaemonDbusInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceDbusInterface::DeviceDbusInterface(const QString& id, QObject* parent)
|
||||
: OrgKdeKdeconnectDeviceInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceDbusInterface::~DeviceDbusInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceBatteryDbusInterface::DeviceBatteryDbusInterface(const QString& id, QObject* parent)
|
||||
: OrgKdeKdeconnectDeviceBatteryInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceBatteryDbusInterface::~DeviceBatteryDbusInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceNotificationsDbusInterface::DeviceNotificationsDbusInterface(const QString& id, QObject* parent)
|
||||
: OrgKdeKdeconnectDeviceNotificationsInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceNotificationsDbusInterface::~DeviceNotificationsDbusInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NotificationDbusInterface::NotificationDbusInterface(const QString& deviceId, const QString& notificationId, QObject* parent)
|
||||
: OrgKdeKdeconnectDeviceNotificationsNotificationInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+deviceId+"/notifications/"+notificationId, QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NotificationDbusInterface::~NotificationDbusInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SftpDbusInterface::SftpDbusInterface(const QString& id, QObject* parent)
|
||||
: OrgKdeKdeconnectDeviceSftpInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + id + "/sftp", QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SftpDbusInterface::~SftpDbusInterface() {}
|
||||
SftpDbusInterface::~SftpDbusInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class KDECONNECT_EXPORT DaemonDbusInterface
|
|||
Q_OBJECT
|
||||
public:
|
||||
DaemonDbusInterface(QObject* parent = 0);
|
||||
|
||||
virtual ~DaemonDbusInterface();
|
||||
};
|
||||
|
||||
class KDECONNECT_EXPORT DeviceDbusInterface
|
||||
|
@ -49,7 +49,7 @@ class KDECONNECT_EXPORT DeviceDbusInterface
|
|||
Q_OBJECT
|
||||
public:
|
||||
DeviceDbusInterface(const QString& deviceId, QObject* parent = 0);
|
||||
|
||||
virtual ~DeviceDbusInterface();
|
||||
};
|
||||
|
||||
class KDECONNECT_EXPORT DeviceBatteryDbusInterface
|
||||
|
@ -58,7 +58,7 @@ class KDECONNECT_EXPORT DeviceBatteryDbusInterface
|
|||
Q_OBJECT
|
||||
public:
|
||||
DeviceBatteryDbusInterface(const QString& deviceId, QObject* parent = 0);
|
||||
|
||||
virtual ~DeviceBatteryDbusInterface();
|
||||
};
|
||||
|
||||
class KDECONNECT_EXPORT DeviceNotificationsDbusInterface
|
||||
|
@ -67,7 +67,7 @@ class KDECONNECT_EXPORT DeviceNotificationsDbusInterface
|
|||
Q_OBJECT
|
||||
public:
|
||||
DeviceNotificationsDbusInterface(const QString& deviceId, QObject* parent = 0);
|
||||
|
||||
virtual ~DeviceNotificationsDbusInterface();
|
||||
};
|
||||
|
||||
class KDECONNECT_EXPORT NotificationDbusInterface
|
||||
|
@ -76,7 +76,7 @@ class KDECONNECT_EXPORT NotificationDbusInterface
|
|||
Q_OBJECT
|
||||
public:
|
||||
NotificationDbusInterface(const QString& deviceId, const QString& notificationId, QObject* parent = 0);
|
||||
|
||||
virtual ~NotificationDbusInterface();
|
||||
};
|
||||
|
||||
class KDECONNECT_EXPORT SftpDbusInterface
|
||||
|
|
|
@ -112,27 +112,21 @@ void DevicesModel::refreshDeviceList()
|
|||
return;
|
||||
}
|
||||
|
||||
QDBusPendingReply<QStringList> pendingDeviceIds = m_dbusInterface->devices();
|
||||
pendingDeviceIds.waitForFinished();
|
||||
if (pendingDeviceIds.isError()) return;
|
||||
const QStringList& deviceIds = pendingDeviceIds.value();
|
||||
|
||||
Q_FOREACH(const QString& id, deviceIds) {
|
||||
|
||||
DeviceDbusInterface* deviceDbusInterface = new DeviceDbusInterface(id,this);
|
||||
|
||||
bool onlyPaired = (m_displayFilter & StatusPaired);
|
||||
if (onlyPaired && !deviceDbusInterface->isPaired()) continue;
|
||||
bool onlyReachable = (m_displayFilter & StatusReachable);
|
||||
if (onlyReachable && !deviceDbusInterface->isReachable()) continue;
|
||||
|
||||
QDBusPendingReply<QStringList> pendingDeviceIds = m_dbusInterface->devices(onlyReachable, onlyPaired);
|
||||
pendingDeviceIds.waitForFinished();
|
||||
if (pendingDeviceIds.isError()) return;
|
||||
|
||||
const QStringList& deviceIds = pendingDeviceIds.value();
|
||||
Q_FOREACH(const QString& id, deviceIds) {
|
||||
int firstRow = m_deviceList.size();
|
||||
int lastRow = firstRow;
|
||||
|
||||
beginInsertRows(QModelIndex(), firstRow, lastRow);
|
||||
m_deviceList.append(deviceDbusInterface);
|
||||
m_deviceList.append(new DeviceDbusInterface(id,this));
|
||||
endInsertRows();
|
||||
|
||||
}
|
||||
|
||||
Q_EMIT dataChanged(index(0), index(m_deviceList.size()));
|
||||
|
|
Loading…
Reference in a new issue