1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.core.sysinfo; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.bytearray; 19 import qt.core.string; 20 import qt.helpers; 21 22 /+ #ifndef QSYSINFO_H +/ 23 /+ #define QSYSINFO_H 24 25 26 /* 27 System information 28 */ 29 30 /* 31 * GCC (5-7) has a regression that causes it to emit wrong deprecated warnings: 32 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77849 33 * 34 * Try to work around it by defining our own macro. 35 */ 36 37 #ifdef QT_SYSINFO_DEPRECATED_X 38 #error "QT_SYSINFO_DEPRECATED_X already defined" 39 #endif 40 41 #ifdef Q_CC_GNU 42 #define QT_SYSINFO_DEPRECATED_X(x) 43 #else 44 #define QT_SYSINFO_DEPRECATED_X(x) QT_DEPRECATED_X(x) 45 #endif 46 47 class QString; +/ 48 /+ #define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) +/ 49 extern(D) alias Q_MV_OSX = function string(string major, string minor) 50 { 51 return mixin(interpolateMixin(q{($(major) == 10 ? $(minor) + 2 : ($(major) == 9 ? 1 : 0))})); 52 }; 53 /+ #define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) +/ 54 extern(D) alias Q_MV_IOS = function string(string major, string minor) 55 { 56 return mixin(interpolateMixin(q{(QSysInfo.MacVersion.MV_IOS | $(major) << 4 | $(minor))})); 57 }; 58 /+ #define Q_MV_TVOS(major, minor) (QSysInfo::MV_TVOS | major << 4 | minor) +/ 59 extern(D) alias Q_MV_TVOS = function string(string major, string minor) 60 { 61 return mixin(interpolateMixin(q{(QSysInfo.MacVersion.MV_TVOS | $(major) << 4 | $(minor))})); 62 }; 63 /+ #define Q_MV_WATCHOS(major, minor) (QSysInfo::MV_WATCHOS | major << 4 | minor) +/ 64 extern(D) alias Q_MV_WATCHOS = function string(string major, string minor) 65 { 66 return mixin(interpolateMixin(q{(QSysInfo.MacVersion.MV_WATCHOS | $(major) << 4 | $(minor))})); 67 }; 68 69 extern(C++, class) struct /+ Q_CORE_EXPORT +/ QSysInfo { 70 public: 71 enum Sizes { 72 WordSize = ((void*).sizeof<<3) 73 } 74 75 /+ #if defined(QT_BUILD_QMAKE) +/ 76 version(QT_BUILD_QMAKE) 77 { 78 enum Endian { 79 BigEndian, 80 LittleEndian 81 } 82 /* needed to bootstrap qmake */ 83 extern static __gshared const(int) ByteOrder; 84 } 85 else 86 { 87 /+ #elif defined(Q_BYTE_ORDER) +/ 88 enum Endian { 89 BigEndian, 90 LittleEndian 91 } 92 version(BigEndian) 93 enum ByteOrder = Endian.BigEndian; 94 else version(LittleEndian) 95 enum ByteOrder = Endian.LittleEndian; 96 else 97 static assert(0, "Undefined byte order"); 98 } 99 /+ #endif 100 #if QT_DEPRECATED_SINCE(5, 9) +/ 101 enum /+ QT_DEPRECATED_X("Use QOperatingSystemVersion") +/ WinVersion { 102 WV_None = 0x0000, 103 104 WV_32s = 0x0001, 105 WV_95 = 0x0002, 106 WV_98 = 0x0003, 107 WV_Me = 0x0004, 108 WV_DOS_based= 0x000f, 109 110 /* codenames */ 111 WV_NT = 0x0010, 112 WV_2000 = 0x0020, 113 WV_XP = 0x0030, 114 WV_2003 = 0x0040, 115 WV_VISTA = 0x0080, 116 WV_WINDOWS7 = 0x0090, 117 WV_WINDOWS8 = 0x00a0, 118 WV_WINDOWS8_1 = 0x00b0, 119 WV_WINDOWS10 = 0x00c0, 120 WV_NT_based = 0x00f0, 121 122 /* version numbers */ 123 WV_4_0 = WinVersion.WV_NT, 124 WV_5_0 = WinVersion.WV_2000, 125 WV_5_1 = WinVersion.WV_XP, 126 WV_5_2 = WinVersion.WV_2003, 127 WV_6_0 = WinVersion.WV_VISTA, 128 WV_6_1 = WinVersion.WV_WINDOWS7, 129 WV_6_2 = WinVersion.WV_WINDOWS8, 130 WV_6_3 = WinVersion.WV_WINDOWS8_1, 131 WV_10_0 = WinVersion.WV_WINDOWS10, 132 133 WV_CE = 0x0100, 134 WV_CENET = 0x0200, 135 WV_CE_5 = 0x0300, 136 WV_CE_6 = 0x0400, 137 WV_CE_based = 0x0f00 138 } 139 140 /+ #define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) 141 #define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) 142 #define Q_MV_TVOS(major, minor) (QSysInfo::MV_TVOS | major << 4 | minor) 143 #define Q_MV_WATCHOS(major, minor) (QSysInfo::MV_WATCHOS | major << 4 | minor) +/ 144 enum /+ QT_DEPRECATED_X("Use QOperatingSystemVersion") +/ MacVersion { 145 MV_None = 0xffff, 146 MV_Unknown = 0x0000, 147 148 /* version */ 149 MV_9 = mixin(Q_MV_OSX(q{9}, q{0})), 150 MV_10_0 = mixin(Q_MV_OSX(q{10}, q{0})), 151 MV_10_1 = mixin(Q_MV_OSX(q{10}, q{1})), 152 MV_10_2 = mixin(Q_MV_OSX(q{10}, q{2})), 153 MV_10_3 = mixin(Q_MV_OSX(q{10}, q{3})), 154 MV_10_4 = mixin(Q_MV_OSX(q{10}, q{4})), 155 MV_10_5 = mixin(Q_MV_OSX(q{10}, q{5})), 156 MV_10_6 = mixin(Q_MV_OSX(q{10}, q{6})), 157 MV_10_7 = mixin(Q_MV_OSX(q{10}, q{7})), 158 MV_10_8 = mixin(Q_MV_OSX(q{10}, q{8})), 159 MV_10_9 = mixin(Q_MV_OSX(q{10}, q{9})), 160 MV_10_10 = mixin(Q_MV_OSX(q{10}, q{10})), 161 MV_10_11 = mixin(Q_MV_OSX(q{10}, q{11})), 162 MV_10_12 = mixin(Q_MV_OSX(q{10}, q{12})), 163 164 /* codenames */ 165 MV_CHEETAH = MacVersion.MV_10_0, 166 MV_PUMA = MacVersion.MV_10_1, 167 MV_JAGUAR = MacVersion.MV_10_2, 168 MV_PANTHER = MacVersion.MV_10_3, 169 MV_TIGER = MacVersion.MV_10_4, 170 MV_LEOPARD = MacVersion.MV_10_5, 171 MV_SNOWLEOPARD = MacVersion.MV_10_6, 172 MV_LION = MacVersion.MV_10_7, 173 MV_MOUNTAINLION = MacVersion.MV_10_8, 174 MV_MAVERICKS = MacVersion.MV_10_9, 175 MV_YOSEMITE = MacVersion.MV_10_10, 176 MV_ELCAPITAN = MacVersion.MV_10_11, 177 MV_SIERRA = MacVersion.MV_10_12, 178 179 /* iOS */ 180 MV_IOS = 1 << 8, 181 MV_IOS_4_3 = mixin(Q_MV_IOS(q{4}, q{3})), 182 MV_IOS_5_0 = mixin(Q_MV_IOS(q{5}, q{0})), 183 MV_IOS_5_1 = mixin(Q_MV_IOS(q{5}, q{1})), 184 MV_IOS_6_0 = mixin(Q_MV_IOS(q{6}, q{0})), 185 MV_IOS_6_1 = mixin(Q_MV_IOS(q{6}, q{1})), 186 MV_IOS_7_0 = mixin(Q_MV_IOS(q{7}, q{0})), 187 MV_IOS_7_1 = mixin(Q_MV_IOS(q{7}, q{1})), 188 MV_IOS_8_0 = mixin(Q_MV_IOS(q{8}, q{0})), 189 MV_IOS_8_1 = mixin(Q_MV_IOS(q{8}, q{1})), 190 MV_IOS_8_2 = mixin(Q_MV_IOS(q{8}, q{2})), 191 MV_IOS_8_3 = mixin(Q_MV_IOS(q{8}, q{3})), 192 MV_IOS_8_4 = mixin(Q_MV_IOS(q{8}, q{4})), 193 MV_IOS_9_0 = mixin(Q_MV_IOS(q{9}, q{0})), 194 MV_IOS_9_1 = mixin(Q_MV_IOS(q{9}, q{1})), 195 MV_IOS_9_2 = mixin(Q_MV_IOS(q{9}, q{2})), 196 MV_IOS_9_3 = mixin(Q_MV_IOS(q{9}, q{3})), 197 MV_IOS_10_0 = mixin(Q_MV_IOS(q{10}, q{0})), 198 199 /* tvOS */ 200 MV_TVOS = 1 << 9, 201 MV_TVOS_9_0 = mixin(Q_MV_TVOS(q{9}, q{0})), 202 MV_TVOS_9_1 = mixin(Q_MV_TVOS(q{9}, q{1})), 203 MV_TVOS_9_2 = mixin(Q_MV_TVOS(q{9}, q{2})), 204 MV_TVOS_10_0 = mixin(Q_MV_TVOS(q{10}, q{0})), 205 206 /* watchOS */ 207 MV_WATCHOS = 1 << 10, 208 MV_WATCHOS_2_0 = mixin(Q_MV_WATCHOS(q{2}, q{0})), 209 MV_WATCHOS_2_1 = mixin(Q_MV_WATCHOS(q{2}, q{1})), 210 MV_WATCHOS_2_2 = mixin(Q_MV_WATCHOS(q{2}, q{2})), 211 MV_WATCHOS_3_0 = mixin(Q_MV_WATCHOS(q{3}, q{0})) 212 } 213 214 /+ QT_WARNING_PUSH 215 QT_WARNING_DISABLE_DEPRECATED 216 #if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) 217 QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ 218 static if(versionIsSet!("Windows")) 219 { 220 extern static __gshared const(WinVersion) WindowsVersion; 221 /+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ static WinVersion windowsVersion(); 222 } 223 else 224 { 225 /+ #else 226 QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ extern(D) static __gshared const(WinVersion) WindowsVersion = WinVersion.WV_None; 227 /+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ static WinVersion windowsVersion() { return WinVersion.WV_None; } 228 } 229 /+ #endif 230 #if defined(Q_OS_MAC) 231 QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ 232 static if((versionIsSet!("OSX") || versionIsSet!("iOS") || versionIsSet!("TVOS") || versionIsSet!("WatchOS"))) 233 { 234 extern static __gshared const(MacVersion) MacintoshVersion; 235 /+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ static MacVersion macVersion(); 236 } 237 else 238 { 239 /+ #else 240 QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ extern(D) static __gshared const(MacVersion) MacintoshVersion = MacVersion.MV_None; 241 /+ QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") +/ static MacVersion macVersion() { return MacVersion.MV_None; } 242 } 243 /+ #endif 244 QT_WARNING_POP 245 #endif +/ // QT_DEPRECATED_SINCE(5, 9) 246 247 static QString buildCpuArchitecture(); 248 static QString currentCpuArchitecture(); 249 static QString buildAbi(); 250 251 static QString kernelType(); 252 static QString kernelVersion(); 253 static QString productType(); 254 static QString productVersion(); 255 static QString prettyProductName(); 256 257 static QString machineHostName(); 258 static QByteArray machineUniqueId(); 259 static QByteArray bootUniqueId(); 260 } 261 262 /+ #undef QT_SYSINFO_DEPRECATED_X +/ 263 264 /+ #endif +/ // QSYSINFO_H 265