supla-device
Loading...
Searching...
No Matches
sw_update.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18
19#ifndef SRC_SUPLA_DEVICE_SW_UPDATE_H_
20#define SRC_SUPLA_DEVICE_SW_UPDATE_H_
21
22#define SUPLA_MAX_URL_LENGTH 202
23
24#include <SuplaDevice.h>
25
26namespace Supla {
27
28namespace Device {
29class SwUpdate {
30 public:
31 static SwUpdate *Create(SuplaDeviceClass *sdc,
32 const char *newUrl,
33 Supla::SwUpdateMode mode);
34 virtual ~SwUpdate();
35
36 void start() {
37 started = true;
38 }
39 virtual void iterate() = 0;
40
41 void setUrl(const char *newUrl);
42 bool isStarted() {
43 return started;
44 }
45 bool isFinished() {
46 return finished;
47 }
48 bool isAborted() {
49 return abort;
50 }
51 void useBeta() {
52 beta = true;
53 }
54 void setSkipCert() {
55 skipCert = true;
56 }
57 bool isRetryAllowed() {
58 return retryAllowed;
59 }
60
61 const char *getUrl() const {
62 return updateUrl;
63 }
64 const char *getNewVersion() const {
65 return newVersion;
66 }
67 const char *getChangelogUrl() const {
68 return changelogUrl;
69 }
70
71 bool isSecurityOnly() const {
72 return securityOnly;
73 }
74 void setSecurityOnly() {
75 securityOnly = true;
76 }
77
78 protected:
79 explicit SwUpdate(SuplaDeviceClass *sdc,
80 const char *newUrl,
81 Supla::SwUpdateMode mode);
82
83 bool beta = false;
84 bool skipCert = false;
85 bool securityOnly = false;
86 bool started = false;
87 bool finished = false;
88 bool abort = false;
89 SuplaDeviceClass *sdc = nullptr;
90 char *updateUrl = nullptr;
91 char *newVersion = nullptr;
92 char *changelogUrl = nullptr;
93 bool retryAllowed = false;
94 Supla::SwUpdateMode mode = Supla::SwUpdateMode::NotSet;
95
96 char url[SUPLA_MAX_URL_LENGTH] = {};
97};
98}; // namespace Device
99}; // namespace Supla
100
101#endif // SRC_SUPLA_DEVICE_SW_UPDATE_H_
Definition SuplaDevice.h:162