Added worker/worker-thread-pair.
Worker uses event-loop of worker-thread. Worker itself is used as work-horse for the update-process.
This commit is contained in:
50
worker.h
50
worker.h
@@ -3,9 +3,11 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
#include <QFile>
|
||||
#include <QJsonObject>
|
||||
#include <QHash>
|
||||
|
||||
#include "worker_thread.h"
|
||||
#include "update.h"
|
||||
@@ -25,14 +27,37 @@ class Worker : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
WorkerThread m_workerThread;
|
||||
QTimer m_timer;
|
||||
QTimer m_startUpdateProcess;
|
||||
Update *m_update;
|
||||
ApismClient m_apismClient;
|
||||
GitClient m_gc;
|
||||
QString const m_customerId;
|
||||
QString const m_workingDirectory;
|
||||
QString const m_branchName;
|
||||
QString const m_customerRepository;
|
||||
bool m_maintenanceMode;
|
||||
int m_ismasUpdateRequests;
|
||||
QTimer m_waitForNewUpdates;
|
||||
IsmasClient m_ismasClient;
|
||||
|
||||
int m_machineNr; // setzen
|
||||
int m_customerNr;
|
||||
|
||||
|
||||
enum { ISMAS_UPDATE_REQUESTS = 6 };
|
||||
|
||||
enum class UPDATE_STATUS : quint8 {
|
||||
STARTED,
|
||||
STOPPED,
|
||||
ERROR_BACKEND
|
||||
} m_updateStatus;
|
||||
|
||||
public:
|
||||
explicit Worker(hwinf *hw,
|
||||
QString update_ctrl_file,
|
||||
QString repositoryPath,
|
||||
QString customerId,
|
||||
QString branchName,
|
||||
QString workingDir = ".",
|
||||
bool maintenanceMode = false,
|
||||
bool testMode = false,
|
||||
@@ -45,14 +70,31 @@ public:
|
||||
void quit() { return m_workerThread.quit(); }
|
||||
|
||||
signals:
|
||||
void executeOpkgCommands();
|
||||
void executeOpkgCommands(QStringList);
|
||||
void executeOpkgCommand(QString);
|
||||
void handleChangedFiles(QStringList);
|
||||
void summarizeUpload(QStringList);
|
||||
void summarizeRepositoryStatus();
|
||||
void sendCmdSendVersionToIsmas();
|
||||
void finishUpdateProcess(bool changes);
|
||||
void terminateUpdateProcess();
|
||||
|
||||
public slots:
|
||||
void onIsmasResponseReceived(QJsonObject ismasResponse);
|
||||
void onExecuteOpkgCommands();
|
||||
void onExecuteOpkgCommands(QStringList opkgCommands);
|
||||
void onExecuteOpkgCommand(QString opkgCommand);
|
||||
|
||||
private slots:
|
||||
void runUpdate();
|
||||
void askIsmasForNewData();
|
||||
void onSendCmdSendVersionToIsmas();
|
||||
void onSummarizeRepositoryStatus();
|
||||
void onFinishUpdateProcess(bool changes);
|
||||
void onTerminateUpdateProcess();
|
||||
void onSummarizeUpload(QStringList);
|
||||
void onHandleChangedFiles(QStringList);
|
||||
};
|
||||
|
||||
//Q_DECLARE_METATYPE((QHash<QString, QString>))
|
||||
//Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(QHash)
|
||||
|
||||
#endif // WORKER_H_INCLUDED
|
||||
|
Reference in New Issue
Block a user