Changeset View
Changeset View
Standalone View
Standalone View
autotests/bolt/fakeserver/fakedevice.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2018 - 2019 Daniel Vrátil <dvratil@kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef FAKEDEVICE_H | ||||
22 | #define FAKEDEVICE_H | ||||
23 | | ||||
24 | #include <QObject> | ||||
25 | #include <QDBusObjectPath> | ||||
26 | #include <QJsonObject> | ||||
27 | | ||||
28 | class FakeDeviceException : public std::runtime_error | ||||
29 | { | ||||
30 | public: | ||||
31 | FakeDeviceException(const QString &what) | ||||
32 | : std::runtime_error(what.toStdString()) {} | ||||
33 | }; | ||||
34 | | ||||
35 | class FakeDevice : public QObject | ||||
36 | { | ||||
37 | Q_OBJECT | ||||
38 | Q_CLASSINFO("D-Bus Interface", "org.freedesktop.bolt1.Device") | ||||
39 | | ||||
40 | Q_PROPERTY(QString Uid READ uid CONSTANT) | ||||
41 | Q_PROPERTY(QString Name READ name CONSTANT) | ||||
42 | Q_PROPERTY(QString Vendor READ vendor CONSTANT) | ||||
43 | Q_PROPERTY(QString Type READ type CONSTANT) | ||||
44 | Q_PROPERTY(QString Status READ status CONSTANT) | ||||
45 | Q_PROPERTY(QString AuthFlags READ authFlags CONSTANT) | ||||
46 | Q_PROPERTY(QString Parent READ parent CONSTANT) | ||||
47 | Q_PROPERTY(QString SysfsPath READ sysfsPath CONSTANT) | ||||
48 | Q_PROPERTY(bool Stored READ stored CONSTANT) | ||||
49 | Q_PROPERTY(QString Policy READ policy CONSTANT) | ||||
50 | Q_PROPERTY(QString Key READ key CONSTANT) | ||||
51 | Q_PROPERTY(QString Label READ label WRITE setLabel) | ||||
52 | Q_PROPERTY(quint64 ConnectTime READ connectTime CONSTANT) | ||||
53 | Q_PROPERTY(quint64 AuthorizeTime READ authorizeTime CONSTANT) | ||||
54 | Q_PROPERTY(quint64 StoreTime READ storeTime CONSTANT) | ||||
55 | public: | ||||
56 | explicit FakeDevice(const QString &uid, QObject *parent = nullptr); | ||||
57 | explicit FakeDevice(const QJsonObject &json, QObject *parent = nullptr); | ||||
58 | ~FakeDevice() override; | ||||
59 | | ||||
60 | QDBusObjectPath dbusPath() const; | ||||
61 | | ||||
62 | QString uid() const; | ||||
63 | QString name() const; | ||||
64 | void setName(const QString &name); | ||||
65 | QString vendor() const; | ||||
66 | void setVendor(const QString &vendor); | ||||
67 | QString type() const; | ||||
68 | void setType(const QString &type); | ||||
69 | QString status() const; | ||||
70 | void setStatus(const QString &status); | ||||
71 | QString authFlags() const; | ||||
72 | void setAuthFlags(const QString &authFlags); | ||||
73 | QString parent() const; | ||||
74 | void setParent(const QString &parent); | ||||
75 | QString sysfsPath() const; | ||||
76 | void setSysfsPath(const QString &sysfsPath); | ||||
77 | bool stored() const; | ||||
78 | void setStored(bool stored); | ||||
79 | QString policy() const; | ||||
80 | void setPolicy(const QString &policy); | ||||
81 | QString key() const; | ||||
82 | void setKey(const QString &key); | ||||
83 | QString label() const; | ||||
84 | void setLabel(const QString &label); | ||||
85 | quint64 connectTime() const; | ||||
86 | void setConnectTime(quint64 connectTime); | ||||
87 | quint64 authorizeTime() const; | ||||
88 | void setAuthorizeTime(quint64 authorizeTime); | ||||
89 | quint64 storeTime() const; | ||||
90 | void setStoreTime(quint64 storeTime); | ||||
91 | | ||||
92 | public Q_SLOTS: | ||||
93 | void Authorize(const QString &flags); | ||||
94 | | ||||
95 | private: | ||||
96 | QDBusObjectPath mDBusPath; | ||||
97 | | ||||
98 | QString mUid; | ||||
99 | QString mName; | ||||
100 | QString mVendor; | ||||
101 | QString mType; | ||||
102 | QString mStatus = QStringLiteral("unknown"); | ||||
103 | QString mAuthFlags = QStringLiteral("none"); | ||||
104 | QString mParent; | ||||
105 | QString mSysfsPath; | ||||
106 | QString mPolicy = QStringLiteral("unknown"); | ||||
107 | QString mKey; | ||||
108 | QString mLabel; | ||||
109 | quint64 mConnectTime = 0; | ||||
110 | quint64 mAuthorizeTime = 0; | ||||
111 | quint64 mStoreTime = 0; | ||||
112 | bool mStored = false; | ||||
113 | }; | ||||
114 | | ||||
115 | #endif | ||||
116 | |