diff options
Diffstat (limited to 'xbmc/utils/SystemInfo.h')
| -rw-r--r-- | xbmc/utils/SystemInfo.h | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/xbmc/utils/SystemInfo.h b/xbmc/utils/SystemInfo.h new file mode 100644 index 0000000..c853192 --- /dev/null +++ b/xbmc/utils/SystemInfo.h | |||
| @@ -0,0 +1,156 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "InfoLoader.h" | ||
| 12 | #include "settings/ISubSettings.h" | ||
| 13 | |||
| 14 | #include <string> | ||
| 15 | |||
| 16 | #define KB (1024) // 1 KiloByte (1KB) 1024 Byte (2^10 Byte) | ||
| 17 | #define MB (1024*KB) // 1 MegaByte (1MB) 1024 KB (2^10 KB) | ||
| 18 | #define GB (1024*MB) // 1 GigaByte (1GB) 1024 MB (2^10 MB) | ||
| 19 | #define TB (1024*GB) // 1 TerraByte (1TB) 1024 GB (2^10 GB) | ||
| 20 | |||
| 21 | #define MAX_KNOWN_ATTRIBUTES 46 | ||
| 22 | |||
| 23 | |||
| 24 | class CSysData | ||
| 25 | { | ||
| 26 | public: | ||
| 27 | enum INTERNET_STATE { UNKNOWN, CONNECTED, DISCONNECTED }; | ||
| 28 | CSysData() | ||
| 29 | { | ||
| 30 | Reset(); | ||
| 31 | }; | ||
| 32 | |||
| 33 | void Reset() | ||
| 34 | { | ||
| 35 | internetState = UNKNOWN; | ||
| 36 | }; | ||
| 37 | |||
| 38 | std::string systemUptime; | ||
| 39 | std::string systemTotalUptime; | ||
| 40 | INTERNET_STATE internetState; | ||
| 41 | std::string videoEncoder; | ||
| 42 | std::string cpuFrequency; | ||
| 43 | std::string osVersionInfo; | ||
| 44 | std::string macAddress; | ||
| 45 | std::string batteryLevel; | ||
| 46 | }; | ||
| 47 | |||
| 48 | class CSysInfoJob : public CJob | ||
| 49 | { | ||
| 50 | public: | ||
| 51 | CSysInfoJob(); | ||
| 52 | |||
| 53 | bool DoWork() override; | ||
| 54 | const CSysData &GetData() const; | ||
| 55 | |||
| 56 | static CSysData::INTERNET_STATE GetInternetState(); | ||
| 57 | private: | ||
| 58 | static bool SystemUpTime(int iInputMinutes, int &iMinutes, int &iHours, int &iDays); | ||
| 59 | static std::string GetSystemUpTime(bool bTotalUptime); | ||
| 60 | static std::string GetMACAddress(); | ||
| 61 | static std::string GetVideoEncoder(); | ||
| 62 | static std::string GetBatteryLevel(); | ||
| 63 | |||
| 64 | CSysData m_info; | ||
| 65 | }; | ||
| 66 | |||
| 67 | class CSysInfo : public CInfoLoader, public ISubSettings | ||
| 68 | { | ||
| 69 | public: | ||
| 70 | enum WindowsVersion | ||
| 71 | { | ||
| 72 | WindowsVersionUnknown = -1, // Undetected, unsupported Windows version or OS in not Windows | ||
| 73 | WindowsVersionWin7, // Windows 7, Windows Server 2008 R2 | ||
| 74 | WindowsVersionWin8, // Windows 8, Windows Server 2012 | ||
| 75 | WindowsVersionWin8_1, // Windows 8.1 | ||
| 76 | WindowsVersionWin10, // Windows 10 | ||
| 77 | WindowsVersionWin10_FCU, // Windows 10 Fall Creators Update | ||
| 78 | /* Insert new Windows versions here, when they'll be known */ | ||
| 79 | WindowsVersionFuture = 100 // Future Windows version, not known to code | ||
| 80 | }; | ||
| 81 | enum WindowsDeviceFamily | ||
| 82 | { | ||
| 83 | Mobile = 1, | ||
| 84 | Desktop = 2, | ||
| 85 | IoT = 3, | ||
| 86 | Xbox = 4, | ||
| 87 | Surface = 5, | ||
| 88 | Other = 100 | ||
| 89 | }; | ||
| 90 | |||
| 91 | CSysInfo(void); | ||
| 92 | ~CSysInfo() override; | ||
| 93 | |||
| 94 | bool Load(const TiXmlNode *settings) override; | ||
| 95 | bool Save(TiXmlNode *settings) const override; | ||
| 96 | |||
| 97 | char MD5_Sign[32 + 1]; | ||
| 98 | |||
| 99 | static const std::string& GetAppName(void); // the same name as CCompileInfo::GetAppName(), but const ref to std::string | ||
| 100 | |||
| 101 | static std::string GetKernelName(bool emptyIfUnknown = false); | ||
| 102 | static std::string GetKernelVersionFull(void); // full version string, including "-generic", "-RELEASE" etc. | ||
| 103 | static std::string GetKernelVersion(void); // only digits with dots | ||
| 104 | static std::string GetOsName(bool emptyIfUnknown = false); | ||
| 105 | static std::string GetOsVersion(void); | ||
| 106 | static std::string GetOsPrettyNameWithVersion(void); | ||
| 107 | static std::string GetUserAgent(); | ||
| 108 | static std::string GetDeviceName(); | ||
| 109 | static std::string GetVersion(); | ||
| 110 | static std::string GetVersionShort(); | ||
| 111 | static std::string GetVersionCode(); | ||
| 112 | static std::string GetVersionGit(); | ||
| 113 | static std::string GetBuildDate(); | ||
| 114 | |||
| 115 | bool HasInternet(); | ||
| 116 | bool IsAeroDisabled(); | ||
| 117 | static bool IsWindowsVersion(WindowsVersion ver); | ||
| 118 | static bool IsWindowsVersionAtLeast(WindowsVersion ver); | ||
| 119 | static WindowsVersion GetWindowsVersion(); | ||
| 120 | static int GetKernelBitness(void); | ||
| 121 | static int GetXbmcBitness(void); | ||
| 122 | static const std::string& GetKernelCpuFamily(void); | ||
| 123 | static std::string GetManufacturerName(void); | ||
| 124 | static std::string GetModelName(void); | ||
| 125 | bool GetDiskSpace(std::string drive,int& iTotal, int& iTotalFree, int& iTotalUsed, int& iPercentFree, int& iPercentUsed); | ||
| 126 | std::string GetHddSpaceInfo(int& percent, int drive, bool shortText=false); | ||
| 127 | std::string GetHddSpaceInfo(int drive, bool shortText=false); | ||
| 128 | |||
| 129 | int GetTotalUptime() const { return m_iSystemTimeTotalUp; } | ||
| 130 | void SetTotalUptime(int uptime) { m_iSystemTimeTotalUp = uptime; } | ||
| 131 | |||
| 132 | static std::string GetBuildTargetPlatformName(void); | ||
| 133 | static std::string GetBuildTargetPlatformVersion(void); | ||
| 134 | static std::string GetBuildTargetPlatformVersionDecoded(void); | ||
| 135 | static std::string GetBuildTargetCpuFamily(void); | ||
| 136 | |||
| 137 | static std::string GetUsedCompilerNameAndVer(void); | ||
| 138 | std::string GetPrivacyPolicy(); | ||
| 139 | |||
| 140 | static WindowsDeviceFamily GetWindowsDeviceFamily(); | ||
| 141 | |||
| 142 | protected: | ||
| 143 | CJob *GetJob() const override; | ||
| 144 | std::string TranslateInfo(int info) const override; | ||
| 145 | void OnJobComplete(unsigned int jobID, bool success, CJob *job) override; | ||
| 146 | |||
| 147 | private: | ||
| 148 | CSysData m_info; | ||
| 149 | std::string m_privacyPolicy; | ||
| 150 | static WindowsVersion m_WinVer; | ||
| 151 | int m_iSystemTimeTotalUp; // Uptime in minutes! | ||
| 152 | void Reset(); | ||
| 153 | }; | ||
| 154 | |||
| 155 | extern CSysInfo g_sysinfo; | ||
| 156 | |||
