use of worker/worker-thread so we can work without using buttons (as the cannot be triggered by an automatic update process)

This commit is contained in:
2023-07-11 16:58:49 +02:00
parent bd213b8f8c
commit 26db620465
2 changed files with 89 additions and 26 deletions

View File

@@ -4,27 +4,55 @@
#include <QObject>
#include <QString>
#include <QTimer>
#include <QFile>
#include <QJsonObject>
#include "worker_thread.h"
#include "update.h"
#include "git/git_client.h"
#include "ismas/ismas_client.h"
#include "apism/apism_client.h"
#ifdef PTU5
#define SERIAL_PORT "ttymxc2"
#else
#define SERIAL_PORT "ttyUSB0"
#endif
class hwinf;
class Worker : public QObject {
Q_OBJECT
QString m_update_ctrl_file;
QString m_workingDir;
WorkerThread m_workerThread;
QTimer m_timer;
Update *m_update;
ApismClient m_apismClient;
GitClient m_gc;
public:
explicit Worker(QString update_ctrl_file, QString workingDir);
explicit Worker(hwinf *hw,
QString update_ctrl_file,
QString workingDir = ".",
bool maintenanceMode = false,
bool testMode = false,
bool executeScriptOnly = false,
bool dryRun = false,
QObject *parent = nullptr,
char const *serialInterface = SERIAL_PORT,
char const *baudrate = "115200");
~Worker();
void quit() { return m_workerThread.quit(); }
signals:
void workNow();
void executeOpkgCommands();
public slots:
void work();
void update();
void onIsmasResponseReceived(QJsonObject ismasResponse);
void onExecuteOpkgCommands();
private slots:
void runUpdate();
};
#endif // WORKER_H_INCLUDED