Skip to content

Commit 80a07bc

Browse files
ut005973xionglinlin
authored andcommitted
feat: [Update Client] Merge backend logic for control center update with private update module
Integrate the private update logic from v20 into the v25 control center update module. 1. Functionality is enabled based on the `intranet-update` configuration item under `lastore-daemon`. When disabled, the public update interface of the control center is displayed; when enabled, the interface switches to the private update interface. 2. The private update interface is largely similar to the public interface, with the following key differences: a. The update settings entry is hidden — enterprise-level update users are not allowed to modify update-related configurations. b. The process from checking for updates to downloading is atomic. Enterprise update users cannot refuse downloads, and downloads cannot be canceled during the process. c. After download completion, a re-check button is added. d. For non-mandatory updates, users can choose the update method after download completion: update immediately or update after shutdown. e. A dedicated private update tray is added to provide more detailed download/update status information. The tray is loaded only when the private update switch is enabled. Log: Integrate v20 private update logic into v25 Story: https://pms.uniontech.com/story-view-40191.html Influence: Added private update logic to the control center update module feat: 【更新客户端】更新客户端后端合并-控制中心更新客户端合入私有化更新模块逻辑 v20的私有化更新逻辑合入v25控制中心更新模块 1.通过lastore-daemon下面的intranet-update配置项决定功能私有化功能是否开启,未开启时仍为控制中心公网更新模块界面,开启后切换为私有化更新界面 2.私有化更新界面与公网界面大致相同,主要有以下区别点: a.屏蔽更新设置入口,企业级更新的用户不允许私自修改更新相关配置 b.私有化更新的检查更新到下载流程为原子化操作,企业及更新用户无拒绝下载的权利,下载过程中不允许取消 c.下载完成后添加重复检查按钮 d.若为非强制更新类型的任务,下载完成后允许用户自行决定更新方式,立即更新or关机后更新 e.添加私有化专属托盘,提供更详细的下载更新状态,仅在私有化开关开启时加载托盘 Log: v20私有化更新合入v25 Story: https://pms.uniontech.com/story-view-40191.html Influence: 控制中心更新模块新增私有化更新逻辑
1 parent 69e1637 commit 80a07bc

31 files changed

Lines changed: 2037 additions & 19 deletions

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2025-2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

@@ -40,4 +40,5 @@ add_subdirectory("src/dde-update")
4040
add_subdirectory("src/dde-abrecovery")
4141
add_subdirectory("src/dcc-update-plugin")
4242
add_subdirectory("src/dock-update-plugin")
43+
add_subdirectory("src/private-lastore-tray")
4344

src/common/dbus/updatedbusproxy.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44
#include "updatedbusproxy.h"
@@ -428,6 +428,14 @@ QDBusPendingReply<void> UpdateDBusProxy::GetUpdateDetails(int fd, bool realtime)
428428
return m_managerInter->asyncCallWithArgumentList(QStringLiteral("GetUpdateDetails"), argumentList);
429429
}
430430

431+
QDBusPendingReply<void> UpdateDBusProxy::SetShutdownForceUpdate(bool isShutdownUpdate)
432+
{
433+
qCDebug(logCommon) << "Setting shutdown force update , isShutdownUpdate:" << isShutdownUpdate;
434+
QList<QVariant> argumentList;
435+
argumentList << QVariant::fromValue(isShutdownUpdate);
436+
return m_managerInter->asyncCallWithArgumentList(QStringLiteral("SetShutdownForceUpdate"), argumentList);
437+
}
438+
431439
bool UpdateDBusProxy::onBattery()
432440
{
433441
return qvariant_cast<bool>(m_powerInter->property("OnBattery"));

src/common/dbus/updatedbusproxy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44
#ifndef UPDATEDBUSPROXY_H
@@ -108,7 +108,7 @@ class UpdateDBusProxy : public QObject
108108
QDBusPendingReply<QDBusObjectPath> fixError(const QString &errorType);
109109
QDBusPendingCall CheckUpgrade(int checkMode, int checkOrder);
110110
QDBusPendingReply<void> GetUpdateDetails(int fd, bool realtime);
111-
111+
QDBusPendingReply<void> SetShutdownForceUpdate(bool isShutdownUpdate);
112112

113113
// Power
114114
bool onBattery();

src/dcc-update-plugin/operation/updatemodel.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2011 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -72,6 +72,7 @@ UpdateModel::UpdateModel(QObject* parent)
7272
, m_backupFailedTips("")
7373
, m_installLog("")
7474
, m_isUpdatable(false)
75+
, m_isPrivateUpdate(false)
7576
, m_securityUpdateEnabled(false)
7677
, m_thirdPartyUpdateEnabled(false)
7778
, m_updateMode(UpdateType::Invalid)
@@ -969,6 +970,17 @@ void UpdateModel::setIsUpdatable(bool isUpdatable)
969970
Q_EMIT isUpdatableChanged(isUpdatable);
970971
}
971972

973+
void UpdateModel::setIsPrivateUpdate(bool isPrivateUpdate)
974+
{
975+
qCDebug(logDccUpdatePlugin) << "Setting is private update: " << isPrivateUpdate;
976+
if (m_isPrivateUpdate == isPrivateUpdate) {
977+
return;
978+
}
979+
980+
m_isPrivateUpdate = isPrivateUpdate;
981+
Q_EMIT isPrivateUpdateChanged(isPrivateUpdate);
982+
}
983+
972984
UpdatesStatus UpdateModel::updateStatus(ControlPanelType type) const
973985
{
974986
qCDebug(logDccUpdatePlugin) << "Getting update status for control panel type:" << type;

src/dcc-update-plugin/operation/updatemodel.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2011 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2011 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -29,6 +29,7 @@ class UpdateModel : public QObject
2929
Q_PROPERTY(bool batterIsOK READ batterIsOK NOTIFY batterIsOKChanged FINAL)
3030
Q_PROPERTY(int lastStatus READ lastStatus NOTIFY lastStatusChanged FINAL)
3131
Q_PROPERTY(bool isUpdatable READ isUpdatable NOTIFY isUpdatableChanged FINAL)
32+
Q_PROPERTY(bool isPrivateUpdate READ isPrivateUpdate NOTIFY isPrivateUpdateChanged FINAL)
3233

3334
// ---------------检查更新页面数据---------------
3435
Q_PROPERTY(bool showCheckUpdate READ showCheckUpdate NOTIFY showCheckUpdateChanged FINAL)
@@ -234,6 +235,9 @@ class UpdateModel : public QObject
234235
bool isUpdatable() const { return m_isUpdatable; }
235236
void setIsUpdatable(bool isUpdatable);
236237

238+
bool isPrivateUpdate() const { return m_isPrivateUpdate; }
239+
void setIsPrivateUpdate(bool isPrivateUpdate);
240+
237241
UpdatesStatus updateStatus(ControlPanelType type) const;
238242
UpdatesStatus updateStatus(UpdateType type) const;
239243
QList<UpdateType> updateTypesList(ControlPanelType type) const;
@@ -369,6 +373,7 @@ public slots:
369373

370374
void updateInfoChanged(UpdateType);
371375
void isUpdatableChanged(const bool isUpdatablePackages);
376+
void isPrivateUpdateChanged(const bool isPrivateUpdate);
372377
void updateStatusChanged(ControlPanelType, UpdatesStatus);
373378
void controlTypeChanged();
374379
void lastErrorChanged(UpdatesStatus, UpdateErrorType);
@@ -443,6 +448,7 @@ public slots:
443448
QByteArray m_updateStatus; // lastore daemon发上来的原始json数据
444449

445450
bool m_isUpdatable; // 是否有包可更新
451+
bool m_isPrivateUpdate; //当前是否接入私有化更新
446452
QMap<ControlPanelType, QPair<UpdatesStatus, QList<UpdateType>>> m_controlStatusMap;
447453
QMap<UpdatesStatus, int> m_waitingStatusMap;
448454

src/dcc-update-plugin/operation/updatework.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "common/common/logwatcherhelper.h"
77
#include "utils.h"
88
#include "dconfigwatcher.h"
9+
#include "common/common/dconfig_helper.h"
910
#include "updateloghelper.h"
1011

1112
#include <QDBusError>
@@ -221,6 +222,7 @@ void UpdateWorker::activate()
221222
refreshLastTimeAndCheckCircle();
222223
initTestingChannel();
223224

225+
m_model->setIsPrivateUpdate(DConfigHelper::instance()->getConfig("org.deepin.dde.lastore", "org.deepin.dde.lastore", "","intranet-update", false).toString() == "true");
224226
m_model->setUpdateMode(m_updateInter->updateMode());
225227
m_model->setCheckUpdateMode(m_updateInter->checkUpdateMode());
226228
m_model->setSecurityUpdateEnabled(DConfigWatcher::instance()->getValue(DConfigWatcher::update, "updateSafety").toString() != "Hidden");
@@ -494,6 +496,12 @@ void UpdateWorker::doCheckUpdates()
494496
});
495497
}
496498

499+
void UpdateWorker::reCheckWithUi()
500+
{
501+
m_model->setShowCheckUpdate(true);
502+
doCheckUpdates();
503+
}
504+
497505
void UpdateWorker::setCheckUpdatesJob(const QString& jobPath)
498506
{
499507
qCInfo(logDccUpdatePlugin) << "Set check updates job";
@@ -787,6 +795,12 @@ void UpdateWorker::modalUpgrade(bool rebootAfterUpgrade)
787795
}
788796
}
789797

798+
void UpdateWorker::setShutdownAndUpgrade(bool isShutdownUpdate)
799+
{
800+
qCInfo(logDccUpdatePlugin) << "request shutdown upgrade, upgrade after shutdown:" << isShutdownUpdate;
801+
m_updateInter->SetShutdownForceUpdate(isShutdownUpdate);
802+
}
803+
790804
void UpdateWorker::setBackupJob(const QString& jobPath)
791805
{
792806
qCInfo(logDccUpdatePlugin) << "Create backup upgrade job, path:" << jobPath;

src/dcc-update-plugin/operation/updatework.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class UpdateWorker : public QObject
3737
// 检查更新
3838
Q_INVOKABLE void checkNeedDoUpdates();
3939
Q_INVOKABLE void doCheckUpdates();
40+
Q_INVOKABLE void reCheckWithUi();
4041
void setCheckUpdatesJob(const QString& jobPath);
4142
void createCheckUpdateJob(const QString& jobPath);
4243
void refreshLastTimeAndCheckCircle();
@@ -54,6 +55,7 @@ class UpdateWorker : public QObject
5455
Q_INVOKABLE void doUpgrade(int updateTypes, bool doBackup);
5556
Q_INVOKABLE void reStart();
5657
Q_INVOKABLE void modalUpgrade(bool rebootAfterUpgrade = true);
58+
Q_INVOKABLE void setShutdownAndUpgrade(bool isShutdownUpdate = false);
5759
void setBackupJob(const QString& jobPath);
5860
void setDistUpgradeJob(const QString& jobPath);
5961
void updateSystemVersion();

src/dcc-update-plugin/qml/UpdateControl.qml

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd.
22
// SPDX-License-Identifier: GPL-3.0-or-later
33
import QtQuick
44
import QtQuick.Controls
@@ -118,14 +118,115 @@ ColumnLayout {
118118

119119
Repeater {
120120
model: btnActions
121-
delegate: D.Button {
121+
delegate: Loader {
122+
id: buttonLoader
122123
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
123-
text: modelData
124-
font: D.DTK.fontManager.t6
125124
visible: modelData.length !== 0 && !initAnimation.visible
126125
enabled: updatelistModel.model.isUpdateEnable
127-
onClicked: {
128-
rootLayout.btnClicked(index, updateListModels.getAllUpdateType())
126+
127+
Connections {
128+
target: dccData.model()
129+
function onIsPrivateUpdateChanged() {
130+
updateButtonType()
131+
}
132+
function onIsUpdateDisabledChanged() {
133+
updateButtonType()
134+
}
135+
function onShowCheckUpdateChanged() {
136+
updateButtonType()
137+
}
138+
}
139+
140+
Component.onCompleted: {
141+
updateButtonType()
142+
}
143+
144+
function updateButtonType() {
145+
var model = dccData.model()
146+
if (!model) {
147+
console.log("Model not ready yet")
148+
return
149+
}
150+
if (index === 1) {
151+
buttonLoader.sourceComponent = normalButtonComponent
152+
} else if (model.isPrivateUpdate &&
153+
!model.isUpdateDisabled &&
154+
!model.showCheckUpdate &&
155+
model.preInstallListModel.anyVisible) {
156+
buttonLoader.sourceComponent = dropdownButtonComponent
157+
} else {
158+
// 默认使用普通按钮
159+
buttonLoader.sourceComponent = normalButtonComponent
160+
}
161+
}
162+
163+
Component {
164+
id: normalButtonComponent
165+
D.Button {
166+
text: modelData
167+
font: D.DTK.fontManager.t6
168+
onClicked: {
169+
rootLayout.btnClicked(index, updateListModels.getAllUpdateType())
170+
}
171+
}
172+
}
173+
174+
Component {
175+
id: dropdownButtonComponent
176+
Item {
177+
implicitWidth: button.implicitWidth
178+
implicitHeight: button.implicitHeight
179+
180+
enum InstallType {
181+
Now,
182+
Shutdown
183+
}
184+
185+
property int curType: DropdownButton.InstallType.Now
186+
187+
signal requestUpdateNow()
188+
signal requestUpdateShutdown()
189+
190+
D.Button {
191+
id: button
192+
text: qsTr("Install")
193+
194+
Menu {
195+
id: contextMenu
196+
197+
MenuItem {
198+
text: qsTr("Install Now")
199+
onClicked: {
200+
dccData.work().setShutdownAndUpgrade(false)
201+
dccData.work().doUpgrade(updateListModels.getAllUpdateType(), true)
202+
}
203+
}
204+
205+
MenuItem {
206+
text: qsTr("Install Shutdown")
207+
onClicked: {
208+
dccData.work().setShutdownAndUpgrade(true)
209+
}
210+
}
211+
}
212+
213+
// 点击按钮显示菜单
214+
onClicked: {
215+
contextMenu.open()
216+
}
217+
}
218+
219+
// 连接内部信号到外部
220+
Connections {
221+
target: parent
222+
function onRequestUpdateNow() {
223+
rootLayout.btnClicked(index, 0)
224+
}
225+
function onRequestUpdateShutdown() {
226+
rootLayout.btnClicked(index, 1)
227+
}
228+
}
229+
}
129230
}
130231
}
131232
}
@@ -180,7 +281,7 @@ ColumnLayout {
180281
icon.height: 24
181282
implicitWidth: 24
182283
implicitHeight: 24
183-
visible: isDownloading
284+
visible: isDownloading && !dccData.model().isPrivateUpdate
184285

185286
onClicked: {
186287
rootLayout.closeDownload()

src/dcc-update-plugin/qml/UpdateMain.qml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 - 2027 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd.
22
// SPDX-License-Identifier: GPL-3.0-or-later
33

44
import QtQuick 2.15
@@ -291,7 +291,10 @@ DccObject {
291291
page: UpdateControl {
292292
updateListModels: dccData.model().preInstallListModel
293293
updateTitle: qsTr("Update download completed")
294-
btnActions: [ qsTr("Install updates") ]
294+
btnActions: dccData.model().isPrivateUpdate ? [
295+
qsTr("Install updates"),
296+
qsTr("Check Again")
297+
] : [qsTr("Install updates")]
295298
updateTips: {
296299
if (!dccData.model().batterIsOK) {
297300
return qsTr("The battery capacity is lower than 60%. To get successful updates, please plug in.")
@@ -302,8 +305,12 @@ DccObject {
302305
updateListEnable: !dccData.model().upgradeWaiting
303306

304307
onBtnClicked: function(index, updateType) {
305-
updateSelectDialog.updateType = updateType
306-
updateSelectDialog.show()
308+
if (index === 0) {
309+
updateSelectDialog.updateType = updateType
310+
updateSelectDialog.show()
311+
} else if (index === 1) {
312+
dccData.work().reCheckWithUi();
313+
}
307314
}
308315

309316
UpdateSelectDialog {
@@ -367,7 +374,7 @@ DccObject {
367374

368375
page: UpdateControl {
369376
updateListModels: dccData.model().preUpdatelistModel
370-
updateTitle: !dccData.model().downloadWaiting ? qsTr("Updates Available") : qsTr("Downloading updates...")
377+
updateTitle: !dccData.model().downloadWaiting || dccData.model().isPrivateUpdate ? qsTr("Updates Available") : qsTr("Downloading updates...")
371378
btnActions: [ qsTr("Download") ]
372379
updateTips: qsTr("Update size: ") + dccData.model().preUpdatelistModel.downloadSize
373380
busyState: dccData.model().downloadWaiting
@@ -376,6 +383,12 @@ DccObject {
376383
onBtnClicked: function(index, updateType) {
377384
dccData.work().startDownload(updateType)
378385
}
386+
387+
Component.onCompleted: {
388+
if (dccData.model().isPrivateUpdate) {
389+
dccData.work().startDownload(1)
390+
}
391+
}
379392
}
380393
}
381394

@@ -387,7 +400,7 @@ DccObject {
387400
description: qsTr("Configure Update settings、Security Updates、Auto Download Updates and Updates Notification")
388401
icon: "update_set"
389402
weight: 120
390-
visible: dccData.model().systemActivation
403+
visible: dccData.model().systemActivation && !dccData.model().isPrivateUpdate
391404

392405
UpdateSetting {}
393406
}

0 commit comments

Comments
 (0)