Add a package type that updates the device capabilities
Every time we reload the plugin list, report the plugins that we support. If the remote devices' capabilities change, update the plugin list. Reviewed by Albert Vaca
This commit is contained in:
parent
f65a1f206f
commit
4960247fb5
3 changed files with 16 additions and 2 deletions
|
@ -181,6 +181,10 @@ void Device::reloadPlugins()
|
|||
|
||||
Q_EMIT pluginsChanged();
|
||||
|
||||
NetworkPackage np(PACKAGE_TYPE_CAPABILITIES);
|
||||
np.set<QStringList>("SupportedIncomingInterfaces", m_pluginsByIncomingInterface.keys());
|
||||
np.set<QStringList>("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<QString> newIncomingCapabilities = np.get<QStringList>("SupportedIncomingInterfaces", QStringList()).toSet();
|
||||
QSet<QString> newOutgoingCapabilities = np.get<QStringList>("SupportedOutgoingInterfaces", QStringList()).toSet();
|
||||
|
||||
if (newOutgoingCapabilities != m_outgoingCapabilities || newIncomingCapabilities != m_incomingCapabilities) {
|
||||
m_incomingCapabilities = newIncomingCapabilities;
|
||||
m_outgoingCapabilities = newOutgoingCapabilities;
|
||||
reloadPlugins();
|
||||
}
|
||||
} else if (isPaired()) {
|
||||
QList<KdeConnectPlugin*> plugins = m_pluginsByIncomingInterface.values(np.type());
|
||||
foreach(KdeConnectPlugin* plugin, plugins) {
|
||||
|
|
|
@ -154,8 +154,8 @@ private: //Fields (TODO: dPointer!)
|
|||
QMultiMap<QString, KdeConnectPlugin*> m_pluginsByOutgoingInterface;
|
||||
|
||||
QTimer m_pairingTimeut;
|
||||
const QSet<QString> m_incomingCapabilities;
|
||||
const QSet<QString> m_outgoingCapabilities;
|
||||
QSet<QString> m_incomingCapabilities;
|
||||
QSet<QString> m_outgoingCapabilities;
|
||||
QStringList m_missingPlugins;
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue