Lomiri
Loading...
Searching...
No Matches
displays.h
1/*
2 * Copyright (C) 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ken VanDine <ken.vandine@canonical.com>
18 *
19 */
20
21#ifndef DISPLAYS_H
22#define DISPLAYS_H
23
24#include <QObject>
25#include <QtDBus>
26#include <org_aethercast.h>
27#include <freedesktop_properties.h>
28
29class Displays : public QObject
30{
31 Q_OBJECT
32
33 Q_PROPERTY (bool scanning
34 READ scanning
35 NOTIFY scanningChanged)
36
37 Q_PROPERTY (bool enabled
38 READ enabled
39 WRITE setEnabled
40 NOTIFY enabledChanged)
41
42 Q_PROPERTY (QString state
43 READ state
44 NOTIFY stateChanged)
45
46public:
47 enum State { Idle=1, Disconnected=2, Association=4, Configuration=8, Connected=16, Failure=32 };
48 Q_ENUMS(State)
49 Q_DECLARE_FLAGS(States, State)
50
51 explicit Displays(QObject *parent = nullptr);
52 explicit Displays(const QDBusConnection &dbus, QObject *parent = nullptr);
53 ~Displays() {}
54
55 enum Error {
56 None,
57 Failed,
58 Already,
59 ParamInvalid,
60 InvalidState,
61 NotConnected,
62 NotReady,
63 Unknown
64 };
65 Q_ENUMS(Error)
66
67 void setProperties(const QMap<QString,QVariant> &properties);
68 bool scanning() const { return m_manager->scanning(); }
69 bool enabled() const { return m_manager->enabled(); }
70 void setEnabled(bool);
71 QString state() const { return m_manager->state(); }
72
73Q_SIGNALS:
74 void scanningChanged(bool isActive);
75 void enabledChanged(bool enabled);
76 void stateChanged();
77 void connectedDevicesChanged();
78 void disconnectedDevicesChanged();
79 void connectError(int error);
80
81private Q_SLOTS:
82 void slotPropertiesChanged(const QString &interface, const QVariantMap &changedProperties,
83 const QStringList &invalidatedProperties);
84 void callFinishedSlot(QDBusPendingCallWatcher *call);
85
86private:
87 void getAll();
88
89 QDBusConnection m_dbus;
90 QScopedPointer<OrgAethercastManagerInterface> m_manager;
91 QScopedPointer<OrgFreedesktopDBusPropertiesInterface> m_aethercastProperties;
92 void updateProperties(QSharedPointer<QDBusInterface>);
93 void updateProperty(const QString &key, const QVariant &value);
94 void handleConnectError(QDBusError error);
95};
96
97#endif // DISPLAYS_H