Skip to content

feat: add internal configuration catalog service - #160

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master
Sep 17, 2026
Merged

18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743

@18202781743 18202781743 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add an internal D-Bus configuration catalog to dde-dconfig-daemon
  • Make dde-dconfig and dde-dconfig-editor query the daemon with local fallback
  • Cache configurations and invalidate the cache through configurationsChanged
  • Fix empty app and empty subpath display items

Tests

  • cmake --build build -j6
  • dconfigtest --gtest_filter=ut_DConfigServer.internalCatalog
  • Isolated D-Bus end-to-end checks for apps/resources/subpaths
  • Daemon-unavailable fallback check
  • git diff --check

Summary by Sourcery

Expose a cached internal configuration catalog and update the command-line and graphical clients to use it while improving configuration browsing and editing workflows.

New Features:

  • Add an internal D-Bus configuration catalog for clients to discover applications, resources, and subpaths.
  • Support querying the catalog from dde-dconfig and dde-dconfig-editor with local fallback when the daemon is unavailable.
  • Allow the editor to add temporary application IDs and dynamic subpaths for configuration navigation.

Bug Fixes:

  • Exclude invalid configuration entries and correctly represent empty applications and subpaths in the catalog.
  • Invalidate catalog clients when configurations are updated or reloaded.

Enhancements:

  • Improve editor navigation, refresh controls, selection feedback, layout, sorting, and configuration item presentation.

Build:

  • Generate D-Bus adaptors and interfaces for the internal configuration catalog across supported Qt versions.

Tests:

  • Add coverage for catalog discovery of applications, resources, empty subpaths, and invalid configurations.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @18202781743, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 18 hours and 5 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds an internal /Internal D-Bus catalog backed by validated filesystem discovery, then routes dde-dconfig and dde-dconfig-editor through a cached, signal-invalidated client with local fallback; display handling now avoids empty app/subpath items and tests cover catalog edge cases.

Sequence diagram for cached catalog queries and fallback

sequenceDiagram
    participant App as dde-dconfig or editor
    participant Client as ResourceCatalogClient
    participant Daemon as ConfigManager.Internal
    participant Files as Local configuration directories

    App->>Client: configurations()
    alt cached configurations are valid
        Client-->>App: cached ConfigInfoList
    else cache miss
        Client->>Daemon: configurations()
        alt D-Bus query succeeds
            Daemon-->>Client: ConfigInfoList
            Client-->>App: cached ConfigInfoList
        else daemon unavailable
            Daemon-->>Client: D-Bus error
            Client->>Files: localConfigurations()
            Files-->>Client: discovered ConfigInfoList
            Client-->>App: local ConfigInfoList
        end
    end
    Daemon-->>Client: configurationsChanged()
    Client->>Client: refresh()
Loading

Sequence diagram for catalog invalidation after configuration updates

sequenceDiagram
    participant Update as ConfigManager update or reload
    participant Catalog as DSGConfigCatalog
    participant Client as ResourceCatalogClient
    participant UI as CLI or editor

    Update->>Catalog: configurationsChanged()
    Catalog-->>Client: configurationsChanged()
    Client->>Client: refresh()
    UI->>Client: resourcesForApp(appid)
    Client->>Client: configurations()
    Client-->>UI: refreshed catalog results
Loading

File-Level Changes

Change Details Files
Expose the daemon’s discovered configuration catalog through an internal D-Bus interface.
  • Added ConfigInfo/ConfigInfoList D-Bus metatypes for app, resource, and subpath tuples.
  • Implemented filesystem catalog discovery with deduplication, validation via DConfigFile, and support for generic and app-specific directories.
  • Registered the /Internal object and emitted change notifications after updates, reloads, and local-prefix changes.
dconfig-center/common/configinfo.h
dconfig-center/dde-dconfig-daemon/dconfigcatalog.cpp
dconfig-center/dde-dconfig-daemon/dconfigcatalog.h
dconfig-center/dde-dconfig-daemon/dconfigserver.cpp
dconfig-center/dde-dconfig-daemon/dconfigserver.h
dconfig-center/dde-dconfig-daemon/services/org.desktopspec.ConfigManager.Internal.xml
dconfig-center/dde-dconfig-daemon/services/org.desktopspec.ConfigManager.conf
dconfig-center/dde-dconfig-daemon/src.cmake
Centralize catalog queries in a cached client with daemon-backed lookup and local-directory fallback.
  • Added a singleton ResourceCatalogClient that queries the internal D-Bus API synchronously.
  • Invalidated cached results on configurationsChanged and derived application, resource, subpath, availability, and existence queries from catalog tuples.
  • Retained helper-based local discovery when the daemon is unavailable.
dconfig-center/common/configinfo.h
dconfig-center/common/resourcecatalogclient.cpp
dconfig-center/common/resourcecatalogclient.h
dconfig-center/dde-dconfig/CMakeLists.txt
dconfig-center/dde-dconfig-editor/CMakeLists.txt
Migrate CLI and editor catalog displays to the shared client and correct empty-item presentation.
  • Replaced direct filesystem helper calls in list/get/set/reset/watch validation and editor dialogs with ResourceCatalogClient queries.
  • Excluded empty subpaths from child display entries while retaining root resources.
  • Preserved the virtual no-app label and app IDs when translating display names.
dconfig-center/dde-dconfig/main.cpp
dconfig-center/dde-dconfig-editor/exportdialog.cpp
dconfig-center/dde-dconfig-editor/mainwindow.cpp
dconfig-center/dde-dconfig-editor/oemdialog.cpp
Add coverage for catalog discovery and edge cases.
  • Added fixtures and assertions for app, no-app, nested subpath, empty directory, and invalid configuration entries.
dconfig-center/tests/ut_dconfigserver.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

1. Add DSGConfigCatalog class exposing a new internal D-Bus interface
org.desktopspec.ConfigManager.Internal
2. Register the catalog on the /Internal D-Bus path in DSGConfigServer
3. Emit configurationsChanged signal when update/reload modifies
configurations
4. Propagate local prefix changes to the internal catalog
5. Add D-Bus policy allowing the new internal interface for dde-dconfig
and dde-dconfig-editor
6. Introduce ResourceCatalogClient caching catalog data for dde-dconfig
CLI and dde-dconfig-editor GUI
7. Replace helper.hpp catalog functions with ResourceCatalogClient calls
in CLI and editor
8. Add dynamic appid/subpath support in dde-dconfig-editor and improve
UI (navigation path, selection counters, refresh button, right-aligned
values, modification indicator)
9. Update translations and unit tests for the new internal catalog
10. Add subpath config test fixtures to ut_dconfigserver

Log: Added Internal D-Bus catalog interface consumed by dde-dconfig
and dde-dconfig-editor, plus editor UI improvements and dynamic appid/
subpath support

Influence:
1. Start dde-dconfig-daemon and verify /Internal D-Bus object is
registered and callable
2. Verify DSGConfigCatalog::configurations returns installed resources,
subpaths, and common resources, and excludes invalid configs
3. Use dde-dconfig list/get/set/reset/watch commands to confirm they
still work via ResourceCatalogClient
4. Trigger configuration reload and confirm configurationsChanged signal
is emitted and editor refreshes
5. Test dde-dconfig-editor: specify a new appid via the add button and
verify resources load
6. Test specifying a dynamic subpath from the resource context menu and
verify the value loads
7. Verify export dialog item-selected counter, OEM dialog change
counter, and refresh button behavior
8. Confirm modified value indicator (*) and tooltips behave correctly
9. Run ut_dconfigserver including the new internalCatalog test case

feat: 新增内部配置目录 D-Bus 接口

1. 新增 DSGConfigCatalog 类,暴露新的内部 D-Bus 接口
org.desktopspec.ConfigManager.Internal
2. 在 DSGConfigServer 中注册 /Internal D-Bus 路径上的 catalog 对象
3. 当 update/reload 修改配置时发出 configurationsChanged 信号
4. 将本地前缀变更传递给内部 catalog
5. 新增 D-Bus 策略,允许 dde-dconfig 和 dde-dconfig-editor 访问新的内部
接口
6. 引入 ResourceCatalogClient,为 dde-dconfig 命令行和 dde-dconfig-
editor 图形界面缓存目录数据
7. 在命令行和编辑器中用 ResourceCatalogClient 调用替换 helper.hpp 中的目
录函数
8. dde-dconfig-editor 支持动态添加 appid/subpath,并改进界面(导航路径、
选中计数、刷新按钮、数值右对齐、修改标记)
9. 更新翻译文件并新增内部 catalog 的单元测试
10. 在 ut_dconfigserver 中新增 subpath 配置测试数据

Log: 新增供 dde-dconfig 与 dde-dconfig-editor 使用的内部 D-Bus 目录接
口,并改进编辑器界面及动态 appid/subpath 支持

Influence:
1. 启动 dde-dconfig-daemon,验证 /Internal D-Bus 对象已注册且可调用
2. 验证 DSGConfigCatalog::configurations 返回已安装资源、subpath 以及公
共资源,并排除无效配置
3. 使用 dde-dconfig list/get/set/reset/watch 命令,确认通过
ResourceCatalogClient 仍可正常工作
4. 触发配置 reload,确认 configurationsChanged 信号发出且编辑器刷新
5. 测试 dde-dconfig-editor:通过添加按钮指定新 appid,验证资源加载
6. 测试在资源配置右键菜单中指定动态 subpath,验证数值正确加载
7. 验证导出对话框的选中计数、OEM 对话框的修改计数以及刷新按钮行为
8. 确认修改标记(*)和提示信息显示正确
9. 运行 ut_dconfigserver,包含新增的 internalCatalog 测试用例
@github-actions

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "dconfig-center/dde-dconfig-editor/exportdialog.cpp": {
            "a": [
                "        m_exportView->setModel(model);"
            ],
            "b": [
                "    setWindowTitle(tr(\"export configuration\"));",
                "    m_exportView->setUniformRowHeights(true);",
                "    m_exportView->setTextElideMode(Qt::ElideMiddle);",
                "    m_exportView->setAlternatingRowColors(true);",
                "    m_exportView->setModel(model);",
                "    m_exportView->expandToDepth(0);",
                "    m_exportView->header()->setStretchLastSection(true);",
                "    m_exportView->header()->setSectionResizeMode(0, QHeaderView::Stretch);"
            ]
        },
        "dconfig-center/dde-dconfig-editor/mainwindow.cpp": {
            "a": [
                "    exportView->setFixedSize(QSize(400, 600));"
            ],
            "b": [
                "    exportView->setMinimumSize(QSize(720, 520));",
                "    exportView->resize(QSize(960, 680));"
            ]
        },
        "dconfig-center/dde-dconfig-editor/oemdialog.cpp": {
            "a": [
                "    m_exportView->header()->setMinimumSectionSize(400);"
            ],
            "b": [
                "    m_exportView->setAlternatingRowColors(true);",
                "    m_exportView->setUniformRowHeights(false);",
                "    m_exportView->setTextElideMode(Qt::ElideMiddle);",
                "    m_exportView->header()->setStretchLastSection(true);",
                "    m_exportView->header()->setSectionResizeMode(0, QHeaderView::Stretch);",
                "    m_exportView->header()->setSectionResizeMode(1, QHeaderView::Stretch);"
            ]
        }
    }
}

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 96 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 96 分,大于 70 分通过阈值。本次提交实现了内部 D-Bus 配置目录服务,代码结构清晰,安全防护到位,同时修复了多个既有 Bug。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码语法正确,逻辑清晰。本次提交修复了3个既有Bug:1. dconfigserver.cpp update() 函数中添加了缺失的 return 语句,防止错误路径继续执行;2. oemdialog.cpp 中修复了 setFont(pFont) 改为 setFont(rFont) 的变量名错误;3. exportdialog.cpp 中将 setModel() 从循环内部移至循环外部,避免重复设置模型。所有新增对象均通过 Qt parent 机制正确管理内存,无内存泄漏风险。


2. 代码质量 ✅

评价: 良好 ✅ 通过

潜在问题:

  1. dconfig-center/dde-dconfig-editor/mainwindow.cpp:108 - UI 代码中存在多个魔法数字(QSize(1200, 760)、QSize(32, 32)、9/10 等),建议提取为命名常量
  2. dconfig-center/dde-dconfig-editor/mainwindow.cpp:374 - 新增函数 sortedStrings、normalizeDynamicSubpath、addAppid、addDynamicSubpath、updateNavigation 缺少函数级注释

建议: 1.将 UI 尺寸常量提取为命名常量,如 static const QSize kDefaultWindowSize(1200, 760);2.为新增工具函数添加简短的函数级注释,说明参数和返回值含义。积极方面:清理了 handleModificationInfomation 函数及其拼写错误 MidificationFlag,匿名命名空间用于工具函数符合良好实践,D-Bus 策略注释清晰。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. dconfig-center/dde-dconfig-editor/mainwindow.cpp:407 - refreshApps() 中 sortedStrings() 冗余调用两次,第一次排序可以避免

建议: 优化 refreshApps() 中的排序逻辑,移除第一次冗余的 sortedStrings 调用。积极方面:通过 configurationsChanged 信号正确失效缓存,无阻塞主线程的操作,资源管理合理。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 安全防护到位。normalizeDynamicSubpath() 正确阻止了路径遍历攻击(拦截 . 和 .. 路径组件、反斜杠),并使用 QDir::cleanPath 规范化路径。addAppid() 验证 appid 不为空且不包含 / 和 \ 字符。D-Bus 策略配置与现有接口模式一致,注释说明内部接口不是公开 API。无硬编码密钥、无命令注入风险、无不安全加密算法。


💡 改进建议代码示例

// 建议提取 UI 尺寸常量
static constexpr QSize kDefaultWindowSize(1200, 760);
static constexpr QSize kMinWindowSize(800, 520);
static constexpr QSize kMaxWindowSize(1100, 700);
static constexpr int kIconButtonSize = 32;
static constexpr int kIconPixelSize = 20;

// 建议为工具函数添加注释
/// \brief 对字符串列表进行不区分大小写的排序
/// \param values 待排序的字符串列表
/// \return 排序后的字符串列表
QStringList sortedStrings(QStringList values);

/// \brief 规范化动态子路径,防止路径遍历攻击
/// \param input 用户输入的子路径
/// \param normalized 输出规范化后的子路径
/// \return 输入是否有效
bool normalizeDynamicSubpath(const QString &input, QString *normalized);

// refreshApps 优化:移除第一次冗余排序
void MainWindow::refreshApps(const QString &matchAppid)
{
    auto model = new QStandardItemModel(this);
    // 直接获取并合并,只需排序一次
    auto apps = ResourceCatalogClient::instance().applications();
    for (const QString &appid : dynamicAppids) {
        if (!apps.contains(appid))
            apps.append(appid);
    }
    apps = sortedStrings(apps);  // 只排序一次
    apps.removeAll(NoAppId);
    apps.prepend(NoAppId);
    // ...
}

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "dconfig-center/dde-dconfig-editor/exportdialog.cpp": {
            "a": [
                "        m_exportView->setModel(model);"
            ],
            "b": [
                "    setWindowTitle(tr(\"export configuration\"));",
                "    m_exportView->setUniformRowHeights(true);",
                "    m_exportView->setTextElideMode(Qt::ElideMiddle);",
                "    m_exportView->setAlternatingRowColors(true);",
                "    m_exportView->setModel(model);",
                "    m_exportView->expandToDepth(0);",
                "    m_exportView->header()->setStretchLastSection(true);",
                "    m_exportView->header()->setSectionResizeMode(0, QHeaderView::Stretch);"
            ]
        },
        "dconfig-center/dde-dconfig-editor/mainwindow.cpp": {
            "a": [
                "    exportView->setFixedSize(QSize(400, 600));"
            ],
            "b": [
                "    exportView->setMinimumSize(QSize(720, 520));",
                "    exportView->resize(QSize(960, 680));"
            ]
        },
        "dconfig-center/dde-dconfig-editor/oemdialog.cpp": {
            "a": [
                "    m_exportView->header()->setMinimumSectionSize(400);"
            ],
            "b": [
                "    m_exportView->setAlternatingRowColors(true);",
                "    m_exportView->setUniformRowHeights(false);",
                "    m_exportView->setTextElideMode(Qt::ElideMiddle);",
                "    m_exportView->header()->setStretchLastSection(true);",
                "    m_exportView->header()->setSectionResizeMode(0, QHeaderView::Stretch);",
                "    m_exportView->header()->setSectionResizeMode(1, QHeaderView::Stretch);"
            ]
        }
    }
}

@18202781743
18202781743 merged commit 3f310f5 into linuxdeepin:master Sep 17, 2026
15 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants