Don't clean the devices that looked us up in the first place

This commit is contained in:
Aleix Pol 2015-09-12 20:53:05 +02:00
parent 2707d1f0a8
commit 2c2cb21ee1
3 changed files with 16 additions and 1 deletions

View file

@ -123,7 +123,7 @@ void Daemon::removeDevice(Device* device)
void Daemon::cleanDevices() void Daemon::cleanDevices()
{ {
Q_FOREACH(Device* device, d->mDevices) { Q_FOREACH(Device* device, d->mDevices) {
if (!device->isPaired()) { if (!device->isPaired() && device->connectionSource() == DeviceLink::ConnectionStarted::Remotely) {
removeDevice(device); removeDevice(device);
} }
} }

View file

@ -489,6 +489,18 @@ void Device::setAsPaired()
} }
DeviceLink::ConnectionStarted Device::connectionSource() const
{
DeviceLink::ConnectionStarted ret = DeviceLink::Remotely;
Q_FOREACH(DeviceLink* link, m_deviceLinks) {
if(link->connectionSource() == DeviceLink::ConnectionStarted::Locally) {
ret = DeviceLink::ConnectionStarted::Locally;
break;
}
}
return ret;
}
QStringList Device::availableLinks() const QStringList Device::availableLinks() const
{ {
QStringList sl; QStringList sl;

View file

@ -30,6 +30,7 @@
#include <QtCrypto> #include <QtCrypto>
#include "networkpackage.h" #include "networkpackage.h"
#include "backends/devicelink.h"
class DeviceLink; class DeviceLink;
class KdeConnectPlugin; class KdeConnectPlugin;
@ -108,6 +109,8 @@ public:
void setPluginEnabled(const QString& pluginName, bool enabled); void setPluginEnabled(const QString& pluginName, bool enabled);
bool isPluginEnabled(const QString& pluginName) const; bool isPluginEnabled(const QString& pluginName) const;
DeviceLink::ConnectionStarted connectionSource() const;
public Q_SLOTS: public Q_SLOTS:
///sends a @p np package to the device ///sends a @p np package to the device
virtual bool sendPackage(NetworkPackage& np); virtual bool sendPackage(NetworkPackage& np);