KdeService was not compiling

This commit is contained in:
Albert Vaca 2013-06-18 03:05:32 +02:00
parent 752e1b1b53
commit ff9e8be5ad
10 changed files with 30 additions and 13 deletions

View file

@ -43,7 +43,13 @@ DeviceLink* AvahiDeviceLocator::link(QString id) {
Device* d = visibleDevices[id]; Device* d = visibleDevices[id];
const DNSSD::RemoteService::Ptr& rs = deviceRoutes[d]; const DNSSD::RemoteService::Ptr& rs = deviceRoutes[d];
DeviceLink* dl = new UdpDeviceLink(QHostAddress(rs->hostName()),rs->port()); DeviceLink* dl = new UdpDeviceLink(d, QHostAddress(rs->hostName()),rs->port());
qDebug() << "Sending pair request to device " + id;
NetworkPackage np(12345);
//TODO: Package contents
dl->sendPackage(np);
linkedDevices.append(dl); //Store the ref to be able to delete the memory later linkedDevices.append(dl); //Store the ref to be able to delete the memory later
return dl; return dl;

View file

@ -80,9 +80,11 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
deviceLocators.insert(new FakeDeviceLocator()); deviceLocators.insert(new FakeDeviceLocator());
//TODO: Read paired devices from config //TODO: Read paired devices from config
pairedDevices.push_back(new Device("MyAndroid","MyAndroid")); //pairedDevices.push_back(new Device("MyAndroid","MyAndroid"));
//At boot time, try to link to all paired devices //At boot time, try to link to all paired devices
//FIXME: This should be done for every new visible device, not only at boot
//TODO: Add a way to notify discovered/lost devices
Q_FOREACH (Device* device, pairedDevices) { Q_FOREACH (Device* device, pairedDevices) {
linkTo(device->id()); linkTo(device->id());
} }
@ -122,7 +124,7 @@ bool Daemon::linkDevice(QString id)
} }
QString Daemon::listLinkedDevices(long int id) QString Daemon::listLinkedDevices()
{ {
QString ret; QString ret;
@ -137,6 +139,5 @@ QString Daemon::listLinkedDevices(long int id)
Daemon::~Daemon() Daemon::~Daemon()
{ {
qDebug() << "SAYONARA BABY"; qDebug() << "SAYONARA BABY";
} }

View file

@ -61,15 +61,15 @@ public Q_SLOTS:
Q_SCRIPTABLE bool linkDevice(QString id); Q_SCRIPTABLE bool linkDevice(QString id);
/* /*
Q_SCRIPTABLE bool pairDevice(long id); Q_SCRIPTABLE bool pairDevice(QString id);
Q_SCRIPTABLE QString listPairedDevices(long id); Q_SCRIPTABLE QString listPairedDevices(QString id);
Q_SCRIPTABLE bool linkAllPairedDevices(); Q_SCRIPTABLE bool linkAllPairedDevices();
*/ */
Q_SCRIPTABLE QString listLinkedDevices(long id); Q_SCRIPTABLE QString listLinkedDevices();
private: private:

View file

@ -20,6 +20,8 @@
#include "devicelink.h" #include "devicelink.h"
DeviceLink::DeviceLink() { DeviceLink::DeviceLink(Device* d)
: mDevice(d)
{
//gcc complains if we don't add something to compile on a class with virtual functions //gcc complains if we don't add something to compile on a class with virtual functions
} }

View file

@ -33,7 +33,7 @@ class DeviceLink
Q_OBJECT Q_OBJECT
public: public:
DeviceLink(Device* d) : mDevice(d) { }; DeviceLink(Device* d);
Device* device() { return mDevice; } Device* device() { return mDevice; }

View file

@ -50,6 +50,12 @@ public:
virtual bool pair(Device* d) = 0; virtual bool pair(Device* d) = 0;
virtual QList<Device*> discover() = 0; virtual QList<Device*> discover() = 0;
signals:
//TODO: Emit this to be able to see if it is a known device
//void deviceDiscovered(Device* d);
//void deviceLost(QString id);
}; };
#endif // DEVICELOCATOR_H #endif // DEVICELOCATOR_H

View file

@ -25,8 +25,9 @@
class EchoDeviceLink class EchoDeviceLink
: public DeviceLink : public DeviceLink
{ {
public: public:
EchoDeviceLink(Device* d) : DeviceLink(d) { }
void sendPackage(const NetworkPackage& np) { void sendPackage(const NetworkPackage& np) {
emit receivedPackage(np); emit receivedPackage(np);
} }

View file

@ -24,7 +24,7 @@
FakeDeviceLocator::FakeDeviceLocator() FakeDeviceLocator::FakeDeviceLocator()
{ {
fakeDevice = new Device("fake","Fake device"); fakeDevice = new Device("fake","Fake device");
echoDeviceLink = new EchoDeviceLink(); echoDeviceLink = new EchoDeviceLink(fakeDevice);
} }
bool FakeDeviceLocator::canLink(QString id) { bool FakeDeviceLocator::canLink(QString id) {

View file

@ -21,7 +21,8 @@
#include "udpdevicelink.h" #include "udpdevicelink.h"
UdpDeviceLink::UdpDeviceLink(QHostAddress ip, quint16 port) UdpDeviceLink::UdpDeviceLink(Device* d, QHostAddress ip, quint16 port)
: DeviceLink(d)
{ {
mIp = ip; mIp = ip;

View file

@ -33,7 +33,7 @@ class UdpDeviceLink
Q_OBJECT Q_OBJECT
public: public:
UdpDeviceLink(QHostAddress ip, quint16 port); UdpDeviceLink(Device* d, QHostAddress ip, quint16 port);
void sendPackage(const NetworkPackage& np) { void sendPackage(const NetworkPackage& np) {
mUdpSocket->writeDatagram(np.toString(), mIp, mPort); mUdpSocket->writeDatagram(np.toString(), mIp, mPort);