Debian Codegraph @

src/LomiriSystemInfo/linux/lomiribatteryinfo_linux_p.h

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd and/or its subsidiary(-ies).
4 ** Copyright (C) 2018 BlackBerry Limited. All rights reserved.
5 ** Contact: http://www.qt-project.org/legal
6 **
7 ** This file is part of the QtSystems module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 //
42 // W A R N I N G
43 // -------------
44 //
45 // This file is not part of the Qt API. It exists purely as an
46 // implementation detail. This header file may change from version to
47 // version without notice, or even be removed.
48 //
49 // We mean it.
50 //
51
52 #ifndef QBATTERYINFO_LINUX_P_H
53 #define QBATTERYINFO_LINUX_P_H
54
55 #include <lomiribatteryinfo.h>
56
57 #include <QtCore/qmap.h>
58
59 QT_BEGIN_NAMESPACE
60
61 #if !defined(QT_NO_UDEV)
62 class QUDevWrapper;
63 #else
64 class QTimer;
65 #endif // QT_NO_UDEV
66
67 class LomiriBatteryInfoPrivate : public QObject
68 {
69 Q_OBJECT
70
71 public:
72 LomiriBatteryInfoPrivate(LomiriBatteryInfo *parent);
73 LomiriBatteryInfoPrivate(int batteryIndex, LomiriBatteryInfo *parent);
74 ~LomiriBatteryInfoPrivate();
75
76 int batteryCount();
77 int batteryIndex() const;
78 bool isValid();
79 int level(int battery);
80 int level();
81 int currentFlow(int battery);
82 int currentFlow();
83 int cycleCount(int battery);
84 int cycleCount();
85 int maximumCapacity(int battery);
86 int maximumCapacity();
87 int remainingCapacity(int battery);
88 int remainingCapacity();
89 int remainingChargingTime(int battery);
90 int remainingChargingTime();
91 int voltage(int battery);
92 int voltage();
93 LomiriBatteryInfo::ChargerType chargerType();
94 LomiriBatteryInfo::ChargingState chargingState(int battery);
95 LomiriBatteryInfo::ChargingState chargingState();
96 LomiriBatteryInfo::LevelStatus levelStatus(int battery);
97 LomiriBatteryInfo::LevelStatus levelStatus();
98 LomiriBatteryInfo::Health health(int battery);
99 LomiriBatteryInfo::Health health();
100 float temperature(int battery);
101 float temperature();
102
103 void setBatteryIndex(int batteryIndex);
104
105 Q_SIGNALS:
106 void batteryCountChanged(int count);
107 void batteryIndexChanged(int batteryIndex);
108 void validChanged(bool isValid);
109 void chargerTypeChanged(LomiriBatteryInfo::ChargerType type);
110 void chargingStateChanged(LomiriBatteryInfo::ChargingState state);
111 void levelChanged(int level);
112 void currentFlowChanged(int flow);
113 void cycleCountChanged(int cycleCount);
114 void remainingCapacityChanged(int capacity);
115 void remainingChargingTimeChanged(int seconds);
116 void voltageChanged(int voltage);
117 void levelStatusChanged(LomiriBatteryInfo::LevelStatus levelStatus);
118 void healthChanged(LomiriBatteryInfo::Health health);
119 void temperatureChanged(float temperature);
120
121 protected:
122 void connectNotify(const QMetaMethod &signal);
123 void disconnectNotify(const QMetaMethod &signal);
124
125 private Q_SLOTS:
126 #if !defined(QT_NO_UDEV)
127 void onBatteryDataChanged(int battery, const QByteArray &attribute, const QByteArray &value);
128 void onChargerTypeChanged(const QByteArray &value, bool enabled);
129 #else
130 void onTimeout();
131 #endif // QT_NO_UDEV
132
133 private:
134 LomiriBatteryInfo * const q_ptr;
135 Q_DECLARE_PUBLIC(LomiriBatteryInfo)
136
137 bool watchIsValid;
138 bool forceWatchBatteryCount;
139 bool watchBatteryCount;
140 bool watchChargerType;
141 bool watchChargingState;
142 bool watchCurrentFlow;
143 bool watchRemainingCapacity;
144 bool watchRemainingChargingTime;
145 bool watchVoltage;
146 bool watchLevelStatus;
147 int batteryCounts;
148 int index;
149 QMap<int, int> currentFlows; // <battery ID, current value> pair
150 QMap<int, int> voltages;
151 QMap<int, int> remainingCapacities;
152 QMap<int, int> remainingChargingTimes;
153 QMap<int, int> maximumCapacities;
154 QMap<int, LomiriBatteryInfo::ChargingState> chargingStates;
155 LomiriBatteryInfo::ChargerType currentChargerType;
156 QMap<int, LomiriBatteryInfo::LevelStatus> levelStatuss;
157 #if !defined(QT_NO_UDEV)
158 QUDevWrapper *uDevWrapper;
159 #else
160 QTimer *timer;
161 #endif // QT_NO_UDEV
162
163 int getBatteryCount();
164 int getCurrentFlow(int battery);
165 int getRemainingCapacity(int battery);
166 int getRemainingChargingTime(int battery);
167 int getVoltage(int battery);
168 LomiriBatteryInfo::ChargerType getChargerType();
169 LomiriBatteryInfo::ChargingState getChargingState(int battery);
170 LomiriBatteryInfo::LevelStatus getLevelStatus(int battery);
171 };
172
173 QT_END_NAMESPACE
174
175 #endif // QBATTERYINFO_LINUX_P_H