Commit 920d945a authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

ProtocolVersion is read for already known devices too

It might have changed since last connection, so we don't store it
parent a06cf677
...@@ -140,7 +140,7 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* ...@@ -140,7 +140,7 @@ void Daemon::onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink*
if (mDevices.contains(id)) { if (mDevices.contains(id)) {
//qDebug() << "It is a known device"; //qDebug() << "It is a known device";
Device* device = mDevices[id]; Device* device = mDevices[id];
device->addLink(dl); device->addLink(identityPackage, dl);
} else { } else {
//qDebug() << "It is a new device"; //qDebug() << "It is a new device";
......
...@@ -34,6 +34,8 @@ Device::Device(const QString& id) ...@@ -34,6 +34,8 @@ Device::Device(const QString& id)
m_pairStatus = Device::Paired; m_pairStatus = Device::Paired;
m_protocolVersion = NetworkPackage::ProtocolVersion; //We don't know it yet
//Register in bus //Register in bus
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
...@@ -43,13 +45,8 @@ Device::Device(const NetworkPackage& identityPackage, DeviceLink* dl) ...@@ -43,13 +45,8 @@ Device::Device(const NetworkPackage& identityPackage, DeviceLink* dl)
{ {
m_deviceId = identityPackage.get<QString>("deviceId"); m_deviceId = identityPackage.get<QString>("deviceId");
m_deviceName = identityPackage.get<QString>("deviceName"); m_deviceName = identityPackage.get<QString>("deviceName");
m_protocolVersion = identityPackage.get<int>("protocolVersion"); m_protocolVersion = identityPackage.get<int>("protocolVersion");
if (m_protocolVersion != NetworkPackage::ProtocolVersion) { addLink(identityPackage, dl);
qWarning() << m_deviceName << "- warning, device uses a different protocol version" << m_protocolVersion << "expected" << NetworkPackage::ProtocolVersion;
}
addLink(dl);
m_pairStatus = Device::NotPaired; m_pairStatus = Device::NotPaired;
...@@ -195,10 +192,15 @@ static bool lessThan(DeviceLink* p1, DeviceLink* p2) ...@@ -195,10 +192,15 @@ static bool lessThan(DeviceLink* p1, DeviceLink* p2)
return p1->provider()->priority() > p2->provider()->priority(); 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(); //qDebug() << "Adding link to" << id() << "via" << link->provider();
m_protocolVersion = identityPackage.get<int>("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*)), connect(link, SIGNAL(destroyed(QObject*)),
this, SLOT(linkDestroyed(QObject*))); this, SLOT(linkDestroyed(QObject*)));
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); } QString dbusPath() const { return "/modules/kdeconnect/devices/"+id(); }
//Add and remove links //Add and remove links
void addLink(DeviceLink*); void addLink(const NetworkPackage& identityPackage, DeviceLink*);
void removeLink(DeviceLink*); void removeLink(DeviceLink*);
Q_SCRIPTABLE bool isPaired() const { return m_pairStatus==Device::Paired; } Q_SCRIPTABLE bool isPaired() const { return m_pairStatus==Device::Paired; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment