feat!: register Keysmith with D-Bus
This change provides the most basic D-Bus support in Keysmith. At start up, Keysmith will now register itself and abort if another instance is already running. Full support for the xdg D-Bus activation specification (such as URI opening) is not yet implemented. By default this feature is disabled on Android, but enabled on 'all' other platforms. Explicit control may be exercised by running CMake with -DBUILD_DBUS_INTERFACE=<ON|OFF>. Issues: #18master
parent
893efc09e9
commit
287cbcd480
|
@ -53,6 +53,11 @@ if(NOT BUILD_EXTERNAL AND (NOT ANDROID OR DEFINED BUILD_EXTERNAL))
|
|||
find_package(sodium ${SODIUM_MIN_VERSION} REQUIRED)
|
||||
endif()
|
||||
|
||||
if (BUILD_DBUS_INTERFACE OR (NOT ANDROID AND NOT DEFINED BUILD_DBUS_INTERFACE))
|
||||
find_package(KF5DBusAddons ${KF5_MIN_VERSION} REQUIRED)
|
||||
set(ENABLE_DBUS_INTERFACE ON)
|
||||
endif()
|
||||
|
||||
################ Find testing dependencies ##########
|
||||
|
||||
if (BUILD_TESTING)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
# SPDX-FileCopyrightText: 2019 Bhushan Shah <bshah@kde.org>
|
||||
# SPDX-FileCopyrightText: 2019 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
# SPDX-FileCopyrightText: 2019-2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
# SPDX-FileCopyrightText: 2019-2021 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
# SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
|
||||
# SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
|
||||
#
|
||||
|
@ -19,6 +19,14 @@ add_subdirectory(app)
|
|||
|
||||
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")
|
||||
|
||||
#
|
||||
# The features header should be namespaced, or at least it *must not* be called 'features.h'.
|
||||
# Reason is that the GNU C++ standard library implementation also refers to a 'features.h'
|
||||
# and compilation will blow up very badly inside 'os_defines.h' if it does not get the
|
||||
# 'features.h' it was (really) looking for.
|
||||
#
|
||||
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/keysmith-features.h.in" "${CMAKE_CURRENT_BINARY_DIR}/keysmith-features.h")
|
||||
|
||||
set(keysmith_SRCS
|
||||
main.cpp
|
||||
)
|
||||
|
@ -33,6 +41,10 @@ target_link_libraries(keysmith
|
|||
${keysmith_internal_libs}
|
||||
)
|
||||
|
||||
if (ENABLE_DBUS_INTERFACE)
|
||||
target_link_libraries(keysmith KF5::DBusAddons)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
kirigami_package_breeze_icons(ICONS
|
||||
application-quit
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* SPDX-FileCopyrightText: 2021 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
|
||||
*/
|
||||
#ifndef KEYSMITH_FEATURES_H
|
||||
#define KEYSMITH_FEATURES_H
|
||||
|
||||
// record support for optional features at configure (cmake) time
|
||||
|
||||
#cmakedefine ENABLE_DBUS_INTERFACE true
|
||||
|
||||
#endif
|
|
@ -23,6 +23,7 @@
|
|||
#include "validators/issuervalidator.h"
|
||||
#include "validators/secretvalidator.h"
|
||||
|
||||
#include "keysmith-features.h"
|
||||
#include "version.h"
|
||||
|
||||
/*
|
||||
|
@ -34,6 +35,10 @@
|
|||
static QQmlDebuggingEnabler enabler;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DBUS_INTERFACE
|
||||
#include <KDBusService>
|
||||
#endif
|
||||
|
||||
Q_DECL_EXPORT int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
@ -72,6 +77,10 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||
|
||||
app::Proxy proxy(&app);
|
||||
|
||||
#ifdef ENABLE_DBUS_INTERFACE
|
||||
KDBusService service(KDBusService::Unique);
|
||||
#endif
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
|
||||
|
|
Loading…
Reference in New Issue