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(ECMInstallIcons)
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
include(ECMQMLModules)
|
if (NOT SAILFISHOS)
|
||||||
|
include(ECMQMLModules)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(KDEConnectMacros.cmake)
|
include(KDEConnectMacros.cmake)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,24 @@
|
||||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
# 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)
|
function(kdeconnect_add_plugin plugin)
|
||||||
kcoreaddons_add_plugin(${ARGN} INSTALL_NAMESPACE kdeconnect)
|
set(options)
|
||||||
endfunction()
|
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 "networkpacket.h"
|
||||||
#include "device.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;
|
struct KdeConnectPluginPrivate;
|
||||||
|
|
||||||
class KDECONNECTCORE_EXPORT KdeConnectPlugin
|
class KDECONNECTCORE_EXPORT KdeConnectPlugin
|
||||||
|
|
|
@ -20,9 +20,12 @@
|
||||||
|
|
||||||
#include "pluginloader.h"
|
#include "pluginloader.h"
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QPluginLoader>
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
#include <KPluginLoader>
|
#include <KPluginLoader>
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
|
#include <QStaticPlugin>
|
||||||
|
|
||||||
#include "core_debug.h"
|
#include "core_debug.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
@ -39,10 +42,24 @@ PluginLoader* PluginLoader::instance()
|
||||||
|
|
||||||
PluginLoader::PluginLoader()
|
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/"));
|
const QVector<KPluginMetaData> data = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"));
|
||||||
for (const KPluginMetaData& metadata : data) {
|
for (const KPluginMetaData& metadata : data) {
|
||||||
plugins[metadata.pluginId()] = metadata;
|
plugins[metadata.pluginId()] = metadata;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PluginLoader::getPluginList() const
|
QStringList PluginLoader::getPluginList() const
|
||||||
|
@ -65,12 +82,16 @@ KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& plugin
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SAILFISHOS
|
||||||
|
KPluginFactory* factory = pluginsFactories.value(pluginName);
|
||||||
|
#else
|
||||||
KPluginLoader loader(service.fileName());
|
KPluginLoader loader(service.fileName());
|
||||||
KPluginFactory* factory = loader.factory();
|
KPluginFactory* factory = loader.factory();
|
||||||
if (!factory) {
|
if (!factory) {
|
||||||
qCDebug(KDECONNECT_CORE) << "KPluginFactory could not load the plugin:" << service.pluginId() << loader.errorString();
|
qCDebug(KDECONNECT_CORE) << "KPluginFactory could not load the plugin:" << service.pluginId() << loader.errorString();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const QStringList outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPacketType"));
|
const QStringList outgoingInterfaces = KPluginMetaData::readStringList(service.rawData(), QStringLiteral("X-KdeConnect-OutgoingPacketType"));
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,13 @@
|
||||||
|
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
|
|
||||||
|
#include "kdeconnectcore_export.h"
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
class KdeConnectPlugin;
|
class KdeConnectPlugin;
|
||||||
|
class KPluginFactory;
|
||||||
|
|
||||||
class PluginLoader
|
class KDECONNECTCORE_EXPORT PluginLoader
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -46,9 +49,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PluginLoader();
|
PluginLoader();
|
||||||
|
|
||||||
QHash<QString, KPluginMetaData> plugins;
|
QHash<QString, KPluginMetaData> plugins;
|
||||||
|
#ifdef SAILFISHOS
|
||||||
|
QHash<QString, KPluginFactory*> pluginsFactories;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#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/share/shareplugin.h shareinterface)
|
||||||
geninterface(${PROJECT_SOURCE_DIR}/plugins/remotesystemvolume/remotesystemvolumeplugin.h remotesystemvolumeinterface)
|
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
|
set_target_properties(kdeconnectinterfaces PROPERTIES
|
||||||
VERSION ${KDECONNECT_VERSION}
|
VERSION ${KDECONNECT_VERSION}
|
||||||
SOVERSION ${KDECONNECT_VERSION_MAJOR}
|
SOVERSION ${KDECONNECT_VERSION_MAJOR}
|
||||||
|
|
|
@ -4,16 +4,19 @@ install(FILES kdeconnect_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
||||||
|
|
||||||
add_subdirectory(ping)
|
add_subdirectory(ping)
|
||||||
add_subdirectory(battery)
|
add_subdirectory(battery)
|
||||||
add_subdirectory(sendnotifications)
|
|
||||||
add_subdirectory(mpriscontrol)
|
|
||||||
add_subdirectory(photo)
|
|
||||||
add_subdirectory(remotecommands)
|
add_subdirectory(remotecommands)
|
||||||
add_subdirectory(mprisremote)
|
|
||||||
add_subdirectory(remotecontrol)
|
add_subdirectory(remotecontrol)
|
||||||
add_subdirectory(lockdevice)
|
|
||||||
add_subdirectory(remotesystemvolume)
|
add_subdirectory(remotesystemvolume)
|
||||||
|
add_subdirectory(clipboard)
|
||||||
|
add_subdirectory(presenter)
|
||||||
|
add_subdirectory(runcommand)
|
||||||
|
|
||||||
if(NOT SAILFISHOS)
|
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(contacts)
|
||||||
add_subdirectory(share)
|
add_subdirectory(share)
|
||||||
add_subdirectory(remotekeyboard)
|
add_subdirectory(remotekeyboard)
|
||||||
|
@ -22,8 +25,6 @@ if(NOT SAILFISHOS)
|
||||||
add_subdirectory(telephony)
|
add_subdirectory(telephony)
|
||||||
add_subdirectory(mousepad)
|
add_subdirectory(mousepad)
|
||||||
add_subdirectory(sms)
|
add_subdirectory(sms)
|
||||||
add_subdirectory(runcommand)
|
|
||||||
add_subdirectory(presenter)
|
|
||||||
add_subdirectory(screensaver-inhibit)
|
add_subdirectory(screensaver-inhibit)
|
||||||
|
|
||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
K_PLUGIN_CLASS_WITH_JSON(RemoteSystemVolumePlugin, "kdeconnect_remotesystemvolume.json")
|
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)
|
RemoteSystemVolumePlugin::RemoteSystemVolumePlugin(QObject* parent, const QVariantList& args)
|
||||||
: KdeConnectPlugin(parent, args)
|
: KdeConnectPlugin(parent, args)
|
||||||
|
|
|
@ -10,18 +10,19 @@ target_link_libraries(kdeconnect_runcommand
|
||||||
KF5::I18n)
|
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} )
|
endif()
|
||||||
install(FILES kdeconnect_runcommand_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
|
|
||||||
|
|
|
@ -28,8 +28,13 @@
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
|
#ifdef SAILFISHOS
|
||||||
|
#define KCMUTILS_VERSION 0
|
||||||
|
#else
|
||||||
#include <KShell>
|
#include <KShell>
|
||||||
#include <kcmutils_version.h>
|
#include <kcmutils_version.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <core/networkpacket.h>
|
#include <core/networkpacket.h>
|
||||||
#include <core/device.h>
|
#include <core/device.h>
|
||||||
|
|
Loading…
Reference in a new issue