Repository navigation
feat: add internal configuration catalog service - #160
Conversation
There was a problem hiding this comment.
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.
Reviewer's GuideAdds 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 fallbacksequenceDiagram
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()
Sequence diagram for catalog invalidation after configuration updatessequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
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 测试用例
|
Warning
详情 {
"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 pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码语法正确,逻辑清晰。本次提交修复了3个既有Bug:1. dconfigserver.cpp update() 函数中添加了缺失的 return 语句,防止错误路径继续执行;2. oemdialog.cpp 中修复了 setFont(pFont) 改为 setFont(rFont) 的变量名错误;3. exportdialog.cpp 中将 setModel() 从循环内部移至循环外部,避免重复设置模型。所有新增对象均通过 Qt parent 机制正确管理内存,无内存泄漏风险。 2. 代码质量 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 1.将 UI 尺寸常量提取为命名常量,如 static const QSize kDefaultWindowSize(1200, 760);2.为新增工具函数添加简短的函数级注释,说明参数和返回值含义。积极方面:清理了 handleModificationInfomation 函数及其拼写错误 MidificationFlag,匿名命名空间用于工具函数符合良好实践,D-Bus 策略注释清晰。 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 优化 refreshApps() 中的排序逻辑,移除第一次冗余的 sortedStrings 调用。积极方面:通过 configurationsChanged 信号正确失效缓存,无阻塞主线程的操作,资源管理合理。 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 安全防护到位。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 代码审查工具自动生成 |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Warning
详情 {
"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);"
]
}
}
} |
Summary
Tests
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:
Bug Fixes:
Enhancements:
Build:
Tests: