-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswupdater.h
51 lines (43 loc) · 1.13 KB
/
swupdater.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef SWUPDATER_H
#define SWUPDATER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QtWebSockets/QWebSocket>
#include <QFile>
#define STRING_SUCCESS "SWUPDATE successful !"
class SWUpdater : public QObject
{
Q_OBJECT
Q_PROPERTY(QString qUrl MEMBER m_url NOTIFY urlChanged)
Q_PROPERTY(QString qFile MEMBER m_pathImage)
public:
explicit SWUpdater();
/// destructor
virtual~SWUpdater();
Q_SIGNALS:
void onDisconnected();
void urlChanged();
void uploadReady();
void updateFinished();
public Q_SLOTS:
void onConnected();
void onUrlChanged();
void onUpload();
void onMessage(const QString &message);
void onUpdateFinished();
void onUploadFinished();
void onUploadProgress(qint64 bytesSent, qint64 bytesTotal);
private:
QWebSocket m_webSocket;
QString m_url;
QString m_websocket_url;
bool m_connected = false;
bool m_onUpdate = false;
QFile *m_file = nullptr;
QString m_pathImage;
QString m_swuImage;
QNetworkAccessManager *m_manager = nullptr;
QString extractImageName(QString &);
};
#endif // SWUPDATER_H