libkazv
inbound-group-session-p.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of libkazv.
3  * SPDX-FileCopyrightText: 2021 Tusooa Zhu <tusooa@kazv.moe>
4  * SPDX-License-Identifier: AGPL-3.0-or-later
5  */
6 
7 #pragma once
8 #include <libkazv-config.hpp>
9 
11 
12 #include <vodozemac.h>
13 
14 #include <immer/map.hpp>
15 
16 namespace Kazv
17 {
19  {
20  std::string eventId;
22  friend bool operator==(const KeyOfDecryptedEvent &a, const KeyOfDecryptedEvent &b) = default;
23  friend bool operator!=(const KeyOfDecryptedEvent &a, const KeyOfDecryptedEvent &b) = default;
24  };
25 
26  inline void to_json(nlohmann::json &j, const KeyOfDecryptedEvent &k)
27  {
28  j = nlohmann::json::object();
29  j["eventId"] = k.eventId;
30  j["originServerTs"] = k.originServerTs;
31  }
32 
33  inline void from_json(const nlohmann::json &j, KeyOfDecryptedEvent &k)
34  {
35  k.eventId = j.at("eventId");
36  k.originServerTs = j.at("originServerTs");
37  }
38 
40  {
42  InboundGroupSessionPrivate(std::string sessionKey, std::string ed25519Key);
45 
46  std::optional<rust::Box<vodozemac::megolm::InboundGroupSession>> session;
47 
48  std::string ed25519Key;
49 
50  bool valid{false};
51  bool isImported{false};
52 
53  immer::map<std::uint32_t /* index */, KeyOfDecryptedEvent> decryptedEvents;
54 
55  std::size_t checkError(std::size_t code) const;
56  std::string error() const;
57 
58  std::string pickle() const;
59  bool unpickle(std::string pickleData);
60  bool unpickleFromLibolm(std::string pickleData);
61  };
62 
63 }
Definition: location.hpp:10
nlohmann::json json
Definition: jsonwrap.hpp:20
std::int_fast64_t Timestamp
Definition: event.hpp:18
void to_json(nlohmann::json &j, const KeyOfGroupSession &k)
Definition: crypto-util.hpp:43
void from_json(const nlohmann::json &j, KeyOfGroupSession &k)
Definition: crypto-util.hpp:37
Definition: inbound-group-session-p.hpp:40
InboundGroupSessionPrivate()
Definition: inbound-group-session.cpp:18
std::optional< rust::Box< vodozemac::megolm::InboundGroupSession > > session
Definition: inbound-group-session-p.hpp:46
bool isImported
Definition: inbound-group-session-p.hpp:51
std::size_t checkError(std::size_t code) const
std::string ed25519Key
Definition: inbound-group-session-p.hpp:48
bool unpickle(std::string pickleData)
Definition: inbound-group-session.cpp:72
immer::map< std::uint32_t, KeyOfDecryptedEvent > decryptedEvents
Definition: inbound-group-session-p.hpp:53
std::string pickle() const
Definition: inbound-group-session.cpp:65
bool unpickleFromLibolm(std::string pickleData)
Definition: inbound-group-session.cpp:80
bool valid
Definition: inbound-group-session-p.hpp:50
Definition: inbound-group-session-p.hpp:19
friend bool operator==(const KeyOfDecryptedEvent &a, const KeyOfDecryptedEvent &b)=default
Timestamp originServerTs
Definition: inbound-group-session-p.hpp:21
friend bool operator!=(const KeyOfDecryptedEvent &a, const KeyOfDecryptedEvent &b)=default
std::string eventId
Definition: inbound-group-session-p.hpp:20