2017-11-07 22:55:28 +00:00
|
|
|
/*************************************************************************
|
2018-03-22 17:29:40 +00:00
|
|
|
* Copyright (C) 2017-2018 by Andrius Štikonas <andrius@stikonas.eu> *
|
2017-11-07 22:55:28 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef KPMCORE_EXTERNALCOMMANDHELPER_H
|
|
|
|
#define KPMCORE_EXTERNALCOMMANDHELPER_H
|
|
|
|
|
|
|
|
#include <KAuth>
|
|
|
|
|
2018-03-19 10:33:20 +00:00
|
|
|
#include <QEventLoop>
|
2018-01-24 15:22:42 +00:00
|
|
|
#include <QString>
|
2017-11-07 22:55:28 +00:00
|
|
|
#include <QProcess>
|
|
|
|
|
2018-03-23 22:45:51 +00:00
|
|
|
class QTimer;
|
|
|
|
|
2017-11-07 22:55:28 +00:00
|
|
|
using namespace KAuth;
|
|
|
|
|
|
|
|
class ExternalCommandHelper : public QObject
|
|
|
|
{
|
|
|
|
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:
|
|
|
|
void progress(int);
|
2018-03-19 10:33:20 +00:00
|
|
|
void quit();
|
2018-01-24 15:22:42 +00:00
|
|
|
|
|
|
|
public:
|
2018-03-21 17:01:40 +00:00
|
|
|
bool readData(const QString& sourceDevice, QByteArray& buffer, qint64 offset, qint64 size);
|
|
|
|
bool writeData(const QString& targetDevice, const QByteArray& buffer, qint64 offset);
|
2018-01-24 15:22:42 +00:00
|
|
|
|
2017-11-07 22:55:28 +00:00
|
|
|
public Q_SLOTS:
|
2018-03-19 10:33:20 +00:00
|
|
|
ActionReply init(const QVariantMap& args);
|
|
|
|
Q_SCRIPTABLE QVariantMap start(const QString& Uuid, const QString& command, const QStringList& arguments, const QByteArray& input, const QStringList& environment);
|
2018-03-21 20:51:30 +00:00
|
|
|
Q_SCRIPTABLE bool copyblocks(const QString& Uuid, const QString& sourceDevice, const qint64 sourceFirstByte, const qint64 sourceLength, const QString& targetDevice, const qint64 targetFirstByte, const qint64 blockSize);
|
2018-03-19 10:33:20 +00:00
|
|
|
Q_SCRIPTABLE void exit(const QString& Uuid);
|
2018-03-23 21:19:33 +00:00
|
|
|
|
2017-11-07 22:55:28 +00:00
|
|
|
private:
|
|
|
|
void onReadOutput();
|
2018-03-21 17:01:40 +00:00
|
|
|
bool isCallerAuthorized(const QString& Uuid);
|
2017-11-07 22:55:28 +00:00
|
|
|
|
2018-03-19 10:33:20 +00:00
|
|
|
QEventLoop m_loop;
|
|
|
|
QString m_callerUuid;
|
|
|
|
QString m_command;
|
|
|
|
QString m_sourceDevice;
|
|
|
|
QProcess m_cmd;
|
2018-03-23 21:19:33 +00:00
|
|
|
|
2018-03-23 22:45:51 +00:00
|
|
|
QTimer *timer;
|
2017-11-07 22:55:28 +00:00
|
|
|
// QByteArray output;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|