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];
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;

View file

@ -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";
}

View file

@ -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:

View file

@ -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
}

View file

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

View file

@ -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

View file

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

View file

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

View file

@ -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;

View file

@ -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);