Changeset View
Changeset View
Standalone View
Standalone View
src/util/externalcommandhelper.h
Show All 18 Lines | |||||
19 | #define KPMCORE_EXTERNALCOMMANDHELPER_H | 19 | #define KPMCORE_EXTERNALCOMMANDHELPER_H | ||
20 | 20 | | |||
21 | #include <memory> | 21 | #include <memory> | ||
22 | #include <unordered_set> | 22 | #include <unordered_set> | ||
23 | 23 | | |||
24 | #include <KAuth> | 24 | #include <KAuth> | ||
25 | 25 | | |||
26 | #include <QEventLoop> | 26 | #include <QEventLoop> | ||
27 | #include <QRandomGenerator64> | | |||
28 | #include <QString> | 27 | #include <QString> | ||
29 | #include <QProcess> | 28 | #include <QProcess> | ||
30 | 29 | | |||
31 | #include <QtCrypto> | | |||
32 | | ||||
33 | using namespace KAuth; | 30 | using namespace KAuth; | ||
34 | 31 | | |||
35 | class ExternalCommandHelper : public QObject | 32 | class ExternalCommandHelper : public QObject | ||
36 | { | 33 | { | ||
37 | Q_OBJECT | 34 | Q_OBJECT | ||
38 | Q_CLASSINFO("D-Bus Interface", "org.kde.kpmcore.externalcommand") | 35 | Q_CLASSINFO("D-Bus Interface", "org.kde.kpmcore.externalcommand") | ||
39 | 36 | | |||
40 | Q_SIGNALS: | 37 | Q_SIGNALS: | ||
41 | void progress(int); | 38 | void progress(int); | ||
42 | void quit(); | 39 | void quit(); | ||
43 | 40 | | |||
44 | public: | 41 | public: | ||
45 | bool readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size); | 42 | bool readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size); | ||
46 | bool writeData(const QString& targetDevice, const QByteArray& buffer, const qint64 offset); | 43 | bool writeData(const QString& targetDevice, const QByteArray& buffer, const qint64 offset); | ||
47 | 44 | | |||
48 | public Q_SLOTS: | 45 | public Q_SLOTS: | ||
49 | ActionReply init(const QVariantMap& args); | 46 | ActionReply init(const QVariantMap& args); | ||
50 | Q_SCRIPTABLE quint64 getNonce(); | 47 | Q_SCRIPTABLE QVariantMap start(const QString& command, const QStringList& arguments, const QByteArray& input, const int processChannelMode); | ||
51 | Q_SCRIPTABLE QVariantMap start(const QByteArray& signature, const quint64 nonce, const QString& command, const QStringList& arguments, const QByteArray& input, const int processChannelMode); | 48 | Q_SCRIPTABLE QVariantMap copyblocks(const QString& sourceDevice, const qint64 sourceFirstByte, const qint64 sourceLength, const QString& targetDevice, const qint64 targetFirstByte, const qint64 blockSize); | ||
52 | Q_SCRIPTABLE QVariantMap copyblocks(const QByteArray& signature, const quint64 nonce, const QString& sourceDevice, const qint64 sourceFirstByte, const qint64 sourceLength, const QString& targetDevice, const qint64 targetFirstByte, const qint64 blockSize); | 49 | Q_SCRIPTABLE bool writeData(const QByteArray& buffer, const QString& targetDevice, const qint64 targetFirstByte); | ||
53 | Q_SCRIPTABLE bool writeData(const QByteArray& signature, const quint64 nonce, const QByteArray& buffer, const QString& targetDevice, const qint64 targetFirstByte); | 50 | Q_SCRIPTABLE void exit(); | ||
54 | Q_SCRIPTABLE void exit(const QByteArray& signature, const quint64 nonce); | | |||
55 | 51 | | |||
56 | private: | 52 | private: | ||
57 | void onReadOutput(); | 53 | void onReadOutput(); | ||
58 | 54 | | |||
59 | std::unique_ptr<QEventLoop> m_loop; | 55 | std::unique_ptr<QEventLoop> m_loop; | ||
60 | QCA::Initializer initializer; | | |||
61 | QCA::PublicKey m_publicKey; | | |||
62 | QRandomGenerator64 m_Generator; | | |||
63 | std::unordered_set<quint64> m_Nonces; | | |||
64 | QProcess m_cmd; | 56 | QProcess m_cmd; | ||
65 | | ||||
66 | // QByteArray output; | 57 | // QByteArray output; | ||
67 | }; | 58 | }; | ||
68 | 59 | | |||
69 | #endif | 60 | #endif |