From: Joshua Peisach Date: Mon, 10 Aug 2020 12:24:50 +0000 (-0400) Subject: New upstream version 5.2.2.3 X-Git-Tag: archive/raspbian/5.7.12-2+rpi1^2~3^2~15 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1c3a96c55a05ba0751352fc077c4747e6227ed6c;p=dtkcore.git New upstream version 5.2.2.3 --- diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 0a04128..0000000 --- a/LICENSE +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/README.md b/README.md deleted file mode 100644 index 150a69d..0000000 --- a/README.md +++ /dev/null @@ -1,52 +0,0 @@ -## Deepin Tool Kit Core {#mainpage} - -Deepint Tool Kit (Dtk) is the base development tool of all C++/Qt Developer work on Deepin. - -You should read the [Deepin Application Specification](\ref doc/Specification) firstly. - -## Dependencies - -### Build dependencies - -* Qt >= 5.6 - -## Installation - -### Build from source code - -1. Make sure you have installed all dependencies. - -2. Build: - -```` -$ mkdir build -$ cd build -$ qmake .. -$ make -```` - -3. Install: - -```` -$ sudo make install -```` - -## Getting help - -Any usage issues can ask for help via - -* [Gitter](https://gitter.im/orgs/linuxdeepin/rooms) -* [IRC channel](https://webchat.freenode.net/?channels=deepin) -* [Forum](https://bbs.deepin.org) -* [WiKi](https://wiki.deepin.org/) - -## Getting involved - -We encourage you to report issues and contribute changes - -* [Contribution guide for developers](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers-en). (English) -* [开发者代码贡献指南](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers) (中文) - -## License - -deepin-tool-kit is licensed under [GPLv3](LICENSE). diff --git a/debian/source/format b/debian/source/format index 163aaf8..89ae9db 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff --git a/src/dsysinfo.cpp b/src/dsysinfo.cpp index 030ddb9..a364f4c 100644 --- a/src/dsysinfo.cpp +++ b/src/dsysinfo.cpp @@ -47,6 +47,7 @@ public: #ifdef Q_OS_LINUX void ensureDeepinInfo(); + bool ensureOsVersion(); #endif void ensureReleaseInfo(); void ensureComputerInfo(); @@ -58,6 +59,22 @@ public: QString deepinVersion; QString deepinEdition; QString deepinCopyright; + + QString majorVersion; + QString minorVersion; + struct MinVersion { + MinVersion():A(0), BC(0), D(0){ + } + uint A, BC, D; // A-BC-D + }; + struct OSBuild { + OSBuild():A(0), B(0), C(0), D(0), xyz(100){ + } + uint A, B, C, D, E, xyz; // ABCDE.xyz + }; + + MinVersion minVersion; + OSBuild osBuild; #endif QScopedPointer distributionInfo; @@ -82,7 +99,7 @@ DSysInfoPrivate::DSysInfoPrivate() #ifdef Q_OS_LINUX void DSysInfoPrivate::ensureDeepinInfo() { - if (deepinType >= 0) + if (static_cast(deepinType) >= 0) return; QFile file("/etc/deepin-version"); @@ -158,6 +175,54 @@ void DSysInfoPrivate::ensureDeepinInfo() QSettings distributionInfo(distributionInfoFile, QSettings::IniFormat); // TODO: treat as `.desktop` format instead of `.ini` } +bool DSysInfoPrivate::ensureOsVersion() +{ + if (minVersion.A > 0) + return true; + + DDesktopEntry entry("/etc/os-version"); + majorVersion = entry.stringValue("MajorVersion", "Version"); + minorVersion = entry.stringValue("MinorVersion", "Version"); + Q_ASSERT(minorVersion.length() == 4); + + // A-BC-D + bool ok = false; + uint minv = minorVersion.toUInt(&ok); + if (ok) { + minVersion.D = minv % 10; + } else if (minorVersion.length() > 0) { + // 0-9...A-Z + minVersion.D = 10 + static_cast(minorVersion.right(1).data()->toLatin1() - 'A'); + } + uint minVer = minorVersion.left(3).toUInt(); + minVersion.BC = minVer % 100; + minVer /= 100; + minVersion.A = minVer % 10; + + // ABCDE.xyz + QString osb = entry.stringValue("OsBuild", "Version"); + QStringList osbs = osb.split("."); + Q_ASSERT(osbs.size() == 2 && osbs.value(0).size() == 5); + uint left = osbs.value(0).trimmed().toUInt(&ok); + Q_ASSERT(ok); + if (ok) { + osBuild.E = left % 10; + left /= 10; + osBuild.D = left % 10; + left /= 10; + osBuild.C = left % 10; // default C is 0 + left /= 10; + osBuild.B = left % 10; + left /= 10; + osBuild.A = left % 10; + } + + // xyz + osBuild.xyz = osbs.value(1).trimmed().toUInt(&ok); + + return ok; +} + static QString unquote(const QByteArray &value) { if (value.at(0) == '"' || value.at(0) == '\'') { @@ -290,7 +355,7 @@ void DSysInfoPrivate::ensureReleaseInfo() case 'U': if (productTypeString.compare("ubuntu", Qt::CaseInsensitive) == 0) { productType = DSysInfo::Ubuntu; - } else if (productTypeString.compare("uos", Qt::CaseInsensitive) == 0) { + } else if (productTypeString.compare("uos", Qt::CaseInsensitive) == 0 || productTypeString.compare("UnionTech OS", Qt::CaseInsensitive) == 0) { productType = DSysInfo::Uos; } break; @@ -474,6 +539,161 @@ QString DSysInfo::deepinCopyright() return siGlobal->deepinCopyright; } + +/*! + * \~chinese \brief DSysInfo::osType 系统类型 + * \~chinese \row 显示系统类型【1:桌面】【2:服务器】【3:专用设备】 + * \~chinese \note 根据 osBuild.B 判断 + */ +DSysInfo::UosType DSysInfo::uosType() +{ + siGlobal->ensureOsVersion(); + + UosType ost = UosTypeUnknown; + if ((siGlobal->osBuild.B > UosTypeUnknown && siGlobal->osBuild.B < UosTypeCount)) { + ost = static_cast(siGlobal->osBuild.B); + } + + return ost; +} + +/*! + * \~chinese \brief DSysInfo::osEditionType 版本类型 + * \~chinese \row 显示版本类型 专业版/个人版/社区版... + * \~chinese \note 根据 osBuild.B && osBuild.D + */ +DSysInfo::UosEdition DSysInfo::uosEditionType() +{ + siGlobal->ensureOsVersion(); + UosEdition ospt = UosEditionUnknown; + + if (siGlobal->osBuild.B == UosDesktop) { + ospt = static_cast(siGlobal->osBuild.D); + } else if (siGlobal->osBuild.B == UosServer) { + ospt = static_cast(siGlobal->osBuild.D + UosMilitary); + } else if (siGlobal->osBuild.B == UosDevice){ + ospt = UosProfessional; + } + + return ospt; +} + +/*! + * \~chinese \brief DSysInfo::osArch 架构信息(使用一个字节的二进制位,从低位到高位) + * \~chinese \row 【0x8 sw64】【0x4 mips64】【0x2 arm64】【0x1 amd64】 + */ +DSysInfo::UosArch DSysInfo::uosArch() +{ + siGlobal->ensureOsVersion(); + + return static_cast(siGlobal->osBuild.E); +} + +static QString getUosVersionValue(const QString &key, const QLocale &locale) +{ + DDesktopEntry entry("/etc/os-version"); + QString localKey = QString("%1[%2]").arg(key, locale.name()); + + return entry.stringValue(localKey, "Version", entry.stringValue(key, "Version")); +} + +/*! + * \~chinese \brief DSysInfo::osProductTypeName 版本名称 + * \~chinese \row ProductType[xx] 项对应的值, 如果找不到对应语言的默认使用 ProductType的值(Desktop/Server/Device) + * \~chinese \param locale 当前系统语言 + */ +QString DSysInfo::uosProductTypeName(const QLocale &locale) +{ + return getUosVersionValue("ProductType", locale); +} + +/*! + * \~chinese \brief DSysInfo::osSystemName 版本名称 + * \~chinese \row SystemName[xx] 项对应的值, 如果找不到对应语言的默认使用 SystemName 的值 Uniontech OS + * \~chinese \param locale 当前系统语言 + */ +QString DSysInfo::uosSystemName(const QLocale &locale) +{ + return getUosVersionValue("SystemName", locale); +} + +/*! + * \~chinese \brief DSysInfo::osEditionName 版本名称 + * \~chinese \row EditionName[xx] 项对应的值, 如果找不到对应语言的默认使用 EditionName 的值(Professional/Home/Community...) + * \~chinese \param locale 当前系统语言 + */ +QString DSysInfo::uosEditionName(const QLocale &locale) +{ + return getUosVersionValue("EditionName", locale); +} + +/*! + * \~chinese \brief DSysInfo::spVersion 阶段版本名称 + * \~chinese \row 小版本号 A-BC-D 中 BC, 返回 SP1-SPxx, 如果正式版返回空 + * \~chinese \note minVersion.BC == 00:正式版本 minVersion.BC == 01-99:SP1….SP99 + */ +QString DSysInfo::spVersion() +{ + siGlobal->ensureOsVersion(); + if (siGlobal->minVersion.BC > 0) { + return QString("SP%1").arg(siGlobal->minVersion.BC); + } else { + return QString(); // 00 正式版 + } +} + +/*! + * \~chinese \brief DSysInfo::udpateVersion 更新版本名称 + * \~chinese \row 小版本号 A-BC-D 中 D, 返回 update1… update9, 如果正式版返回空 + * \~chinese \note minVersion.D == 0:正式版本 minVersion.D == 1-9:update1… update9,updateA...updateZ + */ +QString DSysInfo::udpateVersion() +{ + siGlobal->ensureOsVersion(); + if (siGlobal->minVersion.D > 0) { + uint uv = siGlobal->minVersion.D; + if (uv < 10) { + return QString("update%1").arg(uv); + } else { + return QString("update").append(QChar(uv - 10 + 'A')); + } + } else { + return QString(); // 0 正式版 + } +} + +/*! + * \~chinese \brief DSysInfo::majorVersion 主版本号 + * \~chinese \row 主版本号 【20】【23】【25】【26】【29】【30】 + * \~chinese \note 返回 MajorVersion 的值 + */ +QString DSysInfo::majorVersion() +{ + siGlobal->ensureOsVersion(); + return siGlobal->majorVersion; +} + +/*! + * \~chinese \brief DSysInfo::minorVersion 小版本号 + * \~chinese \row 【ABCD】 ·[0-9]{4} + * \~chinese \note 返回 MinorVersion 的值 + */ +QString DSysInfo::minorVersion() +{ + siGlobal->ensureOsVersion(); + return siGlobal->minorVersion; +} + +/*! + * \~chinese \brief DSysInfo::buildVersion 小版本号 + * \~chinese \row 系统镜像批次号,按时间顺序(不可回退)从100-999递增 + * \~chinese \note 返回 osBuild.xyz 的值 + */ +QString DSysInfo::buildVersion() +{ + siGlobal->ensureOsVersion(); + return QString::number(siGlobal->osBuild.xyz); +} #endif QString DSysInfo::deepinDistributionInfoPath() diff --git a/src/dsysinfo.h b/src/dsysinfo.h index 4fd17a1..9c41c49 100644 --- a/src/dsysinfo.h +++ b/src/dsysinfo.h @@ -67,6 +67,38 @@ public: Manufacturer //!< manufacturer of the current distribution or device }; + enum UosType { + UosTypeUnknown, + UosDesktop, + UosServer, + UosDevice, + + UosTypeCount // must at last + }; + + enum UosEdition { + UosEditionUnknown, + UosProfessional, + UosHome, + UosCommunity, + UosMilitary, + UosEnterprise, + UosEnterpriseC, + UosEuler, + UosMilitaryS, // for Server + + UosEditionCount // must at last + }; + + // 注意:此处架构是从OsBuild获取的系统版本的Arch信息,并不是指硬件的Arch信息 + enum UosArch { + UosArchUnknown, + UosAMD64 = 1 << 0, + UosARM64 = 1 << 1, + UosMIPS64 = 1 << 2, + UosSW64 = 1 << 3 + }; + #ifdef Q_OS_LINUX static bool isDeepin(); static bool isDDE(); @@ -75,6 +107,20 @@ public: static QString deepinVersion(); static QString deepinEdition(); static QString deepinCopyright(); + + // uos version interface + static UosType uosType(); + static UosEdition uosEditionType(); + static UosArch uosArch(); + static QString uosProductTypeName(const QLocale &locale = QLocale::system()); + static QString uosSystemName(const QLocale &locale = QLocale::system()); + static QString uosEditionName(const QLocale &locale = QLocale::system()); + + static QString spVersion(); // SP1...SP99 + static QString udpateVersion(); // update1...update9 + static QString majorVersion(); + static QString minorVersion(); + static QString buildVersion(); // xyz #endif Q_DECL_DEPRECATED_X("Use distributionInfoPath() instead") static QString deepinDistributionInfoPath(); diff --git a/src/dtk_translation.prf b/src/dtk_translation.prf index 76a75dc..352c022 100644 --- a/src/dtk_translation.prf +++ b/src/dtk_translation.prf @@ -1,6 +1,6 @@ message ("Process dtk translation") -message ("Add DTK_NO_TRANSLATION=YES to qmake arguments skip this") -message ("Add DTK_STATIC_TRANSLATION=YES to add support static translations") +message ("Add DTK_NO_TRANSLATION=YES to qmake arguments to skip this") +message ("Add DTK_STATIC_TRANSLATION=YES to add support for static translations") # TODO: check lrelease/lupdate exist diff --git a/tests/dutils/dutiltester.cpp b/tests/dutils/dutiltester.cpp index b50ca9a..a5326ab 100644 --- a/tests/dutils/dutiltester.cpp +++ b/tests/dutils/dutiltester.cpp @@ -33,6 +33,7 @@ #include "settings/dsettings.h" #include "settings/dsettingsgroup.h" #include "settings/dsettingsoption.h" +#include "dsysinfo.h" DCORE_USE_NAMESPACE @@ -225,3 +226,18 @@ void TestDUtil::testGroups() qDebug() << settings->group("shortcuts.ternimal"); qDebug() << settings->group("shortcuts.ternimal")->options(); } + +void TestDUtil::testSysInfo() +{ + qDebug() << DSysInfo::uosType() << + DSysInfo::uosEditionType() << + DSysInfo::uosArch() << + DSysInfo::uosProductTypeName() << + DSysInfo::uosSystemName() << + DSysInfo::uosEditionName() << + DSysInfo::spVersion() << + DSysInfo::udpateVersion() << + DSysInfo::majorVersion() << + DSysInfo::minorVersion() << + DSysInfo::buildVersion() ; +} diff --git a/tests/dutils/dutiltester.h b/tests/dutils/dutiltester.h index be9beac..f53ea34 100644 --- a/tests/dutils/dutiltester.h +++ b/tests/dutils/dutiltester.h @@ -35,6 +35,7 @@ private Q_SLOTS: void testDBusSender(); void testGroups(); + void testSysInfo(); }; diff --git a/tools/deepin-os-release/main.cpp b/tools/deepin-os-release/main.cpp index cdd5ec6..e98aa9d 100644 --- a/tools/deepin-os-release/main.cpp +++ b/tools/deepin-os-release/main.cpp @@ -92,15 +92,24 @@ int main(int argc, char *argv[]) printf("Product Type: %s\n", qPrintable(DSysInfo::productTypeString())); printf("Product Version: %s\n", qPrintable(DSysInfo::productVersion())); + printf("Uos Product Name: %s\n", qPrintable(DSysInfo::uosProductTypeName())); + printf("Uos SystemName Name: %s\n", qPrintable(DSysInfo::uosSystemName())); + printf("Uos Product Name: %s\n", qPrintable(DSysInfo::uosEditionName())); + printf("Uos SP Version: %s\n", qPrintable(DSysInfo::spVersion())); + printf("Uos update Version: %s\n", qPrintable(DSysInfo::udpateVersion())); + printf("Uos major Version: %s\n", qPrintable(DSysInfo::majorVersion())); + printf("Uos minor Version: %s\n", qPrintable(DSysInfo::minorVersion())); + printf("Uos build Version: %s\n", qPrintable(DSysInfo::buildVersion())); + if (distributionInfoValid()) { printDistributionOrgInfo(DSysInfo::Distribution); printDistributionOrgInfo(DSysInfo::Distributor); } } else { if (parser.isSet(option_deepin_type)) - printf("%s", qPrintable(DSysInfo::deepinTypeDisplayName(QLocale::c()))); + printf("%s", qPrintable(DSysInfo::uosEditionName(QLocale::c()))); else if (parser.isSet(option_deepin_version)) - printf("%s", qPrintable(DSysInfo::deepinVersion())); + printf("%s", qPrintable(DSysInfo::majorVersion())); else if (parser.isSet(option_deepin_edition)) printf("%s", qPrintable(DSysInfo::deepinEdition())); else if (parser.isSet(option_deepin_copyright)) diff --git a/tools/script/dtk-license.py b/tools/script/dtk-license.py index bc3a071..cf49e81 100644 --- a/tools/script/dtk-license.py +++ b/tools/script/dtk-license.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import fnmatch import os diff --git a/tools/script/dtk-translate.py b/tools/script/dtk-translate.py index 9cb06f8..97bb7e6 100644 --- a/tools/script/dtk-translate.py +++ b/tools/script/dtk-translate.py @@ -1,4 +1,4 @@ -#!env python +#!/usr/bin/env python3 import sys,os,fnmatch from subprocess import call