From c70f2555f1745f46e90d558dc0af363d0f019cd6 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 16 Jan 2014 12:13:17 +0100 Subject: [PATCH 1/3] Addd destructors to Dbus interfaces They are needed to instantiate them as non-pointer variables --- libkdeconnect/dbusinterfaces.cpp | 38 +++++++++++++++++++++++++++++++- libkdeconnect/dbusinterfaces.h | 10 ++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/libkdeconnect/dbusinterfaces.cpp b/libkdeconnect/dbusinterfaces.cpp index 14ab9f092..d20511125 100644 --- a/libkdeconnect/dbusinterfaces.cpp +++ b/libkdeconnect/dbusinterfaces.cpp @@ -49,4 +49,40 @@ NotificationDbusInterface::NotificationDbusInterface(const QString& deviceId, co : OrgKdeKdeconnectDeviceNotificationsNotificationInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+deviceId+"/notifications/"+notificationId, QDBusConnection::sessionBus(), parent) { -} \ No newline at end of file +} + +SftpDbusInterface::SftpDbusInterface(const QString& id, QObject* parent) + : OrgKdeKdeconnectDeviceSftpInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + id + "/sftp", QDBusConnection::sessionBus(), parent) +{ + +} + +SftpDbusInterface::~SftpDbusInterface() +{ + +} + +DaemonDbusInterface::~DaemonDbusInterface() +{ + +} + +DeviceBatteryDbusInterface::~DeviceBatteryDbusInterface() +{ + +} + +DeviceDbusInterface::~DeviceDbusInterface() +{ + +} + +DeviceNotificationsDbusInterface::~DeviceNotificationsDbusInterface() +{ + +} + +NotificationDbusInterface::~NotificationDbusInterface() +{ + +} diff --git a/libkdeconnect/dbusinterfaces.h b/libkdeconnect/dbusinterfaces.h index 58dc50844..0ab09fa27 100644 --- a/libkdeconnect/dbusinterfaces.h +++ b/libkdeconnect/dbusinterfaces.h @@ -39,7 +39,7 @@ class KDECONNECT_EXPORT DaemonDbusInterface Q_OBJECT public: DaemonDbusInterface(QObject* parent = 0); - + virtual ~DaemonDbusInterface(); }; class KDECONNECT_EXPORT DeviceDbusInterface @@ -48,7 +48,7 @@ class KDECONNECT_EXPORT DeviceDbusInterface Q_OBJECT public: DeviceDbusInterface(const QString& deviceId, QObject* parent = 0); - + virtual ~DeviceDbusInterface(); }; class KDECONNECT_EXPORT DeviceBatteryDbusInterface @@ -57,7 +57,7 @@ class KDECONNECT_EXPORT DeviceBatteryDbusInterface Q_OBJECT public: DeviceBatteryDbusInterface(const QString& deviceId, QObject* parent = 0); - + virtual ~DeviceBatteryDbusInterface(); }; class KDECONNECT_EXPORT DeviceNotificationsDbusInterface @@ -66,7 +66,7 @@ class KDECONNECT_EXPORT DeviceNotificationsDbusInterface Q_OBJECT public: DeviceNotificationsDbusInterface(const QString& deviceId, QObject* parent = 0); - + virtual ~DeviceNotificationsDbusInterface(); }; class KDECONNECT_EXPORT NotificationDbusInterface @@ -75,7 +75,7 @@ class KDECONNECT_EXPORT NotificationDbusInterface Q_OBJECT public: NotificationDbusInterface(const QString& deviceId, const QString& notificationId, QObject* parent = 0); - + virtual ~NotificationDbusInterface(); }; From 3073e66bb36dbda96faecdcc1a2326ee41288fdd Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 16 Jan 2014 12:14:05 +0100 Subject: [PATCH 2/3] Daemon devices() can now filter by visible and/or paired visibleDevices() is not needed anymore and has been removed --- kded/daemon.cpp | 13 ++++--------- kded/daemon.h | 3 +-- libkdeconnect/devicesmodel.cpp | 20 +++++++------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/kded/daemon.cpp b/kded/daemon.cpp index 31598c52b..b390ae883 100644 --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -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()) { - ret.append(device->id()); - } + 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) { diff --git a/kded/daemon.h b/kded/daemon.h index b4b7594f6..2644dfa0b 100644 --- a/kded/daemon.h +++ b/kded/daemon.h @@ -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); diff --git a/libkdeconnect/devicesmodel.cpp b/libkdeconnect/devicesmodel.cpp index 0f717fcad..7b7a7495a 100644 --- a/libkdeconnect/devicesmodel.cpp +++ b/libkdeconnect/devicesmodel.cpp @@ -112,27 +112,21 @@ void DevicesModel::refreshDeviceList() return; } - QDBusPendingReply pendingDeviceIds = m_dbusInterface->devices(); + + bool onlyPaired = (m_displayFilter & StatusPaired); + bool onlyReachable = (m_displayFilter & StatusReachable); + + QDBusPendingReply pendingDeviceIds = m_dbusInterface->devices(onlyReachable, onlyPaired); 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; - 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())); From 904c5484e7004727dc36160e4ffdd660f556da63 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 16 Jan 2014 12:16:09 +0100 Subject: [PATCH 3/3] Ooops --- libkdeconnect/dbusinterfaces.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libkdeconnect/dbusinterfaces.cpp b/libkdeconnect/dbusinterfaces.cpp index d20511125..a9013ffb6 100644 --- a/libkdeconnect/dbusinterfaces.cpp +++ b/libkdeconnect/dbusinterfaces.cpp @@ -51,17 +51,6 @@ NotificationDbusInterface::NotificationDbusInterface(const QString& deviceId, co } -SftpDbusInterface::SftpDbusInterface(const QString& id, QObject* parent) - : OrgKdeKdeconnectDeviceSftpInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + id + "/sftp", QDBusConnection::sessionBus(), parent) -{ - -} - -SftpDbusInterface::~SftpDbusInterface() -{ - -} - DaemonDbusInterface::~DaemonDbusInterface() {