Propagate pairingError
This commit is contained in:
parent
1848e96a91
commit
af43a21864
3 changed files with 25 additions and 16 deletions
|
@ -460,28 +460,27 @@ void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, Netwo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LanPairingHandler* LanLinkProvider::createPairingHandler(DeviceLink* link)
|
||||||
|
{
|
||||||
|
LanPairingHandler* ph = mPairingHandlers.value(link->deviceId());
|
||||||
|
if (!ph) {
|
||||||
|
ph = new LanPairingHandler(link);
|
||||||
|
qDebug() << "creating pairing handler for" << link->deviceId();
|
||||||
|
connect (ph, &LanPairingHandler::pairingError, link, &DeviceLink::pairingError);
|
||||||
|
mPairingHandlers[link->deviceId()] = ph;
|
||||||
|
}
|
||||||
|
return ph;
|
||||||
|
}
|
||||||
|
|
||||||
void LanLinkProvider::userRequestsPair(const QString& deviceId)
|
void LanLinkProvider::userRequestsPair(const QString& deviceId)
|
||||||
{
|
{
|
||||||
LanPairingHandler* ph = mPairingHandlers.value(deviceId);
|
LanPairingHandler* ph = createPairingHandler(mLinks.value(deviceId));
|
||||||
if (!ph) {
|
|
||||||
LanDeviceLink* link = mLinks.value(deviceId);
|
|
||||||
qDebug() << "Creating LanPairingHandler with link " << link;
|
|
||||||
ph = new LanPairingHandler(link);
|
|
||||||
mPairingHandlers[deviceId] = ph;
|
|
||||||
}
|
|
||||||
|
|
||||||
ph->requestPairing();
|
ph->requestPairing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanLinkProvider::incomingPairPackage(DeviceLink* deviceLink, const NetworkPackage& np)
|
void LanLinkProvider::incomingPairPackage(DeviceLink* deviceLink, const NetworkPackage& np)
|
||||||
{
|
{
|
||||||
const QString deviceId = deviceLink->deviceId();
|
LanPairingHandler* ph = createPairingHandler(deviceLink);
|
||||||
LanPairingHandler* ph = mPairingHandlers.value(deviceId);
|
|
||||||
if (!ph) {
|
|
||||||
ph = new LanPairingHandler(deviceLink);
|
|
||||||
mPairingHandlers[deviceId] = ph;
|
|
||||||
}
|
|
||||||
|
|
||||||
ph->packageReceived(np);
|
ph->packageReceived(np);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,10 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void configureSocket(QSslSocket* socket);
|
static void configureSocket(QSslSocket* socket);
|
||||||
|
LanPairingHandler* createPairingHandler(DeviceLink* link);
|
||||||
|
|
||||||
void onNetworkConfigurationChanged(const QNetworkConfiguration &config);
|
void onNetworkConfigurationChanged(const QNetworkConfiguration &config);
|
||||||
void addLink(const QString& deviceId, QSslSocket* socket, NetworkPackage* receivedPackage, DeviceLink::ConnectionStarted connectionOrigin);
|
void addLink(const QString& deviceId, QSslSocket* socket, NetworkPackage* receivedPackage, DeviceLink::ConnectionStarted connectionOrigin);
|
||||||
void refreshPairingHandler(const QString &deviceId);
|
|
||||||
|
|
||||||
Server* mServer;
|
Server* mServer;
|
||||||
QUdpSocket* mUdpServer;
|
QUdpSocket* mUdpServer;
|
||||||
|
|
|
@ -47,6 +47,11 @@
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(KDECONNECT_CORE, "kdeconnect.core")
|
Q_LOGGING_CATEGORY(KDECONNECT_CORE, "kdeconnect.core")
|
||||||
|
|
||||||
|
static void warn(const QString &info)
|
||||||
|
{
|
||||||
|
qWarning() << "Device pairing error" << info;
|
||||||
|
}
|
||||||
|
|
||||||
Device::Device(QObject* parent, const QString& id)
|
Device::Device(QObject* parent, const QString& id)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_deviceId(id)
|
, m_deviceId(id)
|
||||||
|
@ -59,6 +64,8 @@ Device::Device(QObject* parent, const QString& id)
|
||||||
|
|
||||||
//Register in bus
|
//Register in bus
|
||||||
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||||
|
|
||||||
|
connect(this, &Device::pairingError, this, &warn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLink* dl)
|
Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLink* dl)
|
||||||
|
@ -72,6 +79,8 @@ Device::Device(QObject* parent, const NetworkPackage& identityPackage, DeviceLin
|
||||||
|
|
||||||
//Register in bus
|
//Register in bus
|
||||||
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
QDBusConnection::sessionBus().registerObject(dbusPath(), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||||
|
|
||||||
|
connect(this, &Device::pairingError, this, &warn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::~Device()
|
Device::~Device()
|
||||||
|
|
Loading…
Reference in a new issue