File indexing completed on 2024-04-28 04:00:30
0001 /* 0002 SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #ifndef PURPOSE_PROCESSJOB_H 0008 #define PURPOSE_PROCESSJOB_H 0009 0010 #include "job.h" 0011 #include <QJsonObject> 0012 #include <QLocalServer> 0013 #include <QLocalSocket> 0014 #include <QPointer> 0015 #include <QProcess> 0016 0017 namespace Purpose 0018 { 0019 /** 0020 * @internal 0021 * 0022 * Purpose jobs can optionally run on an external process. This class interfaces 0023 * with the external process. 0024 */ 0025 class ProcessJob : public Job 0026 { 0027 Q_OBJECT 0028 public: 0029 ProcessJob(const QString &pluginPath, const QString &pluginType, const QJsonObject &data, QObject *parent); 0030 ~ProcessJob() override; 0031 0032 void start() override; 0033 0034 private: 0035 void writeSocket(); 0036 void readSocket(); 0037 void processStateChanged(QProcess::ProcessState state); 0038 0039 QPointer<QProcess> m_process; 0040 0041 QString m_pluginPath; 0042 QString m_pluginType; 0043 QJsonObject m_data; 0044 QLocalServer m_socket; 0045 QPointer<QLocalSocket> m_localSocket; 0046 }; 0047 0048 } 0049 0050 #endif