| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). | 
| 4 | ** Copyright (C) 2014 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:LGPL21$ | 
| 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 http://www.qt.io/terms-conditions. For further | 
| 16 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | 
| 21 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | 
| 22 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | 
| 23 | ** following information to ensure the GNU Lesser General Public License | 
| 24 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | 
| 25 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
| 26 | ** | 
| 27 | ** As a special exception, The Qt Company gives you certain additional | 
| 28 | ** rights. These rights are described in The Qt Company LGPL Exception | 
| 29 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
| 30 | ** | 
| 31 | ** $QT_END_LICENSE$ | 
| 32 | ** | 
| 33 | ****************************************************************************/ | 
| 34 |  | 
| 35 | // | 
| 36 | //  W A R N I N G | 
| 37 | //  ------------- | 
| 38 | // | 
| 39 | // This file is not part of the Qt API.  It exists purely as an | 
| 40 | // implementation detail.  This header file may change from version to | 
| 41 | // version without notice, or even be removed. | 
| 42 | // | 
| 43 | // We mean it. | 
| 44 | // | 
| 45 |  | 
| 46 | #ifndef QBATTERYINFO_LINUX_P_H | 
| 47 | #define QBATTERYINFO_LINUX_P_H | 
| 48 |  | 
| 49 | #include <qbatteryinfo.h> | 
| 50 |  | 
| 51 | #include <QtCore/qmap.h> | 
| 52 |  | 
| 53 | QT_BEGIN_NAMESPACE | 
| 54 |  | 
| 55 | #if !defined(QT_NO_UDEV) | 
| 56 | class QUDevWrapper; | 
| 57 | #else | 
| 58 | class QTimer; | 
| 59 | #endif // QT_NO_UDEV | 
| 60 |  | 
| 61 | class QBatteryInfoPrivate : public QObject | 
| 62 | { | 
| 63 |     Q_OBJECT | 
| 64 |  | 
| 65 | public: | 
| 66 |     QBatteryInfoPrivate(QBatteryInfo *parent); | 
| 67 |     QBatteryInfoPrivate(int batteryIndex, QBatteryInfo *parent); | 
| 68 |     ~QBatteryInfoPrivate(); | 
| 69 |  | 
| 70 |     int batteryCount(); | 
| 71 |     int batteryIndex() const; | 
| 72 |     bool isValid(); | 
| 73 |     int level(int battery); | 
| 74 |     int level(); | 
| 75 |     int currentFlow(int battery); | 
| 76 |     int currentFlow(); | 
| 77 |     int cycleCount(int battery); | 
| 78 |     int cycleCount(); | 
| 79 |     int maximumCapacity(int battery); | 
| 80 |     int maximumCapacity(); | 
| 81 |     int remainingCapacity(int battery); | 
| 82 |     int remainingCapacity(); | 
| 83 |     int remainingChargingTime(int battery); | 
| 84 |     int remainingChargingTime(); | 
| 85 |     int voltage(int battery); | 
| 86 |     int voltage(); | 
| 87 |     QBatteryInfo::ChargerType chargerType(); | 
| 88 |     QBatteryInfo::ChargingState chargingState(int battery); | 
| 89 |     QBatteryInfo::ChargingState chargingState(); | 
| 90 |     QBatteryInfo::LevelStatus levelStatus(int battery); | 
| 91 |     QBatteryInfo::LevelStatus levelStatus(); | 
| 92 |     QBatteryInfo::Health health(int battery); | 
| 93 |     QBatteryInfo::Health health(); | 
| 94 |     float temperature(int battery); | 
| 95 |     float temperature(); | 
| 96 |  | 
| 97 |     void setBatteryIndex(int batteryIndex); | 
| 98 |  | 
| 99 | Q_SIGNALS: | 
| 100 |     void batteryCountChanged(int count); | 
| 101 |     void batteryIndexChanged(int batteryIndex); | 
| 102 |     void validChanged(bool isValid); | 
| 103 |     void chargerTypeChanged(QBatteryInfo::ChargerType type); | 
| 104 |     void chargingStateChanged(QBatteryInfo::ChargingState state); | 
| 105 |     void levelChanged(int level); | 
| 106 |     void currentFlowChanged(int flow); | 
| 107 |     void cycleCountChanged(int cycleCount); | 
| 108 |     void remainingCapacityChanged(int capacity); | 
| 109 |     void remainingChargingTimeChanged(int seconds); | 
| 110 |     void voltageChanged(int voltage); | 
| 111 |     void levelStatusChanged(QBatteryInfo::LevelStatus levelStatus); | 
| 112 |     void healthChanged(QBatteryInfo::Health health); | 
| 113 |     void temperatureChanged(float temperature); | 
| 114 |  | 
| 115 | protected: | 
| 116 |     void connectNotify(const QMetaMethod &signal); | 
| 117 |     void disconnectNotify(const QMetaMethod &signal); | 
| 118 |  | 
| 119 | private Q_SLOTS: | 
| 120 | #if !defined(QT_NO_UDEV) | 
| 121 |     void onBatteryDataChanged(int battery, const QByteArray &attribute, const QByteArray &value); | 
| 122 |     void onChargerTypeChanged(const QByteArray &value, bool enabled); | 
| 123 | #else | 
| 124 |     void onTimeout(); | 
| 125 | #endif // QT_NO_UDEV | 
| 126 |  | 
| 127 | private: | 
| 128 |     QBatteryInfo * const q_ptr; | 
| 129 |     Q_DECLARE_PUBLIC(QBatteryInfo) | 
| 130 |  | 
| 131 |     bool watchIsValid; | 
| 132 |     bool forceWatchBatteryCount; | 
| 133 |     bool watchBatteryCount; | 
| 134 |     bool watchChargerType; | 
| 135 |     bool watchChargingState; | 
| 136 |     bool watchCurrentFlow; | 
| 137 |     bool watchRemainingCapacity; | 
| 138 |     bool watchRemainingChargingTime; | 
| 139 |     bool watchVoltage; | 
| 140 |     bool watchLevelStatus; | 
| 141 |     int batteryCounts; | 
| 142 |     int index; | 
| 143 |     QMap<int, int> currentFlows; // <battery ID, current value> pair | 
| 144 |     QMap<int, int> voltages; | 
| 145 |     QMap<int, int> remainingCapacities; | 
| 146 |     QMap<int, int> remainingChargingTimes; | 
| 147 |     QMap<int, int> maximumCapacities; | 
| 148 |     QMap<int, QBatteryInfo::ChargingState> chargingStates; | 
| 149 |     QBatteryInfo::ChargerType currentChargerType; | 
| 150 |     QMap<int, QBatteryInfo::LevelStatus> levelStatuss; | 
| 151 | #if !defined(QT_NO_UDEV) | 
| 152 |     QUDevWrapper *uDevWrapper; | 
| 153 | #else | 
| 154 |     QTimer *timer; | 
| 155 | #endif // QT_NO_UDEV | 
| 156 |  | 
| 157 |     int getBatteryCount(); | 
| 158 |     int getCurrentFlow(int battery); | 
| 159 |     int getRemainingCapacity(int battery); | 
| 160 |     int getRemainingChargingTime(int battery); | 
| 161 |     int getVoltage(int battery); | 
| 162 |     QBatteryInfo::ChargerType getChargerType(); | 
| 163 |     QBatteryInfo::ChargingState getChargingState(int battery); | 
| 164 |     QBatteryInfo::LevelStatus getLevelStatus(int battery); | 
| 165 | }; | 
| 166 |  | 
| 167 | QT_END_NAMESPACE | 
| 168 |  | 
| 169 | #endif // QBATTERYINFO_LINUX_P_H | 
| 170 |  |