From 0cd268dd361cb21be0dcf1862dbd5ff3c8bbb8cb Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Fri, 1 Feb 2019 17:38:40 -0500 Subject: [PATCH] Fix Yubikey detection in Database Settings/Wizard * Fixes #2608 --- src/gui/masterkey/YubiKeyEditWidget.cpp | 19 ++++++++++++------- src/gui/masterkey/YubiKeyEditWidget.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gui/masterkey/YubiKeyEditWidget.cpp b/src/gui/masterkey/YubiKeyEditWidget.cpp index 96b06833d9..9ecd918ef1 100644 --- a/src/gui/masterkey/YubiKeyEditWidget.cpp +++ b/src/gui/masterkey/YubiKeyEditWidget.cpp @@ -79,9 +79,9 @@ QWidget* YubiKeyEditWidget::componentEditWidget() // clang-format off connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection); - // clang-format on - + connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection); connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection); + // clang-format on pollYubikey(); #endif @@ -102,9 +102,11 @@ void YubiKeyEditWidget::pollYubikey() if (!m_compEditWidget) { return; } + + m_isDetected = false; + m_compUi->comboChallengeResponse->clear(); m_compUi->buttonRedetectYubikey->setEnabled(false); m_compUi->comboChallengeResponse->setEnabled(false); - m_compUi->comboChallengeResponse->clear(); m_compUi->yubikeyProgress->setVisible(true); // YubiKey init is slow, detect asynchronously to not block the UI @@ -119,12 +121,8 @@ void YubiKeyEditWidget::yubikeyDetected(int slot, bool blocking) return; } YkChallengeResponseKey yk(slot, blocking); - m_compUi->comboChallengeResponse->clear(); // add detected YubiKey to combo box and encode blocking mode in LSB, slot number in second LSB m_compUi->comboChallengeResponse->addItem(yk.getName(), QVariant((slot << 1u) | blocking)); - m_compUi->comboChallengeResponse->setEnabled(true); - m_compUi->buttonRedetectYubikey->setEnabled(true); - m_compUi->yubikeyProgress->setVisible(false); m_isDetected = true; #else Q_UNUSED(slot); @@ -132,6 +130,13 @@ void YubiKeyEditWidget::yubikeyDetected(int slot, bool blocking) #endif } +void YubiKeyEditWidget::yubikeyDetectComplete() +{ + m_compUi->comboChallengeResponse->setEnabled(true); + m_compUi->buttonRedetectYubikey->setEnabled(true); + m_compUi->yubikeyProgress->setVisible(false); +} + void YubiKeyEditWidget::noYubikeyFound() { #ifdef WITH_XC_YUBIKEY diff --git a/src/gui/masterkey/YubiKeyEditWidget.h b/src/gui/masterkey/YubiKeyEditWidget.h index 8d7498034f..549f7f44fd 100644 --- a/src/gui/masterkey/YubiKeyEditWidget.h +++ b/src/gui/masterkey/YubiKeyEditWidget.h @@ -46,6 +46,7 @@ class YubiKeyEditWidget : public KeyComponentWidget private slots: void yubikeyDetected(int slot, bool blocking); + void yubikeyDetectComplete(); void noYubikeyFound(); void pollYubikey();