Make plugins work in SailfishConnect
This commit is contained in:
parent
875cf16a40
commit
bb5539c8c3
10 changed files with 86 additions and 30 deletions
|
@ -22,7 +22,9 @@ include(ECMSetupVersion)
|
|||
include(ECMInstallIcons)
|
||||
include(FeatureSummary)
|
||||
include(GenerateExportHeader)
|
||||
if (NOT SAILFISHOS)
|
||||
include(ECMQMLModules)
|
||||
endif()
|
||||
|
||||
include(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
|
||||
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()
|
||||
|
|
|
@ -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<classname >();)
|
||||
#endif
|
||||
|
||||
struct KdeConnectPluginPrivate;
|
||||
|
||||
class KDECONNECTCORE_EXPORT KdeConnectPlugin
|
||||
|
|
|
@ -20,9 +20,12 @@
|
|||
|
||||
#include "pluginloader.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <QPluginLoader>
|
||||
#include <KPluginMetaData>
|
||||
#include <KPluginLoader>
|
||||
#include <KPluginFactory>
|
||||
#include <QStaticPlugin>
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "device.h"
|
||||
|
@ -39,10 +42,24 @@ PluginLoader* PluginLoader::instance()
|
|||
|
||||
PluginLoader::PluginLoader()
|
||||
{
|
||||
#ifdef SAILFISHOS
|
||||
const QVector<QStaticPlugin> 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<KPluginFactory*>(staticPlugin.instance()));
|
||||
}
|
||||
}
|
||||
#else
|
||||
const QVector<KPluginMetaData> 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"));
|
||||
|
||||
|
|
|
@ -27,10 +27,13 @@
|
|||
|
||||
#include <KPluginMetaData>
|
||||
|
||||
#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<QString, KPluginMetaData> plugins;
|
||||
|
||||
|
||||
#ifdef SAILFISHOS
|
||||
QHash<QString, KPluginFactory*> pluginsFactories;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -4,16 +4,19 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
|||
|
||||
add_subdirectory(ping)
|
||||
add_subdirectory(battery)
|
||||
add_subdirectory(remotecommands)
|
||||
add_subdirectory(remotecontrol)
|
||||
add_subdirectory(remotesystemvolume)
|
||||
add_subdirectory(clipboard)
|
||||
add_subdirectory(presenter)
|
||||
add_subdirectory(runcommand)
|
||||
|
||||
if(NOT SAILFISHOS)
|
||||
add_subdirectory(sendnotifications)
|
||||
add_subdirectory(mpriscontrol)
|
||||
add_subdirectory(photo)
|
||||
add_subdirectory(remotecommands)
|
||||
add_subdirectory(mprisremote)
|
||||
add_subdirectory(remotecontrol)
|
||||
add_subdirectory(lockdevice)
|
||||
add_subdirectory(remotesystemvolume)
|
||||
if(NOT SAILFISHOS)
|
||||
add_subdirectory(clipboard)
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -10,7 +10,7 @@ target_link_libraries(kdeconnect_runcommand
|
|||
KF5::I18n)
|
||||
|
||||
#----------------------
|
||||
|
||||
if(NOT SAILFISHOS)
|
||||
set( kdeconnect_runcommand_config_SRCS runcommand_config.cpp )
|
||||
|
||||
add_library(kdeconnect_runcommand_config MODULE ${kdeconnect_runcommand_config_SRCS} )
|
||||
|
@ -25,3 +25,4 @@ target_link_libraries( kdeconnect_runcommand_config
|
|||
|
||||
install(TARGETS kdeconnect_runcommand_config DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
install(FILES kdeconnect_runcommand_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
|
||||
endif()
|
||||
|
|
|
@ -28,8 +28,13 @@
|
|||
#include <QLoggingCategory>
|
||||
#include <QSettings>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#ifdef SAILFISHOS
|
||||
#define KCMUTILS_VERSION 0
|
||||
#else
|
||||
#include <KShell>
|
||||
#include <kcmutils_version.h>
|
||||
#endif
|
||||
|
||||
#include <core/networkpacket.h>
|
||||
#include <core/device.h>
|
||||
|
|
Loading…
Reference in a new issue