Aktualizr
C++ SOTA Client
results.h
Go to the documentation of this file.
1 #ifndef RESULTS_H_
2 #define RESULTS_H_
3 /** \file */
4 
5 #include <string>
6 #include <vector>
7 
8 #include "campaign/campaign.h"
9 #include "uptane/tuf.h"
10 
11 /**
12  * Container for information about available campaigns.
13  */
15  public:
16  explicit CampaignCheckResult(std::vector<campaign::Campaign> campaigns_in) : campaigns(std::move(campaigns_in)) {}
17  std::vector<campaign::Campaign> campaigns;
18 };
19 
20 /**
21  * Status of an update.
22  */
23 enum class UpdateStatus {
24  /* Updates are available for ECUs known to aktualizr. */
25  kUpdatesAvailable = 0,
26  /* No updates are available for ECUs known to aktualizr. */
27  kNoUpdatesAvailable,
28  /* There was an error checking for updates. */
29  kError,
30 };
31 
32 /**
33  * Container for information about available updates.
34  */
36  public:
37  UpdateCheckResult() = default;
38  UpdateCheckResult(std::vector<Uptane::Target> updates_in, unsigned int ecus_count_in, UpdateStatus status_in,
39  const Json::Value &targets_meta_in, std::string message_in)
40  : updates(std::move(updates_in)),
41  ecus_count(ecus_count_in),
42  status(status_in),
43  targets_meta(targets_meta_in),
44  message(std::move(message_in)) {}
45  std::vector<Uptane::Target> updates;
46  unsigned int ecus_count{0};
47  UpdateStatus status{UpdateStatus::kNoUpdatesAvailable};
48  Json::Value targets_meta;
49  std::string message;
50 };
51 
52 /**
53  * Result of an attempt to pause or resume a download.
54  */
55 enum class PauseResult {
56  /* Download was paused successfully. */
57  kPaused = 0,
58  /* Download was resumed successfully. */
59  kResumed,
60  /* Download was already paused, so there is nothing to do. */
61  kAlreadyPaused,
62  /* Download has already completed, so there is nothing to do. */
63  kAlreadyComplete,
64  /* No download is in progress, so there is nothing to do. */
65  kNotDownloading,
66  /* Download was not paused, so there is nothing to do. */
67  kNotPaused,
68 };
69 
70 /**
71  * Status of an update download.
72  */
73 enum class DownloadStatus {
74  /* Update was downloaded successfully. */
75  kSuccess = 0,
76  /* Some targets in the update were downloaded successfully, but some were not. */
77  kPartialSuccess,
78  /* There are no targets to download for this update. */
79  kNothingToDownload,
80  /* There was an error downloading targets. */
81  kError,
82 };
83 
84 /**
85  * Container for information about downloading an update.
86  */
88  public:
89  DownloadResult() = default;
90  DownloadResult(std::vector<Uptane::Target> updates_in, DownloadStatus status_in, std::string message_in)
91  : updates(std::move(updates_in)), status(status_in), message(std::move(message_in)) {}
92  std::vector<Uptane::Target> updates;
93  DownloadStatus status{DownloadStatus::kNothingToDownload};
94  std::string message;
95 };
96 
97 /**
98  * Installation report for a given target on a given ECU.
99  */
101  public:
103  : update(std::move(update_in)), serial(std::move(serial_in)), status(std::move(status_in)) {}
104  Uptane::Target update;
105  Uptane::EcuSerial serial;
106  data::OperationResult status;
107 };
108 
109 /**
110  * Container for information about installing an update.
111  */
113  public:
114  InstallResult() = default;
115  explicit InstallResult(std::vector<InstallReport> reports_in) : reports(std::move(reports_in)) {}
116  std::vector<InstallReport> reports;
117 };
118 
119 #endif // RESULTS_H_
DownloadStatus
Status of an update download.
Definition: results.h:73
Installation report for a given target on a given ECU.
Definition: results.h:100
PauseResult
Result of an attempt to pause or resume a download.
Definition: results.h:55
UpdateStatus
Status of an update.
Definition: results.h:23
Container for information about downloading an update.
Definition: results.h:87
Container for information about available campaigns.
Definition: results.h:14
Container for information about available updates.
Definition: results.h:35
Container for information about installing an update.
Definition: results.h:112