Changeset View
Changeset View
Standalone View
Standalone View
src/util/externalcommandhelper.h
Show All 17 Lines | |||||
18 | #ifndef KPMCORE_EXTERNALCOMMANDHELPER_H | 18 | #ifndef KPMCORE_EXTERNALCOMMANDHELPER_H | ||
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 <QDBusContext> | ||||
26 | #include <QEventLoop> | 27 | #include <QEventLoop> | ||
27 | #include <QString> | 28 | #include <QString> | ||
28 | #include <QProcess> | 29 | #include <QProcess> | ||
29 | 30 | | |||
31 | #include <PolkitQt1/Authority> | ||||
32 | | ||||
30 | using namespace KAuth; | 33 | using namespace KAuth; | ||
31 | 34 | | |||
32 | class ExternalCommandHelper : public QObject | 35 | using namespace PolkitQt1; | ||
36 | | ||||
37 | class ExternalCommandHelper : public QObject, protected QDBusContext | ||||
33 | { | 38 | { | ||
34 | Q_OBJECT | 39 | Q_OBJECT | ||
35 | Q_CLASSINFO("D-Bus Interface", "org.kde.kpmcore.externalcommand") | 40 | Q_CLASSINFO("D-Bus Interface", "org.kde.kpmcore.externalcommand") | ||
36 | 41 | | |||
37 | Q_SIGNALS: | 42 | Q_SIGNALS: | ||
38 | void progress(int); | 43 | void progress(int); | ||
39 | void quit(); | 44 | void quit(); | ||
45 | void actionAuthorized(); | ||||
40 | 46 | | |||
41 | public: | 47 | public: | ||
42 | bool readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size); | 48 | bool readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size); | ||
43 | bool writeData(const QString& targetDevice, const QByteArray& buffer, const qint64 offset); | 49 | bool writeData(const QString& targetDevice, const QByteArray& buffer, const qint64 offset); | ||
44 | 50 | | |||
45 | public Q_SLOTS: | 51 | public Q_SLOTS: | ||
46 | ActionReply init(const QVariantMap& args); | 52 | ActionReply init(const QVariantMap& args); | ||
47 | Q_SCRIPTABLE QVariantMap start(const QString& command, const QStringList& arguments, const QByteArray& input, const int processChannelMode); | 53 | Q_SCRIPTABLE QVariantMap start(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); | 54 | Q_SCRIPTABLE QVariantMap copyblocks(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); | 55 | Q_SCRIPTABLE bool writeData(const QByteArray& buffer, const QString& targetDevice, const qint64 targetFirstByte); | ||
50 | Q_SCRIPTABLE void exit(); | 56 | Q_SCRIPTABLE void exit(); | ||
57 | Q_SCRIPTABLE bool authorize(const QString &actionId, const Subject &subject, | ||||
58 | const Authority::AuthorizationFlags flags); | ||||
51 | 59 | | |||
52 | private: | 60 | private: | ||
53 | void onReadOutput(); | 61 | void onReadOutput(); | ||
54 | 62 | | |||
55 | std::unique_ptr<QEventLoop> m_loop; | 63 | std::unique_ptr<QEventLoop> m_loop; | ||
56 | QProcess m_cmd; | 64 | QProcess m_cmd; | ||
57 | // QByteArray output; | 65 | // QByteArray output; | ||
58 | }; | 66 | }; | ||
59 | 67 | | |||
60 | #endif | 68 | #endif |