feat: add systemd units and plugin groups for tray loader - #518
yixinshark wants to merge 1 commit into
Conversation
Add dde-tray-loader.target and a template instance service with lifetime coupled to dde-shell@DDE.service, group tray plugins via DConfig into per-group loader instances, add --group/--check-group support, and unset DDE_CURRENT_COMPOSITOR so loaders connect to the dock's internal dockplugin compositor instead of the outer session compositor. 新增 dde-tray-loader.target 及模板实例服务,生命周期与 dde-shell@DDE.service 绑定;通过 DConfig 将托盘插件分组为独立加载器实例, 新增 --group/--check-group 支持;并清除 DDE_CURRENT_COMPOSITOR,使加载器 连接 dock 内部的 dockplugin 合成器而非外层会话合成器。 Log: add systemd units and plugin groups for tray loader Pms: TASK-395865
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yixinshark 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 |
Reviewer's GuideThe PR moves tray plugin startup into four independently managed loader instances launched through a new systemd user target, with lifecycle coupling to dde-shell@DDE.service. Loader instances resolve plugins from a DConfig-owned grouping schema, skip genuinely empty groups via --check-group, report configuration failures distinctly, and unset the dock compositor environment so they connect to the dock's internal compositor. Sequence diagram for grouped tray loader startupsequenceDiagram
participant Systemd as systemd
participant Loader as trayplugin-loader
participant Config as DConfig
participant Dock as Dock compositor
Systemd->>Loader: --check-group groupName
Loader->>Loader: isValidGroup(groupName)
Loader->>Config: pluginPathsForGroup(groupName)
Config-->>Loader: plugin paths or config failure
alt group is empty
Loader-->>Systemd: exit 1
else config failure
Loader-->>Systemd: exit 255
else group has plugins
Systemd->>Loader: --group groupName
Loader->>Config: pluginPathsForGroup(groupName)
Loader->>Loader: pluginManager loads plugin paths
Loader->>Loader: qunsetenv QT_SCALE_FACTOR
Loader->>Loader: qunsetenv DDE_CURRENT_COMPOSITOR
Loader->>Dock: connect to internal dockplugin compositor
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/loader/trayplugingroups.cpp" line_range="11" />
<code_context>
+ dirs << pluginDirs();
+
+ QStringList pluginPaths;
+ for (const auto &pluginDir : std::as_const(dirs)) {
+ QDir dir(pluginDir);
+ if (!dir.exists()) {
</code_context>
<issue_to_address>
**issue (bug_risk):** The new source uses `std::as_const` without including `<utility>`, where it is declared. A conforming build therefore fails to compile `trayplugingroups.cpp` with `std::as_const` not declared.
**Suggested fix:** Add `#include <utility>` to `trayplugingroups.cpp`.
```suggestion
#include <QScopedPointer>
#include <utility>
```
</issue_to_address>
### Comment 2
<location path="src/loader/trayplugingroups.cpp" line_range="24-27" />
<code_context>
+ // Keep in sync with the directories previously scanned by dde-shell
+ // (panels/dock/loadtrayplugins.h).
+ static const QStringList dirs = {
+ "/usr/lib/dde-dock/plugins/",
+ "/usr/lib/dde-dock/plugins/quick-trays/",
+ "/usr/lib/dde-dock/plugins/system-trays/"
+ };
+ return dirs;
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** The group scanner only searches absolute `/usr/lib/dde-dock/...` directories, while the plugins are installed relative to the configured CMake install prefix. When the project is installed with a prefix other than `/usr`, every group is reported empty and no tray plugins are started.
**Triggers:** When the package is installed under a non-`/usr` prefix.
**Suggested fix:** Derive the plugin directories from configured install paths, for example by substituting `CMAKE_INSTALL_PREFIX`/`CMAKE_INSTALL_LIBDIR` into generated code or passing the paths through the service environment.
</issue_to_address>|
|
||
| #include <QDir> | ||
| #include <QLoggingCategory> | ||
| #include <QScopedPointer> |
There was a problem hiding this comment.
issue (bug_risk): The new source uses std::as_const without including <utility>, where it is declared. A conforming build therefore fails to compile trayplugingroups.cpp with std::as_const not declared.
Suggested fix: Add #include <utility> to trayplugingroups.cpp.
| #include <QScopedPointer> | |
| #include <QScopedPointer> | |
| #include <utility> |
| "/usr/lib/dde-dock/plugins/", | ||
| "/usr/lib/dde-dock/plugins/quick-trays/", | ||
| "/usr/lib/dde-dock/plugins/system-trays/" | ||
| }; |
There was a problem hiding this comment.
issue (bug_risk): The group scanner only searches absolute /usr/lib/dde-dock/... directories, while the plugins are installed relative to the configured CMake install prefix. When the project is installed with a prefix other than /usr, every group is reported empty and no tray plugins are started.
Triggers: When the package is installed under a non-/usr prefix.
Suggested fix: Derive the plugin directories from configured install paths, for example by substituting CMAKE_INSTALL_PREFIX/CMAKE_INSTALL_LIBDIR into generated code or passing the paths through the service environment.
deepin pr auto reviewAI 代码审查报告
总体评分
总体评价: 代码审查通过。未发现安全问题,代码结构清晰,注释完整,逻辑正确。本次提交为 dde-tray-loader 添加了 systemd 用户单元和基于 DConfig 的插件分组机制,将托盘插件按组隔离到独立进程中运行,生命周期与 dock shell 绑定。 漏洞统计
漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 维度1:语法逻辑(25/25)✓
分析内容本次提交涉及 14 个文件的变更,包括新增 C++ 源文件(trayplugingroups.h/cpp)、修改 main.cpp 入口逻辑、新增 systemd 单元文件和 DConfig 配置 schema。 main.cpp 变更分析:
trayplugingroups.cpp 分析:
systemd 单元文件分析:
无语法错误,无逻辑缺陷,边界处理完善。 维度2:代码质量(25/25)✓
分析内容注释完整性(5/5):
代码重复(5/5):
结构合理性(5/5):
调试信息清理(5/5):
维度3:代码性能(20/20)✓
分析内容资源使用:
算法复杂度:
无性能瓶颈:
维度4:代码安全(30/30)✓
安全分析1. 命令注入风险评估:无风险
2. 路径遍历风险评估:无风险
3. 敏感信息泄露评估:无风险
4. 输入验证:完善
5. 缓冲区安全:安全
6. systemd 安全配置:良好
文件分析清单
审查结论本次提交为 dde-tray-loader 添加了 systemd 用户单元和基于 DConfig 的插件分组机制,实现了以下功能:
代码质量优秀,注释详尽,逻辑清晰,无安全漏洞。建议合入。 |
Pms: TASK-395865
Summary
Test plan
Summary by Sourcery
Introduce lifecycle-managed, independently isolated tray plugin loader groups for the dock shell.
New Features:
Bug Fixes:
Enhancements:
Build: