| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef PURPOSEJOB_H |
| 8 | #define PURPOSEJOB_H |
| 9 | |
| 10 | #include <KJob> |
| 11 | #include <QJsonArray> |
| 12 | #include <QJsonObject> |
| 13 | #include <QMimeData> |
| 14 | #include <QUrl> |
| 15 | #include <purpose/purpose_export.h> |
| 16 | |
| 17 | /*! |
| 18 | * \namespace Purpose |
| 19 | * \inmodule Purpose |
| 20 | */ |
| 21 | namespace Purpose |
| 22 | { |
| 23 | class JobPrivate; |
| 24 | |
| 25 | /*! |
| 26 | * \class Purpose::Job |
| 27 | * \inheaderfile Purpose/Job |
| 28 | * \inmodule Purpose |
| 29 | * |
| 30 | * \brief Job that will actually perform the sharing. |
| 31 | * |
| 32 | * When start is called, the sharing process will start and when the job |
| 33 | * emits finished, we'll know it's over. |
| 34 | * |
| 35 | * The start method called shouldn't be called before all data has been |
| 36 | * filled in. |
| 37 | */ |
| 38 | class PURPOSE_EXPORT Job : public KJob |
| 39 | { |
| 40 | Q_OBJECT |
| 41 | /*! |
| 42 | * \property Purpose::Job::data |
| 43 | * Represents the data the job will have available to perform its task. |
| 44 | */ |
| 45 | Q_PROPERTY(QJsonObject data READ data CONSTANT) |
| 46 | |
| 47 | /*! |
| 48 | * \property Purpose::Job::output |
| 49 | * Returns the output generated by the plugin. |
| 50 | * |
| 51 | * The information offered will depend on the plugin type. |
| 52 | */ |
| 53 | Q_PROPERTY(QJsonObject output READ output WRITE setOutput NOTIFY outputChanged) |
| 54 | public: |
| 55 | explicit Job(QObject *parent = nullptr); |
| 56 | ~Job() override; |
| 57 | |
| 58 | /*! |
| 59 | * \brief Should only be called after constructing. |
| 60 | * |
| 61 | * \internal |
| 62 | */ |
| 63 | void setData(const QJsonObject &data); |
| 64 | QJsonObject data() const; |
| 65 | |
| 66 | QJsonObject output() const; |
| 67 | void setOutput(const QJsonObject &output); |
| 68 | |
| 69 | Q_SIGNALS: |
| 70 | void outputChanged(const QJsonObject &output); |
| 71 | |
| 72 | private: |
| 73 | Q_DECLARE_PRIVATE(Job) |
| 74 | QScopedPointer<JobPrivate> const d_ptr; |
| 75 | }; |
| 76 | |
| 77 | } |
| 78 | |
| 79 | #endif |
| 80 | |