Skip to content

Commit aa005e8

Browse files
authored
chore: add DBus adaptor for bootmaker interface (#74)
Add BootMakerAdaptor class to handle DBus communication Log: add DBus adaptor for bootmaker interface
1 parent cbfde24 commit aa005e8

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

src/configs/dbus/BootMakerAdaptor.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#include "BootMakerAdaptor.h"
6+
#include <QtCore/QMetaObject>
7+
#include <QtCore/QByteArray>
8+
#include <QtCore/QList>
9+
#include <QtCore/QMap>
10+
#include <QtCore/QString>
11+
#include <QtCore/QStringList>
12+
#include <QtCore/QVariant>
13+
14+
/*
15+
* Implementation of adaptor class BootMakerAdaptor
16+
*/
17+
18+
BootMakerAdaptor::BootMakerAdaptor(QObject *parent)
19+
: QDBusAbstractAdaptor(parent)
20+
{
21+
// constructor
22+
setAutoRelaySignals(true);
23+
}
24+
25+
BootMakerAdaptor::~BootMakerAdaptor()
26+
{
27+
// destructor
28+
}
29+
30+
QString BootMakerAdaptor::DeviceList()
31+
{
32+
// handle method call com.deepin.bootmaker.DeviceList
33+
QString out0;
34+
QMetaObject::invokeMethod(parent(), "DeviceList", Q_RETURN_ARG(QString, out0));
35+
return out0;
36+
}
37+
38+
bool BootMakerAdaptor::Install(const QString &image, const QString &device, const QString &partition, bool formatDevice)
39+
{
40+
// handle method call com.deepin.bootmaker.Install
41+
bool out0;
42+
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));
43+
return out0;
44+
}
45+
46+
void BootMakerAdaptor::Reboot()
47+
{
48+
// handle method call com.deepin.bootmaker.Reboot
49+
QMetaObject::invokeMethod(parent(), "Reboot");
50+
}
51+
52+
void BootMakerAdaptor::Start()
53+
{
54+
// handle method call com.deepin.bootmaker.Start
55+
QMetaObject::invokeMethod(parent(), "Start");
56+
}
57+
58+
void BootMakerAdaptor::Stop()
59+
{
60+
// handle method call com.deepin.bootmaker.Stop
61+
QMetaObject::invokeMethod(parent(), "Stop");
62+
}
63+

src/configs/dbus/BootMakerAdaptor.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
#ifndef BOOTMAKERADAPTOR_H
6+
#define BOOTMAKERADAPTOR_H
7+
8+
#include <QtCore/QObject>
9+
#include <QtDBus/QtDBus>
10+
QT_BEGIN_NAMESPACE
11+
class QByteArray;
12+
template<class T> class QList;
13+
template<class Key, class Value> class QMap;
14+
class QString;
15+
class QStringList;
16+
class QVariant;
17+
QT_END_NAMESPACE
18+
19+
/*
20+
* Adaptor class for interface com.deepin.bootmaker
21+
*/
22+
class BootMakerAdaptor: public QDBusAbstractAdaptor
23+
{
24+
Q_OBJECT
25+
Q_CLASSINFO("D-Bus Interface", "com.deepin.bootmaker")
26+
Q_CLASSINFO("D-Bus Introspection", ""
27+
" <interface name=\"com.deepin.bootmaker\">\n"
28+
" <signal name=\"DeviceListChanged\">\n"
29+
" <arg direction=\"out\" type=\"s\" name=\"deviceListJson\"/>\n"
30+
" </signal>\n"
31+
" <signal name=\"Finished\">\n"
32+
" <arg direction=\"out\" type=\"i\" name=\"errcode\"/>\n"
33+
" <arg direction=\"out\" type=\"s\" name=\"description\"/>\n"
34+
" </signal>\n"
35+
" <signal name=\"ReportProgress\">\n"
36+
" <arg direction=\"out\" type=\"i\" name=\"current\"/>\n"
37+
" <arg direction=\"out\" type=\"i\" name=\"total\"/>\n"
38+
" <arg direction=\"out\" type=\"s\" name=\"title\"/>\n"
39+
" <arg direction=\"out\" type=\"s\" name=\"description\"/>\n"
40+
" </signal>\n"
41+
" <method name=\"DeviceList\">\n"
42+
" <arg direction=\"out\" type=\"s\"/>\n"
43+
" </method>\n"
44+
" <method name=\"Reboot\"/>\n"
45+
" <method name=\"Start\"/>\n"
46+
" <method name=\"Stop\"/>\n"
47+
" <method name=\"Install\">\n"
48+
" <arg direction=\"out\" type=\"b\"/>\n"
49+
" <arg direction=\"in\" type=\"s\" name=\"image\"/>\n"
50+
" <arg direction=\"in\" type=\"s\" name=\"device\"/>\n"
51+
" <arg direction=\"in\" type=\"s\" name=\"partition\"/>\n"
52+
" <arg direction=\"in\" type=\"b\" name=\"formatDevice\"/>\n"
53+
" </method>\n"
54+
" </interface>\n"
55+
"")
56+
public:
57+
BootMakerAdaptor(QObject *parent);
58+
virtual ~BootMakerAdaptor();
59+
60+
public: // PROPERTIES
61+
public Q_SLOTS: // METHODS
62+
QString DeviceList();
63+
bool Install(const QString &image, const QString &device, const QString &partition, bool formatDevice);
64+
void Reboot();
65+
void Start();
66+
void Stop();
67+
Q_SIGNALS: // SIGNALS
68+
void DeviceListChanged(const QString &deviceListJson);
69+
void Finished(int errcode, const QString &description);
70+
void ReportProgress(int current, int total, const QString &title, const QString &description);
71+
};
72+
73+
#endif

0 commit comments

Comments
 (0)