| 87 | } |
| 88 | |
| 89 | QSet<QString> PluginLoader::pluginsForCapabilities(const QSet<QString> &incoming, const QSet<QString> &outgoing) const |
| 90 | { |
| 91 | if (incoming.isEmpty() && outgoing.isEmpty()) { |
| 92 | // Assume every plugin is supported until we get the actual capabilities |
| 93 | const auto allPlugins = getPluginList(); |
| 94 | return QSet(allPlugins.begin(), allPlugins.end()); |
| 95 | } |
| 96 | |
| 97 | QSet<QString> ret; |
| 98 | |
| 99 | for (const KPluginMetaData &service : plugins) { |
| 100 | // Check if capabilities intersect with the remote device |
| 101 | const QStringList pluginIncomingCapabilities = service.rawData().value(QStringLiteral("X-KdeConnect-SupportedPacketType")).toVariant().toStringList(); |
| 102 | const QStringList pluginOutgoingCapabilities = service.rawData().value(QStringLiteral("X-KdeConnect-OutgoingPacketType")).toVariant().toStringList(); |
| 103 | |
| 104 | bool capabilitiesEmpty = (pluginIncomingCapabilities.isEmpty() && pluginOutgoingCapabilities.isEmpty()); |
| 105 | if (!capabilitiesEmpty) { |
| 106 | bool capabilitiesIntersect = (outgoing.intersects(QSet(pluginIncomingCapabilities.begin(), pluginIncomingCapabilities.end())) |
| 107 | || incoming.intersects(QSet(pluginOutgoingCapabilities.begin(), pluginOutgoingCapabilities.end()))); |
| 108 | |
| 109 | if (!capabilitiesIntersect) { |
| 110 | qCDebug(KDECONNECT_CORE) << "Not loading plugin" << service.pluginId() << "because device doesn't support it"; |
| 111 | continue; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | // If we get here, the plugin can be loaded |
| 116 | ret += service.pluginId(); |
| 117 | } |
| 118 | |
| 119 | return ret; |
| 120 | } |
no outgoing calls
no test coverage detected