Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/dcc-update-plugin/operation/updatedatastructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,10 @@ struct UpgradeSpeedLimitConfig {
QDateTime endTime; // 结束时间

bool ifInOnlineLimit() const {
if (limitType != 3) {
return false;
}

if (!startTime.isValid() || !endTime.isValid()) {
return false;
}
if (limitType == 2)
return true;

QDateTime currentTime = QDateTime::currentDateTime();
return currentTime >= startTime && currentTime <= endTime;
return false;
}

bool shouldLimitRate() const {
Expand Down Expand Up @@ -185,7 +179,6 @@ struct UpgradeSpeedLimitConfig {

static UpgradeSpeedLimitConfig fromJson(const QByteArray& configStr)
{
qWarning() << "xiongbo123 fromJson: " << configStr;
UpgradeSpeedLimitConfig config;
QJsonParseError jsonParseError;
const QJsonDocument doc = QJsonDocument::fromJson(configStr, &jsonParseError);
Expand Down Expand Up @@ -318,6 +311,15 @@ struct LastoreDaemonUpdateStatus {
}
};

inline QString transferDeliveryConfigToLastoreDeliveryConfig(const QString& deliveryConfig)
{
LastoreUpgradeSpeedLimitConfig lastoreDeliveryConfig;
lastoreDeliveryConfig.isOnlineSpeedLimit = UpgradeSpeedLimitConfig::fromJson(deliveryConfig.toUtf8()).ifInOnlineLimit();
lastoreDeliveryConfig.speedLimitEnabled = UpgradeSpeedLimitConfig::fromJson(deliveryConfig.toUtf8()).shouldLimitRate();
lastoreDeliveryConfig.limitSpeed = QString::number(UpgradeSpeedLimitConfig::fromJson(deliveryConfig.toUtf8()).currentRate);
return lastoreDeliveryConfig.toJson();
}

const int INSTALLATION_IS_READY = 1 << 0; // 是否可以安装
const int UPDATE_IS_DISABLED = 1 << 1; // 更新功能是否被禁用
struct LastoreDaemonDConfigStatusHelper {
Expand Down
1 change: 1 addition & 0 deletions src/dcc-update-plugin/operation/updateloghelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ QString UpdateLogHelper::sumCveLevelUp(const QMap<VulLevel, int>& vulCount)

void UpdateLogHelper::handleUpdateLog(const QString &log)
{
qCDebug(logDccUpdatePlugin) << "Handling update log: " << log;
qCDebug(logDccUpdatePlugin) << "Handling update log, length:" << log.length();
const QJsonDocument& doc = QJsonDocument::fromJson(log.toLocal8Bit());
const QJsonObject& rootObj = doc.object();
Expand Down
21 changes: 18 additions & 3 deletions src/dcc-update-plugin/operation/updatemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,9 +1169,11 @@ DownloadSpeedLimitConfig UpdateModel::speedLimitConfig() const
return DownloadSpeedLimitConfig::fromJson(m_speedLimitConfig);
}

void UpdateModel::setSpeedLimitConfig(const QByteArray& config)
void UpdateModel::setSpeedLimitConfig(const QByteArray& config, bool isFromQml)
{
qCDebug(logDccUpdatePlugin) << "Set speed limit config:" << config;
if (DownloadSpeedLimitConfig::fromJson(m_speedLimitConfig).isOnlineSpeedLimit && isFromQml)
return;
if (m_speedLimitConfig == config)
return;

Expand Down Expand Up @@ -1523,7 +1525,6 @@ void UpdateModel::onUpdatePropertiesChanged(const QString& interfaceName, const
{
qCDebug(logDccUpdatePlugin) << "Update properties changed for interface:" << interfaceName << "properties count:" << changedProperties.size();
Q_UNUSED(invalidatedProperties)

if (interfaceName == "org.deepin.dde.Lastore1.Manager") {
qCDebug(logDccUpdatePlugin) << "Handling Lastore Manager property changes";
if (changedProperties.contains("CheckUpdateMode")) {
Expand Down Expand Up @@ -1561,7 +1562,21 @@ void UpdateModel::onUpdatePropertiesChanged(const QString& interfaceName, const

if (changedProperties.contains("P2PUpdateEnable")) {
qCDebug(logDccUpdatePlugin) << "P2PUpdateEnable property changed";
setP2PUpdateEnabled(changedProperties.value("P2PUpdateEnable").toBool());
setUpgradeDeliveryEnable(changedProperties.value("P2PUpdateEnable").toBool());
}
}

if (interfaceName == "org.deepin.upgradedelivery") {
qCDebug(logDccUpdatePlugin) << "Handling upgrade delivery property changes";
if (changedProperties.contains("DownloadLimitSpeed")) {
qCDebug(logDccUpdatePlugin) << "P2PUpgradeDownloadSpeedLimitConfig property changed";
qCDebug(logDccUpdatePlugin) << "P2PUpgradeDownloadSpeedLimitConfig property changed " << changedProperties.value("DownloadLimitSpeed");
setUpgradeDownloadSpeedLimitConfig(transferDeliveryConfigToLastoreDeliveryConfig(changedProperties.value("DownloadLimitSpeed").toByteArray()).toUtf8());
}

if (changedProperties.contains("UploadLimitSpeed")) {
qCDebug(logDccUpdatePlugin) << "P2PUpgradeUploadSpeedLimitConfig property changed";
setUpgradeUploadSpeedLimitConfig(transferDeliveryConfigToLastoreDeliveryConfig(changedProperties.value("UploadLimitSpeed").toByteArray()).toUtf8());
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/dcc-update-plugin/operation/updatemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class UpdateModel : public QObject
Q_PROPERTY(QString upgradeDownloadSpeedCurrentRate READ upgradeDownloadSpeedCurrentRate NOTIFY upgradeDownloadSpeedLimitConfigChanged FINAL)
Q_PROPERTY(QString upgradeDownloadSpeedLimitRate READ upgradeDownloadSpeedLimitRate NOTIFY upgradeDownloadSpeedLimitConfigChanged FINAL)
Q_PROPERTY(bool upgradeDownloadSpeedEnable READ upgradeDownloadSpeedEnable NOTIFY upgradeDownloadSpeedLimitConfigChanged FINAL)
Q_PROPERTY(bool upgradeDownloadSpeedIsOnline READ upgradeDownloadSpeedIsOnline NOTIFY upgradeDownloadSpeedLimitConfigChanged FINAL)
Q_PROPERTY(QString upgradeUploadSpeedCurrentRate READ upgradeUploadSpeedCurrentRate NOTIFY upgradeUploadSpeedLimitConfigChanged FINAL)
Q_PROPERTY(QString upgradeUploadSpeedLimitRate READ upgradeUploadSpeedLimitRate NOTIFY upgradeUploadSpeedLimitConfigChanged FINAL)
Q_PROPERTY(bool upgradeUploadSpeedEnable READ upgradeUploadSpeedEnable NOTIFY upgradeUploadSpeedLimitConfigChanged FINAL)
Expand Down Expand Up @@ -282,7 +283,7 @@ class UpdateModel : public QObject
bool downloadIsOnlineSpeedLimit() const;
QString downloadSpeedLimitSize() const;
DownloadSpeedLimitConfig speedLimitConfig() const;
void setSpeedLimitConfig(const QByteArray &config);
void setSpeedLimitConfig(const QByteArray &config, bool isFromQml = false);

void setUpgradeDownloadSpeedLimitConfig(const QByteArray& config, bool needEmitSignal = true);
QString upgradeDownloadSpeedCurrentRate() const;
Expand Down
20 changes: 3 additions & 17 deletions src/dcc-update-plugin/operation/updatework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ void UpdateWorker::setDownloadSpeedLimitEnabled(bool enable)
config.downloadSpeedLimitEnabled = enable;
config.isOnlineSpeedLimit = false;
// dbus返回需要1s,导致界面更新慢,这里直接先更新model
m_model->setSpeedLimitConfig(config.toJson().toUtf8());
m_model->setSpeedLimitConfig(config.toJson().toUtf8(), true);
setDownloadSpeedLimitConfig(config.toJson());
}

Expand Down Expand Up @@ -1294,17 +1294,6 @@ void UpdateWorker::initTestingChannel()
});
}

QString UpdateWorker::transferDeliveryConfigToLastoreDeliveryConfig(const QString& deliveryConfig)
{
qCDebug(logDccUpdatePlugin) << "xiongbo55555 transferDeliveryConfigToLastoreDeliveryConfig " << deliveryConfig;
LastoreUpgradeSpeedLimitConfig lastoreDeliveryConfig;
lastoreDeliveryConfig.isOnlineSpeedLimit = UpgradeSpeedLimitConfig::fromJson(deliveryConfig.toUtf8()).ifInOnlineLimit();
lastoreDeliveryConfig.speedLimitEnabled = UpgradeSpeedLimitConfig::fromJson(deliveryConfig.toUtf8()).shouldLimitRate();
lastoreDeliveryConfig.limitSpeed = QString::number(UpgradeSpeedLimitConfig::fromJson(deliveryConfig.toUtf8()).currentRate);
qCDebug(logDccUpdatePlugin) << "xiongbo55555 " << lastoreDeliveryConfig.toJson();
return lastoreDeliveryConfig.toJson();
}

void UpdateWorker::refreshUpgradeDeliveryInfo()
{
qCDebug(logDccUpdatePlugin) << "Refresh upgrade delivery info";
Expand Down Expand Up @@ -1786,11 +1775,10 @@ void UpdateWorker::setUpgradeDeliveryEnabled(bool enabled, bool fromRetryDialog)
//设置更新传递下载限速
void UpdateWorker::setUpgradeDeliveryDownloadLimitSpeed(const QString& speed, bool enable)
{
qCInfo(logDccUpdatePlugin) << "xiongbo123 speed: " << speed;
LastoreUpgradeSpeedLimitConfig downloadSpeedLimitConfig;
downloadSpeedLimitConfig.isOnlineSpeedLimit = false;
downloadSpeedLimitConfig.speedLimitEnabled = enable;
downloadSpeedLimitConfig.limitSpeed = QString::number(speed.toInt() * 1024);
downloadSpeedLimitConfig.limitSpeed = speed;
qCInfo(logDccUpdatePlugin) << "Set upgrade download speed limit: " << downloadSpeedLimitConfig.toJson();
auto watcher = new QDBusPendingCallWatcher(m_updateInter->SetUpgradeDeliveryDownloadSpeedLimit(downloadSpeedLimitConfig.toJson()), this);
connect(watcher, &QDBusPendingCallWatcher::finished, [watcher, this, downloadSpeedLimitConfig] {
Expand All @@ -1801,7 +1789,6 @@ void UpdateWorker::setUpgradeDeliveryDownloadLimitSpeed(const QString& speed, bo
Q_EMIT upgradeDeliveryConfigSetFailed();
return;
}
m_model->setUpgradeDownloadSpeedLimitConfig(downloadSpeedLimitConfig.toJson().toUtf8(), false);
});
}

Expand All @@ -1811,7 +1798,7 @@ void UpdateWorker::setUpgradeDeliveryUploadLimitSpeed(const QString& speed, bool
LastoreUpgradeSpeedLimitConfig uploadSpeedLimitConfig;
uploadSpeedLimitConfig.isOnlineSpeedLimit = false;
uploadSpeedLimitConfig.speedLimitEnabled = enable;
uploadSpeedLimitConfig.limitSpeed = QString::number(speed.toInt() * 1024);
uploadSpeedLimitConfig.limitSpeed = speed;
qCInfo(logDccUpdatePlugin) << "Set upgrade upload speed limit: " << uploadSpeedLimitConfig.toJson();
auto watcher = new QDBusPendingCallWatcher(m_updateInter->SetUpgradeDeliveryUploadSpeedLimit(uploadSpeedLimitConfig.toJson()), this);
connect(watcher, &QDBusPendingCallWatcher::finished, [watcher, this, uploadSpeedLimitConfig] {
Expand All @@ -1822,7 +1809,6 @@ void UpdateWorker::setUpgradeDeliveryUploadLimitSpeed(const QString& speed, bool
Q_EMIT upgradeDeliveryConfigSetFailed();
return;
}
m_model->setUpgradeUploadSpeedLimitConfig(uploadSpeedLimitConfig.toJson().toUtf8(), false);
});
}

Expand Down
1 change: 0 additions & 1 deletion src/dcc-update-plugin/operation/updatework.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class UpdateWorker : public QObject
void setRemovePackageJob(const QString& jobPath);
QString getServiceUrlByRegion();
void refreshUpgradeDeliveryInfo();
QString transferDeliveryConfigToLastoreDeliveryConfig(const QString& deliveryConfig);

Q_INVOKABLE bool openUrl(const QString& url);
Q_INVOKABLE void onRequestRetry(int type, int updateTypes);
Expand Down
23 changes: 19 additions & 4 deletions src/dcc-update-plugin/qml/UpdateSetting.qml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ DccObject {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: qsTr("Failed to change Upgrade Delivery setting")
text: root.pendingUpgradeDeliveryEnabled ? qsTr("Update Delivery Optimization service exception. Failed to enable.")
: qsTr("Update Delivery Optimization service exception. Failed to disable.")
}

Item {
Expand All @@ -122,7 +123,7 @@ DccObject {
focus: upgradeDeliverySetEnableFailedDialog.visible
onClicked: {
upgradeDeliverySetEnableFailedDialog.close()
dccData.work().setUpgradeDeliveryEnabled(!root.pendingUpgradeDeliveryEnabled, true)
dccData.work().setUpgradeDeliveryEnabled(root.pendingUpgradeDeliveryEnabled, true)
}
}

Expand Down Expand Up @@ -335,7 +336,7 @@ DccObject {
name: "upgradeDeliverySwitch"
parentName: "upgradeDeliveryGrp"
displayName: qsTr("Upgrade Delivery")
description: qsTr("Turning this on may cause your device to send previously downloaded system updates to devices on the local network. Turning this off will clear files cached for update delivery on restart")
description: qsTr("When enabled, your device may share previously downloaded system updates with other devices on your local network.When you turn it off, cached files from update delivery will be cleared during the next restart.")
weight: 10
enabled: !dccData.model().updateProhibited
pageType: DccObject.Editor
Expand All @@ -361,13 +362,20 @@ DccObject {
}

DccObject {
id: upgradeDeliveryUploadLimitSetting
name: "upgradeDeliveryUploadLimitSetting"
parentName: "upgradeDeliveryGrp"
displayName: qsTr("Upgrade Delivery Upload Limit Setting")
visible: dccData.model().upgradeDeliveryEnable
weight: 20
enabled: !dccData.model().upgradeUploadSpeedIsOnline
pageType: DccObject.Item
Connections {
target: dccData.model()
function onUpgradeUploadSpeedLimitConfigChanged() {
upgradeDeliveryUploadLimitSetting.enabled = !dccData.model().upgradeUploadSpeedIsOnline
}
}
page: RowLayout {
D.CheckBox {
id: limitCheckBox
Expand Down Expand Up @@ -454,13 +462,20 @@ DccObject {
}

DccObject {
id: upgradeDeliveryDownloadLimitSetting
name: "upgradeDeliveryDownloadLimitSetting"
parentName: "upgradeDeliveryGrp"
displayName: qsTr("Upgrade Delivery Download Limit Setting")
visible: dccData.model().upgradeDeliveryEnable
weight: 20
enabled: !dccData.model().upgradeDownloadSpeedIsOnline
pageType: DccObject.Item
Connections {
target: dccData.model()
function onUpgradeDownloadSpeedLimitConfigChanged() {
upgradeDeliveryDownloadLimitSetting.enabled = !dccData.model().upgradeDownloadSpeedIsOnline
}
}
page: RowLayout {
D.CheckBox {
id: limitCheckBox
Expand Down Expand Up @@ -591,7 +606,7 @@ DccObject {
page: RowLayout {
D.LineEdit {
id: lineEdit
maximumLength: 5
maximumLength: 6
validator: RegularExpressionValidator { regularExpression: /^\d*$/ }
alertText: qsTr("Only numbers between 10-999999 are allowed")
alertDuration: 3000
Expand Down
14 changes: 11 additions & 3 deletions src/dcc-update-plugin/translations/update_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
<translation>传递优化</translation>
</message>
<message>
<source>Turning this on may cause your device to send previously downloaded system updates to devices on the local network. Turning this off will clear files cached for update delivery on restart</source>
<source>When enabled, your device may share previously downloaded system updates with other devices on your local network.When you turn it off, cached files from update delivery will be cleared during the next restart.</source>
<translation>开启此功能,你的设备可能会将以前下载的部分系统更新发送到本地网络的设备上。关闭此功能后,将在重启时清除传递优化时缓存的文件</translation>
</message>
<message>
Expand Down Expand Up @@ -532,11 +532,19 @@
</message>
<message>
<source>Failed to change Upgrade Delivery setting</source>
<translation>更新传递优化服务异常,设置失败</translation>
<translation>更新传递优化服务异常</translation>
</message>
<message>
<source>Update Delivery Optimization service exception. Failed to enable.</source>
<translation>更新传递优化服务异常,开启失败</translation>
</message>
<message>
<source>Update Delivery Optimization service exception. Failed to disable.</source>
<translation>更新传递优化服务异常,关闭失败</translation>
</message>
<message>
<source>Retry</source>
<translation>重试</translation>
<translation>再试一次</translation>
</message>
<message>
<source>OK</source>
Expand Down
20 changes: 14 additions & 6 deletions src/dcc-update-plugin/translations/update_zh_HK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,19 +444,19 @@
</message>
<message>
<source>Upgrade Delivery</source>
<translation>更新傳遞</translation>
<translation>傳遞優化</translation>
</message>
<message>
<source>Turning this on may cause your device to send previously downloaded system updates to devices on the local network. Turning this off will clear files cached for update delivery on restart</source>
<source>When enabled, your device may share previously downloaded system updates with other devices on your local network.When you turn it off, cached files from update delivery will be cleared during the next restart.</source>
<translation>開啟此功能,你的裝置可能會將以前下載的部分系統更新傳送到本地網絡的裝置上。關閉此功能後,將在重新啟動時清除更新傳遞時快取的檔案</translation>
</message>
<message>
<source>Upgrade Delivery Download Limit Setting</source>
<translation>更新傳遞-下載限速</translation>
<translation>下載限速</translation>
</message>
<message>
<source>Upgrade Delivery Upload Limit Setting</source>
<translation>更新傳遞-上傳限速</translation>
<translation>上傳限速</translation>
</message>
<message>
<source>Limit Speed</source>
Expand Down Expand Up @@ -528,11 +528,19 @@
</message>
<message>
<source>Failed to change Upgrade Delivery setting</source>
<translation>更新傳遞優化服務異常,設置失敗</translation>
<translation>更新傳遞優化服務異常</translation>
</message>
<message>
<source>Update Delivery Optimization service exception. Failed to enable.</source>
<translation>更新傳遞優化服務異常,開啓失敗</translation>
</message>
<message>
<source>Update Delivery Optimization service exception. Failed to disable.</source>
<translation>更新傳遞優化服務異常,關閉失敗</translation>
</message>
<message>
<source>Retry</source>
<translation>重試</translation>
<translation>再試一次</translation>
</message>
<message>
<source>OK</source>
Expand Down
Loading
Loading