2013-06-06 04:57:06 +01:00
|
|
|
/**
|
|
|
|
* Copyright 2013 Albert Vaca <albertvaka@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License or (at your option) version 3 or any later version
|
|
|
|
* accepted by the membership of KDE e.V. (or its successor approved
|
|
|
|
* by the membership of KDE e.V.), which shall act as a proxy
|
|
|
|
* defined in Section 14 of version 3 of the license.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DEVICE_H
|
|
|
|
#define DEVICE_H
|
|
|
|
|
2013-06-25 17:08:34 +01:00
|
|
|
#include <QObject>
|
|
|
|
#include <QDBusConnection>
|
2013-06-06 04:57:06 +01:00
|
|
|
#include <QString>
|
2013-07-03 02:52:44 +01:00
|
|
|
#include <qvector.h>
|
|
|
|
#include "devicelinks/devicelink.h"
|
|
|
|
|
|
|
|
class DeviceLink;
|
2013-08-13 04:07:32 +01:00
|
|
|
class PackageInterface;
|
2013-06-06 04:57:06 +01:00
|
|
|
|
2013-07-28 21:00:45 +01:00
|
|
|
class Device
|
|
|
|
: public QObject
|
2013-06-06 04:57:06 +01:00
|
|
|
{
|
2013-06-25 17:08:34 +01:00
|
|
|
Q_OBJECT
|
2013-07-26 15:21:19 +01:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device")
|
|
|
|
Q_PROPERTY(QString id READ id)
|
|
|
|
Q_PROPERTY(QString name READ name)
|
2013-06-25 17:08:34 +01:00
|
|
|
|
2013-06-06 04:57:06 +01:00
|
|
|
public:
|
2013-07-03 02:52:44 +01:00
|
|
|
//Device known from KConfig, we trust it but we need to wait for a incoming devicelink to communicate
|
2013-06-25 17:08:34 +01:00
|
|
|
Device(const QString& id, const QString& name);
|
2013-06-06 04:57:06 +01:00
|
|
|
|
2013-07-03 02:52:44 +01:00
|
|
|
//Device known via a presentation package sent to us via a devicelink, we know everything but we don't trust it yet
|
|
|
|
Device(const QString& id, const QString& name, DeviceLink* dl);
|
|
|
|
|
|
|
|
//Device known via discovery, we know nothing and have to ask for a presentation package
|
|
|
|
//(not supported yet, do we need it or we can rely on the device presenging itself?)
|
|
|
|
//Device(const QString& id, DeviceLink* dl);
|
|
|
|
|
2013-07-26 15:21:19 +01:00
|
|
|
QString id() const{ return m_deviceId; }
|
|
|
|
QString name() const { return m_deviceName; }
|
|
|
|
|
2013-07-04 18:17:22 +01:00
|
|
|
//Add and remove links
|
2013-07-03 02:52:44 +01:00
|
|
|
void addLink(DeviceLink*);
|
|
|
|
void removeLink(DeviceLink*);
|
2013-06-17 11:23:08 +01:00
|
|
|
|
2013-08-13 04:07:32 +01:00
|
|
|
Q_SCRIPTABLE QStringList availableLinks() const;
|
|
|
|
Q_SCRIPTABLE bool paired() const { return m_paired; }
|
|
|
|
Q_SCRIPTABLE bool reachable() const { return !m_deviceLinks.empty(); }
|
2013-07-28 21:00:45 +01:00
|
|
|
|
2013-07-04 18:17:22 +01:00
|
|
|
//Send and receive
|
2013-07-03 02:52:44 +01:00
|
|
|
Q_SIGNALS:
|
2013-08-13 04:07:32 +01:00
|
|
|
void receivedPackage(const NetworkPackage& np);
|
2013-07-03 02:52:44 +01:00
|
|
|
public Q_SLOTS:
|
2013-08-10 04:21:55 +01:00
|
|
|
bool sendPackage(const NetworkPackage& np) const;
|
2013-07-23 16:50:09 +01:00
|
|
|
|
2013-08-13 04:07:32 +01:00
|
|
|
//Dbus operations called from kcm
|
2013-07-23 16:50:09 +01:00
|
|
|
public Q_SLOTS:
|
2013-07-03 02:52:44 +01:00
|
|
|
Q_SCRIPTABLE void setPair(bool b);
|
2013-08-13 04:07:32 +01:00
|
|
|
Q_SCRIPTABLE void reloadPlugins();
|
2013-07-03 02:52:44 +01:00
|
|
|
Q_SCRIPTABLE void sendPing();
|
|
|
|
|
2013-07-28 21:00:45 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
void reachableStatusChanged();
|
|
|
|
|
2013-07-03 02:52:44 +01:00
|
|
|
private Q_SLOTS:
|
2013-07-04 18:17:22 +01:00
|
|
|
void linkDestroyed(QObject* o = 0);
|
2013-07-03 02:52:44 +01:00
|
|
|
void privateReceivedPackage(const NetworkPackage& np);
|
2013-06-06 04:57:06 +01:00
|
|
|
|
|
|
|
private:
|
2013-07-03 02:52:44 +01:00
|
|
|
bool m_paired;
|
|
|
|
QString m_deviceId;
|
|
|
|
QString m_deviceName;
|
2013-07-04 18:17:22 +01:00
|
|
|
QList<DeviceLink*> m_deviceLinks;
|
2013-08-13 04:07:32 +01:00
|
|
|
QList<PackageInterface*> m_plugins;
|
2013-07-03 02:52:44 +01:00
|
|
|
bool m_knownIdentiy;
|
|
|
|
|
|
|
|
|
2013-06-06 04:57:06 +01:00
|
|
|
};
|
|
|
|
|
2013-08-13 04:07:32 +01:00
|
|
|
Q_DECLARE_METATYPE(Device*)
|
|
|
|
|
2013-06-06 04:57:06 +01:00
|
|
|
#endif // DEVICE_H
|