1 | /* |
2 | SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@blue-systems.com> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-or-later |
5 | */ |
6 | |
7 | #ifndef PURPOSE_PROCESSJOB_H |
8 | #define PURPOSE_PROCESSJOB_H |
9 | |
10 | #include "job.h" |
11 | #include <QJsonObject> |
12 | #include <QLocalServer> |
13 | #include <QLocalSocket> |
14 | #include <QPointer> |
15 | #include <QProcess> |
16 | |
17 | namespace Purpose |
18 | { |
19 | /** |
20 | * @internal |
21 | * |
22 | * Purpose jobs can optionally run on an external process. This class interfaces |
23 | * with the external process. |
24 | */ |
25 | class ProcessJob : public Job |
26 | { |
27 | Q_OBJECT |
28 | public: |
29 | ProcessJob(const QString &pluginPath, const QString &pluginType, const QJsonObject &data, QObject *parent); |
30 | ~ProcessJob() override; |
31 | |
32 | void start() override; |
33 | |
34 | private: |
35 | void writeSocket(); |
36 | void readSocket(); |
37 | void processStateChanged(QProcess::ProcessState state); |
38 | |
39 | QPointer<QProcess> m_process; |
40 | |
41 | QString m_pluginPath; |
42 | QString m_pluginType; |
43 | QJsonObject m_data; |
44 | QLocalServer m_socket; |
45 | QPointer<QLocalSocket> m_localSocket; |
46 | }; |
47 | |
48 | } |
49 | |
50 | #endif |
51 | |