Fixed outging capabilities
This commit is contained in:
parent
3269b7a9c2
commit
217d4b60ff
2 changed files with 8 additions and 4 deletions
|
@ -110,6 +110,7 @@ void Device::reloadPlugins()
|
||||||
QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface;
|
QMultiMap<QString, KdeConnectPlugin*> newPluginsByIncomingInterface;
|
||||||
QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface;
|
QMultiMap<QString, KdeConnectPlugin*> newPluginsByOutgoingInterface;
|
||||||
QSet<QString> supportedIncomingInterfaces;
|
QSet<QString> supportedIncomingInterfaces;
|
||||||
|
QSet<QString> supportedOutgoingInterfaces;
|
||||||
QStringList unsupportedPlugins;
|
QStringList unsupportedPlugins;
|
||||||
|
|
||||||
if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices
|
if (isPaired() && isReachable()) { //Do not load any plugin for unpaired devices, nor useless loading them for unreachable devices
|
||||||
|
@ -119,7 +120,6 @@ void Device::reloadPlugins()
|
||||||
PluginLoader* loader = PluginLoader::instance();
|
PluginLoader* loader = PluginLoader::instance();
|
||||||
const bool deviceSupportsCapabilities = !m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty();
|
const bool deviceSupportsCapabilities = !m_incomingCapabilities.isEmpty() || !m_outgoingCapabilities.isEmpty();
|
||||||
|
|
||||||
//Code borrowed from KWin
|
|
||||||
foreach (const QString& pluginName, loader->getPluginList()) {
|
foreach (const QString& pluginName, loader->getPluginList()) {
|
||||||
const KPluginMetaData service = loader->getPluginInfo(pluginName);
|
const KPluginMetaData service = loader->getPluginInfo(pluginName);
|
||||||
const QSet<QString> incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
|
const QSet<QString> incomingInterfaces = KPluginMetaData::readStringList(service.rawData(), "X-KdeConnect-SupportedPackageType").toSet();
|
||||||
|
@ -129,13 +129,13 @@ void Device::reloadPlugins()
|
||||||
|
|
||||||
if (pluginEnabled) {
|
if (pluginEnabled) {
|
||||||
supportedIncomingInterfaces += incomingInterfaces;
|
supportedIncomingInterfaces += incomingInterfaces;
|
||||||
|
supportedOutgoingInterfaces += outgoingInterfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
//If we don't find intersection with the received on one end and the sent on the other, we don't
|
//If we don't find intersection with the received on one end and the sent on the other, we don't
|
||||||
//let the plugin stay
|
//let the plugin stay
|
||||||
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
|
//Also, if no capabilities are specified on the other end, we don't apply this optimizaton, as
|
||||||
//we assume that the other client doesn't know about capabilities.
|
//we assume that the other client doesn't know about capabilities.
|
||||||
|
|
||||||
const bool capabilitiesSupported = deviceSupportsCapabilities && (!incomingInterfaces.isEmpty() || !outgoingInterfaces.isEmpty());
|
const bool capabilitiesSupported = deviceSupportsCapabilities && (!incomingInterfaces.isEmpty() || !outgoingInterfaces.isEmpty());
|
||||||
if (capabilitiesSupported
|
if (capabilitiesSupported
|
||||||
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
|
&& (m_incomingCapabilities & outgoingInterfaces).isEmpty()
|
||||||
|
@ -159,6 +159,7 @@ void Device::reloadPlugins()
|
||||||
foreach(const QString& interface, outgoingInterfaces) {
|
foreach(const QString& interface, outgoingInterfaces) {
|
||||||
newPluginsByOutgoingInterface.insert(interface, plugin);
|
newPluginsByOutgoingInterface.insert(interface, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
newPluginMap[pluginName] = plugin;
|
newPluginMap[pluginName] = plugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,12 +168,14 @@ void Device::reloadPlugins()
|
||||||
//Erase all left plugins in the original map (meaning that we don't want
|
//Erase all left plugins in the original map (meaning that we don't want
|
||||||
//them anymore, otherwise they would have been moved to the newPluginMap)
|
//them anymore, otherwise they would have been moved to the newPluginMap)
|
||||||
const QStringList newSupportedIncomingInterfaces = supportedIncomingInterfaces.toList();
|
const QStringList newSupportedIncomingInterfaces = supportedIncomingInterfaces.toList();
|
||||||
|
const QStringList newSupportedOutgoingInterfaces = supportedOutgoingInterfaces.toList();
|
||||||
const bool capabilitiesChanged = (m_pluginsByOutgoingInterface != newPluginsByOutgoingInterface
|
const bool capabilitiesChanged = (m_pluginsByOutgoingInterface != newPluginsByOutgoingInterface
|
||||||
|| m_supportedIncomingInterfaces != newSupportedIncomingInterfaces);
|
|| m_supportedIncomingInterfaces != newSupportedIncomingInterfaces);
|
||||||
qDeleteAll(m_plugins);
|
qDeleteAll(m_plugins);
|
||||||
m_plugins = newPluginMap;
|
m_plugins = newPluginMap;
|
||||||
m_pluginsByOutgoingInterface = newPluginsByOutgoingInterface;
|
|
||||||
m_supportedIncomingInterfaces = newSupportedIncomingInterfaces;
|
m_supportedIncomingInterfaces = newSupportedIncomingInterfaces;
|
||||||
|
m_supportedOutgoingInterfaces = newSupportedOutgoingInterfaces;
|
||||||
|
m_pluginsByOutgoingInterface = newPluginsByOutgoingInterface;
|
||||||
m_pluginsByIncomingInterface = newPluginsByIncomingInterface;
|
m_pluginsByIncomingInterface = newPluginsByIncomingInterface;
|
||||||
m_unsupportedPlugins = unsupportedPlugins;
|
m_unsupportedPlugins = unsupportedPlugins;
|
||||||
|
|
||||||
|
@ -185,7 +188,7 @@ void Device::reloadPlugins()
|
||||||
{
|
{
|
||||||
NetworkPackage np(PACKAGE_TYPE_CAPABILITIES);
|
NetworkPackage np(PACKAGE_TYPE_CAPABILITIES);
|
||||||
np.set<QStringList>("IncomingCapabilities", newSupportedIncomingInterfaces);
|
np.set<QStringList>("IncomingCapabilities", newSupportedIncomingInterfaces);
|
||||||
np.set<QStringList>("OutgoingCapabilities", newPluginsByOutgoingInterface.keys());
|
np.set<QStringList>("OutgoingCapabilities", newSupportedOutgoingInterfaces);
|
||||||
sendPackage(np);
|
sendPackage(np);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,7 @@ private: //Fields (TODO: dPointer!)
|
||||||
QSet<QString> m_incomingCapabilities;
|
QSet<QString> m_incomingCapabilities;
|
||||||
QSet<QString> m_outgoingCapabilities;
|
QSet<QString> m_outgoingCapabilities;
|
||||||
QStringList m_supportedIncomingInterfaces;
|
QStringList m_supportedIncomingInterfaces;
|
||||||
|
QStringList m_supportedOutgoingInterfaces;
|
||||||
QStringList m_unsupportedPlugins;
|
QStringList m_unsupportedPlugins;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue