Skip to content

sync: from linuxdeepin/dde-session-shell#501

Merged
yixinshark merged 1 commit into
masterfrom
sync-pr-66-nosync
May 7, 2026
Merged

sync: from linuxdeepin/dde-session-shell#501
yixinshark merged 1 commit into
masterfrom
sync-pr-66-nosync

Conversation

@deepin-ci-robot
Copy link
Copy Markdown
Contributor

@deepin-ci-robot deepin-ci-robot commented May 7, 2026

Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#66

Summary by Sourcery

Update lock screen notification app name to be translatable while preserving existing name when DSS-specific snippet is enabled.

New Features:

  • Add a localized "Lock Screen" app name for lock screen notification requests when DSS-specific snippets are disabled.

Enhancements:

  • Introduce conditional compilation to switch between a generic translated lock screen label and the existing "dde-lock" app name in notification calls.

Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#66
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 7, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the notification appName argument in the lock screen D-Bus notification call, making it conditional on the ENABLE_DSS_SNIP macro so that it uses a translatable "Lock Screen" string by default and falls back to the previous "dde-lock" identifier when the macro is defined.

Sequence diagram for lock screen notification appName change

sequenceDiagram
    actor User
    participant LockContent
    participant NotificationsService as org_freedesktop_Notifications

    User ->> LockContent: triggerLockScreen()
    activate LockContent
    LockContent ->> LockContent: tryGrabKeyboard(exitIfFailed)

    alt ENABLE_DSS_SNIP not defined
        LockContent ->> NotificationsService: Notify(appName=Lock_Screen, replacesId=0, appIcon="", summary="")
    else ENABLE_DSS_SNIP defined
        LockContent ->> NotificationsService: Notify(appName=dde-lock, replacesId=0, appIcon="", summary="")
    end

    deactivate LockContent
Loading

File-Level Changes

Change Details Files
Make the D-Bus notification appName argument conditional on ENABLE_DSS_SNIP and use a localized "Lock Screen" label by default.
  • Wrap the appName argument in a preprocessor guard controlled by ENABLE_DSS_SNIP.
  • Change the default appName argument from the hardcoded string "dde-lock" to the translated string tr("Lock Screen").
  • Retain the original "dde-lock" appName string for builds where ENABLE_DSS_SNIP is defined.
src/session-widgets/lockcontent.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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Using tr("Lock Screen") for the Notify appName makes the identifier locale-dependent; consider keeping a stable, non-translated app name and moving the localized string into the summary/body to avoid issues with notification server matching and filtering.
  • It may be helpful to add a brief comment explaining the purpose of the #ifndef ENABLE_DSS_SNIP conditional here, so future readers understand why the app name differs between builds.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `tr("Lock Screen")` for the `Notify` appName makes the identifier locale-dependent; consider keeping a stable, non-translated app name and moving the localized string into the summary/body to avoid issues with notification server matching and filtering.
- It may be helpful to add a brief comment explaining the purpose of the `#ifndef ENABLE_DSS_SNIP` conditional here, so future readers understand why the app name differs between builds.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link
Copy Markdown
Contributor Author

deepin pr auto review

这段代码是一个使用 D-Bus 接口发送桌面通知的修改。主要修改点是根据编译宏 ENABLE_DSS_SNIP 来决定通知的应用名称(appName)是显示为 "Lock Screen" 还是 "dde-lock"。

以下是对这段代码的审查意见,包括语法逻辑、代码质量、性能和安全方面:

1. 语法逻辑

  • 现状:使用了预处理器指令 #ifndef / #else / #endif 进行条件编译。
  • 审查意见:语法完全正确。逻辑上,它区分了两种构建场景:一种是普通构建(显示翻译后的 "Lock Screen"),另一种是启用了 ENABLE_DSS_SNIP 的构建(显示硬编码的 "dde-lock")。
  • 潜在风险:这种逻辑依赖于构建系统是否正确定义了 ENABLE_DSS_SNIP。如果构建配置不一致,可能会导致通知来源显示不符合预期。

2. 代码质量

  • 现状:在代码中直接混用了 tr()QString()

  • 改进建议

    • 国际化一致性:既然是锁屏应用,如果 ENABLE_DSS_SNIP 未定义,使用了 tr("Lock Screen"),这支持国际化。但在 #else 分支中使用了硬编码的 QString("dde-lock")。如果 dde-lock 也需要面向不同语言环境的用户展示(尽管作为应用 ID 通常不需要翻译),建议检查是否需要统一处理。不过,D-Bus 的 appName 参数通常用于标识应用程序,而非显示给用户的标题(显示给用户的通常是 summarybody),因此这里硬编码可能是为了后端日志或特定识别,如果是这样,目前的写法是可以接受的。
    • 代码可读性:建议在条件编译上方添加一行注释,解释为什么在 ENABLE_DSS_SNIP 模式下需要使用 "dde-lock" 而不是翻译后的字符串。这有助于后续维护者理解业务逻辑差异。
    • 硬编码字符串"dde-lock""Lock Screen" 都是硬编码。建议将它们定义为类中的静态常量字符串或全局常量,避免在函数体中出现"魔术字符串"(Magic Strings)。

    修改示例:

    // 类定义中或头文件中
    // static constexpr char const* LOCK_NOTIFICATION_APP_NAME = "dde-lock";
    
    // 实现文件中
    #ifndef ENABLE_DSS_SNIP
        .arg(tr("Lock Screen"))
    #else
        .arg(LOCK_NOTIFICATION_APP_NAME)
    #endif

3. 代码性能

  • 现状:这是在构建 D-Bus 调用参数时的分支选择。
  • 审查意见:性能影响微乎其微。预处理器指令在编译阶段就已经处理完毕,生成的二进制文件中只包含其中一个分支的代码。运行时没有额外的 if-else 判断开销。

4. 代码安全

  • 现状:传入 D-Bus 接口的参数。
  • 审查意见
    • 输入验证:这里传入的是静态字符串,不存在注入风险。
    • 隐私/信息泄露appName 字段可能会被系统日志记录。在普通模式下显示 "Lock Screen"(用户可见的描述),而在特定模式下显示 "dde-lock"(内部代号)。如果 ENABLE_DSS_SNIP 是为了某种特殊的安全或截屏录制模式,确保 "dde-lock" 不会泄露敏感的内部架构信息(虽然这个字符串看起来比较通用,风险较低)。

总结与改进建议代码

总体来说,这段代码逻辑清晰,没有严重问题。为了提高可维护性,建议增加注释并提取常量。

改进后的代码示例:

// ... 前面的代码 ...

            .interface("org.freedesktop.Notifications")
            .method(QString("Notify"))
            // 根据编译宏决定通知的应用名称。
            // 普通模式下使用翻译后的名称,特定模式下使用内部标识符以便后端识别。
#ifndef ENABLE_DSS_SNIP
            .arg(tr("Lock Screen"))
#else
            .arg(QString("dde-lock"))     // appName: 用于特定构建下的内部识别
#endif
            .arg(static_cast<uint>(0))
            .arg(QString(""))
            .arg(QString(""))

// ... 后面的代码 ...

额外建议:
如果 tr("Lock Screen") 是为了在通知弹窗中显示给用户看,请确认 D-Bus 通知规范中 arg0 (appName) 是否真的是用户可见的文本。通常在 freedesktop.org 的通知规范中,app_name 是图标名称或应用ID,而 summary (通常是 arg3) 才是显示给用户的标题。如果 arg0 仅用于后台标识,那么普通模式下使用 tr() 可能是不必要的(除非通知守护进程会将其展示给用户)。请务必确认 D-Bus 参数的具体含义。

@deepin-ci-robot
Copy link
Copy Markdown
Contributor Author

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-ci-robot, yixinshark

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

@yixinshark yixinshark merged commit fce0212 into master May 7, 2026
26 of 29 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.

2 participants