2020-10-01 00:33:19 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2017-2020 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
SPDX-FileCopyrightText: 2018 Huzaifa Faruqui <huzaifafaruqui@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2019 Shubham Jangra <aryan100jangid@gmail.com>
|
2020-10-09 20:41:41 +01:00
|
|
|
SPDX-FileCopyrightText: 2020 David Edmundson <kde@davidedmundson.co.uk>
|
2020-10-01 00:33:19 +01:00
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2017-11-07 22:55:28 +00:00
|
|
|
|
|
|
|
#ifndef KPMCORE_EXTERNALCOMMANDHELPER_H
|
|
|
|
#define KPMCORE_EXTERNALCOMMANDHELPER_H
|
|
|
|
|
2018-08-03 19:37:24 +01:00
|
|
|
#include <memory>
|
2018-07-21 11:03:25 +01:00
|
|
|
#include <unordered_set>
|
|
|
|
|
2018-03-19 10:33:20 +00:00
|
|
|
#include <QEventLoop>
|
2019-06-12 17:41:11 +01:00
|
|
|
#include <QString>
|
2017-11-07 22:55:28 +00:00
|
|
|
#include <QProcess>
|
2020-10-08 02:23:24 +01:00
|
|
|
#include <QDBusContext>
|
|
|
|
|
|
|
|
class QDBusServiceWatcher;
|
2017-11-07 22:55:28 +00:00
|
|
|
|
2020-10-08 02:23:24 +01:00
|
|
|
class ExternalCommandHelper : public QObject, public QDBusContext
|
2017-11-07 22:55:28 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-03-19 10:33:20 +00:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kpmcore.externalcommand")
|
2017-11-07 22:55:28 +00:00
|
|
|
|
2018-01-24 15:22:42 +00:00
|
|
|
Q_SIGNALS:
|
2020-10-11 23:46:20 +01:00
|
|
|
Q_SCRIPTABLE void progress(int);
|
|
|
|
Q_SCRIPTABLE void report(QString);
|
2018-01-24 15:22:42 +00:00
|
|
|
|
|
|
|
public:
|
2020-10-08 02:23:24 +01:00
|
|
|
ExternalCommandHelper();
|
2019-03-29 17:51:51 +00:00
|
|
|
bool readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size);
|
|
|
|
bool writeData(const QString& targetDevice, const QByteArray& buffer, const qint64 offset);
|
2018-01-24 15:22:42 +00:00
|
|
|
|
2017-11-07 22:55:28 +00:00
|
|
|
public Q_SLOTS:
|
2020-10-11 22:45:13 +01:00
|
|
|
Q_SCRIPTABLE QVariantMap RunCommand(const QString& command, const QStringList& arguments, const QByteArray& input, const int processChannelMode);
|
|
|
|
Q_SCRIPTABLE QVariantMap CopyBlocks(const QString& sourceDevice, const qint64 sourceFirstByte, const qint64 sourceLength, const QString& targetDevice, const qint64 targetFirstByte, const qint64 blockSize);
|
|
|
|
Q_SCRIPTABLE bool WriteData(const QByteArray& buffer, const QString& targetDevice, const qint64 targetFirstByte);
|
|
|
|
Q_SCRIPTABLE bool CreateFile(const QString& filePath, const QByteArray& fileContents);
|
2018-03-23 21:19:33 +00:00
|
|
|
|
2017-11-07 22:55:28 +00:00
|
|
|
private:
|
2020-10-08 02:23:24 +01:00
|
|
|
bool isCallerAuthorized();
|
|
|
|
|
|
|
|
void onReadOutput();
|
|
|
|
QDBusServiceWatcher *m_serviceWatcher = nullptr;
|
2017-11-07 22:55:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|