Compare commits

...

15 Commits

Author SHA1 Message Date
deepin-admin-bot 23c069ddb9 chore: Sync by 559e91167d
sync by github workflow

Log: none
Influence: none
2023-07-10 06:12:34 +00:00
wangfei bf0a4a7bef feat: add license feature
add license feature

Log: add license feature
2023-05-11 13:39:07 +08:00
deepin-admin-bot b7b859508d chore: Sync by 2e5e092ba3
sync by github workflow

Log: none
Influence: none
2023-05-10 02:23:53 +00:00
deepin-admin-bot cfd8219696 chore: Sync by 2dd22560f7
sync by github workflow

Log: none
Influence: none
2023-04-14 08:41:31 +00:00
deepin-admin-bot a6741c39fa chore: Sync by c5d10d3aeb
sync by github workflow

Log: none
Influence: none
2023-04-14 08:31:57 +00:00
deepin-admin-bot 3f67f9ce7d chore: Sync by d45f73b2d0
sync by github workflow

Log: none
Influence: none
2022-12-28 07:55:21 +00:00
deepin-admin-bot 8f0ea1d10b chore: Sync by 3de30af6dc
sync by github workflow

Log: none
Influence: none
2022-11-24 08:45:35 +00:00
ck 31f01ba34f chore: update changelog
update changelog

Log: update changelog
Influence: none
Change-Id: Ic6864bb5c396db262673ae232b364f19914541b7
2022-11-24 13:50:12 +08:00
wang fei 51bfccfda2 chore: 完善cpu信息获取接口(cpuModelName)
分别按以下顺序取其值,取到就返回:
1. 首先匹配sw,hw-klv里的特殊字段;
2. 然后取model name字段;
3. 最后通过lscpu命令获取;

Log: 修改cpu信息获取接口
Task: https://pms.uniontech.com/task-view-218217.html
Influence: cpuModelName接口
Change-Id: I6ba1a66f1d898725ebcb9a59791f6d466149a3a3
2022-11-22 08:57:40 +00:00
deepin-admin-bot 4a75e87df8 chore: Sync by 6aa579e31c
sync by github workflow

Log: none
Influence: none
2022-11-18 02:00:26 +00:00
deepin-admin-bot bd4e3a7a92 chore: Sync by 50ad27fb2a
sync by github workflow

Log: none
Influence: none
2022-11-16 03:44:15 +00:00
deepin-admin-bot 6fa340336f chore: Sync by d15debb9d3
sync by github workflow

Log: none
Influence: none
2022-11-11 06:54:21 +00:00
deepin-admin-bot 8e4ba2ecf0 chore: Sync by 6fbf8e00b9
sync by github workflow

Log: none
Influence: none
2022-10-14 05:24:48 +00:00
Ye ShanShan d031357a68 chore: Modify some nonstandard writing
Change Warning log to Debug.
  Rename GlobalUID to InvalidUID avoiding to misunderstand.
  cache saved only it's setValue has been called.

Log: 移除错误的输出警告,当cache被修改后才保存
Influence: 如果没有设置值,再不会生成缓存文件
Change-Id: I1f71513e91bef3412f593281e68fea44801fe07b
2022-08-31 13:02:07 +08:00
deepin-bot[bot] bf30a50edb
chore: Sync by (#74)
chore: Sync by
2022-07-19 09:10:28 +00:00
17 changed files with 593 additions and 11 deletions

20
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,20 @@
blank_issues_enabled: false
contact_links:
- name: BUG Report | 缺陷报告
url: https://github.com/linuxdeepin/dtk/issues/new?assignees=&labels=&template=bug-report.yml
about: Please create bug reports to the issue board in our dtk repo.
- name: docs-update | 文档补充
url: https://github.com/linuxdeepin/dtk/issues/new?assignees=&labels=&template=docs-update.yml
about: Please create docs-update to the issue board in our dtk repo.
- name: unit-test-report | 单元测试报告
url: https://github.com/linuxdeepin/dtk/issues/new?assignees=&labels=&template=unit-test-report.yml
about: Please create unit-test-report to the issue board in our dtk repo.
- name: Feature Request | 特性请求
url: https://github.com/linuxdeepin/developer-center/discussions/new?category=features-request-ideas-%E7%89%B9%E6%80%A7%E8%AF%B7%E6%B1%82-%E5%A4%B4%E8%84%91%E9%A3%8E%E6%9A%B4
about: Please create feature requests to the discussion board in our developer-center repo.
- name: General Discussion & Questions | 常规讨论与问答
url: https://github.com/linuxdeepin/developer-center/discussions/categories/q-a-%E9%97%AE%E7%AD%94%E6%9D%BF%E5%9D%97
about: Please use the discussion board in our developer-center repo.

16
.github/workflows/call-auto-tag.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: auto tag
on:
pull_request_target:
types: [opened, synchronize, closed]
paths:
- "debian/changelog"
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
auto_tag:
uses: linuxdeepin/.github/.github/workflows/auto-tag.yml@master
secrets: inherit

15
.github/workflows/call-clacheck.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Call CLA check
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
clacheck:
uses: linuxdeepin/.github/.github/workflows/cla-check.yml@master
secrets: inherit

View File

@ -0,0 +1,26 @@
name: deploy docs
on:
push:
branches: ["master"]
workflow_dispatch:
inputs:
tag:
required: true
type: string
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
deploydocs:
uses: linuxdeepin/.github/.github/workflows/deploy-dev-doc.yml@master
with:
ref: ${{ inputs.tag }}
secrets: inherit

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
dtkcore (5.5.35) unstable; urgency=medium
* Release 5.5.35
-- Deepin Packages Builder <packages@deepin.com> Thu, 24 Nov 2022 13:28:15 +0800
dtkcore (5.0.3) unstable; urgency=medium
* Release 5.0.3

1
src/DLicenseInfo Normal file
View File

@ -0,0 +1 @@
#include "dlicenseinfo.h"

View File

@ -286,7 +286,7 @@ public:
qCWarning(cfLog, "Can't acquire config manager. error:\"%s\"", qPrintable(dbus_reply.error().message()));
return false;
} else {
qCWarning(cfLog(), "dbus path=\"%s\"", qPrintable(dbus_path.path()));
qCDebug(cfLog(), "dbus path=\"%s\"", qPrintable(dbus_path.path()));
config.reset(new DSGConfigManager(DSG_CONFIG_MANAGER, dbus_path.path(),
QDBusConnection::systemBus(), owner->q_func()));
if (!config->isValid()) {

View File

@ -152,7 +152,7 @@ static DConfigFile::Version parseVersion(const QJsonObject &obj) {
#define MAGIC_OVERRIDE QLatin1String("dsg.config.override")
#define MAGIC_CACHE QLatin1String("dsg.config.cache")
static const uint GlobalUID = 0xFFFF;
static const uint InvalidUID = 0xFFFF;
inline static bool checkMagic(const QJsonObject &obj, QLatin1String request) {
return obj[QLatin1String("magic")].toString() == request;
@ -1014,6 +1014,7 @@ public:
values.setTime(key, QDateTime::currentDateTime().toString(Qt::ISODate));
values.setUser(key, uid);
values.setAppId(key, appid.isEmpty() ? configKey.appId : appid);
cacheChanged = true;
return true;
}
@ -1028,7 +1029,7 @@ public:
DConfigInfo values;
uint userid;
bool global;
char padding [3] = {};
bool cacheChanged = false;
};
DConfigCacheImpl::DConfigCacheImpl(const DConfigKey &configKey, const uint uid, bool global)
@ -1080,6 +1081,9 @@ bool DConfigCacheImpl::load(const QString &localPrefix)
bool DConfigCacheImpl::save(const QString &localPrefix, QJsonDocument::JsonFormat format, bool sync)
{
if (!cacheChanged)
return true;
const QString &dir = getCacheDir(localPrefix);
if (dir.isEmpty()) {
qCWarning(cfLog, "save Falied because home directory is not exist for the user[%d].", userid);
@ -1237,14 +1241,14 @@ DConfigFile::DConfigFile(const QString &appId, const QString &name, const QStrin
Q_ASSERT(!name.isEmpty());
D_D(DConfigFile);
d->globalCache = new DConfigCacheImpl(d->configKey, GlobalUID, true);
d->globalCache = new DConfigCacheImpl(d->configKey, InvalidUID, true);
}
DConfigFile::DConfigFile(const DConfigFile &other)
: DObject(*new DConfigFilePrivate(this, other.d_func()->configKey))
{
D_D(DConfigFile);
auto cache = new DConfigCacheImpl(d->configKey, GlobalUID, true);
auto cache = new DConfigCacheImpl(d->configKey, InvalidUID, true);
cache->values = other.d_func()->globalCache->values;
d->globalCache = cache;
}

205
src/dlicenseinfo.cpp Normal file
View File

@ -0,0 +1,205 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "dlicenseinfo.h"
#include <DObjectPrivate>
#include <QFile>
#include <QJsonParseError>
#include <QJsonObject>
#include <QJsonArray>
#include <QDebug>
DCORE_BEGIN_NAMESPACE
class DLicenseInfo::DComponentInfoPrivate : public DObjectPrivate
{
public:
QString name;
QString version;
QString copyRight;
QString licenseName;
protected:
explicit DComponentInfoPrivate(DLicenseInfo::DComponentInfo *qq)
: DObjectPrivate(qq)
{
}
private:
Q_DECLARE_PUBLIC(DLicenseInfo::DComponentInfo)
friend class DLicenseInfoPrivate;
};
DLicenseInfo::DComponentInfo::DComponentInfo(DObject * parent)
: DObject(*new DLicenseInfo::DComponentInfoPrivate(this), parent)
{
}
DLicenseInfo::DComponentInfo::~DComponentInfo()
{
}
QString DLicenseInfo::DComponentInfo::name() const
{
return d_func()->name;
}
QString DLicenseInfo::DComponentInfo::version() const
{
return d_func()->version;
}
QString DLicenseInfo::DComponentInfo::copyRight() const
{
return d_func()->copyRight;
}
QString DLicenseInfo::DComponentInfo::licenseName() const
{
return d_func()->licenseName;
}
class Q_DECL_HIDDEN DLicenseInfoPrivate : public DObjectPrivate
{
public:
explicit DLicenseInfoPrivate(DLicenseInfo *qq);
~DLicenseInfoPrivate() override;
bool loadFile(const QString &file);
bool loadContent(const QByteArray &content);
QByteArray licenseContent(const QString &licenseName);
void clear();
QString licenseSearchPath;
DLicenseInfo::DComponentInfos componentInfos;
};
DLicenseInfoPrivate::DLicenseInfoPrivate(DLicenseInfo *qq)
: DObjectPrivate(qq)
{
}
DLicenseInfoPrivate::~DLicenseInfoPrivate()
{
clear();
}
bool DLicenseInfoPrivate::loadFile(const QString &file)
{
QFile jsonFile(file);
if (!jsonFile.open(QIODevice::ReadOnly)) {
qWarning() << QString("Failed on open file: \"%1\", error message: \"%2\"").arg(
qPrintable(jsonFile.fileName()), qPrintable(jsonFile.errorString()));
return false;
}
return loadContent(jsonFile.readAll());
}
bool DLicenseInfoPrivate::loadContent(const QByteArray &content)
{
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(content, &error);
if (error.error != QJsonParseError::NoError) {
qWarning() << "When loading the license, parseJson failed:" << qPrintable(error.errorString());
return false;
}
if (!jsonDoc.isArray()) {
qWarning() << "When loading the license, parseJson failed: it is not a JSON array";
return false;
}
clear();
QJsonArray array = jsonDoc.array();
for (const QJsonValue &value : array) {
if (!value.isObject()) {
qWarning() << "When loading the license, parseJson failed: it is not a JSON object!";
return false;
}
DLicenseInfo::DComponentInfo *componentInfo = new DLicenseInfo::DComponentInfo;
QJsonObject obj = value.toObject();
QJsonValue name = obj.value("name");
QJsonValue version = obj.value("version");
QJsonValue copyright = obj.value("copyright");
QJsonValue license = obj.value("license");
if (!name.isString() || !version.isString()
|| !copyright.isString() || !license.isString()) {
qWarning() << "When loading the license, parseJson failed: it is not a string!";
return false;
}
componentInfo->d_func()->name = name.toString();
componentInfo->d_func()->version = version.toString();
componentInfo->d_func()->copyRight = copyright.toString();
componentInfo->d_func()->licenseName = license.toString();
componentInfos.append(componentInfo);
}
return true;
}
QByteArray DLicenseInfoPrivate::licenseContent(const QString &licenseName)
{
QByteArray content;
QStringList dirs{"/usr/share/spdx-license"};
if (!licenseSearchPath.isEmpty())
dirs.prepend(licenseSearchPath);
for (const QString &dir : dirs) {
QFile file(QString("%1/%2.txt").arg(dir).arg(licenseName));
if (!file.exists())
continue;
if (file.open(QIODevice::ReadOnly)) {
content = file.readAll();
file.close();
break;
}
}
if (content.isEmpty()) {
qWarning() << QString("License content is empty when getting license content!");
}
return content;
}
void DLicenseInfoPrivate::clear()
{
qDeleteAll(componentInfos);
componentInfos.clear();
}
DLicenseInfo::DLicenseInfo(DObject *parent)
: DObject(*new DLicenseInfoPrivate(this), parent)
{
}
bool DLicenseInfo::loadContent(const QByteArray &content)
{
D_D(DLicenseInfo);
return d->loadContent(content);
}
bool DLicenseInfo::loadFile(const QString &file)
{
D_D(DLicenseInfo);
return d->loadFile(file);
}
void DLicenseInfo::setLicenseSearchPath(const QString &path)
{
D_D(DLicenseInfo);
d->licenseSearchPath = path;
}
QByteArray DLicenseInfo::licenseContent(const QString &licenseName)
{
D_D(DLicenseInfo);
return d->licenseContent(licenseName);
}
DLicenseInfo::DComponentInfos DLicenseInfo::componentInfos() const
{
D_DC(DLicenseInfo);
return d->componentInfos;
}
DCORE_END_NAMESPACE

49
src/dlicenseinfo.h Normal file
View File

@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef DLICENSEINFO_H
#define DLICENSEINFO_H
#include <dtkcore_global.h>
#include <dobject.h>
DCORE_BEGIN_NAMESPACE
class DLicenseInfoPrivate;
class LIBDTKCORESHARED_EXPORT DLicenseInfo : public DObject
{
public:
explicit DLicenseInfo(DObject *parent = nullptr);
bool loadContent(const QByteArray &content);
bool loadFile(const QString &file);
void setLicenseSearchPath(const QString &path);
QByteArray licenseContent(const QString &licenseName);
class DComponentInfoPrivate;
class LIBDTKCORESHARED_EXPORT DComponentInfo : public DObject
{
public:
explicit DComponentInfo(DObject *parent = nullptr);
~DComponentInfo() override;
QString name() const;
QString version() const;
QString copyRight() const;
QString licenseName() const;
private:
D_DECLARE_PRIVATE(DComponentInfo)
friend class DLicenseInfoPrivate;
};
using DComponentInfos = QVector<DComponentInfo*>;
DComponentInfos componentInfos() const;
private:
D_DECLARE_PRIVATE(DLicenseInfo)
};
DCORE_END_NAMESPACE
#endif // DLICENSEINFO_H

View File

@ -60,7 +60,7 @@ public:
void ensureReleaseInfo();
void ensureComputerInfo();
QMap<QString, QString> parseInfoFile(QFile &file);
QMap<QString, QString> parseInfoContent(const QString &content);
#ifdef Q_OS_LINUX
DSysInfo::DeepinType deepinType = DSysInfo::DeepinType(-1);
QMap<QString, QString> deepinTypeMap; //Type Name with Language
@ -515,6 +515,21 @@ QMap<QString, QString> DSysInfoPrivate::parseInfoFile(QFile &file)
return map;
}
QMap<QString, QString> DSysInfoPrivate::parseInfoContent(const QString &content)
{
QMap<QString, QString> map;
QStringList lineContents = content.split("\n");
for (auto lineContent : lineContents) {
if (lineContent.contains(':')) {
QStringList list = lineContent.split(':');
if (list.size() == 2) {
map.insert(list.first().trimmed(), list.back().trimmed());
}
}
}
return map;
}
Q_GLOBAL_STATIC(DSysInfoPrivate, siGlobal)
QString DSysInfo::operatingSystemName()
@ -984,6 +999,9 @@ QString DSysInfo::computerName()
QString DSysInfo::cpuModelName()
{
if (!siGlobal->cpuModelName.isEmpty())
return siGlobal->cpuModelName;
#ifdef Q_OS_LINUX
static QFile file("/proc/cpuinfo");
@ -998,10 +1016,31 @@ QString DSysInfo::cpuModelName()
} else if (map.contains("cpu model")) {
// loonson3-cpuinfo sw-cpuinfo
siGlobal->cpuModelName = map.value("cpu model");
} else if (map.contains("Hardware")) {
// "HardWare" field contains cpu info on huawei kirin machine (e.g. klv or klu)
siGlobal->cpuModelName = map.value("Hardware");
}
file.close();
}
// Get the cpu info by executing lscpu command
if (siGlobal->cpuModelName.isEmpty()) {
QProcess lscpu;
QStringList env = QProcess::systemEnvironment();
env << "LC_ALL=C"; // Add an environment variable
lscpu.setEnvironment(env);
lscpu.start("/usr/bin/lscpu");
if (lscpu.waitForFinished(3000)) {
const QMap<QString, QString> map = siGlobal->parseInfoContent(lscpu.readAll());
if (map.contains("Model name")) {
siGlobal->cpuModelName = map.value("Model name");
}
} else {
qWarning() << "lscpu:" << lscpu.errorString();
}
}
return siGlobal->cpuModelName;
#endif
return QString();

View File

@ -14,14 +14,16 @@ HEADERS += $$PWD/dtkcore_global.h \
dconfig.h \
dsysinfo.h \
dsecurestring.h \
ddesktopentry.h
ddesktopentry.h \
dlicenseinfo.h
SOURCES += \
dconfig.cpp \
dsysinfo.cpp \
dsecurestring.cpp \
ddesktopentry.cpp \
dtkcore_global.cpp
dtkcore_global.cpp \
dlicenseinfo.cpp
linux: {
HEADERS += \
@ -64,7 +66,8 @@ includes.files += \
$$PWD/DSecureString \
$$PWD/DDesktopEntry \
$$PWD/DConfigFile \
$$PWD/DConfig
$$PWD/DConfig \
$$PWD/DLicenseInfo
# ----------------------------------------------
# install config

View File

@ -8,5 +8,7 @@
<file>data/dconf-global.meta.json</file>
<file>data/dconf-global.override.json</file>
<file>data/dconf-example_other_app_configure.meta.json</file>
<file>data/LGPLv3.txt</file>
<file>data/example-license.json</file>
</qresource>
</RCC>

164
tests/data/LGPLv3.txt Normal file
View File

@ -0,0 +1,164 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
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.

View File

@ -0,0 +1,8 @@
[
{
"name": "dtk",
"version": "5.6.8",
"copyright": "Copyright 2023 The Uniontech Company Ltd. All rights reserved.",
"license": "LGPLv3"
}
]

View File

@ -51,13 +51,15 @@ HEADERS += $$PWD/ut_*.h \
$$PWD/../src/dsysinfo.h \
$$PWD/../src/dsecurestring.h \
$$PWD/../src/ddesktopentry.h \
$$PWD/../src/dconfig.h
$$PWD/../src/dconfig.h \
$$PWD/../src/dlicenseinfo.h
SOURCES += $$PWD/*.cpp \
$$PWD/../src/dsysinfo.cpp \
$$PWD/../src/dsecurestring.cpp \
$$PWD/../src/ddesktopentry.cpp \
$$PWD/../src/dconfig.cpp
$$PWD/../src/dconfig.cpp \
$$PWD/../src/dlicenseinfo.cpp
linux: {
HEADERS += \

View File

@ -36,6 +36,7 @@
#include "settings/dsettingsoption.h"
#include "dsysinfo.h"
#include "base/dsingleton.h"
#include "dlicenseinfo.h"
DCORE_USE_NAMESPACE
@ -481,6 +482,27 @@ TEST_F(ut_DUtil, testOsVersion)
QFile::remove("/tmp/etc/os-version");
}
TEST_F(ut_DUtil, testLicense)
{
DLicenseInfo licenseInfo;
QString jsonContent = u8R"([
{
"name": "dtk",
"version": "5.6.8",
"copyright": "Copyright 2023 THe Uniontech Company Ltd. All rights reserved.",
"license": "LGPLv3"
}
]
)";
licenseInfo.setLicenseSearchPath(":/data/");
ASSERT_TRUE(licenseInfo.loadContent(jsonContent.toLatin1()));
EXPECT_EQ(licenseInfo.componentInfos().count(), 1);
ASSERT_TRUE(licenseInfo.loadFile(":/data/example-license.json"));
EXPECT_EQ(licenseInfo.componentInfos().count(), 1);
ASSERT_FALSE(licenseInfo.licenseContent("LGPLv3").isEmpty());
}
TEST_F(ut_DUtil, testDDesktopEntry)
{
DDesktopEntry entry("/tmp/etc/os-version");