mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 23:39:45 -05: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_YUBIKEY "Include YubiKey support." OFF)
|
||||
option(WITH_XC_SSHAGENT "Include SSH agent support." OFF)
|
||||
option(WITH_XC_DBUS "Include DBus support." OFF)
|
||||
|
||||
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"
|
||||
|
@ -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}
|
||||
core/ScreenLockListenerDBus.h
|
||||
core/ScreenLockListenerDBus.cpp
|
||||
gui/MainWindowAdaptor.cpp
|
||||
)
|
||||
endif()
|
||||
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(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(DBus WITH_XC_DBUS "Take keepassxc control by DBus")
|
||||
|
||||
if(WITH_XC_HTTP)
|
||||
add_subdirectory(http)
|
||||
@ -211,13 +211,6 @@ if(WITH_XC_BROWSER)
|
||||
set(keepassxcbrowser_LIB keepassxcbrowser)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE AND WITH_XC_DBUS)
|
||||
set(keepassx_SOURCES
|
||||
${keepassx_SOURCES}
|
||||
gui/MainWindowAdaptor.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectory(autotype)
|
||||
add_subdirectory(cli)
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#cmakedefine WITH_XC_HTTP
|
||||
#cmakedefine WITH_XC_YUBIKEY
|
||||
#cmakedefine WITH_XC_SSHAGENT
|
||||
#cmakedefine WITH_XC_DBUS
|
||||
|
||||
#cmakedefine KEEPASSXC_DIST
|
||||
#cmakedefine KEEPASSXC_DIST_TYPE "@KEEPASSXC_DIST_TYPE@"
|
||||
|
@ -24,11 +24,6 @@
|
||||
#include <QShortcut>
|
||||
#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 "autotype/AutoType.h"
|
||||
@ -61,15 +56,14 @@
|
||||
#include "browser/BrowserOptionDialog.h"
|
||||
#endif
|
||||
|
||||
#include "gui/SettingsWidget.h"
|
||||
#include "gui/PasswordGeneratorWidget.h"
|
||||
|
||||
#ifdef WITH_XC_DBUS
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <QtDBus>
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS)
|
||||
#include <QList>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include "gui/MainWindowAdaptor.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "gui/SettingsWidget.h"
|
||||
#include "gui/PasswordGeneratorWidget.h"
|
||||
|
||||
#ifdef WITH_XC_HTTP
|
||||
class HttpPlugin: public ISettingsPage
|
||||
@ -175,16 +169,13 @@ MainWindow::MainWindow()
|
||||
, m_appExiting(false)
|
||||
{
|
||||
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);
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
dbus.registerObject("/keepassxc", this);
|
||||
dbus.registerService("org.keepassxc.MainWindow");
|
||||
#else
|
||||
qWarning("DBus is not available on this system");
|
||||
#endif
|
||||
#endif
|
||||
dbus.registerService("org.keepassxc.KeePassXC.MainWindow");
|
||||
#endif
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
@ -1145,3 +1136,8 @@ void MainWindow::closeAllDatabases()
|
||||
{
|
||||
m_ui->tabWidget->closeAllDatabases();
|
||||
}
|
||||
|
||||
void MainWindow::lockAllDatabases()
|
||||
{
|
||||
lockDatabasesAfterInactivity();
|
||||
}
|
@ -38,8 +38,8 @@ class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
Q_CLASSINFO("D-Bus Interface", "org.keepassxc.MainWindow")
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS)
|
||||
Q_CLASSINFO("D-Bus Interface", "org.keepassxc.KeePassXC.MainWindow")
|
||||
#endif
|
||||
|
||||
public:
|
||||
@ -67,10 +67,11 @@ public slots:
|
||||
void hideYubiKeyPopup();
|
||||
void bringToFront();
|
||||
void closeAllDatabases();
|
||||
void lockAllDatabases();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void changeEvent(QEvent* event) override;
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void changeEvent(QEvent* event) override;
|
||||
|
||||
private slots:
|
||||
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
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
@ -24,42 +24,40 @@
|
||||
MainWindowAdaptor::MainWindowAdaptor(QObject *parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
// constructor
|
||||
setAutoRelaySignals(true);
|
||||
}
|
||||
|
||||
MainWindowAdaptor::~MainWindowAdaptor()
|
||||
{
|
||||
// destructor
|
||||
}
|
||||
|
||||
void MainWindowAdaptor::appExit()
|
||||
{
|
||||
// handle method call org.keepassxc.MainWindow.appExit
|
||||
QMetaObject::invokeMethod(parent(), "appExit");
|
||||
}
|
||||
|
||||
void MainWindowAdaptor::closeAllDatabases()
|
||||
{
|
||||
// handle method call org.keepassxc.MainWindow.closeAllDatabases
|
||||
QMetaObject::invokeMethod(parent(), "closeAllDatabases");
|
||||
}
|
||||
|
||||
void MainWindowAdaptor::lockAllDatabases()
|
||||
{
|
||||
QMetaObject::invokeMethod(parent(), "lockAllDatabases");
|
||||
}
|
||||
|
||||
void MainWindowAdaptor::openDatabase(const QString &fileName)
|
||||
{
|
||||
// handle method call org.keepassxc.MainWindow.openDatabase
|
||||
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
@ -9,17 +9,19 @@
|
||||
* before re-generating it.
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOWADAPTOR_H_1486736200
|
||||
#define MAINWINDOWADAPTOR_H_1486736200
|
||||
#ifndef MAINWINDOWADAPTOR_H
|
||||
#define MAINWINDOWADAPTOR_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtDBus/QtDBus>
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QByteArray;
|
||||
template<class T> class QList;
|
||||
template<class Key, class Value> class QMap;
|
||||
class QString;
|
||||
class QStringList;
|
||||
class QVariant;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/*
|
||||
* Adaptor class for interface org.keepassxc.MainWindow
|
||||
@ -43,6 +45,7 @@ class MainWindowAdaptor: public QDBusAbstractAdaptor
|
||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"appExit\"/>\n"
|
||||
" <method name=\"lockAllDatabases\"/>\n"
|
||||
" <method name=\"closeAllDatabases\"/>\n"
|
||||
" </interface>\n"
|
||||
"")
|
||||
@ -50,14 +53,15 @@ public:
|
||||
MainWindowAdaptor(QObject *parent);
|
||||
virtual ~MainWindowAdaptor();
|
||||
|
||||
public: // PROPERTIES
|
||||
public Q_SLOTS: // METHODS
|
||||
public:
|
||||
public slots:
|
||||
void appExit();
|
||||
void closeAllDatabases();
|
||||
void lockAllDatabases();
|
||||
void openDatabase(const QString &fileName);
|
||||
void openDatabase(const QString &fileName, const QString &pw);
|
||||
void openDatabase(const QString &fileName, const QString &pw, const QString &keyFile);
|
||||
Q_SIGNALS: // SIGNALS
|
||||
signals:
|
||||
};
|
||||
|
||||
#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">
|
||||
<node>
|
||||
<interface name="org.keepassxc.MainWindow">
|
||||
<interface name="org.keepassxc.KeePassXC.MainWindow">
|
||||
<method name="openDatabase">
|
||||
<arg name="fileName" type="s" direction="in"/>
|
||||
<arg name="pw" type="s" direction="in"/>
|
||||
@ -15,6 +15,8 @@
|
||||
</method>
|
||||
<method name="appExit">
|
||||
</method>
|
||||
<method name="lockAllDatabases">
|
||||
</method>
|
||||
<method name="closeAllDatabases">
|
||||
</method>
|
||||
</interface>
|
Loading…
Reference in New Issue
Block a user