Skip to content
Open
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
# SPDX-FileCopyrightText: 2025-2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

Expand Down Expand Up @@ -40,4 +40,5 @@ add_subdirectory("src/dde-update")
add_subdirectory("src/dde-abrecovery")
add_subdirectory("src/dcc-update-plugin")
add_subdirectory("src/dock-update-plugin")
add_subdirectory("src/private-lastore-tray")

63 changes: 63 additions & 0 deletions src/common/dbus/updateassistant.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "updateassistant.h"

UpdateAssistant::UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
, d_ptr(new UpdateAssistantPrivate)
{
QDBusConnection::systemBus().connect("org.deepin.upgradedelivery", "/org/deepin/upgradedelivery", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onPropertyChanged(QString, QVariantMap, QStringList)));
}

UpdateAssistant::~UpdateAssistant()
{
}

void UpdateAssistant::onPropertyChanged(const QString& interfaceName,
const QVariantMap& changedProperties,
const QStringList& invalidatedProperties)
{
if (interfaceName != staticInterfaceName())
return;

if (changedProperties.contains("UploadLimitSpeed")) {
Q_EMIT UploadLimitSpeedChanged(uploadLimitSpeed());
}
if (changedProperties.contains("DownloadLimitSpeed")) {
Q_EMIT DownloadLimitSpeedChanged(downloadLimitSpeed());
}

return;
}

void UpdateAssistant::CallQueued(const QString &callName, const QList<QVariant> &args)
{
if (d_ptr->m_waittingCalls.contains(callName)) {
d_ptr->m_waittingCalls[callName] = args;
return;
}
if (d_ptr->m_processingCalls.contains(callName)) {
d_ptr->m_waittingCalls.insert(callName, args);
} else {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
connect(watcher, &QDBusPendingCallWatcher::finished, this, &UpdateAssistant::onPendingCallFinished);
d_ptr->m_processingCalls.insert(callName, watcher);
}
}

void UpdateAssistant::onPendingCallFinished(QDBusPendingCallWatcher *w)
{
if (!w)
return;
w->deleteLater();
const auto callName = d_ptr->m_processingCalls.key(w);
Q_ASSERT(!callName.isEmpty());
if (callName.isEmpty())
return;
d_ptr->m_processingCalls.remove(callName);
if (!d_ptr->m_waittingCalls.contains(callName))
return;
const auto args = d_ptr->m_waittingCalls.take(callName);
CallQueued(callName, args);
}
84 changes: 84 additions & 0 deletions src/common/dbus/updateassistant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef UPDATEASSISTANT_H
#define UPDATEASSISTANT_H

#include <QtCore/QObject>

Check warning on line 7 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 7 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 7 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QByteArray>

Check warning on line 8 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QByteArray> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 8 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QByteArray> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 8 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QByteArray> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QList>

Check warning on line 9 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QList> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 9 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QList> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 9 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QList> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QMap>

Check warning on line 10 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QMap> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 10 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QMap> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 10 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QMap> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QString>

Check warning on line 11 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QString> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QString> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QString> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QStringList>

Check warning on line 12 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QStringList> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QStringList> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QStringList> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtCore/QVariant>

Check warning on line 13 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtCore/QVariant> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtDBus/QtDBus>

Check warning on line 14 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtDBus/QtDBus> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtDBus/QtDBus> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtDBus/QtDBus> not found. Please note: Cppcheck does not need standard library headers to get proper results.

class UpdateAssistantPrivate
{
public:
UpdateAssistantPrivate() = default;

public:
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
QMap<QString, QList<QVariant>> m_waittingCalls;
};

/*
* Proxy class for interface org.deepin.updateassistant
*/
class UpdateAssistant: public QDBusAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "org.deepin.upgradedelivery"; }

public:
UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);

~UpdateAssistant();

Q_PROPERTY(QString UploadLimitSpeed READ uploadLimitSpeed NOTIFY UploadLimitSpeedChanged)
inline QString uploadLimitSpeed() const
{ return qvariant_cast<QString>(internalPropGet("UploadLimitSpeed")); }

Q_PROPERTY(QString DownloadLimitSpeed READ downloadLimitSpeed NOTIFY DownloadLimitSpeedChanged)
inline QString downloadLimitSpeed() const
{ return qvariant_cast<QString>(internalPropGet("DownloadLimitSpeed")); }

public Q_SLOTS: // METHODS

Check warning on line 49 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.

Check warning on line 49 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.

Check warning on line 49 in src/common/dbus/updateassistant.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.

inline QDBusPendingReply<void> SetUploadRateLimit(int speed)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(speed);
return asyncCallWithArgumentList(QStringLiteral("SetUploadRateLimit"), argumentList);
}

inline QDBusPendingReply<void> SetDownloadRateLimit(int speed)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(speed);
return asyncCallWithArgumentList(QStringLiteral("SetDownloadRateLimit"), argumentList);
}

Q_SIGNALS: // SIGNALS
// begin property changed signals
void propertyChanged(const QString &propertyName, const QVariant &value);
void UploadLimitSpeedChanged(const QString & speed) const;
void DownloadLimitSpeedChanged(const QString & speed) const;

public Q_SLOTS:
void CallQueued(const QString &callName, const QList<QVariant> &args);

private Q_SLOTS:
void onPendingCallFinished(QDBusPendingCallWatcher *w);
void onPropertyChanged(const QString& interfaceName,
const QVariantMap& changedProperties,
const QStringList& invalidatedProperties);

private:
UpdateAssistantPrivate *d_ptr;
};

#endif // UPDATEASSISTANT_H
50 changes: 49 additions & 1 deletion src/common/dbus/updatedbusproxy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "updatedbusproxy.h"
Expand Down Expand Up @@ -207,6 +207,16 @@
return qvariant_cast<QString>(m_managerInter->property("UpdateStatus"));
}

bool UpdateDBusProxy::p2PUpdateEnable()

Check warning on line 210 in src/common/dbus/updatedbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'p2PUpdateEnable' is never used.

Check warning on line 210 in src/common/dbus/updatedbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'p2PUpdateEnable' is never used.

Check warning on line 210 in src/common/dbus/updatedbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'p2PUpdateEnable' is never used.
{
return qvariant_cast<bool>(m_managerInter->property("P2PUpdateEnable"));
}

bool UpdateDBusProxy::p2PUpdateSupport()
{
return qvariant_cast<bool>(m_managerInter->property("P2PUpdateSupport"));
}

bool UpdateDBusProxy::immutableAutoRecovery()
{
return qvariant_cast<bool>(m_managerInter->property("ImmutableAutoRecovery"));
Expand Down Expand Up @@ -387,6 +397,36 @@
return m_managerInter->asyncCallWithArgumentList(QStringLiteral("GetUpdateLogs"), argumentList);
}

QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryEnable(bool enable)
{
qCDebug(logCommon) << "Setting upgrade delivery enable :" << enable;
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(enable);
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetP2PUpdateEnable"), argumentList);
}

QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit)
{
qCDebug(logCommon) << "Setting upgrade delivery download speed limit : " << downloadLimit;
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(downloadLimit);
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryDownloadSpeedLimit"), argumentList);
}

QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit)
{
qCDebug(logCommon) << "Setting upgrade delivery upload speed limit : " << uploadLimit;
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(uploadLimit);
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryUploadSpeedLimit"), argumentList);
}

QDBusPendingReply<void> UpdateDBusProxy::ClearUpgradeDeliveryCache()
{
qCDebug(logCommon) << "Clearing upgrade delivery cache";
return m_updateInter->asyncCall(QStringLiteral("CleanTransmissionFiles"));
}

QDBusPendingReply<void> UpdateDBusProxy::SetIdleDownloadConfig(const QString& config)
{
qCDebug(logCommon) << "Setting idle download config:" << config;
Expand Down Expand Up @@ -428,6 +468,14 @@
return m_managerInter->asyncCallWithArgumentList(QStringLiteral("GetUpdateDetails"), argumentList);
}

QDBusPendingReply<void> UpdateDBusProxy::SetShutdownForceUpdate(bool isShutdownUpdate)
{
qCDebug(logCommon) << "Setting shutdown force update , isShutdownUpdate:" << isShutdownUpdate;
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(isShutdownUpdate);
return m_managerInter->asyncCallWithArgumentList(QStringLiteral("SetShutdownForceUpdate"), argumentList);
}

bool UpdateDBusProxy::onBattery()
{
return qvariant_cast<bool>(m_powerInter->property("OnBattery"));
Expand Down
17 changes: 15 additions & 2 deletions src/common/dbus/updatedbusproxy.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef UPDATEDBUSPROXY_H
Expand Down Expand Up @@ -70,6 +70,12 @@ class UpdateDBusProxy : public QObject
Q_PROPERTY(bool ImmutableAutoRecovery READ immutableAutoRecovery NOTIFY ImmutableAutoRecoveryChanged)
bool immutableAutoRecovery();

Q_PROPERTY(bool P2PUpdateEnable READ p2PUpdateEnable NOTIFY P2PUpdateEnableChanged)
bool p2PUpdateEnable();

Q_PROPERTY(bool P2PUpdateSupport READ p2PUpdateSupport NOTIFY P2PUpdateSupportChanged)
bool p2PUpdateSupport();

QString hardwareId();

quint64 checkUpdateMode();
Expand Down Expand Up @@ -103,12 +109,16 @@ class UpdateDBusProxy : public QObject
QDBusPendingReply<void> SetDownloadSpeedLimit(const QString &config);
QDBusPendingReply<qlonglong> QueryAllSizeWithSource(int updateType);
QDBusPendingReply<QString> GetUpdateLogs(int updateType);
QDBusPendingReply<void> SetUpgradeDeliveryEnable(bool enable);
QDBusPendingReply<void> SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit);
QDBusPendingReply<void> SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit);
QDBusPendingReply<void> ClearUpgradeDeliveryCache();
QDBusPendingReply<void> SetIdleDownloadConfig(const QString &config);
QDBusPendingReply<QDBusObjectPath> PrepareDistUpgradePartly(int updateMode);
QDBusPendingReply<QDBusObjectPath> fixError(const QString &errorType);
QDBusPendingCall CheckUpgrade(int checkMode, int checkOrder);
QDBusPendingReply<void> GetUpdateDetails(int fd, bool realtime);

QDBusPendingReply<void> SetShutdownForceUpdate(bool isShutdownUpdate);

// Power
bool onBattery();
Expand Down Expand Up @@ -137,6 +147,7 @@ class UpdateDBusProxy : public QObject
void AutoInstallUpdatesChanged(bool value) const;
void AutoInstallUpdateTypeChanged(qulonglong value) const;
void MirrorSourceChanged(const QString &value) const;
void UpgradeDeliveryEnabledChanged(bool value) const;
void AutoCheckUpdatesChanged(bool value) const;
void ClassifiedUpdatablePackagesChanged(LastoreUpdatePackagesInfo value) const;

Expand All @@ -146,6 +157,8 @@ class UpdateDBusProxy : public QObject
void UpdateModeChanged(qulonglong value) const;
void UpdateStatusChanged(QString value) const;
void ImmutableAutoRecoveryChanged(bool value) const;
void P2PUpdateEnableChanged(bool value) const;
void P2PUpdateSupportChanged(bool value) const;
void managerInterServiceValidChanged(bool value) const;

// Power
Expand Down
Loading
Loading