mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-23 22:39:43 -05:00
Add methods isHardwareKeySupported and refreshHardwareKeys to DBus
This commit is contained in:
parent
20a2a96222
commit
de3d40b644
@ -716,6 +716,43 @@ void MainWindow::appExit()
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if application was built with hardware key support.
|
||||
* Intented to be used by 3rd-party applications using DBus.
|
||||
*
|
||||
* @return True if built with hardware key support, false otherwise
|
||||
*/
|
||||
bool MainWindow::isHardwareKeySupported()
|
||||
{
|
||||
#ifdef WITH_XC_YUBIKEY
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes list of hardware keys known.
|
||||
* Triggers the DatabaseOpenWidget to automatically select the key last used for a database if found.
|
||||
* Intented to be used by 3rd-party applications using DBus.
|
||||
*
|
||||
* @return True if any key was found, false otherwise or if application lacks hardware key support
|
||||
*/
|
||||
bool MainWindow::refreshHardwareKeys()
|
||||
{
|
||||
#ifdef WITH_XC_YUBIKEY
|
||||
auto yk = YubiKey::instance();
|
||||
// find keys sync to allow returning if any key was found
|
||||
bool found = yk->findValidKeys();
|
||||
// emit signal so DatabaseOpenWidget can select last used key
|
||||
// emit here manually because sync findValidKeys() cannot do that properly
|
||||
emit yk->detectComplete(found);
|
||||
return found;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::updateLastDatabasesMenu()
|
||||
{
|
||||
m_ui->menuRecentDatabases->clear();
|
||||
|
@ -69,6 +69,8 @@ signals:
|
||||
public slots:
|
||||
void openDatabase(const QString& filePath, const QString& password = {}, const QString& keyfile = {});
|
||||
void appExit();
|
||||
bool isHardwareKeySupported();
|
||||
bool refreshHardwareKeys();
|
||||
void displayGlobalMessage(const QString& text,
|
||||
MessageWidget::MessageType type,
|
||||
bool showClosebutton = true,
|
||||
|
@ -15,6 +15,12 @@
|
||||
</method>
|
||||
<method name="appExit">
|
||||
</method>
|
||||
<method name="isHardwareKeySupported">
|
||||
<arg name="hardwareKeySupported" type="b" direction="out"/>
|
||||
</method>
|
||||
<method name="refreshHardwareKeys">
|
||||
<arg name="found" type="b" direction="out"/>
|
||||
</method>
|
||||
<method name="lockAllDatabases">
|
||||
</method>
|
||||
<method name="closeAllDatabases">
|
||||
|
Loading…
Reference in New Issue
Block a user