Debian Codegraph @

tests/mocks/Lomiri/Connectivity/networking-status.h

raw
1 /*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 #ifndef FAKE_NETWORKING_STATUS_H
19 #define FAKE_NETWORKING_STATUS_H
20
21 #include <QObject>
22 #include <QVector>
23
24 class Q_DECL_EXPORT NetworkingStatus : public QObject
25 {
26 Q_OBJECT
27 Q_DISABLE_COPY(NetworkingStatus)
28
29 Q_PROPERTY(QVector<Limitations> limitations READ limitations NOTIFY limitationsChanged)
30 Q_PROPERTY(Status status READ status WRITE setStatus NOTIFY statusChanged)
31 Q_PROPERTY(bool online READ online NOTIFY onlineChanged)
32 Q_PROPERTY(bool limitedBandwidth READ limitedBandwidth WRITE setLimitedBandwidth NOTIFY limitedBandwidthChanged)
33
34 public:
35 explicit NetworkingStatus(QObject *parent = 0);
36 virtual ~NetworkingStatus();
37
38 enum Limitations {
39 Bandwidth
40 };
41 Q_ENUM(Limitations)
42
43 enum Status {
44 Offline,
45 Connecting,
46 Online
47 };
48 Q_ENUM(Status)
49
50 QVector<Limitations> limitations() const;
51 NetworkingStatus::Status status() const;
52 bool online() const;
53 bool limitedBandwidth() const;
54
55 // Only in the fake one
56 void setLimitedBandwidth(bool limited);
57 void setStatus(NetworkingStatus::Status status);
58
59 Q_SIGNALS:
60 void limitationsChanged();
61 void statusChanged(NetworkingStatus::Status status);
62 void onlineChanged(bool value);
63 void limitedBandwidthChanged(bool value);
64
65 private:
66 QVector<NetworkingStatus::Limitations> m_limitations;
67 NetworkingStatus::Status m_status;
68 };
69
70 Q_DECLARE_METATYPE(NetworkingStatus::Limitations)
71 Q_DECLARE_METATYPE(QVector<NetworkingStatus::Limitations>)
72 Q_DECLARE_METATYPE(NetworkingStatus::Status)
73
74 #endif // FAKE_NETWORKING_STATUS_H