From 8c3056a2862c336ea12d2df95fb2136cfa545aca Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Tue, 13 Aug 2013 06:03:12 +0200 Subject: [PATCH] Oops fixed crash introduced in previous commit --- daemon/device.cpp | 4 ++-- daemon/device.h | 1 + daemon/plugins/pluginloader.cpp | 17 ++++++++++++++--- daemon/plugins/pluginloader.h | 5 ++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/daemon/device.cpp b/daemon/device.cpp index a86d95147..099fd9a61 100644 --- a/daemon/device.cpp +++ b/daemon/device.cpp @@ -76,8 +76,8 @@ void Device::reloadPlugins() foreach (const QString& pluginName, loader->getPluginList()) { const QString value = pluginStates.value(pluginName + QString::fromLatin1("Enabled"), QString()); - KPluginInfo plugininfo(pluginName); - bool enabled = (value.isNull() ? plugininfo.isPluginEnabledByDefault() : QVariant(value).toBool()); + KPluginInfo info = loader->getPluginInfo(pluginName); + bool enabled = (value.isNull() ? info.isPluginEnabledByDefault() : QVariant(value).toBool()); qDebug() << pluginName << "enabled:" << enabled; diff --git a/daemon/device.h b/daemon/device.h index 1d8552668..556e47030 100644 --- a/daemon/device.h +++ b/daemon/device.h @@ -58,6 +58,7 @@ public: void removeLink(DeviceLink*); Q_SCRIPTABLE QStringList availableLinks() const; + Q_SCRIPTABLE bool trusted() const { return m_paired; } Q_SCRIPTABLE bool paired() const { return m_paired; } Q_SCRIPTABLE bool reachable() const { return !m_deviceLinks.empty(); } diff --git a/daemon/plugins/pluginloader.cpp b/daemon/plugins/pluginloader.cpp index c0a4f968d..2c0f91294 100644 --- a/daemon/plugins/pluginloader.cpp +++ b/daemon/plugins/pluginloader.cpp @@ -47,11 +47,22 @@ QStringList PluginLoader::getPluginList() return plugins.keys(); } -KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(QString id, Device* device) { +KPluginInfo PluginLoader::getPluginInfo(const QString& name) { - KService::Ptr service = plugins[id]; + KService::Ptr service = plugins[name]; if (!service) { - qDebug() << "Plugin unknown" << id; + qDebug() << "Plugin unknown" << name; + return KPluginInfo(); + } + + return KPluginInfo(service); +} + +KdeConnectPlugin* PluginLoader::instantiatePluginForDevice(const QString& name, Device* device) { + + KService::Ptr service = plugins[name]; + if (!service) { + qDebug() << "Plugin unknown" << name; return NULL; } diff --git a/daemon/plugins/pluginloader.h b/daemon/plugins/pluginloader.h index 590ca253e..0665d2f59 100644 --- a/daemon/plugins/pluginloader.h +++ b/daemon/plugins/pluginloader.h @@ -27,6 +27,7 @@ #include #include +#include class Device; class KdeConnectPlugin; @@ -36,8 +37,10 @@ class PluginLoader public: static PluginLoader* instance(); - KdeConnectPlugin* instantiatePluginForDevice(QString name, Device* device); + QStringList getPluginList(); + KPluginInfo getPluginInfo(const QString& name); + KdeConnectPlugin* instantiatePluginForDevice(const QString& name, Device* device); private: PluginLoader();