Generate the D-Bus adaptor class on the fly

That prevents mismatches between the adaptor class and the D-Bus
definition file.

Note that this is a backward-incompatible change. For example, the
command to lock all databases is changed from

> dbus-send --session --print-reply --dest=org.keepassxc.KeePassXC.MainWindow --type=method_call /keepassxc org.keepassxc.MainWindow.lockAllDatabases

to

> dbus-send --session --print-reply --dest=org.keepassxc.KeePassXC.MainWindow --type=method_call /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases

Fixes: https://github.com/keepassxreboot/keepassxc/issues/5355
This commit is contained in:
Chih-Hsuan Yen 2021-01-10 00:26:06 +08:00 committed by Jonathan White
parent e07d143c9b
commit c363e4a969
4 changed files with 5 additions and 128 deletions

View File

@ -206,10 +206,13 @@ endif()
if(UNIX AND NOT APPLE)
set(keepassx_SOURCES
${keepassx_SOURCES}
gui/MainWindowAdaptor.cpp
gui/osutils/nixutils/ScreenLockListenerDBus.cpp
gui/osutils/nixutils/NixUtils.cpp
gui/osutils/nixutils/X11Funcs.cpp)
qt5_add_dbus_adaptor(keepassx_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h
MainWindow)
endif()
if(WIN32)
set(keepassx_SOURCES

View File

@ -72,7 +72,7 @@
#endif
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) && !defined(QT_NO_DBUS)
#include "gui/MainWindowAdaptor.h"
#include "mainwindowadaptor.h"
#endif
const QString MainWindow::BaseWindowTitle = "KeePassXC";

View File

@ -1,57 +0,0 @@
/*
* 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.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#include "MainWindowAdaptor.h"
/*
* Implementation of adaptor class MainWindowAdaptor
*/
MainWindowAdaptor::MainWindowAdaptor(QObject* parent)
: QDBusAbstractAdaptor(parent)
{
setAutoRelaySignals(true);
}
MainWindowAdaptor::~MainWindowAdaptor()
{
}
void MainWindowAdaptor::appExit()
{
QMetaObject::invokeMethod(parent(), "appExit");
}
void MainWindowAdaptor::closeAllDatabases()
{
QMetaObject::invokeMethod(parent(), "closeAllDatabases");
}
void MainWindowAdaptor::lockAllDatabases()
{
QMetaObject::invokeMethod(parent(), "lockAllDatabases");
}
void MainWindowAdaptor::openDatabase(const QString& fileName)
{
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName));
}
void MainWindowAdaptor::openDatabase(const QString& fileName, const 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)
{
QMetaObject::invokeMethod(
parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw), Q_ARG(QString, keyFile));
}

View File

@ -1,69 +0,0 @@
/*
* 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.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#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
*/
class MainWindowAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.keepassxc.MainWindow")
Q_CLASSINFO("D-Bus Introspection",
""
" <interface name=\"org.keepassxc.MainWindow\">\n"
" <method name=\"openDatabase\">\n"
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"pw\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"keyFile\"/>\n"
" </method>\n"
" <method name=\"openDatabase\">\n"
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"pw\"/>\n"
" </method>\n"
" <method name=\"openDatabase\">\n"
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
" </method>\n"
" <method name=\"appExit\"/>\n"
" <method name=\"lockAllDatabases\"/>\n"
" <method name=\"closeAllDatabases\"/>\n"
" </interface>\n"
"")
public:
MainWindowAdaptor(QObject* parent);
virtual ~MainWindowAdaptor();
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);
signals:
};
#endif