File indexing completed on 2022-11-23 12:18:32

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org>
0003 
0004 #include "simulationctl.h"
0005 
0006 #include <QFile>
0007 
0008 static QString readCLIData()
0009 {
0010     QFile file(":/plasma-disks/fixtures/cli.txt");
0011     const bool open = file.open(QFile::ReadOnly);
0012     Q_ASSERT(open);
0013     return file.readAll();
0014 }
0015 
0016 void SimulationCtl::run(const QString &devicePath)
0017 {
0018     qDebug() << "SIMULATING" << devicePath;
0019     QFile file(devicePath);
0020     Q_ASSERT(file.open(QIODevice::ReadOnly | QIODevice::Text));
0021     QJsonParseError error;
0022     const auto document = QJsonDocument::fromJson(file.readAll(), &error);
0023     Q_ASSERT(error.error == QJsonParseError::NoError);
0024     Q_EMIT finished(devicePath, document, readCLIData());
0025 }