Compare commits

..

1 Commits
master ... fix

Author SHA1 Message Date
Ye ShanShan c695367b4f fix: correct bitwise operation in dconfig status tracking
1. Fixed incorrect bitwise AND operation in property status tracking
2. Changed `fetchAndAndOrdered(1 << index)` to `fetchAndAndOrdered(~(1
<< index))`
3. This ensures proper bit clearing when unsetting property flags
4. The change was made in both the generated header and the generator
tool
5. Without this fix, status tracking would incorrectly set bits instead
of clearing them

fix: 修正 dconfig 状态跟踪中的位操作

1. 修复了属性状态跟踪中错误的位与操作
2. 将 `fetchAndAndOrdered(1 << index)` 改为 `fetchAndAndOrdered(~(1
<< index))`
3. 确保在取消设置属性标志时能正确清除位
4. 修改同时应用于生成的头部文件和生成器工具
5. 若不修复此问题,状态跟踪会错误地设置位而非清除它们
2025-05-08 16:57:49 +08:00
38 changed files with 78 additions and 646 deletions

View File

@ -1,50 +0,0 @@
name: Auto Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.0.0)'
type: string
required: false
name:
description: 'The name of the person to release the version'
type: string
required: false
email:
description: 'The email of the person to release the version'
type: string
required: false
timezone:
description: 'The timezone in the debian changelog file'
required: false
type: string
default: 'Asia/Shanghai'
workflow_call:
inputs:
version:
description: 'Release version (e.g., 1.0.0)'
type: string
required: true
name:
description: 'The name of the person to release the version'
type: string
required: false
email:
description: 'The email of the person to release the version'
type: string
required: false
timezone:
description: 'The timezone in the debian changelog file'
required: false
type: string
default: 'Asia/Shanghai'
jobs:
auto_tag:
uses: linuxdeepin/.github/.github/workflows/auto-release.yml@master
secrets: inherit
with:
version: ${{ inputs.version }}
name: ${{ inputs.name }}
email: ${{ inputs.email }}
timezone: ${{ inputs.timezone }}

View File

@ -30,7 +30,7 @@ Copyright: None
License: CC0-1.0
# cmake
Files: *.cmake *CMakeLists.txt *.pc.in, cmake/*.in misc/*.in VERSION VERSION.in
Files: *.cmake *CMakeLists.txt *.pc.in, cmake/*.in misc/*.in
Copyright: None
License: CC0-1.0

View File

@ -9,5 +9,3 @@
# are always ignored
linglong.yaml
conanfile.py
VERSION
CHANGELOG.md

View File

@ -1,98 +1,3 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [5.7.25] - 2025-10-30
## [5.7.24] - 2025-10-16
### Added
- Support Qt 6.10
### Fixed
- Replace rmdir with rename for directory operations
- Prevent thread-safety issue in D-Bus config manager
- Sync with qt5platform-plugins
## [5.7.23] - 2025-09-25
### Added
- Add fallback type conversion in demarshall function
### Changed
- Feat: DPinyin::firstLetters support set ToneStyle
- 增加服务器教育版和国防版
### Fixed
- Fix trash validation for symlinks
- Fix heap-use-after-free issue
- Fix dconfig static variable release issue
## [5.7.22] - 2025-09-04
### Fixed
- Resolve non-reproducible DBUS code generation issue
## [5.7.21] - 2025-08-14
### Added
- Add deprecation ignore support for DTK
## [5.7.20] - 2025-07-31
### Changed
- Improve D-Bus resource management with RAII
### Fixed
- Use QCoreApplication for application name
- Resolve compilation warnings and Qt6 compatibility issues
## [5.7.19] - 2025-07-03
### Added
- Add security hardening flags to build configuration
### Changed
- Replace QtDBus with libdbus-1 in dsgapplication
## [5.7.18] - 2025-06-27
### Fixed
- Improve logging rules environment variable handling
- Copy cachePrefix in DConfigFile copy constructor
- Make version parameter optional in release workflow
## [5.7.17] - 2025-06-18
### Added
- Feat(ci): add auto release
- Add license for VERSION.in
### Changed
- Support VERSION file
- Update .syncexclude
### Fixed
- .deepin@main -> .deepin@master
<a name="5.7.14"></a>
## 5.7.14 (2025-04-12)

View File

@ -1,9 +1,6 @@
cmake_minimum_required (VERSION 3.13)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" DTK_FILE_VERSION)
string(STRIP "${DTK_FILE_VERSION}" DTK_FILE_VERSION)
set(DTK_VERSION "${DTK_FILE_VERSION}" CACHE STRING "DTK version")
set (DTK_VERSION "5.6.12" CACHE STRING "define project version")
project (DtkCore
VERSION ${DTK_VERSION}
DESCRIPTION "DTK Core module"

View File

@ -1 +0,0 @@
5.7.25

View File

@ -1 +0,0 @@
@version@

View File

@ -1,6 +1,6 @@
# Maintainer: justforlxz <justforlxz@gmail.com>
pkgname=dtkcore-git
pkgver=5.7.25
pkgver=5.6.16
pkgrel=1
sourcename=dtkcore
sourcetars=("$sourcename"_"$pkgver".tar.xz)
@ -19,6 +19,7 @@ sha512sums=('SKIP')
build() {
cd $sourcedir
version=$(echo $pkgver | awk -F'[+_~-]' '{print $1}')
cmake \
-GNinja \
-DMKSPECS_INSTALL_DIR=lib/qt/mkspecs/modules \
@ -30,7 +31,8 @@ build() {
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DD_DSG_APP_DATA_FALLBACK=/var/dsg/appdata \
-DBUILD_WITH_SYSTEMD=ON
-DBUILD_WITH_SYSTEMD=ON \
-DDTK_VERSION=$version
ninja
}

68
debian/changelog vendored
View File

@ -1,71 +1,3 @@
dtkcore (5.7.25) unstable; urgency=medium
* Release 5.7.25
-- yeshanshan <yeshanshan@uniontech.com> Thu, 30 Oct 2025 21:47:32 +0800
dtkcore (5.7.24) unstable; urgency=medium
* Release 5.7.24
-- yeshanshan <yeshanshan@uniontech.com> Thu, 16 Oct 2025 19:45:57 +0800
dtkcore (5.7.23) unstable; urgency=medium
* Release 5.7.23
-- yeshanshan <packages@deepin.org> Thu, 25 Sep 2025 16:49:58 +0800
dtkcore (5.7.22) unstable; urgency=medium
* Release 5.7.22
-- yeshanshan <yeshanshan@uniontech.com> Thu, 04 Sep 2025 19:27:28 +0800
dtkcore (5.7.21) unstable; urgency=medium
* Release 5.7.21
-- yeshanshan <packages@deepin.org> Thu, 14 Aug 2025 19:47:41 +0800
dtkcore (5.7.20) unstable; urgency=medium
* Release 5.7.20
-- yeshanshan <yeshanshan@uniontech.com> Thu, 31 Jul 2025 20:00:27 +0800
dtkcore (5.7.19) unstable; urgency=medium
* Release 5.7.19
-- yeshanshan <yeshanshan@uniontech.com> Thu, 03 Jul 2025 21:11:07 +0800
dtkcore (5.7.18) unstable; urgency=medium
* Release 5.7.18
-- yeshanshan <yeshanshan@uniontech.com> Fri, 27 Jun 2025 17:07:16 +0800
dtkcore (5.7.17) unstable; urgency=medium
* Release 5.7.17
-- asterwyx <wangyixue@uniontech.com> Wed, 18 Jun 2025 18:01:08 +0800
dtkcore (5.7.16) unstable; urgency=medium
* fix: add missing UosMilitary edition type cases
-- YeShanShan <yeshanshan@uniontech.com> Mon, 19 May 2025 17:21:50 +0800
dtkcore (5.7.15) unstable; urgency=medium
* fix: correct bitwise operation in dconfig status tracking
* chore: update REUSE license file patterns
* fix: add QPointer check for parent object safety
-- YeShanShan <yeshanshan@uniontech.com> Thu, 08 May 2025 17:53:02 +0800
dtkcore (5.7.14) unstable; urgency=medium
* fix: resolve compilation failure on Qt 6.9

2
debian/control vendored
View File

@ -5,7 +5,7 @@ Maintainer: Deepin Packages Builder <packages@deepin.com>
Build-Depends: debhelper-compat ( =12), pkg-config,
qttools5-dev-tools, qttools5-dev, qtbase5-private-dev, doxygen,
libgsettings-qt-dev, libgtest-dev, libdtkcommon-dev, cmake,
libuchardet-dev, libicu-dev, libdtklog-dev, libdbus-1-dev
libuchardet-dev, libicu-dev, libdtklog-dev
Standards-Version: 3.9.8
Package: libdtkcore5

9
debian/rules vendored
View File

@ -4,15 +4,10 @@ include /usr/share/dpkg/default.mk
export QT_SELECT = qt5
export DEB_CXXFLAGS_MAINT_APPEND = -Ofast
# 安全编译参数
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall
export DEB_CXXFLAGS_MAINT_APPEND = -Wall
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-E
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
VERSION = $(DEB_VERSION_UPSTREAM)
PACK_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}')
# Calculate build version:
# 5.6.8 -> 0; 5.6.8.7 -> 7; 5.6.8+u001 -> 1; 5.6.8.7+u001 -> 7; 5.6.8.0+u001 -> 0
@ -27,7 +22,7 @@ endif
dh $@
override_dh_auto_configure:
dh_auto_configure -- -DBUILD_WITH_SYSTEMD=ON -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=ON -DBUILD_VERSION=$(BUILD_VER) -DD_DSG_APP_DATA_FALLBACK=/var/dsg/appdata
dh_auto_configure -- -DBUILD_WITH_SYSTEMD=ON -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=ON -DBUILD_VERSION=$(BUILD_VER) -DDTK_VERSION=$(PACK_VER) -DD_DSG_APP_DATA_FALLBACK=/var/dsg/appdata
#override_dh_auto_test:
# echo "skip auto test"

View File

@ -79,7 +79,6 @@ public:
UosMilitaryS, // for Server
UosDeviceEdition,
UosEducation,
UosDefense,
UosEditionCount // must at last
};

View File

@ -35,11 +35,9 @@
#if defined(DTK_STATIC_LIB)
# define LIBDTKCORESHARED_EXPORT
# define D_IGNORE_DEPRECATIONS
#else
#if defined(LIBDTKCORE_LIBRARY)
# define LIBDTKCORESHARED_EXPORT Q_DECL_EXPORT
# define D_IGNORE_DEPRECATIONS
#else
# define LIBDTKCORESHARED_EXPORT Q_DECL_IMPORT
#endif
@ -49,10 +47,6 @@
#define D_DECL_DEPRECATED_X(text) Q_DECL_HIDDEN
#define D_DECL_DEPRECATED Q_DECL_HIDDEN
#else
#if defined(D_IGNORE_DEPRECATIONS)
#define D_DECL_DEPRECATED
#define D_DECL_DEPRECATED_X(text)
#else
#ifdef __GNUC__
#if __GNUC__ < 13
#define D_DECL_DEPRECATED __attribute__((__deprecated__))
@ -66,7 +60,6 @@
#define D_DECL_DEPRECATED_X Q_DECL_DEPRECATED_X
#endif
#endif
#endif
#define DTK_VERSION_CHECK(major, minor, patch, build) ((major<<24)|(minor<<16)|(patch<<8)|build)
#define DTK_VERSION DTK_VERSION_CHECK(DTK_VERSION_MAJOR, DTK_VERSION_MINOR, DTK_VERSION_PATCH, DTK_VERSION_BUILD)

View File

@ -26,7 +26,6 @@ QStringList LIBDTKCORESHARED_EXPORT pinyin(const QString& words, ToneStyle ts =
// support polyphonic
QStringList LIBDTKCORESHARED_EXPORT firstLetters(const QString& words);
QStringList LIBDTKCORESHARED_EXPORT firstLetters(const QString& words, ToneStyle ts);
DCORE_END_NAMESPACE

View File

@ -1,5 +1,5 @@
Name: dtkcore
Version: 5.7.25
Version: 5.5.18
Release: 1%{?dist}
Summary: Deepin tool kit core modules
License: LGPLv3+

View File

@ -8,20 +8,13 @@ set(CMAKE_AUTORCC ON)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
find_package(Dtk${DTK_VERSION_MAJOR}Log REQUIRED)
find_package(DBus1 REQUIRED)
if(LINUX)
find_package(PkgConfig REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS DBus)
if(${QT_VERSION_MAJOR} EQUAL 5)
if("${QT_VERSION_MAJOR}" STREQUAL "5")
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt) #Dtk6 removed.
elseif(${QT_VERSION_MAJOR} EQUAL 6)
if(${Qt6Core_VERSION} VERSION_GREATER_EQUAL 6.10.0)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS CorePrivate)
endif()
else()
message(FATAL_ERROR "Unsupported Qt version: ${QT_VERSION_MAJOR}")
endif()
endif()
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Xml)
find_package(DtkBuildHelper REQUIRED)
@ -31,12 +24,6 @@ find_package(ICU REQUIRED COMPONENTS uc)
pkg_check_modules(uchardet REQUIRED uchardet)
# end text encoding
# QObjectAutoMOC
set_property(SOURCE ../include/base/dsingleton.h PROPERTY SKIP_AUTOMOC ON)
if("${DTK_VERSION_MAJOR}" STREQUAL "6")
set_property(SOURCE ../include/util/dthreadutils.h PROPERTY SKIP_AUTOMOC ON)
endif()
# start base
include(base/base.cmake)
# end base
@ -127,9 +114,6 @@ target_compile_definitions(${LIB_NAME} PRIVATE
LIBDTKCORE_LIBRARY
)
target_link_libraries(${LIB_NAME} PRIVATE
dbus-1
)
target_include_directories(${LIB_NAME} PRIVATE
${uchardet_INCLUDE_DIRS}
)

View File

@ -621,20 +621,10 @@ bool DDciFileEngine::supportsExtension(QAbstractFileEngine::Extension extension)
return extension == AtEndExtension;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
DDciFileEngine::TriStateResult DDciFileEngine::cloneTo(QAbstractFileEngine *target)
#else
bool DDciFileEngine::cloneTo(QAbstractFileEngine *target)
#endif
{
const QByteArray &data = file->dataRef(subfilePath);
auto ret = target->write(data.constData(), data.size()) == data.size();
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
return ret ? DDciFileEngine::TriStateResult::Success : DDciFileEngine::TriStateResult::Failed;
#else
return ret;
#endif
return target->write(data.constData(), data.size()) == data.size();
}
bool DDciFileEngine::forceSave(bool writeFile) const

View File

@ -129,11 +129,7 @@ public:
ExtensionReturn *output = 0) override;
bool supportsExtension(Extension extension) const override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
TriStateResult cloneTo(QAbstractFileEngine *target) override;
#else
bool cloneTo(QAbstractFileEngine *target) override;
#endif
private:
bool forceSave(bool writeFile = false) const;

View File

@ -173,13 +173,13 @@ public:
if (owner->appId == NoAppId)
return true;
std::unique_ptr<DConfigFile> file(new DConfigFile(NoAppId, owner->name, owner->subpath));
QScopedPointer<DConfigFile> file(new DConfigFile(NoAppId, owner->name, owner->subpath));
const bool canFallbackToGeneric = !file->meta()->metaPath(prefix).isEmpty();
if (canFallbackToGeneric) {
std::unique_ptr<DConfigCache> cache(file->createUserCache(getuid()));
QScopedPointer<DConfigCache> cache(file->createUserCache(getuid()));
if (file->load(prefix) && cache->load(prefix)) {
genericConfigFile.reset(file.release());
genericConfigCache.reset(cache.release());
genericConfigFile.reset(file.take());
genericConfigCache.reset(cache.take());
}
}
return true;
@ -326,16 +326,15 @@ public:
DSGConfig dsg_config(DSG_CONFIG, "/", QDBusConnection::systemBus());
QDBusPendingReply<QDBusObjectPath> dbus_reply = dsg_config.acquireManager(owner->appId, owner->name, owner->subpath);
const QDBusObjectPath dbus_path = dbus_reply.value();
const auto path = dbus_path.path(); // 显式拷贝避免其它线程共用systemBus连接而修改dbus数据
if (dbus_reply.isError() || path.isEmpty()) {
if (dbus_reply.isError() || dbus_path.path().isEmpty()) {
qCWarning(cfLog, "Can't acquire config manager. error:\"%s\"", qPrintable(dbus_reply.error().message()));
return false;
} else {
qCDebug(cfLog, "dbus path=\"%s\"", qPrintable(path));
config.reset(new DSGConfigManager(DSG_CONFIG_MANAGER, 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()) {
qCWarning(cfLog, "Can't acquire config path=\"%s\"", qPrintable(path));
qCWarning(cfLog(), "Can't acquire config path=\"%s\"", qPrintable(dbus_path.path()));
config.reset();
return false;
} else {
@ -371,7 +370,7 @@ public:
complexType >> list;
QVariantList res;
res.reserve(list.size());
for (const auto &item : std::as_const(list)) {
for (const auto &item : qAsConst(list)) {
res << decodeQDBusArgument(item);
}
return res;

View File

@ -1407,7 +1407,6 @@ DConfigFile::DConfigFile(const DConfigFile &other)
D_D(DConfigFile);
auto cache = new DConfigCacheImpl(d->configKey, InvalidUID, true);
cache->values = other.d_func()->globalCache->values;
cache->cachePrefix = other.d_func()->globalCache->cachePrefix;
d->globalCache = cache;
}

View File

@ -12,10 +12,13 @@
#include <QByteArray>
#include <QCoreApplication>
#include <QDebug>
#include <QDBusUnixFileDescriptor>
#include <QDBusReply>
#include <QRegularExpression>
#include <QLoggingCategory>
#include <QDBusConnectionInterface>
#include <dbus/dbus.h>
#include <DDBusInterface>
#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(dsgApp, "dtk.core.dsg")
@ -25,198 +28,6 @@ Q_LOGGING_CATEGORY(dsgApp, "dtk.core.dsg", QtInfoMsg)
DCORE_BEGIN_NAMESPACE
// D-Bus resource deleters for RAII management
static void dbusErrorDeleter(DBusError *error) {
if (error) { dbus_error_free(error); delete error; }
}
static void dbusConnectionDeleter(DBusConnection *conn) {
if (conn) dbus_connection_unref(conn);
}
static void dbusMessageDeleter(DBusMessage *msg) {
if (msg) dbus_message_unref(msg);
}
// D-Bus utility functions using libdbus-1
static bool checkDBusServiceActivatable(const QByteArray &service)
{
auto error = std::unique_ptr<DBusError, void(*)(DBusError*)>(new DBusError, dbusErrorDeleter);
dbus_error_init(error.get());
DBusConnection *connection = dbus_bus_get(DBUS_BUS_SESSION, error.get());
if (dbus_error_is_set(error.get())) {
qCWarning(dsgApp) << "Failed to connect to session bus:" << error->message;
return false;
}
if (!connection) {
qCWarning(dsgApp) << "Failed to get session bus connection";
return false;
}
auto connGuard = std::unique_ptr<DBusConnection, void(*)(DBusConnection*)>(connection, dbusConnectionDeleter);
// Create method call to check if service is registered
DBusMessage *msg = dbus_message_new_method_call(
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"NameHasOwner"
);
if (!msg) {
qCWarning(dsgApp) << "Failed to create D-Bus message";
return false;
}
auto msgGuard = std::unique_ptr<DBusMessage, void(*)(DBusMessage*)>(msg, dbusMessageDeleter);
{
const char *serviceName = service.constData();
if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &serviceName, DBUS_TYPE_INVALID)) {
qCWarning(dsgApp) << "Failed to append arguments to D-Bus message";
return false;
}
}
// Send message and get reply
DBusMessage *reply = dbus_connection_send_with_reply_and_block(connection, msg, 1000, error.get());
msgGuard.reset(); // msg is consumed by the call
if (dbus_error_is_set(error.get())) {
qCWarning(dsgApp) << "D-Bus call failed:" << error->message;
return false;
}
if (!reply) {
qCWarning(dsgApp) << "No reply received from D-Bus";
return false;
}
auto replyGuard = std::unique_ptr<DBusMessage, void(*)(DBusMessage*)>(reply, dbusMessageDeleter);
dbus_bool_t hasOwner = FALSE;
if (!dbus_message_get_args(reply, error.get(), DBUS_TYPE_BOOLEAN, &hasOwner, DBUS_TYPE_INVALID)) {
qCWarning(dsgApp) << "Failed to parse D-Bus reply:" << error->message;
return false;
}
if (!hasOwner) {
return false;
}
// Check if service is activatable
DBusMessage *msg2 = dbus_message_new_method_call(
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"ListActivatableNames"
);
if (!msg2) {
qCWarning(dsgApp) << "Failed to create ListActivatableNames message";
return false;
}
auto msg2Guard = std::unique_ptr<DBusMessage, void(*)(DBusMessage*)>(msg2, dbusMessageDeleter);
DBusMessage *reply2 = dbus_connection_send_with_reply_and_block(connection, msg2, 1000, error.get());
if (dbus_error_is_set(error.get())) {
qCWarning(dsgApp) << "ListActivatableNames call failed:" << error->message;
return false;
}
if (!reply2) {
return false;
}
auto reply2Guard = std::unique_ptr<DBusMessage, void(*)(DBusMessage*)>(reply2, dbusMessageDeleter);
DBusMessageIter iter, array_iter;
dbus_message_iter_init(reply2, &iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
return false;
}
dbus_message_iter_recurse(&iter, &array_iter);
bool found = false;
while (dbus_message_iter_get_arg_type(&array_iter) == DBUS_TYPE_STRING) {
const char *name;
dbus_message_iter_get_basic(&array_iter, &name);
if (service == name) {
found = true;
break;
}
dbus_message_iter_next(&array_iter);
}
return found;
}
static QByteArray callDBusIdentifyMethod(const QByteArray &serviceName, const QByteArray &path,
const QByteArray &interface, int pidfd)
{
auto error = std::unique_ptr<DBusError, void(*)(DBusError*)>(new DBusError, dbusErrorDeleter);
dbus_error_init(error.get());
DBusConnection *connection = dbus_bus_get(DBUS_BUS_SESSION, error.get());
if (dbus_error_is_set(error.get())) {
qCWarning(dsgApp) << "Failed to connect to session bus:" << error->message;
return QByteArray();
}
if (!connection) {
qCWarning(dsgApp) << "Failed to get session bus connection";
return QByteArray();
}
auto connGuard = std::unique_ptr<DBusConnection, void(*)(DBusConnection*)>(connection, dbusConnectionDeleter);
// Create method call - string data is now managed by caller
DBusMessage *msg = dbus_message_new_method_call(
serviceName.constData(),
path.constData(),
interface.constData(),
"Identify"
);
if (!msg) {
qCWarning(dsgApp) << "Failed to create D-Bus message";
return QByteArray();
}
auto msgGuard = std::unique_ptr<DBusMessage, void(*)(DBusMessage*)>(msg, dbusMessageDeleter);
// Append Unix file descriptor
if (!dbus_message_append_args(msg, DBUS_TYPE_UNIX_FD, &pidfd, DBUS_TYPE_INVALID)) {
qCWarning(dsgApp) << "Failed to append Unix FD to D-Bus message";
return QByteArray();
}
// Send message and get reply
DBusMessage *reply = dbus_connection_send_with_reply_and_block(connection, msg, 5000, error.get());
msgGuard.reset(); // msg is consumed by the call
if (dbus_error_is_set(error.get())) {
qCWarning(dsgApp) << "Identify from AM failed:" << error->message;
return QByteArray();
}
if (!reply) {
qCWarning(dsgApp) << "No reply received from Identify method";
return QByteArray();
}
auto replyGuard = std::unique_ptr<DBusMessage, void(*)(DBusMessage*)>(reply, dbusMessageDeleter);
const char *result;
if (!dbus_message_get_args(reply, error.get(), DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID)) {
qCWarning(dsgApp) << "Failed to parse Identify reply:" << error->message;
return QByteArray();
}
QByteArray appId = QByteArray(result);
qCInfo(dsgApp) << "AppId is fetched from AM, and value is " << appId;
return appId;
}
static inline QByteArray getSelfAppId() {
// The env is set by the application starter(eg, org.desktopspec.ApplicationManager service)
QByteArray selfId = qgetenv("DSG_APP_ID");
@ -225,9 +36,17 @@ static inline QByteArray getSelfAppId() {
return DSGApplication::getId(QCoreApplication::applicationPid());
}
static bool isServiceActivatable(const QByteArray &service)
static bool isServiceActivatable(const QString &service)
{
return checkDBusServiceActivatable(service);
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(service))
return false;
const QDBusReply<QStringList> activatableNames = QDBusConnection::sessionBus().interface()->
callWithArgumentList(QDBus::AutoDetect,
QLatin1String("ListActivatableNames"),
QList<QVariant>());
return activatableNames.value().contains(service);
}
// Format appId to valid.
@ -272,18 +91,6 @@ QByteArray DSGApplication::id()
return result;
}
/**
* Get application ID for a given process ID
*
* This function has been updated to use libdbus-1 instead of Qt D-Bus to fix
* the bug(pms:BUG-278055) where calling this function before QCoreApplication
* initialization would fail. This is particularly important when the service
* is being started by D-Bus activation and DSGApplication::id() is called
* during early startup.
*
* @param pid Process ID to get the application ID for
* @return Application ID as QByteArray, or empty array on failure
*/
QByteArray DSGApplication::getId(qint64 pid)
{
if (!isServiceActivatable("org.desktopspec.ApplicationManager1")) {
@ -297,13 +104,21 @@ QByteArray DSGApplication::getId(qint64 pid)
return QByteArray();
}
QByteArray appId = callDBusIdentifyMethod("org.desktopspec.ApplicationManager1",
"/org/desktopspec/ApplicationManager1",
"org.desktopspec.ApplicationManager1",
pidfd);
DDBusInterface infc("org.desktopspec.ApplicationManager1",
"/org/desktopspec/ApplicationManager1",
"org.desktopspec.ApplicationManager1");
QDBusReply<QString> reply = infc.call("Identify", QVariant::fromValue(QDBusUnixFileDescriptor(pidfd)));
// see QDBusUnixFileDescriptor: The original file descriptor is not touched and must be closed by the user.
close(pidfd);
if (!reply.isValid()) {
qCWarning(dsgApp) << "Identify from AM failed." << reply.error().message();
return QByteArray();
}
const QByteArray appId = reply.value().toLatin1();
qCInfo(dsgApp) << "AppId is fetched from AM, and value is " << appId;
return appId;
}

View File

@ -93,14 +93,7 @@ public:
struct OSBuild {
OSBuild():A(0), B(0), C(0), D(0), xyz(100){
}
/* ABCDE.xyz模式
A B C D E x yz
线 线
1 1 1 1 1 1 2
------------------------- 09A~Z --------------------------- 1 00~99AA~ZZ
*/
uint A, B, C, D, E, xyz;
uint A, B, C, D, E, xyz; // ABCDE.xyz
};
MinVersion minVersion;
@ -146,12 +139,9 @@ bool DSysInfoPrivate::splitA_BC_DMode()
minVersion.D = minv % 10;
} else if (minorVersion.length() > 0) {
const QString D = minorVersion.right(1);
const QChar ch = D.at(0);
if (ch.isDigit()) {
minVersion.D = static_cast<uint>(ch.unicode() - '0');
} else if (ch >= 'A' && ch <= 'Z') {
// 0-9...A-Z -> 10..35
minVersion.D = 10 + static_cast<uint>(ch.unicode() - 'A');
if (D.contains(QRegularExpression("[0-9A-Z]"))) {
// 0-9...A-Z
minVersion.D = 10 + static_cast<uint>(D.data()->toLatin1() - 'A');
} else {
qWarning() << "invalid minorVersion";
minVersion.D = 0;
@ -276,24 +266,19 @@ bool DSysInfoPrivate::ensureOsVersion()
D_ASSET_EXIT(left.size() == 5, "OsBuild version(ls) invalid!");
int idx = 0;
auto parseDigitOrAZ = [&](const QString &s, bool *outOk) -> uint {
if (s.isEmpty()) { if (outOk) *outOk = false; return 0u; }
const QChar ch = s.at(0);
if (ch.isDigit()) { if (outOk) *outOk = true; return static_cast<uint>(ch.unicode() - '0'); }
if (ch >= 'A' && ch <= 'Z') { if (outOk) *outOk = true; return static_cast<uint>(ch.toLatin1()); }
if (outOk) *outOk = false;
return 0u;
};
osBuild.A = parseDigitOrAZ(left.value(idx++, "0"), &ok);
osBuild.A = left.value(idx++, "0").toUInt(&ok);
D_ASSET_EXIT(ok, "OsBuild version(A) invalid!");
osBuild.B = parseDigitOrAZ(left.value(idx++, "0"), &ok);
osBuild.B = left.value(idx++, "0").toUInt(&ok);
D_ASSET_EXIT(ok, "OsBuild version(B) invalid!");
osBuild.C = parseDigitOrAZ(left.value(idx++, "0"), &ok);
D_ASSET_EXIT(ok, "OsBuild version(C) invalid!");
osBuild.D = parseDigitOrAZ(left.value(idx++, "0"), &ok);
osBuild.C = left.value(idx++, "0").toUInt(&ok);
if (!ok) {
auto c = left.value(idx-1, "0").toLatin1();
D_ASSET_EXIT(c.size()>0, "OsBuild version(C) invalid!");
osBuild.C = uint(c.at(0));
}
osBuild.D = left.value(idx++, "0").toUInt(&ok);
D_ASSET_EXIT(ok, "OsBuild version(D) invalid!");
osBuild.E = parseDigitOrAZ(left.value(idx++, "0"), &ok);
osBuild.E = left.value(idx++, "0").toUInt(&ok);
D_ASSET_EXIT(ok, "OsBuild version(E) invalid!");
// xyz
@ -679,7 +664,6 @@ DSysInfo::UosEdition DSysInfo::uosEditionType()
case 3:
return UosCommunity;
case 4:
case 9:
return UosMilitary;
case 5:
return UosDeviceEdition;
@ -700,10 +684,6 @@ DSysInfo::UosEdition DSysInfo::uosEditionType()
return UosMilitaryS;
case 5:
return UosDeviceEdition;
case 9:
return UosEducation; // 服务器 教育版(UT-3-PP-PR-001_操作系统标识与产品版本号规范_20250905)
case 'A':
return UosDefense; // 服务器 国防版
default:
break;
}

View File

@ -195,21 +195,12 @@ QAbstractFileEngine::FileFlags DCapFSFileEngine::fileFlags(QAbstractFileEngine::
return ret;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
DCapFSFileEngine::TriStateResult DCapFSFileEngine::cloneTo(QAbstractFileEngine *target)
#else
bool DCapFSFileEngine::cloneTo(QAbstractFileEngine *target)
#endif
{
D_DC(DCapFSFileEngine);
const QString targetPath = target->fileName(DCapFSFileEngine::AbsolutePathName);
if (!d->canReadWrite(targetPath)) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
return DCapFSFileEngine::TriStateResult::Failed;
#else
if (!d->canReadWrite(targetPath))
return false;
#endif
}
return QFSFileEngine::cloneTo(target);
}

View File

@ -123,7 +123,7 @@ static bool renameFile(const QFileInfo &fileInfo, const QString &target, QString
}
}
if (!QDir().rename(fileInfo.filePath(), target)) {
if (!QDir().rmdir(fileInfo.filePath())) {
if (errorString) {
*errorString = QString("Cannot remove the %1 dir").arg(fileInfo.filePath());
}
@ -183,13 +183,11 @@ bool DTrashManager::moveToTrash(const QString &filePath, bool followSymlink)
}
QDir trashDir(TRASH_FILES_PATH);
if (followSymlink && fileInfo.isSymLink()) {
QStorageInfo storageInfo(fileInfo.filePath());
QStorageInfo trashStorageInfo(trashDir);
QStorageInfo storageInfo(fileInfo.filePath());
QStorageInfo trashStorageInfo(trashDir);
if (storageInfo != trashStorageInfo) {
return false;
}
if (storageInfo != trashStorageInfo) {
return false;
}
if (!trashDir.mkpath(TRASH_INFO_PATH)) {

View File

@ -48,13 +48,7 @@ public:
#endif
bool rmdir(const QString &dirName, bool recurseParentDirectories) const override;
FileFlags fileFlags(FileFlags type) const override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
TriStateResult cloneTo(QAbstractFileEngine *target) override;
#else
bool cloneTo(QAbstractFileEngine *target) override;
#endif
bool setSize(qint64 size) override;
QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 1)

View File

@ -72,7 +72,7 @@ dconfig_org_deepin_dtk_preference *DLogManagerPrivate::createDConfig(const QStri
void DLogManagerPrivate::initLoggingRules()
{
if (qEnvironmentVariableIsSet("DTK_DISABLED_LOGGING_RULES") || qEnvironmentVariableIsSet("QT_LOGGING_RULES"))
if (qEnvironmentVariableIsSet("DTK_DISABLED_LOGGING_RULES"))
return;
// 1. 未指定 fallbackId 时,以 dsgAppId 为准
@ -213,7 +213,7 @@ QString DLogManager::getlogFilePath()
if (!QDir(cachePath).exists()) {
QDir(cachePath).mkpath(cachePath);
}
instance()->d_func()->m_logPath = instance()->joinPath(cachePath, QString("%1.log").arg(QCoreApplication::applicationName()));
instance()->d_func()->m_logPath = instance()->joinPath(cachePath, QString("%1.log").arg(qApp->applicationName()));
}
return QDir::toNativeSeparators(DLogManager::instance()->d_func()->m_logPath);

View File

@ -1,7 +1,7 @@
/**
* This file is generated by dconfig2cpp.
* Command line arguments: ./build/tools/dconfig2cpp/dconfig2cpp /usr/share/dsg/configs/org.deepin.dtk.preference.json
* Generation time: 2025-08-20T15:40:55
* Command line arguments: ./build5/tools/dconfig2cpp/dconfig2cpp /usr/share/dsg/configs/org.deepin.dtk.preference.json
* Generation time: 2025-05-08T16:56:17
* JSON file version: 1.0
*
* WARNING: DO NOT MODIFY THIS FILE MANUALLY.
@ -113,7 +113,6 @@ public:
~dconfig_org_deepin_dtk_preference() {
if (m_config.loadRelaxed()) {
m_config.loadRelaxed()->deleteLater();
m_config.storeRelaxed(nullptr);
}
}
@ -566,8 +565,6 @@ private:
updateValue(QStringLiteral("underlineShortcut"), QVariant::fromValue(p_underlineShortcut));
}
if (!m_config.loadRelaxed())
return;
connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
updateValue(key);
}, Qt::DirectConnection);
@ -576,8 +573,6 @@ private:
Q_EMIT configInitializeSucceed(config);
}
void updateValue(const QString &key, const QVariant &fallback = QVariant()) {
if (!m_config.loadRelaxed())
return;
Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread());
const QVariant &value = m_config.loadRelaxed()->value(key, fallback);
if (key == QStringLiteral("autoDisplayFeature")) {
@ -743,8 +738,8 @@ private:
bool p_enableDtkAnimations { false };
bool p_featureUpdated { false };
bool p_keyboardsearchDisabled { false };
// Default value: "*.debug=false"
QString p_rules { QStringLiteral(u"\u002a\u002e\u0064\u0065\u0062\u0075\u0067\u003d\u0066\u0061\u006c\u0073\u0065") };
// Default value: ""
QString p_rules { QLatin1String("") };
qlonglong p_scrollBarPolicy { 0 };
qlonglong p_sizeMode { 0 };
qlonglong p_themeType { 0 };

View File

@ -43,13 +43,6 @@ static QVariant demarshall(const QMetaProperty &metaProperty, const QVariant &va
if (value.userType() == qMetaTypeId<QDBusArgument>()) {
QDBusArgument dbusArg = value.value<QDBusArgument>();
QDBusMetaType::demarshall(dbusArg, PropType(metaProperty), result.data());
} else {
auto copy = value;
if (copy.convert(PropType(metaProperty))) {
result = copy;
} else {
qDebug() << "Failed to convert value type" << value.typeName() << "to property type" << metaProperty.typeName();
}
}
return result;

View File

@ -211,23 +211,11 @@ QStringList pinyin(const QString &words, ToneStyle ts, bool *ok)
\return pinyin first letters list of the words
*/
QStringList firstLetters(const QString &words)
{
return firstLetters(words, TS_Tone);
}
/*!
\fn QStringList Dtk::Core::firstLetters(const QString &words)
\brief Convert Chinese characters to Pinyin firstLetters list
\brief with controllable tone style.
\return pinyin first letters list of the words
*/
QStringList firstLetters(const QString &words, ToneStyle ts)
{
QList<QStringList> result;
bool ok = false;
for (const QChar &w : words) {
QStringList pys = pinyin(w, ts, &ok);
QStringList pys = pinyin(w, TS_Tone, &ok);
if (!ok) {
result << QStringList(w);
continue;

View File

@ -13,7 +13,6 @@
#include <QUrl>
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
#include <QStringConverter>
#include <QTimeZone>
#endif
DCORE_BEGIN_NAMESPACE
@ -68,11 +67,7 @@ bool DRecentManager::addItem(const QString &uri, DRecentData &data)
QFile file(RECENT_PATH);
file.open(QIODevice::ReadWrite | QIODevice::Text);
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
QString dateTime = QDateTime::currentDateTime().toTimeZone(QTimeZone::UTC).toString(Qt::ISODate);
#else
QString dateTime = QDateTime::currentDateTime().toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate);
#endif
QDomDocument doc;
if (!doc.setContent(&file)) {

View File

@ -229,21 +229,7 @@ bool DVtableHook::hasVtable(const void *obj)
{
quintptr **_obj = (quintptr**)(obj);
// 验证 vtable 是否匹配
quintptr *ghost_vtable = objToGhostVfptr.value(obj);
if (!ghost_vtable) {
return false;
}
// 检查当前对象的 vtable 指针是否指向我们记录的 ghost vtable
if (*_obj != adjustToEntry(ghost_vtable)) {
// vtable 不匹配,说明地址被重用了
qCDebug(vtableHook) << "hasVtable: vtable mismatch! Address reused by different object."
<< "obj:" << QString("0x%1").arg((quintptr)obj, 0, 16);
return false;
}
return true;
return objToGhostVfptr.contains(_obj);
}
void DVtableHook::resetVtable(const void *obj)

View File

@ -20,12 +20,6 @@ if(LINUX)
find_package(PkgConfig REQUIRED)
if("${QT_VERSION_MAJOR}" STREQUAL "5")
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt)
elseif(${QT_VERSION_MAJOR} EQUAL 6)
if(${Qt6Core_VERSION} VERSION_GREATER_EQUAL 6.10.0)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS CorePrivate)
endif()
else()
message(FATAL_ERROR "Unsupported Qt version: ${QT_VERSION_MAJOR}")
endif()
endif()
@ -34,8 +28,6 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Concurrent)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test)
find_package(GTest REQUIRED)
include(GoogleTest)
# for test.so
set(TEST_SO_NAME vtabletest${DTK_VERSION_MAJOR})
add_subdirectory(./testso)
@ -118,4 +110,4 @@ target_include_directories( ${BIN_NAME} PUBLIC
./testso/
)
gtest_discover_tests(${BIN_NAME})
add_test(NAME ${BIN_NAME} COMMAND ${BIN_NAME})

View File

@ -68,11 +68,5 @@ TEST_F(ut_DPinyin, firstLetters)
bool isPermutation = std::is_permutation(ls.begin() , ls.end(), letters.begin());
ASSERT_TRUE(isPermutation);
QString words2("安全中心");
QStringList && result = firstLetters(words2, TS_NoneTone);
ASSERT_TRUE(result.count() == 1);
ASSERT_TRUE(result.constFirst() == "aqzx");
ASSERT_TRUE(result.constFirst() != firstLetters(words2).constFirst());
}

View File

@ -3,13 +3,6 @@ set(BIN_NAME ${TARGET_NAME}${DTK_VERSION_MAJOR})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
if(${QT_VERSION_MAJOR} EQUAL 6)
if(${Qt6Core_VERSION} VERSION_GREATER_EQUAL 6.10.0)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS CorePrivate)
endif()
endif()
add_definitions(-DDTK_NO_PROJECT)
# start dci
include(../../src/dci/dci.cmake)

View File

@ -354,7 +354,6 @@ int main(int argc, char *argv[]) {
headerStream << " ~" << className << R"(() {
if (m_config.loadRelaxed()) {
m_config.loadRelaxed()->deleteLater();
m_config.storeRelaxed(nullptr);
}
}
@ -459,8 +458,6 @@ int main(int argc, char *argv[]) {
headerStream << " }\n";
}
headerStream << R"(
if (!m_config.loadRelaxed())
return;
connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
updateValue(key);
}, Qt::DirectConnection);
@ -469,8 +466,6 @@ int main(int argc, char *argv[]) {
Q_EMIT configInitializeSucceed(config);
}
void updateValue(const QString &key, const QVariant &fallback = QVariant()) {
if (!m_config.loadRelaxed())
return;
Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread());
const QVariant &value = m_config.loadRelaxed()->value(key, fallback);
)";

View File

@ -4,12 +4,6 @@ set(BIN_NAME ${TARGET_NAME}${DTK_VERSION_MAJOR})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
if(${QT_VERSION_MAJOR} EQUAL 6)
if(${Qt6Core_VERSION} VERSION_GREATER_EQUAL 6.10.0)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS CorePrivate)
endif()
endif()
add_definitions(-DDTK_NO_PROJECT)
# start dci
set(dci_SRCS

View File

@ -5,12 +5,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS DBus)
if(${QT_VERSION_MAJOR} EQUAL 6)
if (${Qt6DBus_VERSION} VERSION_GREATER_EQUAL 6.10.0)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS DBusPrivate)
endif()
endif()
add_executable(${BIN_NAME}
qdbusxml2cpp.cpp
)

View File

@ -598,7 +598,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf
<< endl;
}
QStringList annotations;
QSet<QString> annotations;
for (const QDBusIntrospection::Interface *interface : interfaces) {
for (const auto &method : interface->methods) {
for (int i(0); i != method.outputArgs.size(); ++i) {
@ -638,7 +638,6 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf
}
}
annotations.removeDuplicates();
if (!skipIncludeAnnotations) {
for (const QString &annotation : annotations) {
if (annotation.indexOf('<') == -1) {