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  };
23 
24  inline void to_json(nlohmann::json &j, const KeyOfDecryptedEvent &k)
25  {
26  j = nlohmann::json::object();
27  j["eventId"] = k.eventId;
28  j["originServerTs"] = k.originServerTs;
29  }
30 
31  inline void from_json(const nlohmann::json &j, KeyOfDecryptedEvent &k)
32  {
33  k.eventId = j.at("eventId");
34  k.originServerTs = j.at("originServerTs");
35  }
36 
38  {
39  return a.eventId == b.eventId
41  }
42 
44  {
45  return !(a == b);
46  }
47 
49  {
51  InboundGroupSessionPrivate(std::string sessionKey, std::string ed25519Key);
54 
55  std::optional<rust::Box<vodozemac::megolm::InboundGroupSession>> session;
56 
57  std::string ed25519Key;
58 
59  bool valid{false};
60 
61  immer::map<std::uint32_t /* index */, KeyOfDecryptedEvent> decryptedEvents;
62 
63  std::size_t checkError(std::size_t code) const;
64  std::string error() const;
65 
66  std::string pickle() const;
67  bool unpickle(std::string pickleData);
68  bool unpickleFromLibolm(std::string pickleData);
69  };
70 
71 }
Definition: location.hpp:10
bool operator!=(BaseJob a, BaseJob b)
Definition: basejob.cpp:292
nlohmann::json json
Definition: jsonwrap.hpp:20
std::int_fast64_t Timestamp
Definition: event.hpp:18
bool operator==(BaseJob a, BaseJob b)
Definition: basejob.cpp:280
void to_json(nlohmann::json &j, const KeyOfGroupSession &k)
Definition: crypto-util.hpp:42
void from_json(const nlohmann::json &j, KeyOfGroupSession &k)
Definition: crypto-util.hpp:36
Definition: inbound-group-session-p.hpp:49
InboundGroupSessionPrivate()
Definition: inbound-group-session.cpp:18
std::optional< rust::Box< vodozemac::megolm::InboundGroupSession > > session
Definition: inbound-group-session-p.hpp:55
std::size_t checkError(std::size_t code) const
std::string ed25519Key
Definition: inbound-group-session-p.hpp:57
bool unpickle(std::string pickleData)
Definition: inbound-group-session.cpp:57
immer::map< std::uint32_t, KeyOfDecryptedEvent > decryptedEvents
Definition: inbound-group-session-p.hpp:61
std::string pickle() const
Definition: inbound-group-session.cpp:50
bool unpickleFromLibolm(std::string pickleData)
Definition: inbound-group-session.cpp:65
bool valid
Definition: inbound-group-session-p.hpp:59
Definition: inbound-group-session-p.hpp:19
Timestamp originServerTs
Definition: inbound-group-session-p.hpp:21
std::string eventId
Definition: inbound-group-session-p.hpp:20