Improve naming in PluginLoader variables
This commit is contained in:
parent
df99f3677f
commit
750b2d67b1
1 changed files with 14 additions and 14 deletions
|
@ -12,8 +12,8 @@
|
||||||
#include <QStaticPlugin>
|
#include <QStaticPlugin>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include "core_debug.h"
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
#include "kdeconnect_debug.h"
|
||||||
#include "kdeconnectconfig.h"
|
#include "kdeconnectconfig.h"
|
||||||
#include "kdeconnectplugin.h"
|
#include "kdeconnectplugin.h"
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ PluginLoader *PluginLoader::instance()
|
||||||
PluginLoader::PluginLoader()
|
PluginLoader::PluginLoader()
|
||||||
{
|
{
|
||||||
const QVector<KPluginMetaData> data = KPluginMetaData::findPlugins(QStringLiteral("kdeconnect"));
|
const QVector<KPluginMetaData> data = KPluginMetaData::findPlugins(QStringLiteral("kdeconnect"));
|
||||||
for (const KPluginMetaData &metadata : data) {
|
for (const KPluginMetaData &data : data) {
|
||||||
plugins[metadata.pluginId()] = metadata;
|
plugins[data.pluginId()] = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ KdeConnectPlugin *PluginLoader::instantiatePluginForDevice(const QString &plugin
|
||||||
QStringList PluginLoader::incomingCapabilities() const
|
QStringList PluginLoader::incomingCapabilities() const
|
||||||
{
|
{
|
||||||
QSet<QString> ret;
|
QSet<QString> ret;
|
||||||
for (const KPluginMetaData &service : plugins) {
|
for (const KPluginMetaData &data : plugins) {
|
||||||
QStringList rawValues = service.value(QStringLiteral("X-KdeConnect-SupportedPacketType"), QStringList());
|
QStringList rawValues = data.value(QStringLiteral("X-KdeConnect-SupportedPacketType"), QStringList());
|
||||||
ret += QSet<QString>(rawValues.begin(), rawValues.end());
|
ret += QSet<QString>(rawValues.begin(), rawValues.end());
|
||||||
}
|
}
|
||||||
return ret.values();
|
return ret.values();
|
||||||
|
@ -79,8 +79,8 @@ QStringList PluginLoader::incomingCapabilities() const
|
||||||
QStringList PluginLoader::outgoingCapabilities() const
|
QStringList PluginLoader::outgoingCapabilities() const
|
||||||
{
|
{
|
||||||
QSet<QString> ret;
|
QSet<QString> ret;
|
||||||
for (const KPluginMetaData &service : plugins) {
|
for (const KPluginMetaData &data : plugins) {
|
||||||
QStringList rawValues = service.value(QStringLiteral("X-KdeConnect-OutgoingPacketType"), QStringList());
|
QStringList rawValues = data.value(QStringLiteral("X-KdeConnect-OutgoingPacketType"), QStringList());
|
||||||
ret += QSet<QString>(rawValues.begin(), rawValues.end());
|
ret += QSet<QString>(rawValues.begin(), rawValues.end());
|
||||||
}
|
}
|
||||||
return ret.values();
|
return ret.values();
|
||||||
|
@ -92,20 +92,20 @@ QSet<QString> PluginLoader::pluginsForCapabilities(const QSet<QString> &incoming
|
||||||
|
|
||||||
QString myDeviceType = KdeConnectConfig::instance().deviceType().toString();
|
QString myDeviceType = KdeConnectConfig::instance().deviceType().toString();
|
||||||
|
|
||||||
for (const KPluginMetaData &service : plugins) {
|
for (const KPluginMetaData &data : plugins) {
|
||||||
// Check if the plugin support this device type
|
// Check if the plugin support this device type
|
||||||
const QStringList supportedDeviceTypes = service.rawData().value(QStringLiteral("X-KdeConnect-SupportedDeviceTypes")).toVariant().toStringList();
|
const QStringList supportedDeviceTypes = data.value(QStringLiteral("X-KdeConnect-SupportedDeviceTypes"), QStringList());
|
||||||
if (!supportedDeviceTypes.isEmpty()) {
|
if (!supportedDeviceTypes.isEmpty()) {
|
||||||
if (!supportedDeviceTypes.contains(myDeviceType)) {
|
if (!supportedDeviceTypes.contains(myDeviceType)) {
|
||||||
qCDebug(KDECONNECT_CORE) << "Not loading plugin" << service.pluginId() << "because this device of type" << myDeviceType
|
qCDebug(KDECONNECT_CORE) << "Not loading plugin" << data.pluginId() << "because this device of type" << myDeviceType
|
||||||
<< "is not supported. Supports:" << supportedDeviceTypes.join(QStringLiteral(", "));
|
<< "is not supported. Supports:" << supportedDeviceTypes.join(QStringLiteral(", "));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if capbilites intersect with the remote device
|
// Check if capbilites intersect with the remote device
|
||||||
const QStringList pluginIncomingCapabilities = service.rawData().value(QStringLiteral("X-KdeConnect-SupportedPacketType")).toVariant().toStringList();
|
const QStringList pluginIncomingCapabilities = data.rawData().value(QStringLiteral("X-KdeConnect-SupportedPacketType")).toVariant().toStringList();
|
||||||
const QStringList pluginOutgoingCapabilities = service.rawData().value(QStringLiteral("X-KdeConnect-OutgoingPacketType")).toVariant().toStringList();
|
const QStringList pluginOutgoingCapabilities = data.rawData().value(QStringLiteral("X-KdeConnect-OutgoingPacketType")).toVariant().toStringList();
|
||||||
|
|
||||||
bool capabilitiesEmpty = (pluginIncomingCapabilities.isEmpty() && pluginOutgoingCapabilities.isEmpty());
|
bool capabilitiesEmpty = (pluginIncomingCapabilities.isEmpty() && pluginOutgoingCapabilities.isEmpty());
|
||||||
if (!capabilitiesEmpty) {
|
if (!capabilitiesEmpty) {
|
||||||
|
@ -113,13 +113,13 @@ QSet<QString> PluginLoader::pluginsForCapabilities(const QSet<QString> &incoming
|
||||||
|| incoming.intersects(QSet(pluginOutgoingCapabilities.begin(), pluginOutgoingCapabilities.end())));
|
|| incoming.intersects(QSet(pluginOutgoingCapabilities.begin(), pluginOutgoingCapabilities.end())));
|
||||||
|
|
||||||
if (!capabilitiesIntersect) {
|
if (!capabilitiesIntersect) {
|
||||||
qCDebug(KDECONNECT_CORE) << "Not loading plugin" << service.pluginId() << "because device doesn't support it";
|
qCDebug(KDECONNECT_CORE) << "Not loading plugin" << data.pluginId() << "because device doesn't support it";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, the plugin can be loaded
|
// If we get here, the plugin can be loaded
|
||||||
ret += service.pluginId();
|
ret += data.pluginId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue