1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2012 Digia Plc 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: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 Digia. For licensing terms and 15 ** conditions see http://qt.digia.com/licensing. For further information 16 ** use the contact form at http://qt.digia.com/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 as published by the Free Software 21 ** Foundation and appearing in the file LICENSE.LGPL included in the 22 ** packaging of this file. Please review the following information to 23 ** ensure the GNU Lesser General Public License version 2.1 requirements 24 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 ** 26 ** In addition, as a special exception, Digia gives you certain additional 27 ** rights. These rights are described in the Digia Qt LGPL Exception 28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 ** 30 ** GNU General Public License Usage 31 ** Alternatively, this file may be used under the terms of the GNU 32 ** General Public License version 3.0 as published by the Free Software 33 ** Foundation and appearing in the file LICENSE.GPL included in the 34 ** packaging of this file. Please review the following information to 35 ** ensure the GNU General Public License version 3.0 requirements will be 36 ** met: http://www.gnu.org/copyleft/gpl.html. 37 ** 38 ** 39 ** $QT_END_LICENSE$ 40 ** 41 ****************************************************************************/ 42 43 #ifndef QSYSTEMINFOBACKEND_SIMULATOR_P_H 44 #define QSYSTEMINFOBACKEND_SIMULATOR_P_H 45 46 47 // 48 // W A R N I N G 49 // ------------- 50 // 51 // This file is not part of the Qt API. It exists purely as an 52 // implementation detail. This header file may change from version to 53 // version without notice, or even be removed. 54 // 55 // We mean it. 56 // 57 58 #include "qsysteminfodata_simulator_p.h" 59 60 QT_BEGIN_NAMESPACE 61 62 // QBatteryInfoSimulatorBackend 63 64 class Q_SYSTEMINFO_EXPORT QBatteryInfoSimulatorBackend : public QObject 65 { 66 Q_OBJECT 67 68 private: 69 QBatteryInfoSimulatorBackend(QObject *parent = 0); 70 Q_DISABLE_COPY(QBatteryInfoSimulatorBackend) 71 72 public: 73 ~QBatteryInfoSimulatorBackend(); 74 static QBatteryInfoSimulatorBackend *getSimulatorBackend(); 75 76 int getBatteryCount(); 77 int getBatteryIndex() const; 78 int getLevel(int battery); 79 int getCurrentFlow(int battery); 80 int getCycleCount(int battery); 81 int getMaximumCapacity(int battery); 82 int getRemainingCapacity(int battery); 83 int getRemainingChargingTime(int battery); 84 int getVoltage(int battery); 85 QBatteryInfo::ChargingState getChargingState(int battery); 86 QBatteryInfo::ChargerType getChargerType(); 87 QBatteryInfo::LevelStatus getLevelStatus(int battery); 88 QBatteryInfo::Health getHealth(int battery); 89 float getTemperature(int battery); 90 91 void setBatteryIndex(int batteryIndex); 92 void setCurrentFlow(int flow); 93 void setCycleCount(int cycleCount); 94 void setMaximumCapacity(int capacity); 95 void setRemainingCapacity(int capacity); 96 void setRemainingChargingTime(int time); 97 void setVoltage(int vol); 98 void setChargingState(QBatteryInfo::ChargingState state); 99 void setChargerType(QBatteryInfo::ChargerType type); 100 void setLevelStatus(QBatteryInfo::LevelStatus levelStatus); 101 void setHealth(QBatteryInfo::Health health); 102 void setTemperature(float temperature); 103 104 Q_SIGNALS: 105 void batteryCountChanged(int count); 106 void batteryIndexChanged(int batteryIndex); 107 void levelChanged(int level); 108 void currentFlowChanged(int flow); 109 void cycleCountChanged(int cycleCount); 110 void remainingCapacityChanged(int capacity); 111 void remainingChargingTimeChanged(int seconds); 112 void voltageChanged(int voltage); 113 void chargingStateChanged(QBatteryInfo::ChargingState state); 114 void chargerTypeChanged(QBatteryInfo::ChargerType type); 115 void levelStatusChanged(QBatteryInfo::LevelStatus levelStatus); 116 void healthChanged(QBatteryInfo::Health health); 117 void temperatureChanged(float temperature); 118 119 private: 120 static QBatteryInfoSimulatorBackend *globalSimulatorBackend; 121 QBatteryInfoData data; 122 }; 123 124 125 // QDeviceInfoSimulatorBackend 126 127 class Q_SYSTEMINFO_EXPORT QDeviceInfoSimulatorBackend : public QObject 128 { 129 Q_OBJECT 130 131 private: 132 QDeviceInfoSimulatorBackend(QObject *parent = 0); 133 Q_DISABLE_COPY(QDeviceInfoSimulatorBackend) 134 135 public: 136 ~QDeviceInfoSimulatorBackend(); 137 static QDeviceInfoSimulatorBackend *getSimulatorBackend(); 138 139 bool hasFeature(QDeviceInfo::Feature); 140 int getImeiCount(); 141 QDeviceInfo::LockTypeFlags getActivatedLocks(); 142 QDeviceInfo::LockTypeFlags getEnabledLocks(); 143 QDeviceInfo::ThermalState getThermalState(); 144 QString getImei(int num); 145 QString getManufacturer(); 146 QString getModel(); 147 QString getProductName(); 148 QString getUniqueDeviceID(); 149 QString getVersion(QDeviceInfo::Version); 150 151 void setFeature(QDeviceInfo::Feature feature, bool enable); 152 void setActivatedLocks(QDeviceInfo::LockTypeFlags flag); 153 void setEnabledLocks(QDeviceInfo::LockTypeFlags flag); 154 void setThermalState(QDeviceInfo::ThermalState state); 155 void setImei(int num, QString imei); 156 void setManufacturer(QString manufacturer); 157 void setModel(QString model); 158 void setProductName(QString name); 159 void setUniqueDeviceID(QString id); 160 void setVersion(QDeviceInfo::Version version, QString versionString); 161 162 Q_SIGNALS: 163 void activatedLocksChanged(QDeviceInfo::LockTypeFlags); 164 void enabledLocksChanged(QDeviceInfo::LockTypeFlags); 165 void thermalStateChanged(QDeviceInfo::ThermalState); 166 167 private: 168 QDeviceInfoData data; 169 static QDeviceInfoSimulatorBackend *globalSimulatorBackend; 170 171 void initFeatureList(); 172 void initImeiList(); 173 void initVersionList(); 174 }; 175 176 // QNetworkInfoSimulatorBackend 177 178 class Q_SYSTEMINFO_EXPORT QNetworkInfoSimulatorBackend : public QObject 179 { 180 Q_OBJECT 181 182 private: 183 QNetworkInfoSimulatorBackend(QNetworkInfo *parent = 0); 184 Q_DISABLE_COPY(QNetworkInfoSimulatorBackend) 185 186 public: 187 ~QNetworkInfoSimulatorBackend(); 188 static QNetworkInfoSimulatorBackend *getSimulatorBackend(); 189 190 int getNetworkInterfaceCount(QNetworkInfo::NetworkMode mode); 191 int getNetworkSignalStrength(QNetworkInfo::NetworkMode mode, int interface); 192 QNetworkInfo::CellDataTechnology getCurrentCellDataTechnology(int interface); 193 QNetworkInfo::NetworkMode getCurrentNetworkMode(); 194 QString getImsi(int interface); 195 QNetworkInfo::NetworkStatus getNetworkStatus(QNetworkInfo::NetworkMode mode, int interface); 196 #ifndef QT_NO_NETWORKINTERFACE 197 QNetworkInterface getInterfaceForMode(QNetworkInfo::NetworkMode mode, int interface); 198 #endif // QT_NO_NETWORKINTERFACE 199 QString getCellId(int interface); 200 QString getCurrentMobileCountryCode(int interface); 201 QString getCurrentMobileNetworkCode(int interface); 202 QString getHomeMobileCountryCode(int interface); 203 QString getHomeMobileNetworkCode(int interface); 204 QString getLocationAreaCode(int interface); 205 QString getMacAddress(QNetworkInfo::NetworkMode mode, int interface); 206 QString getNetworkName(QNetworkInfo::NetworkMode mode, int interface); 207 QNetworkInfo::NetworkMode getMode(QNetworkInfo::NetworkMode mode, int interface); 208 209 void setImsi(int interface, const QString &id); 210 void setCellId(int interface, const QString &id); 211 void setLocationAreaCode(int interface, const QString &code); 212 void setCurrentMobileCountryCode( int interface, const QString &code); 213 void setCurrentMobileNetworkCode(int interface, const QString &code); 214 void setHomeMobileCountryCode(int interface, const QString &code); 215 void setHomeMobileNetworkCode(int interface, const QString &code); 216 void setCellDataTechnology(int interface, QNetworkInfo::CellDataTechnology cellData); 217 void setMode(int interface, QNetworkInfo::NetworkMode mode); 218 void setNetworkName(QNetworkInfo::NetworkMode mode, int interface, const QString &name); 219 void setNetworkMacAddress(QNetworkInfo::NetworkMode mode, int interface, const QString &mac); 220 void setNetworkSignalStrength(QNetworkInfo::NetworkMode mode, int interface, int strength); 221 void setNetworkStatus(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status); 222 223 void addEthernetInterface(QNetworkInfoData::EthernetInfo info); 224 void addWlanInterface(QNetworkInfoData::WLanInfo info); 225 void addCellularInterface(QNetworkInfoData::CellularInfo info); 226 void addBluetoothInterface(QNetworkInfoData::BluetoothInfo info); 227 void removeInterface(QNetworkInfo::NetworkMode mode, int interface); 228 void clearInterface(QNetworkInfo::NetworkMode mode); 229 230 Q_SIGNALS: 231 void cellIdChanged(int interface, const QString &id); 232 void currentCellDataTechnologyChanged(int interface, QNetworkInfo::CellDataTechnology tech); 233 void currentMobileCountryCodeChanged(int interface, const QString &mcc); 234 void currentMobileNetworkCodeChanged(int interface, const QString &mnc); 235 void currentNetworkModeChanged(QNetworkInfo::NetworkMode mode); 236 void locationAreaCodeChanged(int interface, const QString &lac); 237 void networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count); 238 void networkNameChanged(QNetworkInfo::NetworkMode mode, int interface, const QString &name); 239 void networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interface, int strength); 240 void networkStatusChanged(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status); 241 242 private: 243 static QNetworkInfoSimulatorBackend *globalSimulatorBackend; 244 QNetworkInfoData data; 245 246 QNetworkInfoData::BasicNetworkInfo *basicNetworkInfo(QNetworkInfo::NetworkMode mode, int interface); 247 bool isValidInterface(QNetworkInfo::NetworkMode mode, int interface); 248 void clearOrRemoveInterface(QNetworkInfo::NetworkMode mode, int interface, bool clear); 249 }; 250 251 QT_END_NAMESPACE 252 253 #endif // QSYSTEMINFOBACKEND_SIMULATOR_P_H 254