From 9a27a1e70f1151926e08ed3c62dbb758379f0c4c Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Sun, 24 Oct 2021 16:44:03 +0200 Subject: [PATCH] Start purpose integration --- src/CMakeLists.txt | 12 ++++++++ src/neochatpurposeplugin.cpp | 54 +++++++++++++++++++++++++++++++++++ src/neochatpurposeplugin.json | 22 ++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 src/neochatpurposeplugin.cpp create mode 100644 src/neochatpurposeplugin.json diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5f1b34ec..688e516c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,6 +64,18 @@ target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR}) target_link_libraries(neochat PRIVATE Qt::Quick Qt::Qml Qt::Gui Qt::Network Qt::QuickControls2 KF5::I18n KF5::Kirigami2 KF5::Notifications KF5::ConfigCore KF5::ConfigGui KF5::CoreAddons Quotient cmark::cmark ${QTKEYCHAIN_LIBRARIES} QCoro::QCoro) kconfig_add_kcfg_files(neochat GENERATE_MOC neochatconfig.kcfgc) +if(TARGET KF5::Purpose) + function(add_share_plugin name) + kcoreaddons_add_plugin(${name} SOURCES ${ARGN} INSTALL_NAMESPACE "kf5/purpose") + target_link_libraries(${name} Qt5::Core KF5::Purpose) + set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/kf5/purpose") + endfunction() + + add_share_plugin(neochatpurposeplugin neochatpurposeplugin.cpp) + target_link_libraries(neochatpurposeplugin KF5::I18n KF5::Service) +endif() + + if(NEOCHAT_FLATPAK) target_compile_definitions(neochat PRIVATE NEOCHAT_FLATPAK) endif() diff --git a/src/neochatpurposeplugin.cpp b/src/neochatpurposeplugin.cpp new file mode 100644 index 000000000..821fb495e --- /dev/null +++ b/src/neochatpurposeplugin.cpp @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: 2021 Carl Schwan +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +EXPORT_SHARE_VERSION + +namespace +{ +class NeoChatShareJob : public Purpose::Job +{ + Q_OBJECT +public: + explicit NeoChatShareJob(QObject *parent = nullptr) + : Purpose::Job(parent) + { + } + + void start() override + { + } +}; +} + +class Q_DECL_EXPORT NeoChatPurposePlugin : public Purpose::PluginBase +{ + Q_OBJECT +public: + NeoChatPurposePlugin(QObject *parent, const QVariantList &) + : Purpose::PluginBase(parent) + { + } + + Purpose::Job *createJob() const override + { + return new NeoChatShareJob(nullptr); + } +}; + +K_PLUGIN_CLASS_WITH_JSON(NeoChatPurposePlugin, "neochatpurposeplugin.json") + +#include "neochatpurposeplugin.moc" + diff --git a/src/neochatpurposeplugin.json b/src/neochatpurposeplugin.json new file mode 100644 index 000000000..964f63b9c --- /dev/null +++ b/src/neochatpurposeplugin.json @@ -0,0 +1,22 @@ +{ + "KPlugin": { + "Authors": [ + { + "Name": "Carl Schwan" + } + ], + "Category": "Utilities", + + "Description": "Send vith NeoChat", + "Icon": "mail-message", + "License": "GPL", + "Name": "Send with NeoChat", + "X-Purpose-ActionDisplay": "Send with NeoChat..." + }, + "X-Purpose-Configuration": [], + "X-Purpose-Constraints": [], + "X-Purpose-PluginTypes": [ + "Export", + "ShareUrl" + ] +}