From 907740196ab4fd02d212f9100280b2c25b16f9a1 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Fri, 16 Aug 2013 06:26:40 +0200 Subject: [PATCH] Removed onConnectionLost from DeviceLinkProvider (Connect to destroyed on DeviceLink instead) Also, registering Device in dbus too soon fixed --- daemon/device.cpp | 19 +++++++++++-------- daemon/device.h | 4 ++-- daemon/linkproviders/linkprovider.h | 2 +- daemon/linkproviders/loopbacklinkprovider.cpp | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/daemon/device.cpp b/daemon/device.cpp index e349b03de..e96cb95de 100644 --- a/daemon/device.cpp +++ b/daemon/device.cpp @@ -23,10 +23,11 @@ Device::Device(const QString& id, const QString& name) m_paired = true; m_knownIdentiy = true; - //Register in bus - QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors | QDBusConnection::ExportChildObjects); - reloadPlugins(); + + //Register in bus + QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); + } Device::Device(const QString& id, const QString& name, DeviceLink* link) @@ -36,12 +37,13 @@ Device::Device(const QString& id, const QString& name, DeviceLink* link) m_paired = false; m_knownIdentiy = true; - //Register in bus - QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors | QDBusConnection::ExportChildObjects); - addLink(link); reloadPlugins(); + + //Register in bus + QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); + } /* Device::Device(const QString& id, const QString& name, DeviceLink* link) @@ -137,7 +139,8 @@ void Device::addLink(DeviceLink* link) { qDebug() << "Adding link to" << id() << "via" << link->provider(); - connect(link,SIGNAL(destroyed(QObject*)),this,SLOT(linkDestroyed(QObject*))); + connect(link, SIGNAL(destroyed(QObject*)), + this, SLOT(linkDestroyed(QObject*))); m_deviceLinks.append(link); @@ -165,7 +168,7 @@ void Device::removeLink(DeviceLink* link) { m_deviceLinks.removeOne(link); - qDebug() << "RemoveLink"<< m_deviceLinks.size() << "links remaining"; + qDebug() << "RemoveLink" << m_deviceLinks.size() << "links remaining"; if (m_deviceLinks.empty()) { reloadPlugins(); diff --git a/daemon/device.h b/daemon/device.h index 3cef51537..ad2ee6175 100644 --- a/daemon/device.h +++ b/daemon/device.h @@ -80,8 +80,8 @@ private Q_SLOTS: void privateReceivedPackage(const NetworkPackage& np); Q_SIGNALS: - void reachableStatusChanged(); - void pluginsChanged(); + Q_SCRIPTABLE void reachableStatusChanged(); + Q_SCRIPTABLE void pluginsChanged(); private: bool m_paired; diff --git a/daemon/linkproviders/linkprovider.h b/daemon/linkproviders/linkprovider.h index e1f13101d..2a5cfe761 100644 --- a/daemon/linkproviders/linkprovider.h +++ b/daemon/linkproviders/linkprovider.h @@ -54,8 +54,8 @@ public Q_SLOTS: Q_SIGNALS: //NOTE: The provider will to destroy the DeviceLink when it's no longer accessible, // and every user should listen to the destroyed signal to remove its references. + // That's the reason because there is no "onConnectionLost". void onConnectionReceived(const NetworkPackage& identityPackage, DeviceLink*); - void onConnectionLost(DeviceLink*); }; diff --git a/daemon/linkproviders/loopbacklinkprovider.cpp b/daemon/linkproviders/loopbacklinkprovider.cpp index 5b14b1f30..96745d957 100644 --- a/daemon/linkproviders/loopbacklinkprovider.cpp +++ b/daemon/linkproviders/loopbacklinkprovider.cpp @@ -26,7 +26,6 @@ LoopbackLinkProvider::LoopbackLinkProvider() : identityPackage(PACKAGE_TYPE_IDENTITY) { - echoDeviceLink = new EchoDeviceLink("loopback", this); NetworkPackage::createIdentityPackage(&identityPackage); } @@ -44,11 +43,12 @@ void LoopbackLinkProvider::onNetworkChange(QNetworkSession::State state) void LoopbackLinkProvider::onStart() { + echoDeviceLink = new EchoDeviceLink("loopback", this); onNetworkChange(QNetworkSession::Connected); } void LoopbackLinkProvider::onStop() { - onConnectionLost(echoDeviceLink); + delete echoDeviceLink; }