diff --git a/core/device.cpp b/core/device.cpp index fb7ee2b9d..dc938e909 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -181,6 +181,10 @@ void Device::reloadPlugins() Q_EMIT pluginsChanged(); + NetworkPackage np(PACKAGE_TYPE_CAPABILITIES); + np.set("SupportedIncomingInterfaces", m_pluginsByIncomingInterface.keys()); + np.set("SupportedOutgoingInterfaces", m_pluginsByOutgoingInterface.keys()); + sendPackage(np); } QString Device::pluginsConfigFile() const @@ -395,6 +399,15 @@ void Device::privateReceivedPackage(const NetworkPackage& np) } + } else if (np.type() == PACKAGE_TYPE_CAPABILITIES) { + QSet newIncomingCapabilities = np.get("SupportedIncomingInterfaces", QStringList()).toSet(); + QSet newOutgoingCapabilities = np.get("SupportedOutgoingInterfaces", QStringList()).toSet(); + + if (newOutgoingCapabilities != m_outgoingCapabilities || newIncomingCapabilities != m_incomingCapabilities) { + m_incomingCapabilities = newIncomingCapabilities; + m_outgoingCapabilities = newOutgoingCapabilities; + reloadPlugins(); + } } else if (isPaired()) { QList plugins = m_pluginsByIncomingInterface.values(np.type()); foreach(KdeConnectPlugin* plugin, plugins) { diff --git a/core/device.h b/core/device.h index 2b229882d..2e1d48b90 100644 --- a/core/device.h +++ b/core/device.h @@ -154,8 +154,8 @@ private: //Fields (TODO: dPointer!) QMultiMap m_pluginsByOutgoingInterface; QTimer m_pairingTimeut; - const QSet m_incomingCapabilities; - const QSet m_outgoingCapabilities; + QSet m_incomingCapabilities; + QSet m_outgoingCapabilities; QStringList m_missingPlugins; }; diff --git a/core/networkpackagetypes.h b/core/networkpackagetypes.h index 6aa24a297..19d4dec4f 100644 --- a/core/networkpackagetypes.h +++ b/core/networkpackagetypes.h @@ -23,6 +23,7 @@ #define PACKAGE_TYPE_IDENTITY QLatin1String("kdeconnect.identity") #define PACKAGE_TYPE_PAIR QLatin1String("kdeconnect.pair") +#define PACKAGE_TYPE_CAPABILITIES QLatin1String("kdeconnect.capabilities") #define PACKAGE_TYPE_ENCRYPTED QLatin1String("kdeconnect.encrypted") #endif // NETWORKPACKAGETYPES_H