| 1 |
// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DSYSINFO_H |
| 6 |
#define DSYSINFO_H |
| 7 |
|
| 8 |
#include <dtkcore_global.h> |
| 9 |
|
| 10 |
#include <QLocale> |
| 11 |
|
| 12 |
DCORE_BEGIN_NAMESPACE |
| 13 |
|
| 14 |
class DSysInfoPrivate; |
| 15 |
class LIBDTKCORESHARED_EXPORT DSysInfo |
| 16 |
{ |
| 17 |
Q_GADGET |
| 18 |
public: |
| 19 |
enum ProductType { |
| 20 |
UnknownType = 0, |
| 21 |
Deepin, |
| 22 |
ArchLinux, |
| 23 |
CentOS, |
| 24 |
Debian, |
| 25 |
Fedora, |
| 26 |
LinuxMint, |
| 27 |
Manjaro, |
| 28 |
openSUSE, |
| 29 |
SailfishOS, |
| 30 |
Ubuntu, |
| 31 |
Uos, |
| 32 |
Gentoo, |
| 33 |
NixOS |
| 34 |
}; |
| 35 |
|
| 36 |
Q_ENUM(ProductType) |
| 37 |
|
| 38 |
enum DeepinType { |
| 39 |
UnknownDeepin = 0, |
| 40 |
DeepinDesktop, |
| 41 |
DeepinProfessional, |
| 42 |
DeepinServer, |
| 43 |
DeepinPersonal, |
| 44 |
DeepinMilitary |
| 45 |
}; |
| 46 |
|
| 47 |
enum LogoType { |
| 48 |
Normal = 0, |
| 49 |
Light, |
| 50 |
Symbolic, |
| 51 |
Transparent |
| 52 |
}; |
| 53 |
|
| 54 |
enum OrgType { |
| 55 |
Distribution, //!<@~english distribution itself |
| 56 |
Distributor, //!<@~english distributer of the current distribution |
| 57 |
Manufacturer //!<@~english manufacturer of the current distribution or device |
| 58 |
}; |
| 59 |
|
| 60 |
enum UosType { |
| 61 |
UosTypeUnknown, |
| 62 |
UosDesktop, |
| 63 |
UosServer, |
| 64 |
UosDevice, |
| 65 |
UosSmart, |
| 66 |
|
| 67 |
UosTypeCount // must at last |
| 68 |
}; |
| 69 |
|
| 70 |
enum UosEdition { |
| 71 |
UosEditionUnknown, |
| 72 |
UosProfessional, |
| 73 |
UosHome, |
| 74 |
UosCommunity, |
| 75 |
UosMilitary, |
| 76 |
UosEnterprise, |
| 77 |
UosEnterpriseC, |
| 78 |
UosEuler, |
| 79 |
UosMilitaryS, // for Server |
| 80 |
UosDeviceEdition, |
| 81 |
UosEducation, |
| 82 |
|
| 83 |
UosEditionCount // must at last |
| 84 |
}; |
| 85 |
|
| 86 |
enum UosArch { |
| 87 |
UosArchUnknown, |
| 88 |
UosAMD64 = 1 << 0, |
| 89 |
UosARM64 = 1 << 1, |
| 90 |
UosMIPS64 = 1 << 2, |
| 91 |
UosSW64 = 1 << 3 |
| 92 |
}; |
| 93 |
|
| 94 |
//! @~english enum.Arch |
| 95 |
enum Arch { |
| 96 |
ARM64, /*!< @~english arm64 */ |
| 97 |
ARM64_BE, /*!< @~english arm64-be */ |
| 98 |
ARM, /*!< @~english arm */ |
| 99 |
ARM_BE, /*!< @~english arm-be */ |
| 100 |
ALPHA, /*!< @~english alpha */ |
| 101 |
SW_64, /*!< @~english sw_64 */ |
| 102 |
ARC, /*!< @~english arc */ |
| 103 |
ARC_BE, /*!< @~english arc-be */ |
| 104 |
CRIS, /*!< @~english cris */ |
| 105 |
X86_64, /*!< @~english x86-64 */ |
| 106 |
X86, /*!< @~english x86 */ |
| 107 |
IA64, /*!< @~english ia64 */ |
| 108 |
LOONGARCH64,/*!< @~english loongarch64 */ |
| 109 |
M68K, /*!< @~english m68k */ |
| 110 |
MIPS64_LE, /*!< @~english mips64-le */ |
| 111 |
MIPS64, /*!< @~english mips64 */ |
| 112 |
MIPS_LE, /*!< @~english mips-le */ |
| 113 |
MIPS, /*!< @~english mips */ |
| 114 |
NIOS2, /*!< @~english nios2 */ |
| 115 |
PARISC64, /*!< @~english parisc64 */ |
| 116 |
PARISC, /*!< @~english parisc */ |
| 117 |
PPC64_LE, /*!< @~english ppc64-le */ |
| 118 |
PPC64, /*!< @~english ppc64 */ |
| 119 |
PPC, /*!< @~english ppc */ |
| 120 |
PPC_LE, /*!< @~english ppc-le */ |
| 121 |
RISCV32, /*!< @~english riscv32 */ |
| 122 |
RISCV64, /*!< @~english riscv64 */ |
| 123 |
S390X, /*!< @~english s390x */ |
| 124 |
S390, /*!< @~english s390 */ |
| 125 |
SH64, /*!< @~english sh64 */ |
| 126 |
SH, /*!< @~english sh */ |
| 127 |
SPARC64, /*!< @~english sparc64 */ |
| 128 |
SPARC, /*!< @~english sparc */ |
| 129 |
TILEGX, /*!< @~english tilegx */ |
| 130 |
|
| 131 |
NUM_ARCHES, /*!< @~english number of defined Arch types */ |
| 132 |
}; |
| 133 |
Q_ENUM(Arch) // Q_GADGET |
| 134 |
|
| 135 |
#ifdef Q_OS_LINUX |
| 136 |
static bool isDeepin(); |
| 137 |
static bool isDDE(); |
| 138 |
static DeepinType deepinType(); |
| 139 |
static QString deepinTypeDisplayName(const QLocale &locale = QLocale::system()); |
| 140 |
static QString deepinVersion(); |
| 141 |
static QString deepinEdition(); |
| 142 |
static QString deepinCopyright(); |
| 143 |
|
| 144 |
// uos version interface |
| 145 |
static UosType uosType(); |
| 146 |
static UosEdition uosEditionType(); |
| 147 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 148 |
Q_DECL_DEPRECATED_X("Use arch() instead") static UosArch uosArch(); |
| 149 |
#endif |
| 150 |
static QString uosProductTypeName(const QLocale &locale = QLocale::system()); |
| 151 |
static QString uosSystemName(const QLocale &locale = QLocale::system()); |
| 152 |
static QString uosEditionName(const QLocale &locale = QLocale::system()); |
| 153 |
|
| 154 |
static QString spVersion(); // SP1...SP99 |
| 155 |
static QString udpateVersion(); // update1...update9 |
| 156 |
static QString majorVersion(); |
| 157 |
static QString minorVersion(); |
| 158 |
static QString buildVersion(); // xyzs |
| 159 |
#endif |
| 160 |
|
| 161 |
#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0) |
| 162 |
Q_DECL_DEPRECATED_X("Use distributionInfoPath() instead") static QString deepinDistributionInfoPath(); |
| 163 |
Q_DECL_DEPRECATED_X("Use distributionOrgName() instead") static QString deepinDistributorName(); |
| 164 |
Q_DECL_DEPRECATED_X("Use distributionOrgWebsite() instead") static QPair<QString, QString> deepinDistributorWebsite(); |
| 165 |
Q_DECL_DEPRECATED_X("Use distributionOrgLogo() instead") static QString deepinDistributorLogo(LogoType type = Normal, const QString & fallback = QString()); |
| 166 |
#endif |
| 167 |
static QString distributionInfoPath(); |
| 168 |
static QString distributionInfoSectionName(OrgType type); |
| 169 |
|
| 170 |
static QString distributionOrgName(OrgType type = Distribution, const QLocale &locale = QLocale::system()); |
| 171 |
static QPair<QString, QString> distributionOrgWebsite(OrgType type = Distribution); |
| 172 |
static QString distributionOrgLogo(OrgType orgType = Distribution, LogoType type = Normal, const QString & fallback = QString()); |
| 173 |
|
| 174 |
static QString operatingSystemName(); |
| 175 |
static ProductType productType(); |
| 176 |
static QString productTypeString(); |
| 177 |
static QString productVersion(); |
| 178 |
static bool isCommunityEdition(); |
| 179 |
|
| 180 |
static QString computerName(); |
| 181 |
static QString cpuModelName(); |
| 182 |
static qint64 memoryInstalledSize(); |
| 183 |
static qint64 memoryTotalSize(); |
| 184 |
static qint64 systemDiskSize(); |
| 185 |
|
| 186 |
static QDateTime bootTime(); |
| 187 |
static QDateTime shutdownTime(); |
| 188 |
static qint64 uptime(); |
| 189 |
static Arch arch(); |
| 190 |
}; |
| 191 |
|
| 192 |
DCORE_END_NAMESPACE |
| 193 |
|
| 194 |
#endif // DSYSINFO_H |