Skip to content

fix(caldav): disable schedule type creation for third-party accounts - #374

Merged
wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:master
Sep 11, 2026
Merged

wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:master

Conversation

@wyu71

@wyu71 wyu71 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Disable schedule type creation for CalDAV accounts in settings and new event dialogs. Keep schedule type creation available for local accounts and UOS ID accounts.

在账户设置和新建日程窗口中禁用第三方 CalDAV 账户新增日程类型。
保留本地账户和 UOS ID 账户的日程类型新增功能。

Log: 限制第三方账户新增日程类型
PMS: TASK-393989
Influence: 禁止第三方 CalDAV 账户新增日程类型,避免创建无法同步或不应修改的类型, 同时保持本地账户和 UOS ID 账户的原有功能不变。

Summary by Sourcery

Restrict schedule type creation for CalDAV accounts while retaining existing functionality for supported local and UOS ID accounts.

Bug Fixes:

  • Prevent schedule type creation for third-party CalDAV accounts in account settings and new event dialogs.

Enhancements:

  • Preserve schedule type creation and management for local and eligible UOS ID accounts while disabling CalDAV add controls consistently.

Chores:

  • Update the Chinese translation for the CalDAV login permission error message.

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

Sorry @wyu71, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 19 hours and 2 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wyu71

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

@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Disables schedule-type creation and management for third-party CalDAV accounts across settings and new-event dialogs through UI state control and defensive creation guards, while preserving existing schedule types and the original functionality for local and UOS ID accounts.

Sequence diagram for CalDAV schedule type creation prevention

sequenceDiagram
    participant User
    participant JobTypeComboBox
    participant CScheduleDlg
    participant Account

    User->>JobTypeComboBox: updateJobType(Account)
    JobTypeComboBox->>Account: accountType()
    Account-->>JobTypeComboBox: Account_CalDav
    JobTypeComboBox->>JobTypeComboBox: setAddTypeEnabled(false)
    JobTypeComboBox-->>User: Add control disabled
    User->>JobTypeComboBox: slotBtnAddItemClicked()
    JobTypeComboBox-->>User: Return without creating type
    User->>CScheduleDlg: selectScheduleType()
    CScheduleDlg->>JobTypeComboBox: isEditable()
    JobTypeComboBox-->>CScheduleDlg: false
    CScheduleDlg-->>User: Creation unavailable
Loading

File-Level Changes

Change Details Files
Centralize CalDAV-specific restrictions in the schedule-type combo box so third-party accounts cannot create or edit new types while existing types remain selectable.
  • Detect CalDAV accounts during account refresh and disable add/edit controls.
  • Persist the enabled state across lazy custom-widget creation and popup refreshes.
  • Guard the add action handler against programmatic or stale activation.
src/calendar-client/src/customWidget/jobtypecombobox.cpp
src/calendar-client/src/customWidget/jobtypecombobox.h
Add a dialog-level safeguard that prevents schedule-type creation for CalDAV accounts.
  • Reject creation in the new-event schedule-type selection path when the combo box is editable for a CalDAV account.
  • Retain the existing creation flow for local and UOS ID accounts.
src/calendar-client/src/dialog/scheduledlg.cpp
Update account settings permissions to disable CalDAV schedule-type management while preserving supported account behavior.
  • Remove writable-CalDAV accounts from the manage-types permission calculation.
  • Disable the schedule-type overflow/add button for CalDAV accounts.
  • Keep existing schedule types visible and retain local/UOS ID management and export behavior.
src/calendar-client/src/dialog/settingdialog.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

Disable schedule type creation for CalDAV accounts in settings and new event dialogs.
Keep schedule type creation available for local accounts and UOS ID accounts.

在账户设置和新建日程窗口中禁用第三方 CalDAV 账户新增日程类型。
保留本地账户和 UOS ID 账户的日程类型新增功能。

Log: 限制第三方账户新增日程类型
PMS: TASK-393989
Influence: 禁止第三方 CalDAV 账户新增日程类型,避免创建无法同步或不应修改的类型,
同时保持本地账户和 UOS ID 账户的原有功能不变。
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次变更禁用第三方 CalDAV 账户的日程类型创建功能,逻辑清晰,实现合理,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 语法正确,逻辑清晰,边界处理完善。新增 setAddTypeEnabled 方法正确封装了启用/禁用逻辑,slotBtnAddItemClicked 中的防御性检查有效防止了禁用状态下的类型创建。showPopup 中将 hide() 改为 setVisible() 实现了双向可见性控制,修复了原有逻辑仅隐藏不恢复的缺陷。scheduledlg.cpp 中新增 m_accountItem->getAccount() 空指针检查提升了代码安全性。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: 代码结构清晰,注释完整。新增的 setAddTypeEnabled 方法合理封装了按钮和编辑状态的同步管理。settingdialog.cpp 中通过 findChild 获取 moreButton 并禁用的方式与现有代码风格一致。翻译文件中 '账号' 到 '账户' 的修改提升了术语一致性。qCDebug/qCWarning 日志输出符合 Qt 项目规范。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 性能良好,资源使用合理。所有变更均为简单的布尔判断和 UI 状态更新,算法复杂度合理,无性能瓶颈。findChild 调用仅在账户切换时触发,不在高频路径上,性能影响可忽略。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 存在0个安全漏洞。本次变更未引入任何安全风险。新增的空指针检查(m_accountItem->getAccount())提升了代码的防御性。CalDAV 账户类型判断使用枚举值比较,无注入风险。无硬编码密钥、无敏感信息泄露、无用户输入未校验问题。


💡 改进建议代码示例

// 本次代码变更质量优秀,无需改进示例。
// setAddTypeEnabled 方法设计清晰,防御性检查到位:

void JobTypeComboBox::setAddTypeEnabled(bool enabled)
{
    m_addTypeEnabled = enabled;
    if (!enabled && isEditable()) {
        setEditable(false);
        setIconSize(QSize(16, 16));
    }
    if (m_addBtn) {
        m_addBtn->setEnabled(enabled);
        if (!enabled) {
            m_addBtn->setHighlight(false);
        }
    }
}

// slotBtnAddItemClicked 中的防御性检查:
void JobTypeComboBox::slotBtnAddItemClicked()
{
    if (!m_addTypeEnabled) {
        qCDebug(ClientLogger) << "Adding schedule type is disabled";
        return;
    }
    // ...
}

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

@wyu71
wyu71 merged commit 7241061 into linuxdeepin:master Sep 11, 2026
17 of 18 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