Make sure we keep track of changes when the device link changes

Especially useful because it contains the announce name.

CCBUG: 364150
This commit is contained in:
Aleix Pol 2017-07-14 03:30:49 +02:00
parent f7b2cee995
commit d7ec24725f
2 changed files with 6 additions and 7 deletions

View file

@ -501,9 +501,8 @@ void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, Netwo
Q_ASSERT(mPairingHandlers.contains(deviceId));
mPairingHandlers[deviceId]->setDeviceLink(deviceLink);
}
Q_EMIT onConnectionReceived(*receivedPackage, deviceLink);
}
Q_EMIT onConnectionReceived(*receivedPackage, deviceLink);
}
LanPairingHandler* LanLinkProvider::createPairingHandler(DeviceLink* link)

View file

@ -209,7 +209,11 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
{
//qCDebug(KDECONNECT_CORE) << "Adding link to" << id() << "via" << link->provider();
Q_ASSERT(!m_deviceLinks.contains(link));
setName(identityPackage.get<QString>(QStringLiteral("deviceName")));
m_deviceType = str2type(identityPackage.get<QString>(QStringLiteral("deviceType")));
if (m_deviceLinks.contains(link))
return;
m_protocolVersion = identityPackage.get<int>(QStringLiteral("protocolVersion"), -1);
if (m_protocolVersion != NetworkPackage::ProtocolVersion) {
@ -221,10 +225,6 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
m_deviceLinks.append(link);
//re-read the device name from the identityPackage because it could have changed
setName(identityPackage.get<QString>(QStringLiteral("deviceName")));
m_deviceType = str2type(identityPackage.get<QString>(QStringLiteral("deviceType")));
//Theoretically we will never add two links from the same provider (the provider should destroy
//the old one before this is called), so we do not have to worry about destroying old links.
//-- Actually, we should not destroy them or the provider will store an invalid ref!