Fixed loopback link provider

This commit is contained in:
Albert Vaca 2013-08-14 03:10:38 +02:00
parent df6c2f8604
commit 3d6178ae95
3 changed files with 19 additions and 6 deletions

View file

@ -22,8 +22,8 @@
#include "linkproviders/loopbacklinkprovider.h" #include "linkproviders/loopbacklinkprovider.h"
EchoDeviceLink::EchoDeviceLink(const QString& d, LoopbackLinkProvider* a) EchoDeviceLink::EchoDeviceLink(const QString& deviceId, LoopbackLinkProvider* provider)
: DeviceLink(d, a) : DeviceLink(deviceId, provider)
{ {
} }

View file

@ -26,7 +26,7 @@
LoopbackLinkProvider::LoopbackLinkProvider() LoopbackLinkProvider::LoopbackLinkProvider()
: identityPackage(PACKAGE_TYPE_IDENTITY) : identityPackage(PACKAGE_TYPE_IDENTITY)
{ {
echoDeviceLink = new EchoDeviceLink("fake", this); echoDeviceLink = new EchoDeviceLink("loopback", this);
NetworkPackage::createIdentityPackage(&identityPackage); NetworkPackage::createIdentityPackage(&identityPackage);
} }
@ -35,9 +35,20 @@ LoopbackLinkProvider::~LoopbackLinkProvider()
//delete echoDeviceLink; //delete echoDeviceLink;
} }
void LoopbackLinkProvider::setDiscoverable(bool b) void LoopbackLinkProvider::onNetworkChange(QNetworkSession::State state)
{ {
Q_UNUSED(state);
qDebug() << "Echo Device discovery emitted"; 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);
} }

View file

@ -35,7 +35,9 @@ public:
QString name() { return "LoopbackLinkProvider"; } QString name() { return "LoopbackLinkProvider"; }
int priority() { return PRIORITY_LOW; } int priority() { return PRIORITY_LOW; }
void setDiscoverable(bool b); virtual void onStart();
virtual void onStop();
virtual void onNetworkChange(QNetworkSession::State state);
private: private:
DeviceLink* echoDeviceLink; DeviceLink* echoDeviceLink;