diff --git a/core/backends/lan/lanpairinghandler.cpp b/core/backends/lan/lanpairinghandler.cpp index 35c41d00b..226acc47f 100644 --- a/core/backends/lan/lanpairinghandler.cpp +++ b/core/backends/lan/lanpairinghandler.cpp @@ -32,7 +32,7 @@ LanPairingHandler::LanPairingHandler(DeviceLink* deviceLink) , m_status(NotPaired) { m_pairingTimeout.setSingleShot(true); - m_pairingTimeout.setInterval(30 * 1000); //30 seconds of timeout + m_pairingTimeout.setInterval(pairingTimeoutMsec()); connect(&m_pairingTimeout, &QTimer::timeout, this, &LanPairingHandler::pairingTimeout); } diff --git a/core/backends/pairinghandler.h b/core/backends/pairinghandler.h index 0ff161bef..21b0e5801 100644 --- a/core/backends/pairinghandler.h +++ b/core/backends/pairinghandler.h @@ -49,6 +49,7 @@ public: virtual void packageReceived(const NetworkPackage& np) = 0; virtual void unpair() = 0; + virtual int pairingTimeoutMsec() const { return 30 * 1000; } // 30 seconds of timeout (default), subclasses that use different values should override public Q_SLOTS: virtual bool requestPairing() = 0; diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp index 0f242c7b8..80fee6d71 100644 --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -43,7 +44,8 @@ public: void askPairingConfirmation(PairingHandler* d) override { - KNotification* notification = new KNotification(QStringLiteral("pairingRequest")); + KNotification* notification = new KNotification(QStringLiteral("pairingRequest"), + KNotification::Persistent); notification->setIconName(QStringLiteral("dialog-information")); notification->setComponentName(QStringLiteral("kdeconnect")); notification->setText(i18n("Pairing request from %1", getDevice(d->deviceLink()->deviceId())->name())); @@ -51,6 +53,7 @@ public: connect(notification, &KNotification::ignored, d, &PairingHandler::rejectPairing); connect(notification, &KNotification::action1Activated, d, &PairingHandler::acceptPairing); connect(notification, &KNotification::action2Activated, d, &PairingHandler::rejectPairing); + QTimer::singleShot(d->pairingTimeoutMsec(), notification, &KNotification::close); // close after pairing timeout, assuming that the peer uses the same timeout value notification->sendEvent(); }