diff --git a/CMakeLists.txt b/CMakeLists.txt index 130c054d5..8e0167e0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,9 @@ include(ECMSetupVersion) include(ECMInstallIcons) include(FeatureSummary) include(GenerateExportHeader) -include(ECMQMLModules) +if (NOT SAILFISHOS) + include(ECMQMLModules) +endif() include(KDEConnectMacros.cmake) diff --git a/KDEConnectMacros.cmake b/KDEConnectMacros.cmake index bf052ff6b..91d327bbe 100644 --- a/KDEConnectMacros.cmake +++ b/KDEConnectMacros.cmake @@ -2,7 +2,24 @@ # Redistribution and use is allowed according to the terms of the BSD license. -# Thoroughly inspired in kdevplatform_add_plugin -function(kdeconnect_add_plugin) - kcoreaddons_add_plugin(${ARGN} INSTALL_NAMESPACE kdeconnect) -endfunction() +if (SAILFISHOS) + function(kdeconnect_add_plugin plugin) + set(options) + set(oneValueArgs JSON) + set(multiValueArgs SOURCES) + cmake_parse_arguments(KC_ADD_PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT KC_ADD_PLUGIN_SOURCES) + message(FATAL_ERROR "kdeconnect_add_plugin called without SOURCES parameter") + endif() + get_filename_component(json "${KC_ADD_PLUGIN_JSON}" REALPATH) + + add_library(${plugin} STATIC ${KC_ADD_PLUGIN_SOURCES}) + set_property(TARGET ${plugin} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${json}) + set_property(TARGET ${plugin} APPEND PROPERTY COMPILE_DEFINITIONS QT_STATICPLUGIN) + endfunction() +else() + function(kdeconnect_add_plugin) + kcoreaddons_add_plugin(${ARGN} INSTALL_NAMESPACE kdeconnect) + endfunction() +endif() diff --git a/core/kdeconnectplugin.h b/core/kdeconnectplugin.h index aecae0907..a6142a285 100644 --- a/core/kdeconnectplugin.h +++ b/core/kdeconnectplugin.h @@ -29,6 +29,10 @@ #include "networkpacket.h" #include "device.h" +#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5,44,0) +#define K_PLUGIN_CLASS_WITH_JSON(classname,jsonFile) K_PLUGIN_FACTORY_WITH_JSON(classname ## Factory, jsonFile, registerPlugin();) +#endif + struct KdeConnectPluginPrivate; class KDECONNECTCORE_EXPORT KdeConnectPlugin diff --git a/core/pluginloader.cpp b/core/pluginloader.cpp index d853d3bfb..76bf28e5c 100644 --- a/core/pluginloader.cpp +++ b/core/pluginloader.cpp @@ -20,9 +20,12 @@ #include "pluginloader.h" +#include +#include #include #include #include +#include #include "core_debug.h" #include "device.h" @@ -39,10 +42,24 @@ PluginLoader* PluginLoader::instance() PluginLoader::PluginLoader() { +#ifdef SAILFISHOS + const QVector staticPlugins = QPluginLoader::staticPlugins(); + for (auto& staticPlugin : staticPlugins) { + QJsonObject jsonMetadata = staticPlugin.metaData().value(QStringLiteral("MetaData")).toObject(); + KPluginMetaData metadata(jsonMetadata, QString()); + if (metadata.serviceTypes().contains(QStringLiteral("KdeConnect/Plugin"))) { + plugins.insert(metadata.pluginId(), metadata); + pluginsFactories.insert( + metadata.pluginId(), + qobject_cast(staticPlugin.instance())); + } + } +#else const QVector data = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/")); for (const KPluginMetaData& metadata : data) { plugins[metadata.pluginId()] = metadata; } +#endif } QStringList PluginLoader::getPluginList() const @@ -65,12 +82,16 @@ KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& plugin return ret; } +#ifdef SAILFISHOS + KPluginFactory* factory = pluginsFactories.value(pluginName); +#else KPluginLoader loader(service.fileName()); KPluginFactory* factory = loader.factory(); if (!factory) { qCDebug(KDECONNECT_CORE) << "KPluginFactory could not load the plugin:" << service.pluginId() << loader.errorString(); return ret; } +#endif const QStringList outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPacketType")); diff --git a/core/pluginloader.h b/core/pluginloader.h index b3bb264ac..de671c673 100644 --- a/core/pluginloader.h +++ b/core/pluginloader.h @@ -27,10 +27,13 @@ #include +#include "kdeconnectcore_export.h" + class Device; class KdeConnectPlugin; +class KPluginFactory; -class PluginLoader +class KDECONNECTCORE_EXPORT PluginLoader { public: @@ -46,9 +49,11 @@ public: private: PluginLoader(); + QHash plugins; - - +#ifdef SAILFISHOS + QHash pluginsFactories; +#endif }; #endif diff --git a/interfaces/CMakeLists.txt b/interfaces/CMakeLists.txt index 6c71c7cfa..6111deaee 100644 --- a/interfaces/CMakeLists.txt +++ b/interfaces/CMakeLists.txt @@ -39,7 +39,7 @@ geninterface(${PROJECT_SOURCE_DIR}/plugins/sms/conversationsdbusinterface.h conv geninterface(${PROJECT_SOURCE_DIR}/plugins/share/shareplugin.h shareinterface) geninterface(${PROJECT_SOURCE_DIR}/plugins/remotesystemvolume/remotesystemvolumeplugin.h remotesystemvolumeinterface) -add_library(kdeconnectinterfaces SHARED ${libkdeconnect_SRC}) +add_library(kdeconnectinterfaces ${libkdeconnect_SRC}) set_target_properties(kdeconnectinterfaces PROPERTIES VERSION ${KDECONNECT_VERSION} SOVERSION ${KDECONNECT_VERSION_MAJOR} diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 1b1690c15..1acaf4fc9 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -4,16 +4,19 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) add_subdirectory(ping) add_subdirectory(battery) -add_subdirectory(sendnotifications) -add_subdirectory(mpriscontrol) -add_subdirectory(photo) add_subdirectory(remotecommands) -add_subdirectory(mprisremote) add_subdirectory(remotecontrol) -add_subdirectory(lockdevice) add_subdirectory(remotesystemvolume) +add_subdirectory(clipboard) +add_subdirectory(presenter) +add_subdirectory(runcommand) + if(NOT SAILFISHOS) - add_subdirectory(clipboard) + add_subdirectory(sendnotifications) + add_subdirectory(mpriscontrol) + add_subdirectory(photo) + add_subdirectory(mprisremote) + add_subdirectory(lockdevice) add_subdirectory(contacts) add_subdirectory(share) add_subdirectory(remotekeyboard) @@ -22,8 +25,6 @@ if(NOT SAILFISHOS) add_subdirectory(telephony) add_subdirectory(mousepad) add_subdirectory(sms) - add_subdirectory(runcommand) - add_subdirectory(presenter) add_subdirectory(screensaver-inhibit) if(NOT APPLE) diff --git a/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp b/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp index 75b6d9aa1..9ff33206b 100644 --- a/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp +++ b/plugins/remotesystemvolume/remotesystemvolumeplugin.cpp @@ -34,7 +34,7 @@ K_PLUGIN_CLASS_WITH_JSON(RemoteSystemVolumePlugin, "kdeconnect_remotesystemvolume.json") -Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_PING, "kdeconnect.plugin.remotesystemvolume") +Q_LOGGING_CATEGORY(KDECONNECT_PLUGIN_REMOTESYSTEMVOLUME, "kdeconnect.plugin.remotesystemvolume") RemoteSystemVolumePlugin::RemoteSystemVolumePlugin(QObject* parent, const QVariantList& args) : KdeConnectPlugin(parent, args) diff --git a/plugins/runcommand/CMakeLists.txt b/plugins/runcommand/CMakeLists.txt index 6c0a08a1e..b2615e9f2 100644 --- a/plugins/runcommand/CMakeLists.txt +++ b/plugins/runcommand/CMakeLists.txt @@ -10,18 +10,19 @@ target_link_libraries(kdeconnect_runcommand KF5::I18n) #---------------------- +if(NOT SAILFISHOS) + set( kdeconnect_runcommand_config_SRCS runcommand_config.cpp ) -set( kdeconnect_runcommand_config_SRCS runcommand_config.cpp ) + add_library(kdeconnect_runcommand_config MODULE ${kdeconnect_runcommand_config_SRCS} ) + target_link_libraries( kdeconnect_runcommand_config + kdeconnectcore + kdeconnectpluginkcm + KF5::I18n + KF5::CoreAddons + KF5::ConfigWidgets -add_library(kdeconnect_runcommand_config MODULE ${kdeconnect_runcommand_config_SRCS} ) -target_link_libraries( kdeconnect_runcommand_config - kdeconnectcore - kdeconnectpluginkcm - KF5::I18n - KF5::CoreAddons - KF5::ConfigWidgets + ) -) - -install(TARGETS kdeconnect_runcommand_config DESTINATION ${PLUGIN_INSTALL_DIR} ) -install(FILES kdeconnect_runcommand_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) + install(TARGETS kdeconnect_runcommand_config DESTINATION ${PLUGIN_INSTALL_DIR} ) + install(FILES kdeconnect_runcommand_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +endif() diff --git a/plugins/runcommand/runcommandplugin.cpp b/plugins/runcommand/runcommandplugin.cpp index 50b898cfe..469908a19 100644 --- a/plugins/runcommand/runcommandplugin.cpp +++ b/plugins/runcommand/runcommandplugin.cpp @@ -28,8 +28,13 @@ #include #include #include + +#ifdef SAILFISHOS +#define KCMUTILS_VERSION 0 +#else #include #include +#endif #include #include