7 Json::Value Package::toJson() {
10 json[
"version"] = version;
14 Package Package::fromJson(
const std::string& json_str) {
17 reader.parse(json_str, json);
19 package.name = json[
"name"].asString();
20 package.version = json[
"version"].asString();
24 OperationResult::OperationResult(std::string id_in,
UpdateResultCode result_code_in, std::string result_text_in)
25 : id(std::move(id_in)), result_code(result_code_in), result_text(std::move(result_text_in)) {}
27 OperationResult::OperationResult(std::string id_in, InstallOutcome outcome_in)
28 : id(std::move(id_in)), result_code(outcome_in.first), result_text(outcome_in.second) {}
30 InstallOutcome OperationResult::toOutcome()
const {
return InstallOutcome(result_code, result_text); }
32 Json::Value OperationResult::toJson()
const {
35 json[
"result_code"] =
static_cast<int>(result_code);
36 json[
"result_text"] = result_text;
40 OperationResult OperationResult::fromJson(
const std::string& json_str) {
43 reader.parse(json_str, json);
45 operation_result.id = json[
"id"].asString();
46 operation_result.result_code =
static_cast<UpdateResultCode>(json[
"result_code"].asUInt());
47 operation_result.result_text = json[
"result_text"].asString();
48 return operation_result;
51 OperationResult OperationResult::fromOutcome(
const std::string&
id,
const InstallOutcome& outcome) {
53 return operation_result;
58 RunningMode RunningModeFromString(
const std::string& mode) {
59 if (mode ==
"full" || mode.empty()) {
61 }
else if (mode ==
"once") {
63 }
else if (mode ==
"check") {
65 }
else if (mode ==
"download") {
67 }
else if (mode ==
"install") {
69 }
else if (mode ==
"campaign_check") {
71 }
else if (mode ==
"campaign_accept") {
74 throw std::runtime_error(std::string(
"Incorrect running mode: ") + mode);
78 std::string StringFromRunningMode(
RunningMode mode) {
79 std::string mode_str =
"full";
87 mode_str =
"download";
91 return "campaign_check";
93 return "campaign_accept";
Only accept an existing campaign.
Download any available updates and then shut down.
RunningMode
Execution mode to run aktualizr in.
Only check for an existing campaign related to the device.
UpdateResultCode
Result of an update.
Install any available updates and then shut down.