Add handling of update-script
This commit is contained in:
57
update.h
Normal file
57
update.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef UPDATE_H_INCLUDED
|
||||
#define UPDATE_H_INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "DCPlugin/include/hwapi.h"
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
#else
|
||||
#define SERIAL_PORT "ttyUSB0"
|
||||
#endif
|
||||
|
||||
class Update;
|
||||
struct ScopedPointerCustomDeleter {
|
||||
static void cleanup(Update *pointer);
|
||||
};
|
||||
|
||||
// TODO: check hardware compatibility
|
||||
// TODO: opkg commandos
|
||||
|
||||
class Update : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
QScopedPointer<hwinf> m_hw;
|
||||
char const *m_serialInterface;
|
||||
char const *m_baudrate;
|
||||
QFile m_update_ctrl_file;
|
||||
QFile m_update_ctrl_file_copy;
|
||||
QString m_workingDir;
|
||||
|
||||
bool m_init;
|
||||
|
||||
bool updateBinary(char const *fileToSendToDC);
|
||||
bool updatePrinterConf(int nrOfTemplate, char const *fileToSendToDC);
|
||||
bool finishUpdate(bool finish);
|
||||
QStringList getOpenLines();
|
||||
QStringList split(QString line);
|
||||
static constexpr QChar SEPARATOR = QChar(',');
|
||||
|
||||
bool execUpdateScript();
|
||||
public:
|
||||
explicit Update(QString update_ctrl_file,
|
||||
QString workingDir = ".",
|
||||
QObject *parent = nullptr,
|
||||
hwinf *hw = nullptr,
|
||||
char const *serialInterface = SERIAL_PORT,
|
||||
char const *baudrate = "115200");
|
||||
virtual ~Update() override;
|
||||
bool doUpdate();
|
||||
|
||||
bool const m_delete;
|
||||
};
|
||||
#endif // UPDATE_H_INCLUDED
|
Reference in New Issue
Block a user