diff --git a/daemon/devicelinks/echodevicelink.cpp b/daemon/devicelinks/echodevicelink.cpp index dba966cc6..f254b9af4 100644 --- a/daemon/devicelinks/echodevicelink.cpp +++ b/daemon/devicelinks/echodevicelink.cpp @@ -22,8 +22,8 @@ #include "linkproviders/loopbacklinkprovider.h" -EchoDeviceLink::EchoDeviceLink(const QString& d, LoopbackLinkProvider* a) - : DeviceLink(d, a) +EchoDeviceLink::EchoDeviceLink(const QString& deviceId, LoopbackLinkProvider* provider) + : DeviceLink(deviceId, provider) { } diff --git a/daemon/linkproviders/loopbacklinkprovider.cpp b/daemon/linkproviders/loopbacklinkprovider.cpp index 34369c83e..5b14b1f30 100644 --- a/daemon/linkproviders/loopbacklinkprovider.cpp +++ b/daemon/linkproviders/loopbacklinkprovider.cpp @@ -26,7 +26,7 @@ LoopbackLinkProvider::LoopbackLinkProvider() : identityPackage(PACKAGE_TYPE_IDENTITY) { - echoDeviceLink = new EchoDeviceLink("fake", this); + echoDeviceLink = new EchoDeviceLink("loopback", this); NetworkPackage::createIdentityPackage(&identityPackage); } @@ -35,9 +35,20 @@ LoopbackLinkProvider::~LoopbackLinkProvider() //delete echoDeviceLink; } -void LoopbackLinkProvider::setDiscoverable(bool b) +void LoopbackLinkProvider::onNetworkChange(QNetworkSession::State state) { + Q_UNUSED(state); qDebug() << "Echo Device discovery emitted"; - if (b) Q_EMIT onConnectionReceived(identityPackage, echoDeviceLink); + Q_EMIT onConnectionReceived(identityPackage, echoDeviceLink); +} + +void LoopbackLinkProvider::onStart() +{ + onNetworkChange(QNetworkSession::Connected); +} + +void LoopbackLinkProvider::onStop() +{ + onConnectionLost(echoDeviceLink); } diff --git a/daemon/linkproviders/loopbacklinkprovider.h b/daemon/linkproviders/loopbacklinkprovider.h index d4918f65a..72be6e5af 100644 --- a/daemon/linkproviders/loopbacklinkprovider.h +++ b/daemon/linkproviders/loopbacklinkprovider.h @@ -35,7 +35,9 @@ public: QString name() { return "LoopbackLinkProvider"; } int priority() { return PRIORITY_LOW; } - void setDiscoverable(bool b); + virtual void onStart(); + virtual void onStop(); + virtual void onNetworkChange(QNetworkSession::State state); private: DeviceLink* echoDeviceLink;