Debug pairing handlers
Make sure we don't emit if it doesn't actually change Make sure if it changed when we react to a pairing Pair-programmed with Albert Vaca
This commit is contained in:
parent
5d088041c0
commit
6c77bc5a9f
5 changed files with 20 additions and 7 deletions
|
@ -247,8 +247,11 @@ void Daemon::addDevice(Device* device)
|
|||
const QString id = device->id();
|
||||
connect(device, &Device::reachableChanged, this, &Daemon::onDeviceStatusChanged);
|
||||
connect(device, &Device::trustedChanged, this, &Daemon::onDeviceStatusChanged);
|
||||
connect(device, &Device::pairingRequestsChanged, this, &Daemon::pairingRequestsChanged);
|
||||
connect(device, &Device::pairingRequestsChanged, this, [this, device]() { askPairingConfirmation(device); } );
|
||||
connect(device, &Device::hasPairingRequestsChanged, this, &Daemon::pairingRequestsChanged);
|
||||
connect(device, &Device::hasPairingRequestsChanged, this, [this, device](bool hasPairingRequests) {
|
||||
if (hasPairingRequests)
|
||||
askPairingConfirmation(device);
|
||||
} );
|
||||
d->mDevices[id] = device;
|
||||
|
||||
Q_EMIT deviceAdded(id);
|
||||
|
|
|
@ -258,14 +258,20 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
|
|||
|
||||
void Device::addPairingRequest(PairingHandler* handler)
|
||||
{
|
||||
const bool wasEmpty = m_pairRequests.isEmpty();
|
||||
m_pairRequests.insert(handler);
|
||||
Q_EMIT pairingRequestsChanged();
|
||||
|
||||
if (wasEmpty != m_pairRequests.isEmpty())
|
||||
Q_EMIT hasPairingRequestsChanged(!m_pairRequests.isEmpty());
|
||||
}
|
||||
|
||||
void Device::removePairingRequest(PairingHandler* handler)
|
||||
{
|
||||
const bool wasEmpty = m_pairRequests.isEmpty();
|
||||
m_pairRequests.remove(handler);
|
||||
Q_EMIT pairingRequestsChanged();
|
||||
|
||||
if (wasEmpty != m_pairRequests.isEmpty())
|
||||
Q_EMIT hasPairingRequestsChanged(!m_pairRequests.isEmpty());
|
||||
}
|
||||
|
||||
void Device::acceptPairing()
|
||||
|
|
|
@ -44,7 +44,7 @@ class KDECONNECTCORE_EXPORT Device
|
|||
Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableChanged)
|
||||
Q_PROPERTY(bool isTrusted READ isTrusted NOTIFY trustedChanged)
|
||||
Q_PROPERTY(QStringList supportedPlugins READ supportedPlugins NOTIFY pluginsChanged)
|
||||
Q_PROPERTY(bool hasPairingRequests READ hasPairingRequests NOTIFY pairingRequestsChanged)
|
||||
Q_PROPERTY(bool hasPairingRequests READ hasPairingRequests NOTIFY hasPairingRequestsChanged)
|
||||
|
||||
public:
|
||||
|
||||
|
@ -133,7 +133,7 @@ Q_SIGNALS:
|
|||
Q_SCRIPTABLE void pairingError(const QString& error);
|
||||
Q_SCRIPTABLE void nameChanged(const QString& name);
|
||||
|
||||
void pairingRequestsChanged();
|
||||
Q_SCRIPTABLE void hasPairingRequestsChanged(bool hasPairingRequests);
|
||||
|
||||
private: //Methods
|
||||
static DeviceType str2type(const QString &deviceType);
|
||||
|
|
|
@ -32,7 +32,7 @@ QString DaemonDbusInterface::activatedService() {
|
|||
DaemonDbusInterface::DaemonDbusInterface(QObject* parent)
|
||||
: OrgKdeKdeconnectDaemonInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect"), QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
||||
connect(this, &OrgKdeKdeconnectDaemonInterface::pairingRequestsChanged, this, &DaemonDbusInterface::pairingRequestsChangedProxy);
|
||||
}
|
||||
|
||||
DaemonDbusInterface::~DaemonDbusInterface()
|
||||
|
@ -47,6 +47,7 @@ DeviceDbusInterface::DeviceDbusInterface(const QString& id, QObject* parent)
|
|||
connect(this, &OrgKdeKdeconnectDeviceInterface::trustedChanged, this, &DeviceDbusInterface::trustedChangedProxy);
|
||||
connect(this, &OrgKdeKdeconnectDeviceInterface::reachableChanged, this, &DeviceDbusInterface::reachableChangedProxy);
|
||||
connect(this, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, &DeviceDbusInterface::nameChangedProxy);
|
||||
connect(this, &OrgKdeKdeconnectDeviceInterface::hasPairingRequestsChanged, this, &DeviceDbusInterface::hasPairingRequestsChangedProxy);
|
||||
}
|
||||
|
||||
DeviceDbusInterface::~DeviceDbusInterface()
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
|
||||
Q_SIGNALS:
|
||||
void deviceAdded(const QString &id);
|
||||
void pairingRequestsChangedProxy();
|
||||
};
|
||||
|
||||
class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface
|
||||
|
@ -63,6 +64,7 @@ class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface
|
|||
Q_PROPERTY(bool isReachable READ isReachable NOTIFY reachableChangedProxy)
|
||||
Q_PROPERTY(bool isTrusted READ isTrusted NOTIFY trustedChangedProxy)
|
||||
Q_PROPERTY(QString name READ name NOTIFY nameChangedProxy)
|
||||
Q_PROPERTY(bool hasPairingRequests READ hasPairingRequests NOTIFY hasPairingRequestsChangedProxy)
|
||||
|
||||
public:
|
||||
explicit DeviceDbusInterface(const QString& deviceId, QObject* parent = nullptr);
|
||||
|
@ -75,6 +77,7 @@ Q_SIGNALS:
|
|||
void nameChangedProxy(const QString &name);
|
||||
void trustedChangedProxy(bool paired);
|
||||
void reachableChangedProxy(bool reachable);
|
||||
void hasPairingRequestsChangedProxy();
|
||||
|
||||
private:
|
||||
const QString m_id;
|
||||
|
|
Loading…
Reference in a new issue