Removed onConnectionLost from DeviceLinkProvider
(Connect to destroyed on DeviceLink instead) Also, registering Device in dbus too soon fixed
This commit is contained in:
parent
986c49d326
commit
907740196a
4 changed files with 16 additions and 13 deletions
|
@ -23,10 +23,11 @@ Device::Device(const QString& id, const QString& name)
|
|||
m_paired = true;
|
||||
m_knownIdentiy = true;
|
||||
|
||||
//Register in bus
|
||||
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors | QDBusConnection::ExportChildObjects);
|
||||
|
||||
reloadPlugins();
|
||||
|
||||
//Register in bus
|
||||
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||
|
||||
}
|
||||
|
||||
Device::Device(const QString& id, const QString& name, DeviceLink* link)
|
||||
|
@ -36,12 +37,13 @@ Device::Device(const QString& id, const QString& name, DeviceLink* link)
|
|||
m_paired = false;
|
||||
m_knownIdentiy = true;
|
||||
|
||||
//Register in bus
|
||||
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors | QDBusConnection::ExportChildObjects);
|
||||
|
||||
addLink(link);
|
||||
|
||||
reloadPlugins();
|
||||
|
||||
//Register in bus
|
||||
QDBusConnection::sessionBus().registerObject("/modules/kdeconnect/devices/"+id, this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||
|
||||
}
|
||||
/*
|
||||
Device::Device(const QString& id, const QString& name, DeviceLink* link)
|
||||
|
@ -137,7 +139,8 @@ void Device::addLink(DeviceLink* link)
|
|||
{
|
||||
qDebug() << "Adding link to" << id() << "via" << link->provider();
|
||||
|
||||
connect(link,SIGNAL(destroyed(QObject*)),this,SLOT(linkDestroyed(QObject*)));
|
||||
connect(link, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(linkDestroyed(QObject*)));
|
||||
|
||||
m_deviceLinks.append(link);
|
||||
|
||||
|
@ -165,7 +168,7 @@ void Device::removeLink(DeviceLink* link)
|
|||
{
|
||||
m_deviceLinks.removeOne(link);
|
||||
|
||||
qDebug() << "RemoveLink"<< m_deviceLinks.size() << "links remaining";
|
||||
qDebug() << "RemoveLink" << m_deviceLinks.size() << "links remaining";
|
||||
|
||||
if (m_deviceLinks.empty()) {
|
||||
reloadPlugins();
|
||||
|
|
|
@ -80,8 +80,8 @@ private Q_SLOTS:
|
|||
void privateReceivedPackage(const NetworkPackage& np);
|
||||
|
||||
Q_SIGNALS:
|
||||
void reachableStatusChanged();
|
||||
void pluginsChanged();
|
||||
Q_SCRIPTABLE void reachableStatusChanged();
|
||||
Q_SCRIPTABLE void pluginsChanged();
|
||||
|
||||
private:
|
||||
bool m_paired;
|
||||
|
|
|
@ -54,8 +54,8 @@ public Q_SLOTS:
|
|||
Q_SIGNALS:
|
||||
//NOTE: The provider will to destroy the DeviceLink when it's no longer accessible,
|
||||
// and every user should listen to the destroyed signal to remove its references.
|
||||
// That's the reason because there is no "onConnectionLost".
|
||||
void onConnectionReceived(const NetworkPackage& identityPackage, DeviceLink*);
|
||||
void onConnectionLost(DeviceLink*);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
LoopbackLinkProvider::LoopbackLinkProvider()
|
||||
: identityPackage(PACKAGE_TYPE_IDENTITY)
|
||||
{
|
||||
echoDeviceLink = new EchoDeviceLink("loopback", this);
|
||||
NetworkPackage::createIdentityPackage(&identityPackage);
|
||||
}
|
||||
|
||||
|
@ -44,11 +43,12 @@ void LoopbackLinkProvider::onNetworkChange(QNetworkSession::State state)
|
|||
|
||||
void LoopbackLinkProvider::onStart()
|
||||
{
|
||||
echoDeviceLink = new EchoDeviceLink("loopback", this);
|
||||
onNetworkChange(QNetworkSession::Connected);
|
||||
}
|
||||
|
||||
void LoopbackLinkProvider::onStop()
|
||||
{
|
||||
onConnectionLost(echoDeviceLink);
|
||||
delete echoDeviceLink;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue