Repository navigation
feat: expose localized desktop entry Keywords (linuxdeepin/developer-center#3375) - #393
Conversation
1. Add a Keywords property mapping each locale to its decoded word list.
2. Preserve locale keys and escaped separators when parsing desktop entries.
3. Register the D-Bus map type in application manager entry points and add
parser regression tests.
Log: Expose desktop entry keywords for application search consumers
Influence: Consumers select a locale from the Keywords map instead of
merging translations from unrelated locales.
feat: 通过 D-Bus 暴露本地化的桌面应用关键词
1. 新增 Keywords 属性,将各 locale 映射到解码后的关键词列表。
2. 解析桌面文件时保留 locale 键,并正确处理转义的分隔符。
3. 在应用管理器各入口注册 D-Bus 映射类型,补充解析回归测试。
Log: 为应用搜索提供桌面文件中的关键词
Influence: 消费者从 Keywords 映射中选择一个 locale,避免合并无关语言的翻译。
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Hi @foresee-io. Thanks for your PR. 😃 |
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
Hi @foresee-io. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideThe PR adds a locale-preserving Keywords pipeline from desktop files to the Application D-Bus interface: raw localized values are parsed into escaped, de-duplicated keyword lists, exposed as Sequence diagram for localized application Keywords exposuresequenceDiagram
participant DesktopFile
participant ApplicationService
participant DBusClient
DBusClient->>ApplicationService: Keywords()
ApplicationService->>DesktopFile: value(DesktopEntryKeywords)
DesktopFile-->>ApplicationService: localized QStringMap
ApplicationService->>ApplicationService: toKeywordMap(value)
ApplicationService-->>DBusClient: a{sas} QStringListMap
Note over DBusClient: Select locale and apply fallback rules
Flow diagram for localized Keywords parsingflowchart LR
A[Raw localized Keywords] --> B[Split on unescaped semicolons]
B --> C[Decode escaped separators and characters]
C --> D[Trim and remove case-insensitive duplicates]
D --> E[Preserve locale keys]
E --> F["QStringListMap / a{sas}"]
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 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/desktopentry.cpp" line_range="490" />
<code_context>
+
+ auto flushKeyword = [&keywords, ¤t]() {
+ const auto keyword = current.trimmed();
+ if (!keyword.isEmpty() && !keywords.contains(keyword, Qt::CaseInsensitive)) {
+ keywords.append(keyword);
+ }
</code_context>
<issue_to_address>
**Large keyword lists stall manager**
When a local user or application can supply a desktop entry with a very large number of distinct Keywords and a D-Bus client reads that application's Keywords property, `flushKeyword` checks each keyword against all previously collected entries with a case-insensitive linear scan, making parsing quadratic; `ApplicationService::keywords()` invokes this parser when serving the property, so repeated reads of an entry with a very large list can keep the manager busy and delay other clients.
Use a set for case-insensitive duplicate detection, or impose a reasonable limit on keyword count and total input size.
</issue_to_address>|
|
||
| auto flushKeyword = [&keywords, ¤t]() { | ||
| const auto keyword = current.trimmed(); | ||
| if (!keyword.isEmpty() && !keywords.contains(keyword, Qt::CaseInsensitive)) { |
There was a problem hiding this comment.
🟡 Medium · Large keyword lists stall manager
When a local user or application can supply a desktop entry with a very large number of distinct Keywords and a D-Bus client reads that application's Keywords property, flushKeyword checks each keyword against all previously collected entries with a case-insensitive linear scan, making parsing quadratic; ApplicationService::keywords() invokes this parser when serving the property, so repeated reads of an entry with a very large list can keep the manager busy and delay other clients.
Use a set for case-insensitive duplicate detection, or impose a reasonable limit on keyword count and total input size.
Prompt for AI agents
In `src/desktopentry.cpp` at line 490:
**Large keyword lists stall manager**
When a local user or application can supply a desktop entry with a very large number of distinct Keywords and a D-Bus client reads that application's Keywords property, `flushKeyword` checks each keyword against all previously collected entries with a case-insensitive linear scan, making parsing quadratic; `ApplicationService::keywords()` invokes this parser when serving the property, so repeated reads of an entry with a very large list can keep the manager busy and delay other clients.
Use a set for case-insensitive duplicate detection, or impose a reasonable limit on keyword count and total input size.|
I have read the CLA Document and I hereby sign the CLA. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, foresee-io 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 |
Related to linuxdeepin/developer-center#3375.
Desktop Entry defines localized
Keywordsfor application discovery, but the application manager does not expose this metadata to search consumers.This PR adds a read-only
KeywordsD-Bus property (a{sas}), preserving locale keys and decoding keyword lists, including escaped separators. It also registers the required D-Bus types and adds parser regression tests.The locale selection remains the responsibility of consumers.
Desktop Entry 规范定义了用于辅助查找应用的本地化
Keywords字段,但应用管理器尚未向搜索组件提供这一元数据。本 PR 新增只读的
KeywordsD-Bus 属性(a{sas}),保留各 locale 对应的关键词列表,并正确解析转义分隔符。同时注册相关 D-Bus 类型,补充解析回归测试。具体的语言环境选择仍由数据使用方负责。
Summary by Sourcery
Expose parsed, localized desktop-entry keywords to application search consumers over D-Bus.
New Features:
Enhancements:
Tests: