From aa005e8b272e2f352ce45890c635630f64ddd8c6 Mon Sep 17 00:00:00 2001 From: wyu <97944796+wyu71@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:11:45 +0800 Subject: [PATCH] chore: add DBus adaptor for bootmaker interface (#74) Add BootMakerAdaptor class to handle DBus communication Log: add DBus adaptor for bootmaker interface --- src/configs/dbus/BootMakerAdaptor.cpp | 63 +++++++++++++++++++++++ src/configs/dbus/BootMakerAdaptor.h | 73 +++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 src/configs/dbus/BootMakerAdaptor.cpp create mode 100644 src/configs/dbus/BootMakerAdaptor.h diff --git a/src/configs/dbus/BootMakerAdaptor.cpp b/src/configs/dbus/BootMakerAdaptor.cpp new file mode 100644 index 00000000..4111144c --- /dev/null +++ b/src/configs/dbus/BootMakerAdaptor.cpp @@ -0,0 +1,63 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "BootMakerAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class BootMakerAdaptor + */ + +BootMakerAdaptor::BootMakerAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +BootMakerAdaptor::~BootMakerAdaptor() +{ + // destructor +} + +QString BootMakerAdaptor::DeviceList() +{ + // handle method call com.deepin.bootmaker.DeviceList + QString out0; + QMetaObject::invokeMethod(parent(), "DeviceList", Q_RETURN_ARG(QString, out0)); + return out0; +} + +bool BootMakerAdaptor::Install(const QString &image, const QString &device, const QString &partition, bool formatDevice) +{ + // handle method call com.deepin.bootmaker.Install + bool out0; + QMetaObject::invokeMethod(parent(), "Install", Q_RETURN_ARG(bool, out0), Q_ARG(QString, image), Q_ARG(QString, device), Q_ARG(QString, partition), Q_ARG(bool, formatDevice)); + return out0; +} + +void BootMakerAdaptor::Reboot() +{ + // handle method call com.deepin.bootmaker.Reboot + QMetaObject::invokeMethod(parent(), "Reboot"); +} + +void BootMakerAdaptor::Start() +{ + // handle method call com.deepin.bootmaker.Start + QMetaObject::invokeMethod(parent(), "Start"); +} + +void BootMakerAdaptor::Stop() +{ + // handle method call com.deepin.bootmaker.Stop + QMetaObject::invokeMethod(parent(), "Stop"); +} + diff --git a/src/configs/dbus/BootMakerAdaptor.h b/src/configs/dbus/BootMakerAdaptor.h new file mode 100644 index 00000000..9e1f6473 --- /dev/null +++ b/src/configs/dbus/BootMakerAdaptor.h @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef BOOTMAKERADAPTOR_H +#define BOOTMAKERADAPTOR_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface com.deepin.bootmaker + */ +class BootMakerAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.deepin.bootmaker") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + BootMakerAdaptor(QObject *parent); + virtual ~BootMakerAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + QString DeviceList(); + bool Install(const QString &image, const QString &device, const QString &partition, bool formatDevice); + void Reboot(); + void Start(); + void Stop(); +Q_SIGNALS: // SIGNALS + void DeviceListChanged(const QString &deviceListJson); + void Finished(int errcode, const QString &description); + void ReportProgress(int current, int total, const QString &title, const QString &description); +}; + +#endif