1 /* 2 Actiona 3 Copyright (C) 2005 Jonathan Mercier-Ganady 4 5 Actiona is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 Actiona is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 Contact : jmgr@jmgr.info 19 */ 20 21 #pragma once 22 23 #include "code/codeclass.h" 24 25 #include <QObject> 26 #include <QScriptValue> 27 #include <QScriptEngine> 28 #include <QStringList> 29 30 class QDeviceInfo; 31 class QBatteryInfo; 32 class QStorageInfo_Custom; 33 34 class SystemSession; 35 36 namespace Code 37 { 38 class System : public CodeClass 39 { 40 Q_OBJECT 41 Q_ENUMS(DriveType) 42 Q_ENUMS(PowerState) 43 Q_ENUMS(StorageLocation) 44 45 public: 46 enum DriveType 47 { 48 UnknownDrive, 49 InternalDrive, 50 RemovableDrive, 51 RemoteDrive, 52 CdromDrive, 53 RamDrive 54 }; 55 enum PowerState 56 { 57 UnknownState, 58 BatteryPower, 59 WallPower, 60 WallPowerChargingBattery 61 }; 62 enum StorageLocation 63 { 64 Desktop, 65 Documents, 66 Fonts, 67 Applications, 68 Music, 69 Movies, 70 Pictures, 71 Temp, 72 Home, 73 Data, 74 Cache, 75 GenericData, 76 Runtime, 77 Config, 78 Download, 79 GenericCache, 80 GenericConfig 81 }; 82 83 static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); 84 85 System(); 86 ~System() override; 87 88 public slots: toString()89 QString toString() const override { return QStringLiteral("System"); } equals(const QScriptValue & other)90 bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation<System>(other); } 91 QString storageLocationPath(StorageLocation location) const; 92 QString storageLocationName(StorageLocation location) const; 93 QScriptValue openUrl(const QString &url) const; 94 int screenCount() const; 95 QScriptValue availableGeometry(int screen = -1) const; 96 QScriptValue screenGeometry(int screen = -1) const; 97 int primaryScreen() const; 98 bool isVirtualDesktop() const; 99 QString currentDirectory() const; 100 QString username() const; 101 QString variable(const QString &name) const; 102 uint timestamp() const; 103 QString osName() const; 104 QString version() const; 105 QString countryCode() const; 106 QString language() const; 107 QStringList logicalDrives() const; 108 qlonglong availableDiskSpace(const QString &drive) const; 109 qlonglong totalDiskSpace(const QString &drive) const; 110 DriveType driveType(const QString &drive) const; 111 int colorDepth(int screenId = -1) const; 112 int displayBrightness(int screenId = -1) const; 113 int batteryLevel() const; 114 PowerState powerState() const; 115 QString manufacturer() const; 116 QString model() const; 117 QString productName() const; 118 QScriptValue logout(bool force) const; 119 QScriptValue restart(bool force) const; 120 QScriptValue shutdown(bool force) const; 121 QScriptValue suspend(bool force) const; 122 QScriptValue hibernate(bool force) const; 123 QScriptValue lockScreen() const; 124 QScriptValue startScreenSaver() const; 125 126 private: 127 SystemSession *mSystemSession; 128 QDeviceInfo *mDeviceInfo; 129 QBatteryInfo *mBatteryInfo; 130 QStorageInfo_Custom *mStorageInfo; 131 }; 132 } 133 134