File indexing completed on 2022-09-27 16:29:36

0001 /*
0002     SPDX-FileCopyrightText: 2017 Jonathan Riddell <jr@jriddell.org>
0003 
0004     SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006 
0007 #include "imagewriter_helper.h"
0008 #include "isoimagewriter_debug.h"
0009 #include "imagewriter.h"
0010 #include "usbdevice.h"
0011 
0012 #include <KLocalizedString>
0013 #include <kauth_version.h>
0014 #if KAUTH_VERSION >= QT_VERSION_CHECK(5, 92, 0)
0015 #include <KAuth/ActionReply>
0016 #else
0017 #include <KAuthActionReply>
0018 #endif
0019 
0020 #include <QProcess>
0021 #include <QDateTime>
0022 #include <QDebug>
0023 #include <QFile>
0024 #include <QThread>
0025 
0026 #include <stdio.h>
0027 #include <iostream>
0028 #include <time.h>
0029 
0030 ImageWriterHelper::ImageWriterHelper()
0031 {
0032     KLocalizedString::setApplicationDomain("imagewriter");
0033 }
0034 
0035 ActionReply ImageWriterHelper::write(const QVariantMap &args)
0036 {
0037     qDebug() << "ImageWriterHelper::writefile()";
0038     bool zeroing = args["zeroing"].toBool();
0039     QString imageFile = args["imagefile"].toString();
0040     QString visibleName = args[QStringLiteral("usbdevice_visiblename")].toString();
0041     QStringList volumes;
0042     volumes << args[QStringLiteral("usbdevice_volumes")].toString();
0043     quint64 size = args[QStringLiteral("usbdevice_size")].toString().toUInt();
0044     quint32 sectorSize = args[QStringLiteral("usbdevice_sectorsize")].toUInt();
0045     QString physicalDevice = args[QStringLiteral("usbdevice_physicaldevice")].toString();
0046 
0047     UsbDevice* selectedDevice = new UsbDevice();
0048     selectedDevice->m_VisibleName = visibleName;
0049     selectedDevice->m_Volumes = volumes;
0050     selectedDevice->m_Size = size;
0051     selectedDevice->m_SectorSize = sectorSize;
0052     selectedDevice->m_PhysicalDevice = physicalDevice;
0053 
0054     qDebug() << "ImageWriterHelper::writefile() zeroing:" << zeroing;
0055     qDebug() << "ImageWriterHelper::writefile() imageFile:" << imageFile;
0056     qDebug() << "ImageWriterHelper::writefile() physicalDevice:" << physicalDevice;
0057     qDebug() << "ImageWriterHelper::writefile() volumes:" << volumes[0];
0058     qDebug() << "ImageWriterHelper::writefile() size:" << size;
0059     qDebug() << "ImageWriterHelper::writefile() sectorSize:" << sectorSize;
0060 
0061     ImageWriter* writer = new ImageWriter(zeroing ? "" : imageFile, selectedDevice);
0062     writer->writeImage();
0063 
0064     return ActionReply::SuccessReply();
0065 }
0066 
0067 KAUTH_HELPER_MAIN("org.kde.isoimagewriter", ImageWriterHelper)