Skip to content

feat: add language update support to system service - #634

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
52cyb:network
Sep 21, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
52cyb:network

Conversation

@52cyb

@52cyb 52cyb commented Sep 21, 2026

Copy link
Copy Markdown
Contributor
  1. Add initializator() accessor method to SystemContainer class
  2. Include networkinitialization.h header in systemservice.cpp
  3. Implement UpdateLanguage slot in SystemService to handle locale updates
  4. Declare UpdateLanguage slot in SystemService header
  5. Enable language updates to be propagated through the system container to network initialization component

Log: Added support for updating language settings in system service

Influence:

  1. Test UpdateLanguage method with various locale strings
  2. Verify that language updates are properly propagated to network initialization
  3. Test the initializator() accessor returns valid pointer
  4. Verify system service handles language updates without crashes
  5. Test integration with existing connectivity and IP conflict functionality
  6. Verify no memory leaks or null pointer issues when updating language

feat: 为系统服务添加语言更新支持

  1. 在 SystemContainer 类中添加 initializator() 访问器方法
  2. 在 systemservice.cpp 中包含 networkinitialization.h 头文件
  3. 在 SystemService 中实现 UpdateLanguage 槽函数以处理区域设置更新
  4. 在 SystemService 头文件中声明 UpdateLanguage 槽函数
  5. 使语言更新能够通过系统容器传播到网络初始化组件

Log: 新增系统服务语言设置更新功能

Influence:

  1. 使用不同的区域设置字符串测试 UpdateLanguage 方法
  2. 验证语言更新是否正确传播到网络初始化组件
  3. 测试 initializator() 访问器返回有效的指针
  4. 验证系统服务处理语言更新时不会崩溃
  5. 测试与现有连接性和 IP 冲突功能的集成
  6. 验证更新语言时没有内存泄漏或空指针问题

PMS: TASK-395869

Summary by Sourcery

Enable system services to update network language settings at runtime.

New Features:

  • Add support for propagating locale changes from the system service to the network initialization component.

Enhancements:

  • Expose the network initialization component through the system container.

@sourcery-ai

sourcery-ai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds end-to-end language update support by exposing the network initialization component from SystemContainer and forwarding SystemService::UpdateLanguage locale changes to it.

Sequence diagram for system language update propagation

sequenceDiagram
    participant Client
    participant SystemService
    participant SystemContainer
    participant NetworkInitialization

    Client->>SystemService: UpdateLanguage(locale)
    SystemService->>SystemContainer: initializator()
    SystemContainer-->>SystemService: NetworkInitialization*
    SystemService->>NetworkInitialization: updateLanguage(locale)
Loading

File-Level Changes

Change Details Files
Exposes the network initialization component through the system container for service-level delegation.
  • Added a const accessor returning the existing network initialization instance.
  • Implemented the accessor using the container’s stored component pointer.
network-service-plugin/src/system/systemcontainer.h
network-service-plugin/src/system/systemcontainer.cpp
Adds a system-service slot that forwards locale changes to network initialization.
  • Declared the UpdateLanguage slot with a locale string parameter.
  • Included the network initialization interface and delegated locale updates through the new container accessor.
network-service-plugin/src/system/systemservice.h
network-service-plugin/src/system/systemservice.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 reviewed your changes and they look great!


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

1. Add initializator() accessor method to SystemContainer class
2. Include networkinitialization.h header in systemservice.cpp
3. Implement UpdateLanguage slot in SystemService to handle locale
updates
4. Declare UpdateLanguage slot in SystemService header
5. Enable language updates to be propagated through the system container
to network initialization component

Log: Added support for updating language settings in system service

Influence:
1. Test UpdateLanguage method with various locale strings
2. Verify that language updates are properly propagated to network
initialization
3. Test the initializator() accessor returns valid pointer
4. Verify system service handles language updates without crashes
5. Test integration with existing connectivity and IP conflict
functionality
6. Verify no memory leaks or null pointer issues when updating language

feat: 为系统服务添加语言更新支持

1. 在 SystemContainer 类中添加 initializator() 访问器方法
2. 在 systemservice.cpp 中包含 networkinitialization.h 头文件
3. 在 SystemService 中实现 UpdateLanguage 槽函数以处理区域设置更新
4. 在 SystemService 头文件中声明 UpdateLanguage 槽函数
5. 使语言更新能够通过系统容器传播到网络初始化组件

Log: 新增系统服务语言设置更新功能

Influence:
1. 使用不同的区域设置字符串测试 UpdateLanguage 方法
2. 验证语言更新是否正确传播到网络初始化组件
3. 测试 initializator() 访问器返回有效的指针
4. 验证系统服务处理语言更新时不会崩溃
5. 测试与现有连接性和 IP 冲突功能的集成
6. 验证更新语言时没有内存泄漏或空指针问题

PMS: TASK-395869
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 95 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 95 分,大于 70 分通过阈值,代码质量符合要求。新增的 UpdateLanguage 槽函数和 initializator() 访问器实现简洁,遵循了现有代码模式,未发现安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码语法正确,逻辑清晰。m_network 在 SystemService 构造函数中已验证非空(构造函数中调用了 m_network->ipConfilctedChecker()),m_initializator 在 SystemContainer 构造函数中通过 new NetworkInitialization(this) 初始化保证非空。方法签名在 .h 和 .cpp 文件中一致。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. network-service-plugin/src/system/systemservice.cpp:34 - 新增 UpdateLanguage 方法缺少函数注释,未说明参数 locale 的格式要求和功能说明
  2. network-service-plugin/src/system/systemcontainer.cpp:35 - 新增 initializator() 方法缺少函数注释

建议: 建议为 UpdateLanguage 方法添加函数注释,说明 locale 参数的预期格式(如 zh_CN、en_US)及其功能。为 initializator() 添加简要注释说明返回值。OCR 审查建议:SystemContainer 中的原始指针成员(m_ipConflictHandler、m_connectivityHelper、m_initializator)可考虑使用 std::unique_ptr 或 QScopedPointer 管理,以遵循 RAII 原则,防止构造函数异常导致内存泄漏。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,资源使用合理。UpdateLanguage 方法仅进行简单的指针访问和方法调用,无性能开销。locale 参数使用 const QString& 传递,避免了不必要的拷贝。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 未发现安全漏洞。UpdateLanguage 作为 DBus 公开槽函数(Q_CLASSINFO D-Bus Interface),locale 参数来自外部 DBus 调用,建议在传入 NetworkInitialization::updateLanguage() 前进行基本格式校验(如限制为合法的 locale 字符串格式),增强防御性编程。下游 installLanguage() 使用 locale 构造翻译文件路径,虽然 QTranslator::load() 仅加载 .qm 格式文件限制了实际风险,但输入校验仍是良好实践。


💡 改进建议代码示例

// 建议为 UpdateLanguage 添加注释和输入校验

/// \brief UpdateLanguage 更新系统网络服务的语言设置
/// \param locale 语言区域字符串,格式如 "zh_CN"、"en_US"
void SystemService::UpdateLanguage(const QString &locale)
{
    // 基本格式校验,防止非法输入
    if (locale.isEmpty() || locale.length() > 32) {
        qCWarning(DSM) << "Invalid locale string:" << locale;
        return;
    }
    m_network->initializator()->updateLanguage(locale);
}

// SystemContainer 建议使用智能指针管理(RAII)
// 头文件中:
// std::unique_ptr<SystemIPConflict> m_ipConflictHandler;
// std::unique_ptr<ConnectivityProcesser> m_connectivityHelper;
// std::unique_ptr<NetworkInitialization> m_initializator;

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 52cyb, caixr23

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

@52cyb

52cyb commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 628f9dd into linuxdeepin:master Sep 21, 2026
13 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.

3 participants