|
60 | 60 | #include "linglong/api/types/v1/ExportDirs.hpp" |
61 | 61 | #include "linglong/api/types/v1/DialogMessage.hpp" |
62 | 62 | #include "linglong/api/types/v1/DialogHandShakePayload.hpp" |
| 63 | +#include "linglong/api/types/v1/DeviceOption.hpp" |
63 | 64 | #include "linglong/api/types/v1/ContainerProcessStateInfo.hpp" |
64 | 65 | #include "linglong/api/types/v1/CommonResult.hpp" |
65 | 66 | #include "linglong/api/types/v1/CommonOptions.hpp" |
@@ -265,6 +266,9 @@ void to_json(json & j, const UpgradeListResult & x); |
265 | 266 | void from_json(const json & j, LinglongAPIV1 & x); |
266 | 267 | void to_json(json & j, const LinglongAPIV1 & x); |
267 | 268 |
|
| 269 | +void from_json(const json & j, DeviceOption & x); |
| 270 | +void to_json(json & j, const DeviceOption & x); |
| 271 | + |
268 | 272 | void from_json(const json & j, InteractionMessageType & x); |
269 | 273 | void to_json(json & j, const InteractionMessageType & x); |
270 | 274 |
|
@@ -1273,12 +1277,16 @@ j["version"] = x.version; |
1273 | 1277 | } |
1274 | 1278 |
|
1275 | 1279 | inline void from_json(const json & j, RuntimeConfigure& x) { |
| 1280 | +x.deviceMode = get_stack_optional<std::vector<DeviceOption>>(j, "device_mode"); |
1276 | 1281 | x.env = get_stack_optional<std::map<std::string, std::string>>(j, "env"); |
1277 | 1282 | x.extDefs = get_stack_optional<std::map<std::string, std::vector<ExtensionDefine>>>(j, "ext_defs"); |
1278 | 1283 | } |
1279 | 1284 |
|
1280 | 1285 | inline void to_json(json & j, const RuntimeConfigure & x) { |
1281 | 1286 | j = json::object(); |
| 1287 | +if (x.deviceMode) { |
| 1288 | +j["device_mode"] = x.deviceMode; |
| 1289 | +} |
1282 | 1290 | if (x.env) { |
1283 | 1291 | j["env"] = x.env; |
1284 | 1292 | } |
@@ -1357,6 +1365,7 @@ x.commonOptions = get_stack_optional<CommonOptions>(j, "CommonOptions"); |
1357 | 1365 | x.commonResult = get_stack_optional<CommonResult>(j, "CommonResult"); |
1358 | 1366 | x.containerProcessStateInfo = get_stack_optional<ContainerProcessStateInfo>(j, "ContainerProcessStateInfo"); |
1359 | 1367 | x.deviceNode = get_stack_optional<DeviceNode>(j, "DeviceNode"); |
| 1368 | +x.deviceOption = get_stack_optional<DeviceOption>(j, "DeviceOption"); |
1360 | 1369 | x.dialogHandShakePayload = get_stack_optional<DialogHandShakePayload>(j, "DialogHandShakePayload"); |
1361 | 1370 | x.dialogMessage = get_stack_optional<DialogMessage>(j, "DialogMessage"); |
1362 | 1371 | x.exportDirs = get_stack_optional<ExportDirs>(j, "ExportDirs"); |
@@ -1432,6 +1441,9 @@ j["ContainerProcessStateInfo"] = x.containerProcessStateInfo; |
1432 | 1441 | if (x.deviceNode) { |
1433 | 1442 | j["DeviceNode"] = x.deviceNode; |
1434 | 1443 | } |
| 1444 | +if (x.deviceOption) { |
| 1445 | +j["DeviceOption"] = x.deviceOption; |
| 1446 | +} |
1435 | 1447 | if (x.dialogHandShakePayload) { |
1436 | 1448 | j["DialogHandShakePayload"] = x.dialogHandShakePayload; |
1437 | 1449 | } |
@@ -1548,6 +1560,18 @@ j["XDGDirectoryPermissions"] = x.xdgDirectoryPermissions; |
1548 | 1560 | } |
1549 | 1561 | } |
1550 | 1562 |
|
| 1563 | +inline void from_json(const json & j, DeviceOption & x) { |
| 1564 | +if (j == "passthru") x = DeviceOption::Passthru; |
| 1565 | +else { throw std::runtime_error("Input JSON does not conform to schema!"); } |
| 1566 | +} |
| 1567 | + |
| 1568 | +inline void to_json(json & j, const DeviceOption & x) { |
| 1569 | +switch (x) { |
| 1570 | +case DeviceOption::Passthru: j = "passthru"; break; |
| 1571 | +default: throw std::runtime_error("Unexpected value in enumeration \"DeviceOption\": " + std::to_string(static_cast<int>(x))); |
| 1572 | +} |
| 1573 | +} |
| 1574 | + |
1551 | 1575 | inline void from_json(const json & j, InteractionMessageType & x) { |
1552 | 1576 | if (j == "Downgrade") x = InteractionMessageType::Downgrade; |
1553 | 1577 | else if (j == "Install") x = InteractionMessageType::Install; |
|
0 commit comments