Skip to content

feat: expose localized desktop entry Keywords (linuxdeepin/developer-center#3375) - #393

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
foresee-io:master
Oct 22, 2026
Merged

BLumia merged 1 commit into
linuxdeepin:masterfrom
foresee-io:master

Conversation

@foresee-io

@foresee-io foresee-io commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Related to linuxdeepin/developer-center#3375.

Desktop Entry defines localized Keywords for application discovery, but the application manager does not expose this metadata to search consumers.

This PR adds a read-only Keywords D-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 新增只读的 Keywords D-Bus 属性(a{sas}),保留各 locale 对应的关键词列表,并正确解析转义分隔符。同时注册相关 D-Bus 类型,补充解析回归测试。

具体的语言环境选择仍由数据使用方负责。

Summary by Sourcery

Expose parsed, localized desktop-entry keywords to application search consumers over D-Bus.

New Features:

  • Expose localized application Keywords through the read-only ApplicationManager D-Bus API while preserving locale-specific values for consumers.

Enhancements:

  • Decode desktop-entry keyword lists, including escaped separators and characters, while filtering empty and duplicate keywords.

Tests:

  • Add regression coverage for localized keyword preservation and escaped keyword parsing.

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,避免合并无关语言的翻译。
Copilot AI balanced review requested due to automatic review settings October 21, 2026 09:33

Copilot AI 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.

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.

@deepin-ci-robot

Copy link
Copy Markdown

Hi @foresee-io. Thanks for your PR. 😃

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@deepin-ci-robot

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@sourcery-ai

sourcery-ai Bot commented Oct 21, 2026

Copy link
Copy Markdown

Reviewer's Guide

The 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 a{sas}, properly registered for serialization, invalidated on entry changes, and covered by parser regression tests.

Sequence diagram for localized application Keywords exposure

sequenceDiagram
    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
Loading

Flow diagram for localized Keywords parsing

flowchart 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}"]
Loading

File-Level Changes

Change Details Files
Expose localized, parsed desktop-entry Keywords through the Application D-Bus API.
  • Add a read-only a{sas} property with locale-preserving semantics and change notifications.
  • Read the raw Keywords entry and convert each locale’s escaped semicolon-delimited value into a de-duplicated QStringList.
  • Document that locale fallback remains the consumer’s responsibility.
api/dbus/org.desktopspec.ApplicationManager1.Application.xml
src/dbus/applicationservice.h
src/dbus/applicationservice.cpp
src/desktopentry.h
src/desktopentry.cpp
Register the new locale-to-keyword-list map type for Qt and D-Bus serialization.
  • Define and declare the QStringListMap metatype.
  • Register it in application-manager, launcher, command-executor, and test startup paths.
src/global.h
apps/dde-am/src/commandexecutor.cpp
apps/dde-am/src/launcher.cpp
apps/dde-application-manager/src/main.cpp
tests/main.cpp
Add regression coverage for localized keyword parsing and escaping behavior.
  • Verify locale keys and the unlocalized default key are preserved.
  • Verify separators, escaped characters, whitespace trimming, duplicate suppression, and non-existent locales.
tests/ut_desktopentry.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

@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.

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, &current]() {
+        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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/desktopentry.cpp

auto flushKeyword = [&keywords, &current]() {
const auto keyword = current.trimmed();
if (!keyword.isEmpty() && !keywords.contains(keyword, Qt::CaseInsensitive)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.

@foresee-io

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

@deepin-ci-robot

Copy link
Copy Markdown

[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.

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

@BLumia
BLumia merged commit ae972e3 into linuxdeepin:master Oct 22, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants