mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
add function for locking DBs from DBus, fix #687
This commit is contained in:
parent
e560650bf3
commit
98a89e4f2c
@ -46,7 +46,6 @@ option(WITH_XC_BROWSER "Include browser integration with keepassxc-browser." OFF
|
|||||||
option(WITH_XC_HTTP "Include KeePassHTTP-compatible browser integration (deprecated, implies WITH_NETWORKING)." OFF)
|
option(WITH_XC_HTTP "Include KeePassHTTP-compatible browser integration (deprecated, implies WITH_NETWORKING)." OFF)
|
||||||
option(WITH_XC_YUBIKEY "Include YubiKey support." OFF)
|
option(WITH_XC_YUBIKEY "Include YubiKey support." OFF)
|
||||||
option(WITH_XC_SSHAGENT "Include SSH agent support." OFF)
|
option(WITH_XC_SSHAGENT "Include SSH agent support." OFF)
|
||||||
option(WITH_XC_DBUS "Include DBus support." OFF)
|
|
||||||
|
|
||||||
if(WITH_XC_HTTP)
|
if(WITH_XC_HTTP)
|
||||||
message(WARNING "KeePassHTTP support has been deprecated and will be removed in a future version. Please use WITH_XC_BROWSER instead!\n"
|
message(WARNING "KeePassHTTP support has been deprecated and will be removed in a future version. Please use WITH_XC_BROWSER instead!\n"
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
## Using D-BUS feature
|
|
||||||
|
|
||||||
* Open keepassxc database: without password and key file
|
|
||||||
|
|
||||||
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.openDatabase /path/to/database.kdbx
|
|
||||||
|
|
||||||
* Open keepassxc database: with password but without key file
|
|
||||||
|
|
||||||
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.openDatabase /path/to/database.kdbx passwd
|
|
||||||
|
|
||||||
* Open keepassxc database: with password and key file
|
|
||||||
|
|
||||||
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.openDatabase /path/to/database.kdbx passwd /path/to/key
|
|
||||||
|
|
||||||
* Close all keepassxc databases
|
|
||||||
|
|
||||||
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.closeAllDatabases
|
|
||||||
|
|
||||||
* Exit keepassxc
|
|
||||||
|
|
||||||
qdbus org.keepassxc.MainWindow /keepassxc org.keepassxc.MainWindow.exit
|
|
||||||
|
|
||||||
## Develop
|
|
||||||
|
|
||||||
* Regenerate XML file for DBus ( If MainWindow class public methods were modified )
|
|
||||||
|
|
||||||
cd src/gui
|
|
||||||
|
|
||||||
qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp org.keepassxc.MainWindow.xml
|
|
||||||
|
|
||||||
* It can be usefull to know how to generate the XML adaptor
|
|
||||||
|
|
||||||
* * Generate template from sources
|
|
||||||
|
|
||||||
qdbuscpp2xml -M -s MainWindow.h -o org.keepassxc.MainWindow.xml
|
|
||||||
|
|
||||||
* * Make sure interface name is org.keepassxc.MainWindow
|
|
||||||
|
|
||||||
<interface name="org.keepassxc.MainWindow">
|
|
||||||
|
|
@ -174,6 +174,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenB
|
|||||||
set(keepassx_SOURCES ${keepassx_SOURCES}
|
set(keepassx_SOURCES ${keepassx_SOURCES}
|
||||||
core/ScreenLockListenerDBus.h
|
core/ScreenLockListenerDBus.h
|
||||||
core/ScreenLockListenerDBus.cpp
|
core/ScreenLockListenerDBus.cpp
|
||||||
|
gui/MainWindowAdaptor.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
@ -193,7 +194,6 @@ add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with Kee
|
|||||||
add_feature_info(KeePassHTTP WITH_XC_HTTP "Browser integration compatible with ChromeIPass and PassIFox (deprecated, implies Networking)")
|
add_feature_info(KeePassHTTP WITH_XC_HTTP "Browser integration compatible with ChromeIPass and PassIFox (deprecated, implies Networking)")
|
||||||
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
|
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
|
||||||
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
|
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
|
||||||
add_feature_info(DBus WITH_XC_DBUS "Take keepassxc control by DBus")
|
|
||||||
|
|
||||||
if(WITH_XC_HTTP)
|
if(WITH_XC_HTTP)
|
||||||
add_subdirectory(http)
|
add_subdirectory(http)
|
||||||
@ -211,13 +211,6 @@ if(WITH_XC_BROWSER)
|
|||||||
set(keepassxcbrowser_LIB keepassxcbrowser)
|
set(keepassxcbrowser_LIB keepassxcbrowser)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE AND WITH_XC_DBUS)
|
|
||||||
set(keepassx_SOURCES
|
|
||||||
${keepassx_SOURCES}
|
|
||||||
gui/MainWindowAdaptor.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(autotype)
|
add_subdirectory(autotype)
|
||||||
add_subdirectory(cli)
|
add_subdirectory(cli)
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#cmakedefine WITH_XC_HTTP
|
#cmakedefine WITH_XC_HTTP
|
||||||
#cmakedefine WITH_XC_YUBIKEY
|
#cmakedefine WITH_XC_YUBIKEY
|
||||||
#cmakedefine WITH_XC_SSHAGENT
|
#cmakedefine WITH_XC_SSHAGENT
|
||||||
#cmakedefine WITH_XC_DBUS
|
|
||||||
|
|
||||||
#cmakedefine KEEPASSXC_DIST
|
#cmakedefine KEEPASSXC_DIST
|
||||||
#cmakedefine KEEPASSXC_DIST_TYPE "@KEEPASSXC_DIST_TYPE@"
|
#cmakedefine KEEPASSXC_DIST_TYPE "@KEEPASSXC_DIST_TYPE@"
|
||||||
|
@ -24,11 +24,6 @@
|
|||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS)
|
|
||||||
#include <QList>
|
|
||||||
#include <QtDBus/QtDBus>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "config-keepassx.h"
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
#include "autotype/AutoType.h"
|
#include "autotype/AutoType.h"
|
||||||
@ -61,15 +56,14 @@
|
|||||||
#include "browser/BrowserOptionDialog.h"
|
#include "browser/BrowserOptionDialog.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gui/SettingsWidget.h"
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS)
|
||||||
#include "gui/PasswordGeneratorWidget.h"
|
#include <QList>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
#ifdef WITH_XC_DBUS
|
|
||||||
#if defined(Q_OS_LINUX)
|
|
||||||
#include <QtDBus>
|
|
||||||
#include "gui/MainWindowAdaptor.h"
|
#include "gui/MainWindowAdaptor.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
#include "gui/SettingsWidget.h"
|
||||||
|
#include "gui/PasswordGeneratorWidget.h"
|
||||||
|
|
||||||
#ifdef WITH_XC_HTTP
|
#ifdef WITH_XC_HTTP
|
||||||
class HttpPlugin: public ISettingsPage
|
class HttpPlugin: public ISettingsPage
|
||||||
@ -175,16 +169,13 @@ MainWindow::MainWindow()
|
|||||||
, m_appExiting(false)
|
, m_appExiting(false)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
#ifdef WITH_XC_DBUS
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS)
|
||||||
new MainWindowAdaptor(this);
|
new MainWindowAdaptor(this);
|
||||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||||
dbus.registerObject("/keepassxc", this);
|
dbus.registerObject("/keepassxc", this);
|
||||||
dbus.registerService("org.keepassxc.MainWindow");
|
dbus.registerService("org.keepassxc.KeePassXC.MainWindow");
|
||||||
#else
|
#endif
|
||||||
qWarning("DBus is not available on this system");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
@ -1145,3 +1136,8 @@ void MainWindow::closeAllDatabases()
|
|||||||
{
|
{
|
||||||
m_ui->tabWidget->closeAllDatabases();
|
m_ui->tabWidget->closeAllDatabases();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::lockAllDatabases()
|
||||||
|
{
|
||||||
|
lockDatabasesAfterInactivity();
|
||||||
|
}
|
@ -38,8 +38,8 @@ class MainWindow : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS)
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.keepassxc.MainWindow")
|
Q_CLASSINFO("D-Bus Interface", "org.keepassxc.KeePassXC.MainWindow")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -67,10 +67,11 @@ public slots:
|
|||||||
void hideYubiKeyPopup();
|
void hideYubiKeyPopup();
|
||||||
void bringToFront();
|
void bringToFront();
|
||||||
void closeAllDatabases();
|
void closeAllDatabases();
|
||||||
|
void lockAllDatabases();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None);
|
void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* This file was generated by qdbusxml2cpp version 0.7
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp org.keepassxc.MainWindow.xml
|
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp org.keepassxc.MainWindow.xml
|
||||||
*
|
*
|
||||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||||
@ -24,42 +24,40 @@
|
|||||||
MainWindowAdaptor::MainWindowAdaptor(QObject *parent)
|
MainWindowAdaptor::MainWindowAdaptor(QObject *parent)
|
||||||
: QDBusAbstractAdaptor(parent)
|
: QDBusAbstractAdaptor(parent)
|
||||||
{
|
{
|
||||||
// constructor
|
|
||||||
setAutoRelaySignals(true);
|
setAutoRelaySignals(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindowAdaptor::~MainWindowAdaptor()
|
MainWindowAdaptor::~MainWindowAdaptor()
|
||||||
{
|
{
|
||||||
// destructor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowAdaptor::appExit()
|
void MainWindowAdaptor::appExit()
|
||||||
{
|
{
|
||||||
// handle method call org.keepassxc.MainWindow.appExit
|
|
||||||
QMetaObject::invokeMethod(parent(), "appExit");
|
QMetaObject::invokeMethod(parent(), "appExit");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowAdaptor::closeAllDatabases()
|
void MainWindowAdaptor::closeAllDatabases()
|
||||||
{
|
{
|
||||||
// handle method call org.keepassxc.MainWindow.closeAllDatabases
|
|
||||||
QMetaObject::invokeMethod(parent(), "closeAllDatabases");
|
QMetaObject::invokeMethod(parent(), "closeAllDatabases");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowAdaptor::lockAllDatabases()
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(parent(), "lockAllDatabases");
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowAdaptor::openDatabase(const QString &fileName)
|
void MainWindowAdaptor::openDatabase(const QString &fileName)
|
||||||
{
|
{
|
||||||
// handle method call org.keepassxc.MainWindow.openDatabase
|
|
||||||
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName));
|
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowAdaptor::openDatabase(const QString &fileName, const QString &pw)
|
void MainWindowAdaptor::openDatabase(const QString &fileName, const QString &pw)
|
||||||
{
|
{
|
||||||
// handle method call org.keepassxc.MainWindow.openDatabase
|
|
||||||
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw));
|
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowAdaptor::openDatabase(const QString &fileName, const QString &pw, const QString &keyFile)
|
void MainWindowAdaptor::openDatabase(const QString &fileName, const QString &pw, const QString &keyFile)
|
||||||
{
|
{
|
||||||
// handle method call org.keepassxc.MainWindow.openDatabase
|
|
||||||
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw), Q_ARG(QString, keyFile));
|
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw), Q_ARG(QString, keyFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* This file was generated by qdbusxml2cpp version 0.7
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp org.keepassxc.MainWindow.xml
|
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp org.keepassxc.MainWindow.xml
|
||||||
*
|
*
|
||||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||||
@ -9,17 +9,19 @@
|
|||||||
* before re-generating it.
|
* before re-generating it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAINWINDOWADAPTOR_H_1486736200
|
#ifndef MAINWINDOWADAPTOR_H
|
||||||
#define MAINWINDOWADAPTOR_H_1486736200
|
#define MAINWINDOWADAPTOR_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtDBus/QtDBus>
|
#include <QtDBus/QtDBus>
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
template<class T> class QList;
|
template<class T> class QList;
|
||||||
template<class Key, class Value> class QMap;
|
template<class Key, class Value> class QMap;
|
||||||
class QString;
|
class QString;
|
||||||
class QStringList;
|
class QStringList;
|
||||||
class QVariant;
|
class QVariant;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adaptor class for interface org.keepassxc.MainWindow
|
* Adaptor class for interface org.keepassxc.MainWindow
|
||||||
@ -43,6 +45,7 @@ class MainWindowAdaptor: public QDBusAbstractAdaptor
|
|||||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"appExit\"/>\n"
|
" <method name=\"appExit\"/>\n"
|
||||||
|
" <method name=\"lockAllDatabases\"/>\n"
|
||||||
" <method name=\"closeAllDatabases\"/>\n"
|
" <method name=\"closeAllDatabases\"/>\n"
|
||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
"")
|
"")
|
||||||
@ -50,14 +53,15 @@ public:
|
|||||||
MainWindowAdaptor(QObject *parent);
|
MainWindowAdaptor(QObject *parent);
|
||||||
virtual ~MainWindowAdaptor();
|
virtual ~MainWindowAdaptor();
|
||||||
|
|
||||||
public: // PROPERTIES
|
public:
|
||||||
public Q_SLOTS: // METHODS
|
public slots:
|
||||||
void appExit();
|
void appExit();
|
||||||
void closeAllDatabases();
|
void closeAllDatabases();
|
||||||
|
void lockAllDatabases();
|
||||||
void openDatabase(const QString &fileName);
|
void openDatabase(const QString &fileName);
|
||||||
void openDatabase(const QString &fileName, const QString &pw);
|
void openDatabase(const QString &fileName, const QString &pw);
|
||||||
void openDatabase(const QString &fileName, const QString &pw, const QString &keyFile);
|
void openDatabase(const QString &fileName, const QString &pw, const QString &keyFile);
|
||||||
Q_SIGNALS: // SIGNALS
|
signals:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||||
<node>
|
<node>
|
||||||
<interface name="org.keepassxc.MainWindow">
|
<interface name="org.keepassxc.KeePassXC.MainWindow">
|
||||||
<method name="openDatabase">
|
<method name="openDatabase">
|
||||||
<arg name="fileName" type="s" direction="in"/>
|
<arg name="fileName" type="s" direction="in"/>
|
||||||
<arg name="pw" type="s" direction="in"/>
|
<arg name="pw" type="s" direction="in"/>
|
||||||
@ -15,6 +15,8 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="appExit">
|
<method name="appExit">
|
||||||
</method>
|
</method>
|
||||||
|
<method name="lockAllDatabases">
|
||||||
|
</method>
|
||||||
<method name="closeAllDatabases">
|
<method name="closeAllDatabases">
|
||||||
</method>
|
</method>
|
||||||
</interface>
|
</interface>
|
Loading…
Reference in New Issue
Block a user