Skip to content

Commit

Permalink
Fix Yubikey detection in Database Settings/Wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey authored and Jean-Christophe Vassort committed Feb 20, 2019
1 parent 6801c15 commit 9611b7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/gui/masterkey/YubiKeyEditWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -119,19 +121,22 @@ 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);
Q_UNUSED(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
Expand Down
1 change: 1 addition & 0 deletions src/gui/masterkey/YubiKeyEditWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class YubiKeyEditWidget : public KeyComponentWidget

private slots:
void yubikeyDetected(int slot, bool blocking);
void yubikeyDetectComplete();
void noYubikeyFound();
void pollYubikey();

Expand Down

0 comments on commit 9611b7b

Please sign in to comment.