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*
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";
......
......@@ -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<QString>("deviceId");
m_deviceName = identityPackage.get<QString>("deviceName");
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;
}
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<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*)),
this, SLOT(linkDestroyed(QObject*)));
......
......@@ -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; }
......
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