Aktualizr
C++ SOTA Client
events.h
Go to the documentation of this file.
1 #ifndef EVENTS_H_
2 #define EVENTS_H_
3 /** \file */
4 
5 #include <memory>
6 #include <string>
7 
8 #include <boost/signals2.hpp>
9 
10 #include "uptane/tuf.h"
11 #include "utilities/results.h"
12 #include "utilities/types.h"
13 
14 /**
15  * Aktualizr status events.
16  */
17 namespace event {
18 
19 /**
20  * Base class for all event objects.
21  */
22 class BaseEvent {
23  public:
24  BaseEvent() = default;
25  BaseEvent(std::string variant_in) : variant(std::move(variant_in)) {}
26  virtual ~BaseEvent() = default;
27  std::string variant;
28 };
29 
30 /**
31  * Device data has been sent to the server.
32  */
34  public:
35  SendDeviceDataComplete() { variant = "SendDeviceDataComplete"; }
36 };
37 
38 /**
39  * A manifest has been sent to the server.
40  */
42  public:
43  explicit PutManifestComplete(bool success_in) : success(success_in) { variant = "PutManifestComplete"; }
44  bool success;
45 };
46 
47 /**
48  * An update is available for download from the server.
49  */
51  public:
52  explicit UpdateCheckComplete(UpdateCheckResult result_in) : result(std::move(result_in)) {
53  variant = "UpdateCheckComplete";
54  }
55 
56  UpdateCheckResult result;
57 };
58 
59 /**
60  * A download in progress has been paused.
61  */
62 class DownloadPaused : public BaseEvent {
63  public:
64  explicit DownloadPaused(PauseResult result_in) : result(result_in) { variant = "DownloadPaused"; }
65  PauseResult result;
66 };
67 
68 /**
69  * A paused download has been resumed.
70  */
71 class DownloadResumed : public BaseEvent {
72  public:
73  explicit DownloadResumed(PauseResult result_in) : result(result_in) { variant = "DownloadResumed"; }
74  PauseResult result;
75 };
76 
77 /**
78  * A report for a download in progress.
79  */
81  public:
82  DownloadProgressReport(Uptane::Target target_in, std::string description_in, unsigned int progress_in)
83  : target{std::move(target_in)}, description{std::move(description_in)}, progress{progress_in} {
84  variant = "DownloadProgressReport";
85  }
86 
87  Uptane::Target target;
88  std::string description;
89  unsigned int progress;
90 };
91 
92 /**
93  * A target has been downloaded.
94  */
96  public:
97  DownloadTargetComplete(Uptane::Target update_in, bool success_in)
98  : update(std::move(update_in)), success(success_in) {
99  variant = "DownloadTargetComplete";
100  }
101 
102  Uptane::Target update;
103  bool success;
104 };
105 
106 /**
107  * All targets for an update have been downloaded.
108  */
110  public:
111  explicit AllDownloadsComplete(DownloadResult result_in) : result(std::move(result_in)) {
112  variant = "AllDownloadsComplete";
113  }
114 
115  DownloadResult result;
116 };
117 
118 /**
119  * An ECU has begun installation of an update.
120  */
121 class InstallStarted : public BaseEvent {
122  public:
123  explicit InstallStarted(Uptane::EcuSerial serial_in) : serial(std::move(serial_in)) { variant = "InstallStarted"; }
124  Uptane::EcuSerial serial;
125 };
126 
127 /**
128  * An installation attempt on an ECU has completed.
129  */
131  public:
132  InstallTargetComplete(Uptane::EcuSerial serial_in, bool success_in)
133  : serial(std::move(serial_in)), success(success_in) {
134  variant = "InstallTargetComplete";
135  }
136 
137  Uptane::EcuSerial serial;
138  bool success;
139 };
140 
141 /**
142  * All ECU installation attempts for an update have completed.
143  */
145  public:
146  explicit AllInstallsComplete(InstallResult result_in) : result(std::move(result_in)) {
147  variant = "AllInstallsComplete";
148  }
149 
150  InstallResult result;
151 };
152 
153 /**
154  * The server has been queried for available campaigns.
155  */
157  public:
158  explicit CampaignCheckComplete(CampaignCheckResult result_in) : result(std::move(result_in)) {
159  variant = "CampaignCheckComplete";
160  }
161 
162  CampaignCheckResult result;
163 };
164 
165 /**
166  * A campaign has been accepted.
167  */
169  public:
170  CampaignAcceptComplete() { variant = "CampaignAcceptComplete"; }
171 };
172 
173 using Channel = boost::signals2::signal<void(std::shared_ptr<event::BaseEvent>)>;
174 
175 } // namespace event
176 
177 #endif // EVENTS_H_
Device data has been sent to the server.
Definition: events.h:33
A campaign has been accepted.
Definition: events.h:168
All ECU installation attempts for an update have completed.
Definition: events.h:144
An update is available for download from the server.
Definition: events.h:50
A download in progress has been paused.
Definition: events.h:62
A manifest has been sent to the server.
Definition: events.h:41
The server has been queried for available campaigns.
Definition: events.h:156
PauseResult
Result of an attempt to pause or resume a download.
Definition: results.h:55
A report for a download in progress.
Definition: events.h:80
An ECU has begun installation of an update.
Definition: events.h:121
A paused download has been resumed.
Definition: events.h:71
Container for information about downloading an update.
Definition: results.h:87
Container for information about available campaigns.
Definition: results.h:14
All targets for an update have been downloaded.
Definition: events.h:109
An installation attempt on an ECU has completed.
Definition: events.h:130
Container for information about available updates.
Definition: results.h:35
Aktualizr status events.
Definition: events.h:17
Container for information about installing an update.
Definition: results.h:112
Base class for all event objects.
Definition: events.h:22
A target has been downloaded.
Definition: events.h:95