From 920d945a5df1f2b9576689b4c5425b02d86400c8 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 1 Oct 2013 03:11:22 +0200 Subject: [PATCH] ProtocolVersion is read for already known devices too It might have changed since last connection, so we don't store it --- kded/daemon.cpp | 2 +- kded/device.cpp | 16 +++++++++------- kded/device.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/kded/daemon.cpp b/kded/daemon.cpp index e873ed70c..16355d547 100644 --- a/kded/daemon.cpp +++ b/kded/daemon.cpp @@ -140,7 +140,7 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* if (mDevices.contains(id)) { //qDebug() << "It is a known device"; Device* device = mDevices[id]; - device->addLink(dl); + device->addLink(identityPackage, dl); } else { //qDebug() << "It is a new device"; diff --git a/kded/device.cpp b/kded/device.cpp index 035d3a24f..b7b015d8a 100644 --- a/kded/device.cpp +++ b/kded/device.cpp @@ -34,6 +34,8 @@ Device::Device(const QString& id) m_pairStatus = Device::Paired; + m_protocolVersion = NetworkPackage::ProtocolVersion; //We don't know it yet + //Register in bus QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); @@ -43,13 +45,8 @@ Device::Device(const NetworkPackage& identityPackage, DeviceLink* dl) { m_deviceId = identityPackage.get("deviceId"); m_deviceName = identityPackage.get("deviceName"); - m_protocolVersion = identityPackage.get("protocolVersion"); - if (m_protocolVersion != NetworkPackage::ProtocolVersion) { - qWarning() << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPackage::ProtocolVersion; - } - - addLink(dl); + addLink(identityPackage, dl); m_pairStatus = Device::NotPaired; @@ -195,10 +192,15 @@ static bool lessThan(DeviceLink* p1, DeviceLink* p2) return p1->provider()->priority() > p2->provider()->priority(); } -void Device::addLink(DeviceLink* link) +void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link) { //qDebug() << "Adding link to" << id() << "via" << link->provider(); + m_protocolVersion = identityPackage.get("protocolVersion"); + if (m_protocolVersion != NetworkPackage::ProtocolVersion) { + qWarning() << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPackage::ProtocolVersion; + } + connect(link, SIGNAL(destroyed(QObject*)), this, SLOT(linkDestroyed(QObject*))); diff --git a/kded/device.h b/kded/device.h index ea87deadc..7ac646b2c 100644 --- a/kded/device.h +++ b/kded/device.h @@ -62,7 +62,7 @@ public: QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); } //Add and remove links - void addLink(DeviceLink*); + void addLink(const NetworkPackage& identityPackage, DeviceLink*); void removeLink(DeviceLink*); Q_SCRIPTABLE bool isPaired() const { return m_pairStatus==Device::Paired; }