daemon.h 2.18 KB
Newer Older
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**
 * 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/>.
 */

21 22
#ifndef KDECONNECT_DAEMON_H
#define KDECONNECT_DAEMON_H
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
23 24 25

#include <QObject>
#include <QSet>
26
#include <QMap>
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
27

28 29
#include <KDEDModule>
#include <KPluginFactory>
30
#include "kdeconnectcore_export.h"
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
31

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
32 33 34
class DaemonPrivate;
class NetworkPackage;
class DeviceLink;
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
35

36
class KDECONNECTCORE_EXPORT Daemon
37
    : public QObject
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
38 39
{
    Q_OBJECT
40
    Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.daemon")
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
41 42

public:
43
    Daemon(QObject *parent);
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
44 45
    ~Daemon();

Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
46 47
public Q_SLOTS:

48
    //After calling this, signal deviceDiscovered will be triggered for each device
49
    Q_SCRIPTABLE void setDiscoveryEnabled(bool b);
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
50

51 52
    Q_SCRIPTABLE void forceOnNetworkChange();

53
    //Returns a list of ids. The respective devices can be manipulated using the dbus path: "/modules/kdeconnect/Devices/"+id
54
    Q_SCRIPTABLE QStringList devices(bool onlyReachable = false, bool onlyVisible = false) const;
55

Albert Vaca Cintora's avatar
Ooops  
Albert Vaca Cintora committed
56
Q_SIGNALS:
57 58 59
    Q_SCRIPTABLE void deviceAdded(const QString& id);
    Q_SCRIPTABLE void deviceRemoved(const QString& id); //Note that paired devices will never be removed
    Q_SCRIPTABLE void deviceVisibilityChanged(const QString& id, bool isVisible);
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
60

61
private Q_SLOTS:
62
    void onNewDeviceLink(const NetworkPackage& identityPackage, DeviceLink* dl);
63
    void onDeviceReachableStatusChanged();
64

65
private:
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
66
    QScopedPointer<DaemonPrivate> d;
Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
67 68
};

Albert Vaca Cintora's avatar
Albert Vaca Cintora committed
69
#endif