|
59 | 59 | #include "linglong/api/types/v1/ExportDirs.hpp" |
60 | 60 | #include "linglong/api/types/v1/DialogMessage.hpp" |
61 | 61 | #include "linglong/api/types/v1/DialogHandShakePayload.hpp" |
| 62 | +#include "linglong/api/types/v1/DeviceOption.hpp" |
62 | 63 | #include "linglong/api/types/v1/ContainerProcessStateInfo.hpp" |
63 | 64 | #include "linglong/api/types/v1/CommonResult.hpp" |
64 | 65 | #include "linglong/api/types/v1/CommonOptions.hpp" |
@@ -253,6 +254,9 @@ void to_json(json & j, const UpgradeListResult & x); |
253 | 254 | void from_json(const json & j, LinglongAPIV1 & x); |
254 | 255 | void to_json(json & j, const LinglongAPIV1 & x); |
255 | 256 |
|
| 257 | +void from_json(const json & j, DeviceOption & x); |
| 258 | +void to_json(json & j, const DeviceOption & x); |
| 259 | + |
256 | 260 | void from_json(const json & j, InteractionMessageType & x); |
257 | 261 | void to_json(json & j, const InteractionMessageType & x); |
258 | 262 |
|
@@ -1200,12 +1204,16 @@ j["version"] = x.version; |
1200 | 1204 | } |
1201 | 1205 |
|
1202 | 1206 | inline void from_json(const json & j, RuntimeConfigure& x) { |
| 1207 | +x.deviceMode = get_stack_optional<std::vector<DeviceOption>>(j, "device_mode"); |
1203 | 1208 | x.env = get_stack_optional<std::map<std::string, std::string>>(j, "env"); |
1204 | 1209 | x.extDefs = get_stack_optional<std::map<std::string, std::vector<ExtensionDefine>>>(j, "ext_defs"); |
1205 | 1210 | } |
1206 | 1211 |
|
1207 | 1212 | inline void to_json(json & j, const RuntimeConfigure & x) { |
1208 | 1213 | j = json::object(); |
| 1214 | +if (x.deviceMode) { |
| 1215 | +j["device_mode"] = x.deviceMode; |
| 1216 | +} |
1209 | 1217 | if (x.env) { |
1210 | 1218 | j["env"] = x.env; |
1211 | 1219 | } |
@@ -1283,6 +1291,7 @@ x.commonOptions = get_stack_optional<CommonOptions>(j, "CommonOptions"); |
1283 | 1291 | x.commonResult = get_stack_optional<CommonResult>(j, "CommonResult"); |
1284 | 1292 | x.containerProcessStateInfo = get_stack_optional<ContainerProcessStateInfo>(j, "ContainerProcessStateInfo"); |
1285 | 1293 | x.deviceNode = get_stack_optional<DeviceNode>(j, "DeviceNode"); |
| 1294 | +x.deviceOption = get_stack_optional<DeviceOption>(j, "DeviceOption"); |
1286 | 1295 | x.dialogHandShakePayload = get_stack_optional<DialogHandShakePayload>(j, "DialogHandShakePayload"); |
1287 | 1296 | x.dialogMessage = get_stack_optional<DialogMessage>(j, "DialogMessage"); |
1288 | 1297 | x.exportDirs = get_stack_optional<ExportDirs>(j, "ExportDirs"); |
@@ -1354,6 +1363,9 @@ j["ContainerProcessStateInfo"] = x.containerProcessStateInfo; |
1354 | 1363 | if (x.deviceNode) { |
1355 | 1364 | j["DeviceNode"] = x.deviceNode; |
1356 | 1365 | } |
| 1366 | +if (x.deviceOption) { |
| 1367 | +j["DeviceOption"] = x.deviceOption; |
| 1368 | +} |
1357 | 1369 | if (x.dialogHandShakePayload) { |
1358 | 1370 | j["DialogHandShakePayload"] = x.dialogHandShakePayload; |
1359 | 1371 | } |
@@ -1467,6 +1479,18 @@ j["XDGDirectoryPermissions"] = x.xdgDirectoryPermissions; |
1467 | 1479 | } |
1468 | 1480 | } |
1469 | 1481 |
|
| 1482 | +inline void from_json(const json & j, DeviceOption & x) { |
| 1483 | +if (j == "passthru") x = DeviceOption::Passthru; |
| 1484 | +else { throw std::runtime_error("Input JSON does not conform to schema!"); } |
| 1485 | +} |
| 1486 | + |
| 1487 | +inline void to_json(json & j, const DeviceOption & x) { |
| 1488 | +switch (x) { |
| 1489 | +case DeviceOption::Passthru: j = "passthru"; break; |
| 1490 | +default: throw std::runtime_error("Unexpected value in enumeration \"DeviceOption\": " + std::to_string(static_cast<int>(x))); |
| 1491 | +} |
| 1492 | +} |
| 1493 | + |
1470 | 1494 | inline void from_json(const json & j, InteractionMessageType & x) { |
1471 | 1495 | if (j == "Downgrade") x = InteractionMessageType::Downgrade; |
1472 | 1496 | else if (j == "Install") x = InteractionMessageType::Install; |
|
0 commit comments