File Install-the-kontact-plugin-into-kontact5.patch of Package zanshin
From faba24de5cc556870991fcc013a0ef2dceb5eeb9 Mon Sep 17 00:00:00 2001
From: David Faure <faure@kde.org>
Date: Wed, 15 Apr 2020 09:29:42 +0200
Subject: [PATCH] Install the kontact plugin into kontact5, with JSON metadata.
Summary: This will allow kontact to use KPluginLoader one day.
Test Plan:
rm $prefix/lib64/plugins/kontact_zanshinplugin.so ; make install
kontact still finds the zanshin plugin
The same steps (other than old-kontact-interface compatibility) were already
pushed to all other kontact plugins.
Reviewers: ervin
Reviewed By: ervin
Differential Revision: https://phabricator.kde.org/D28847
---
src/zanshin/kontact/CMakeLists.txt | 12 +++++++++++-
src/zanshin/kontact/kontact_plugin.cpp | 20 +++++++++++++++++++-
src/zanshin/kontact/zanshin_plugin.desktop | 2 +-
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/zanshin/kontact/CMakeLists.txt b/src/zanshin/kontact/CMakeLists.txt
index 60913156..be660131 100644
--- a/src/zanshin/kontact/CMakeLists.txt
+++ b/src/zanshin/kontact/CMakeLists.txt
@@ -1,3 +1,12 @@
+# TODO: remove once kontactinterface 5.14.42 is required
+
+if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
+ # CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros.
+ # 3.10+ lets us provide more macro names that require automoc.
+ # KF5 >= 5.42 takes care itself of adding its macros in its cmake config files
+ list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "EXPORT_KONTACT_PLUGIN_WITH_JSON")
+endif()
+
set(part_SRCS
../app/aboutdata.cpp
part.cpp
@@ -22,8 +31,9 @@ set(kontact_SRCS
add_library(kontact_zanshinplugin MODULE ${kontact_SRCS})
target_link_libraries(kontact_zanshinplugin KF5::Parts KF5::KontactInterface)
+kcoreaddons_desktop_to_json(kontact_zanshinplugin zanshin_plugin.desktop)
-install(TARGETS kontact_zanshinplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
+install(TARGETS kontact_zanshinplugin DESTINATION ${KDE_INSTALL_PLUGINDIR}/kontact5)
install(FILES zanshin_plugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/kontact)
install(FILES zanshin_part.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/zanshin)
diff --git a/src/zanshin/kontact/kontact_plugin.cpp b/src/zanshin/kontact/kontact_plugin.cpp
index 4b0d2f92..8edbb4a6 100644
--- a/src/zanshin/kontact/kontact_plugin.cpp
+++ b/src/zanshin/kontact/kontact_plugin.cpp
@@ -25,7 +25,25 @@
#include <KontactInterface/Core>
-EXPORT_KONTACT_PLUGIN(Plugin, zanshin)
+#if KONTACTINTERFACE_VERSION < QT_VERSION_CHECK(5, 14, 42)
+/**
+ Exports Kontact plugin.
+ @param pluginclass the class to instanciate (must derive from KontactInterface::Plugin
+ @param jsonFile filename of the JSON file, generated from a .desktop file
+ */
+#define EXPORT_KONTACT_PLUGIN_WITH_JSON( pluginclass, jsonFile ) \
+ class Instance \
+ { \
+ public: \
+ static QObject *createInstance( QWidget *, QObject *parent, const QVariantList &list ) \
+ { return new pluginclass( static_cast<KontactInterface::Core*>( parent ), list ); } \
+ }; \
+ K_PLUGIN_FACTORY_WITH_JSON( KontactPluginFactory, jsonFile, registerPlugin< pluginclass > \
+ ( QString(), Instance::createInstance ); ) \
+ K_EXPORT_PLUGIN_VERSION(KONTACT_PLUGIN_VERSION)
+#endif
+
+EXPORT_KONTACT_PLUGIN_WITH_JSON(Plugin, "zanshin_plugin.json")
Plugin::Plugin(KontactInterface::Core *core, const QVariantList&)
: KontactInterface::Plugin(core, core, "zanshin")
diff --git a/src/zanshin/kontact/zanshin_plugin.desktop b/src/zanshin/kontact/zanshin_plugin.desktop
index f616a898..58fe05c1 100644
--- a/src/zanshin/kontact/zanshin_plugin.desktop
+++ b/src/zanshin/kontact/zanshin_plugin.desktop
@@ -3,7 +3,7 @@ Type=Service
Icon=zanshin
X-KDE-ServiceTypes=Kontact/Plugin,KPluginInfo
-X-KDE-Library=kontact_zanshinplugin
+X-KDE-Library=kontact5/kontact_zanshinplugin
X-KDE-KontactPluginVersion=10
X-KDE-KontactPartLibraryName=zanshin_part
X-KDE-KontactPartExecutableName=zanshin
--
GitLab