Commit ff9e8be5 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora

KdeService was not compiling

parent 752e1b1b
......@@ -43,7 +43,13 @@ DeviceLink* AvahiDeviceLocator::link(QString id) {
Device* d = visibleDevices[id];
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
return dl;
......
......@@ -80,9 +80,11 @@ Daemon::Daemon(QObject *parent, const QList<QVariant>&)
deviceLocators.insert(new FakeDeviceLocator());
//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
//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) {
linkTo(device->id());
}
......@@ -122,7 +124,7 @@ bool Daemon::linkDevice(QString id)
}
QString Daemon::listLinkedDevices(long int id)
QString Daemon::listLinkedDevices()
{
QString ret;
......@@ -137,6 +139,5 @@ QString Daemon::listLinkedDevices(long int id)
Daemon::~Daemon()
{
qDebug() << "SAYONARA BABY";
}
......@@ -61,15 +61,15 @@ public Q_SLOTS:
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 QString listLinkedDevices(long id);
Q_SCRIPTABLE QString listLinkedDevices();
private:
......
......@@ -20,6 +20,8 @@
#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
}
\ No newline at end of file
......@@ -33,7 +33,7 @@ class DeviceLink
Q_OBJECT
public:
DeviceLink(Device* d) : mDevice(d) { };
DeviceLink(Device* d);
Device* device() { return mDevice; }
......
......@@ -50,6 +50,12 @@ public:
virtual bool pair(Device* d) = 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
......@@ -25,8 +25,9 @@
class EchoDeviceLink
: public DeviceLink
{
public:
EchoDeviceLink(Device* d) : DeviceLink(d) { }
void sendPackage(const NetworkPackage& np) {
emit receivedPackage(np);
}
......
......@@ -24,7 +24,7 @@
FakeDeviceLocator::FakeDeviceLocator()
{
fakeDevice = new Device("fake","Fake device");
echoDeviceLink = new EchoDeviceLink();
echoDeviceLink = new EchoDeviceLink(fakeDevice);
}
bool FakeDeviceLocator::canLink(QString id) {
......
......@@ -21,7 +21,8 @@
#include "udpdevicelink.h"
UdpDeviceLink::UdpDeviceLink(QHostAddress ip, quint16 port)
UdpDeviceLink::UdpDeviceLink(Device* d, QHostAddress ip, quint16 port)
: DeviceLink(d)
{
mIp = ip;
......
......@@ -33,7 +33,7 @@ class UdpDeviceLink
Q_OBJECT
public:
UdpDeviceLink(QHostAddress ip, quint16 port);
UdpDeviceLink(Device* d, QHostAddress ip, quint16 port);
void sendPackage(const NetworkPackage& np) {
mUdpSocket->writeDatagram(np.toString(), mIp, mPort);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment