Debian Codegraph @

src/libdbm/bminterface.cpp

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: GPL-3.0-only
4
5 #include "bminterface.h"
6
7 #include <QDebug>
8 #include <QThread>
9
10
11 #include "backend/bmhandler.h"
12
13 #ifdef Q_OS_LINUX
14 #include "backend/bmdbushandler.h"
15 #else
16 #include "backend/bootmaker.h"
17 #endif
18
19 class BMInterfacePrivate
20 {
21 public:
22 BMInterfacePrivate(BMInterface *parent) : q_ptr(parent) {}
23
24 BMHandler *handler = nullptr;
25
26 BMInterface *q_ptr;
27 Q_DECLARE_PUBLIC(BMInterface)
28 };
29
30 BMInterface::BMInterface(QObject *parent) :
31 QObject(parent), d_ptr(new BMInterfacePrivate(this))
32 {
33 Q_D(BMInterface);
34
35 qRegisterMetaType<QList<DeviceInfo>>();
36
37 #ifdef Q_OS_LINUX
38 d->handler = new BMDbusHandler;
39 #else
40 d->handler = new BootMaker;
41 #endif
42 QThread *handlerwork = new QThread;
43 d->handler->moveToThread(handlerwork);
44 handlerwork->start();
45
46 connect(d->handler, &BMHandler::removablePartitionsChanged,
47 this, &BMInterface::deviceListChanged);
48 connect(d->handler, &BMHandler::finished,
49 this, &BMInterface::finished);
50 // connect(d->handler, &BMHandler::checkFileResult,
51 // this, &BMInterface::checkFileResult);
52 connect(d->handler, &BMHandler::reportProgress,
53 this, &BMInterface::reportProgress);
54 connect(d->handler,&BMHandler::reportProgress1,
55 this,&BMInterface::reportProgress1);
56 connect(this, &BMInterface::startInstall,
57 d->handler, &BMHandler::startInstall );
58 connect(d->handler, &BMHandler::startInstallRet,
59 this, &BMInterface::startInstallRet);
60 }
61
62 BMInterface::~BMInterface()
63 {
64
65 }
66
67 void BMInterface::start()
68 {
69 Q_D(BMInterface);
70 return d->handler->start();
71 }
72
73 void BMInterface::stop()
74 {
75 Q_D(BMInterface);
76 return d->handler->stop();
77 }
78
79 void BMInterface::reboot()
80 {
81 Q_D(BMInterface);
82 return d->handler->reboot();
83 }
84
85 QList<DeviceInfo> BMInterface::deviceList()
86 {
87 qDebug() << "BMInterface deviceList";
88 Q_D(BMInterface);
89 return d->handler->deviceList();
90 }
91
92 bool BMInterface::checkfile(const QString &filepath)
93 {
94 Q_D(BMInterface);
95 return d->handler->checkfile(filepath);
96 }
97
98 //bool BMInterface::install(const QString &image, const QString &device, const QString &partition, bool formatDevice)
99 //{
100 // Q_D(BMInterface);
101 // emit d->handler->reportProgress(5, 0, "init", "");
102 // qDebug() << "start BMInterface::install";
103 // emit d->handler->startInstall(image,device, partition, formatDevice);
104 // return true;
105 //}