1 | /****************************************************************************** |
2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
3 | */ |
4 | |
5 | #pragma once |
6 | |
7 | #include <Quotient/converters.h> |
8 | |
9 | namespace Quotient { |
10 | /// The key data |
11 | struct KeyBackupData { |
12 | /// The index of the first message in the session that the key can decrypt. |
13 | int firstMessageIndex; |
14 | |
15 | /// The number of times this key has been forwarded via key-sharing between |
16 | /// devices. |
17 | int forwardedCount; |
18 | |
19 | /// Whether the device backing up the key verified the device that the key |
20 | /// is from. |
21 | bool isVerified; |
22 | |
23 | /// Algorithm-dependent data. See the documentation for the backup |
24 | /// algorithms in [Server-side key |
25 | /// backups](/client-server-api/#server-side-key-backups) for more |
26 | /// information on the expected format of the data. |
27 | QJsonObject sessionData; |
28 | }; |
29 | |
30 | template <> |
31 | struct JsonObjectConverter<KeyBackupData> { |
32 | static void dumpTo(QJsonObject& jo, const KeyBackupData& pod) |
33 | { |
34 | addParam<>(container&: jo, QStringLiteral("first_message_index" ), |
35 | value: pod.firstMessageIndex); |
36 | addParam<>(container&: jo, QStringLiteral("forwarded_count" ), value: pod.forwardedCount); |
37 | addParam<>(container&: jo, QStringLiteral("is_verified" ), value: pod.isVerified); |
38 | addParam<>(container&: jo, QStringLiteral("session_data" ), value: pod.sessionData); |
39 | } |
40 | static void fillFrom(const QJsonObject& jo, KeyBackupData& pod) |
41 | { |
42 | fillFromJson(jv: jo.value(key: "first_message_index"_ls ), pod&: pod.firstMessageIndex); |
43 | fillFromJson(jv: jo.value(key: "forwarded_count"_ls ), pod&: pod.forwardedCount); |
44 | fillFromJson(jv: jo.value(key: "is_verified"_ls ), pod&: pod.isVerified); |
45 | fillFromJson(jv: jo.value(key: "session_data"_ls ), pod&: pod.sessionData); |
46 | } |
47 | }; |
48 | |
49 | } // namespace Quotient |
50 | |