Debian Codegraph @

src/libdbm/backend/bmdbushandler.h

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: GPL-3.0-only
4
5 #pragma once
6
7 #include "bmhandler.h"
8 #include "bmdbusinterface.h"
9 #include "../util/deviceinfo.h"
10
11 #include <QDebug>
12 #include <QDBusConnection>
13
14 class DeviceMonitor;
15 class BMDbusHandler : public BMHandler
16 {
17 Q_OBJECT
18 public:
19 explicit BMDbusHandler(QObject *parent = nullptr)
20 : BMHandler(parent)
21 {
22 m_dbus = new BMDBusInterface("com.deepin.bootmaker",
23 "/com/deepin/bootmaker",
24 QDBusConnection::systemBus(),
25 this);
26 if (!m_dbus->isValid()) {
27 qDebug() << "m_dbus isValid false error:" << m_dbus->lastError();
28 }
29
30 // Not default timeout (~25s), waiting for polkit authorization to complete.
31 m_dbus->setTimeout(INT_MAX);
32
33 qDebug() << "m_dbus isValid true";
34 connect(m_dbus, &BMDBusInterface::DeviceListChanged,
35 this, [ = ](const QString & addlistJson, const QString& dellistJson) {
36 qDebug() << "DeviceListChanged,";
37 emit removablePartitionsChanged(deviceListFromJson(addlistJson), deviceListFromJson(dellistJson));
38 });
39 connect(m_dbus, &BMDBusInterface::Finished,
40 this, &BMDbusHandler::finished);
41 connect(m_dbus, &BMDBusInterface::ReportProgress,
42 this, &BMDbusHandler::reportProgress);
43 connect(m_dbus, &BMDBusInterface::ReportProgress1,
44 this, &BMDbusHandler::reportProgress1);
45 // connect(m_dbus, &BMDBusInterface::CheckFileResult,
46 // this, &BMDbusHandler::checkFileResult);
47 }
48
49 public slots:
50 void reboot() override
51 {
52 m_dbus->Reboot();
53 }
54
55 void start() override
56 {
57 qDebug() << "start";
58 m_dbus->Start();
59 qDebug() << "m_dbus Start error:" << m_dbus->lastError();
60 }
61
62 void stop() override
63 {
64 m_dbus->Stop();
65 }
66
67 const QList<DeviceInfo> deviceList() const override
68 {
69 qDebug() << "deviceList";
70 return deviceListFromJson(m_dbus->DeviceList());
71 }
72
73 bool install(const QString &image,
74 const QString &device,
75 const QString &partition,
76 bool formatDevice) override
77 {
78 qDebug() << "install";
79 bool ret = m_dbus->Install(image, device, partition, formatDevice);
80 Q_EMIT startInstallRet(ret);
81 return ret;
82 }
83
84 bool checkfile(const QString &filepath) override
85 {
86 qDebug() << "checkfile";
87 return m_dbus->CheckFile(filepath);
88 }
89
90 private:
91 BMDBusInterface *m_dbus = nullptr;
92 };