Skip to content

Commit

Permalink
chore: add DBus adaptor for bootmaker interface (#74)
Browse files Browse the repository at this point in the history
Add BootMakerAdaptor class to handle DBus communication

Log: add DBus adaptor for bootmaker interface
  • Loading branch information
wyu71 authored Jan 14, 2025
1 parent cbfde24 commit aa005e8
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/configs/dbus/BootMakerAdaptor.cpp
Original file line number Diff line number Diff line change
@@ -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 <QtCore/QMetaObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>

/*
* 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");
}

73 changes: 73 additions & 0 deletions src/configs/dbus/BootMakerAdaptor.h
Original file line number Diff line number Diff line change
@@ -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 <QtCore/QObject>
#include <QtDBus/QtDBus>
QT_BEGIN_NAMESPACE
class QByteArray;
template<class T> class QList;
template<class Key, class Value> 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", ""
" <interface name=\"com.deepin.bootmaker\">\n"
" <signal name=\"DeviceListChanged\">\n"
" <arg direction=\"out\" type=\"s\" name=\"deviceListJson\"/>\n"
" </signal>\n"
" <signal name=\"Finished\">\n"
" <arg direction=\"out\" type=\"i\" name=\"errcode\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"description\"/>\n"
" </signal>\n"
" <signal name=\"ReportProgress\">\n"
" <arg direction=\"out\" type=\"i\" name=\"current\"/>\n"
" <arg direction=\"out\" type=\"i\" name=\"total\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"title\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"description\"/>\n"
" </signal>\n"
" <method name=\"DeviceList\">\n"
" <arg direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" <method name=\"Reboot\"/>\n"
" <method name=\"Start\"/>\n"
" <method name=\"Stop\"/>\n"
" <method name=\"Install\">\n"
" <arg direction=\"out\" type=\"b\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"image\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"device\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"partition\"/>\n"
" <arg direction=\"in\" type=\"b\" name=\"formatDevice\"/>\n"
" </method>\n"
" </interface>\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

0 comments on commit aa005e8

Please sign in to comment.