Skip to content

Commit a14c2f6

Browse files
committed
feat: [Update Delivery] Merge update delivery related functionality into Control Center update client
Integrate the update delivery logic from v20 into the v25 Control Center update module: Add an update delivery master switch in the Control Center update advanced settings interface. When the switch is enabled, the interface displays two sub-items: Update Delivery - Upload Speed Limit and Update Delivery - Download Speed Limit. Each sub-item has its own control switch and speed limit input field. Simultaneously, call the relevant SetP2pEnable interface of lastore-daemon, which will attempt to start the upgrade-delivery system service during the next update check of lastore. The switches and input fields for Update Delivery - Upload Speed Limit and Update Delivery - Download Speed Limit independently control the enabling/disabling of upload/download speed limits and their specific values. These values are set by calling the SetDeliveryUploadSpeedLimit and SetDeliveryDownloadSpeedLimit interfaces of lastore-daemon, which are then applied by lastore. The update delivery speed limit configuration supports backend-driven busy/idle time speed limit policies via the update platform. When such policies are active, the Control Center will gray out the Update Delivery - Upload Speed Limit and Update Delivery - Download Speed Limit sub-items accordingly, preventing user modifications. Each operation on the master switch triggers a refresh of the status values for various sub-items. The status values are read from the upgrade-delivery service. Log: Integrate v20 update delivery functionality into v25 Task: https://pms.uniontech.com/task-view-387713.html Influence: New update delivery logic added to the Control Center update module feat: 【更新传递】控制中心更新客户端合入更新传递相关功能 v20的更新传递逻辑合入v25控制中心更新模块 1.添加更新传递总开关在控制中心更新高级设置界面。当开关打开时,界面展示更新传递-上传限速、更新传递-下载限速两个子项,每个子项有各自的控制开关和限速值输入框,同时调用lastore-daemon的SetP2pEnable相关接口,在lastore的下次检查更新时尝试拉起upgrade-delivery系统服务 2.更新传递-上传限速、更新传递-下载限速两个子项的开关和输入框各自控制上传、下载限速的开启和关闭以及具体数值,具体通过调用lastore-daemon的SetDeliveryUploadSpeedLimit和SetDeliveryDownloadSpeedLimit接口交由lastore来实际设置值。 3.更新传递的限速配置支持通过更新平台后端下发忙闲时的限速策略,此时控制中心会根据这一策略适时置灰更新传递-上传限速、更新传递-下载限速两个子项,禁止用户修改 4.每次操作总开关时会适时的刷新各种子项的状态值,具体是从upgrade-delivery服务中读取对应的属性值 Log: v20更新传递功能合入v25 Task: https://pms.uniontech.com/task-view-387713.html Influence: 控制中心更新模块新增更新传递逻辑
1 parent 80a07bc commit a14c2f6

16 files changed

Lines changed: 872 additions & 153 deletions
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* This file was generated by qdbusxml2cpp version 0.8
3+
*
4+
* qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd.
5+
*
6+
* This is an auto-generated file.
7+
* This file may have been hand-edited. Look for HAND-EDIT comments
8+
* before re-generating it.
9+
*/
10+
11+
#include "updateassistant.h"
12+
13+
/*
14+
* Implementation of interface class UpdateAssistant
15+
*/
16+
17+
UpdateAssistant::UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
18+
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
19+
, d_ptr(new UpdateAssistantPrivate)
20+
{
21+
QDBusConnection::systemBus().connect("org.deepin.upgradedelivery", "/org/deepin/upgradedelivery", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onPropertyChanged(QString, QVariantMap, QStringList)));
22+
}
23+
24+
UpdateAssistant::~UpdateAssistant()
25+
{
26+
}
27+
28+
void UpdateAssistant::onPropertyChanged(const QString& interfaceName,
29+
const QVariantMap& changedProperties,
30+
const QStringList& invalidatedProperties)
31+
{
32+
if (interfaceName != staticInterfaceName())
33+
return;
34+
35+
if (changedProperties.contains("UploadLimitSpeed")) {
36+
Q_EMIT UploadLimitSpeedChanged(uploadLimitSpeed());
37+
}
38+
if (changedProperties.contains("DownloadLimitSpeed")) {
39+
Q_EMIT DownloadLimitSpeedChanged(downloadLimitSpeed());
40+
}
41+
42+
return;
43+
}
44+
45+
void UpdateAssistant::CallQueued(const QString &callName, const QList<QVariant> &args)
46+
{
47+
if (d_ptr->m_waittingCalls.contains(callName)) {
48+
d_ptr->m_waittingCalls[callName] = args;
49+
return;
50+
}
51+
if (d_ptr->m_processingCalls.contains(callName)) {
52+
d_ptr->m_waittingCalls.insert(callName, args);
53+
} else {
54+
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
55+
connect(watcher, &QDBusPendingCallWatcher::finished, this, &UpdateAssistant::onPendingCallFinished);
56+
d_ptr->m_processingCalls.insert(callName, watcher);
57+
}
58+
}
59+
60+
void UpdateAssistant::onPendingCallFinished(QDBusPendingCallWatcher *w)
61+
{
62+
if (!w)
63+
return;
64+
w->deleteLater();
65+
const auto callName = d_ptr->m_processingCalls.key(w);
66+
Q_ASSERT(!callName.isEmpty());
67+
if (callName.isEmpty())
68+
return;
69+
d_ptr->m_processingCalls.remove(callName);
70+
if (!d_ptr->m_waittingCalls.contains(callName))
71+
return;
72+
const auto args = d_ptr->m_waittingCalls.take(callName);
73+
CallQueued(callName, args);
74+
}

src/common/dbus/updateassistant.h

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* This file was generated by qdbusxml2cpp version 0.8
3+
*
4+
* qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd.
5+
*
6+
* This is an auto-generated file.
7+
* Do not edit! All changes made to it will be lost.
8+
*/
9+
10+
#ifndef UPDATEASSISTANT_H
11+
#define UPDATEASSISTANT_H
12+
13+
#include <QtCore/QObject>
14+
#include <QtCore/QByteArray>
15+
#include <QtCore/QList>
16+
#include <QtCore/QMap>
17+
#include <QtCore/QString>
18+
#include <QtCore/QStringList>
19+
#include <QtCore/QVariant>
20+
#include <QtDBus/QtDBus>
21+
22+
//#include "module/updatedatastructs.h"
23+
24+
#define TRANSIMISSION_MAX_SPEED 102400
25+
#define TRANSIMISSION_MIN_SPEED 0
26+
#define TRANSIMISSION_SERVICE_ENABLED 1
27+
28+
class UpdateAssistantPrivate
29+
{
30+
public:
31+
UpdateAssistantPrivate() = default;
32+
33+
public:
34+
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
35+
QMap<QString, QList<QVariant>> m_waittingCalls;
36+
};
37+
38+
/*
39+
* Proxy class for interface org.deepin.updateassistant
40+
*/
41+
class UpdateAssistant: public QDBusAbstractInterface
42+
{
43+
Q_OBJECT
44+
public:
45+
static inline const char *staticInterfaceName()
46+
{ return "org.deepin.upgradedelivery"; }
47+
48+
public:
49+
UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);
50+
51+
~UpdateAssistant();
52+
53+
Q_PROPERTY(QString UploadLimitSpeed READ uploadLimitSpeed NOTIFY UploadLimitSpeedChanged)
54+
inline QString uploadLimitSpeed() const
55+
{ return qvariant_cast<QString>(internalPropGet("UploadLimitSpeed")); }
56+
57+
Q_PROPERTY(QString DownloadLimitSpeed READ downloadLimitSpeed NOTIFY DownloadLimitSpeedChanged)
58+
inline QString downloadLimitSpeed() const
59+
{ return qvariant_cast<QString>(internalPropGet("DownloadLimitSpeed")); }
60+
61+
public Q_SLOTS: // METHODS
62+
63+
inline QDBusPendingReply<void> SetUploadRateLimit(int speed)
64+
{
65+
QList<QVariant> argumentList;
66+
argumentList << QVariant::fromValue(speed);
67+
return asyncCallWithArgumentList(QStringLiteral("SetUploadRateLimit"), argumentList);
68+
}
69+
70+
inline QDBusPendingReply<void> SetDownloadRateLimit(int speed)
71+
{
72+
QList<QVariant> argumentList;
73+
argumentList << QVariant::fromValue(speed);
74+
return asyncCallWithArgumentList(QStringLiteral("SetDownloadRateLimit"), argumentList);
75+
}
76+
77+
Q_SIGNALS: // SIGNALS
78+
// begin property changed signals
79+
void propertyChanged(const QString &propertyName, const QVariant &value);
80+
void UploadLimitSpeedChanged(const QString & speed) const;
81+
void DownloadLimitSpeedChanged(const QString & speed) const;
82+
83+
public Q_SLOTS:
84+
void CallQueued(const QString &callName, const QList<QVariant> &args);
85+
86+
private Q_SLOTS:
87+
void onPendingCallFinished(QDBusPendingCallWatcher *w);
88+
void onPropertyChanged(const QString& interfaceName,
89+
const QVariantMap& changedProperties,
90+
const QStringList& invalidatedProperties);
91+
92+
private:
93+
UpdateAssistantPrivate *d_ptr;
94+
};
95+
96+
#endif // UPDATEASSISTANT_H

src/common/dbus/updatedbusproxy.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ QString UpdateDBusProxy::updateStatus()
207207
return qvariant_cast<QString>(m_managerInter->property("UpdateStatus"));
208208
}
209209

210+
bool UpdateDBusProxy::p2PUpdateEnable()
211+
{
212+
return qvariant_cast<bool>(m_managerInter->property("P2PUpdateEnable"));
213+
}
214+
215+
bool UpdateDBusProxy::p2PUpdateSupport()
216+
{
217+
return qvariant_cast<bool>(m_managerInter->property("P2PUpdateSupport"));
218+
}
219+
210220
bool UpdateDBusProxy::immutableAutoRecovery()
211221
{
212222
return qvariant_cast<bool>(m_managerInter->property("ImmutableAutoRecovery"));
@@ -387,6 +397,36 @@ QDBusPendingReply<QString> UpdateDBusProxy::GetUpdateLogs(int updateType)
387397
return m_managerInter->asyncCallWithArgumentList(QStringLiteral("GetUpdateLogs"), argumentList);
388398
}
389399

400+
QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryEnable(bool enable)
401+
{
402+
qCDebug(logCommon) << "Setting upgrade delivery enable :" << enable;
403+
QList<QVariant> argumentList;
404+
argumentList << QVariant::fromValue(enable);
405+
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetP2PUpdateEnable"), argumentList);
406+
}
407+
408+
QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit)
409+
{
410+
qCDebug(logCommon) << "Setting upgrade delivery download speed limit : " << downloadLimit;
411+
QList<QVariant> argumentList;
412+
argumentList << QVariant::fromValue(downloadLimit);
413+
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryDownloadSpeedLimit"), argumentList);
414+
}
415+
416+
QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit)
417+
{
418+
qCDebug(logCommon) << "Setting upgrade delivery upload speed limit : " << uploadLimit;
419+
QList<QVariant> argumentList;
420+
argumentList << QVariant::fromValue(uploadLimit);
421+
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryUploadSpeedLimit"), argumentList);
422+
}
423+
424+
QDBusPendingReply<void> UpdateDBusProxy::ClearUpgradeDeliveryCache()
425+
{
426+
qCDebug(logCommon) << "Clearing upgrade delivery cache";
427+
return m_updateInter->asyncCall(QStringLiteral("CleanTransmissionFiles"));
428+
}
429+
390430
QDBusPendingReply<void> UpdateDBusProxy::SetIdleDownloadConfig(const QString& config)
391431
{
392432
qCDebug(logCommon) << "Setting idle download config:" << config;

src/common/dbus/updatedbusproxy.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class UpdateDBusProxy : public QObject
7070
Q_PROPERTY(bool ImmutableAutoRecovery READ immutableAutoRecovery NOTIFY ImmutableAutoRecoveryChanged)
7171
bool immutableAutoRecovery();
7272

73+
Q_PROPERTY(bool P2PUpdateEnable READ p2PUpdateEnable NOTIFY P2PUpdateEnableChanged)
74+
bool p2PUpdateEnable();
75+
76+
Q_PROPERTY(bool P2PUpdateSupport READ p2PUpdateSupport NOTIFY P2PUpdateSupportChanged)
77+
bool p2PUpdateSupport();
78+
7379
QString hardwareId();
7480

7581
quint64 checkUpdateMode();
@@ -103,6 +109,10 @@ class UpdateDBusProxy : public QObject
103109
QDBusPendingReply<void> SetDownloadSpeedLimit(const QString &config);
104110
QDBusPendingReply<qlonglong> QueryAllSizeWithSource(int updateType);
105111
QDBusPendingReply<QString> GetUpdateLogs(int updateType);
112+
QDBusPendingReply<void> SetUpgradeDeliveryEnable(bool enable);
113+
QDBusPendingReply<void> SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit);
114+
QDBusPendingReply<void> SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit);
115+
QDBusPendingReply<void> ClearUpgradeDeliveryCache();
106116
QDBusPendingReply<void> SetIdleDownloadConfig(const QString &config);
107117
QDBusPendingReply<QDBusObjectPath> PrepareDistUpgradePartly(int updateMode);
108118
QDBusPendingReply<QDBusObjectPath> fixError(const QString &errorType);
@@ -137,6 +147,7 @@ class UpdateDBusProxy : public QObject
137147
void AutoInstallUpdatesChanged(bool value) const;
138148
void AutoInstallUpdateTypeChanged(qulonglong value) const;
139149
void MirrorSourceChanged(const QString &value) const;
150+
void UpgradeDeliveryEnabledChanged(bool value) const;
140151
void AutoCheckUpdatesChanged(bool value) const;
141152
void ClassifiedUpdatablePackagesChanged(LastoreUpdatePackagesInfo value) const;
142153

@@ -146,6 +157,8 @@ class UpdateDBusProxy : public QObject
146157
void UpdateModeChanged(qulonglong value) const;
147158
void UpdateStatusChanged(QString value) const;
148159
void ImmutableAutoRecoveryChanged(bool value) const;
160+
void P2PUpdateEnableChanged(bool value) const;
161+
void P2PUpdateSupportChanged(bool value) const;
149162
void managerInterServiceValidChanged(bool value) const;
150163

151164
// Power

0 commit comments

Comments
 (0)