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);
53  ~InboundGroupSessionPrivate() = default;
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 }
Kazv::InboundGroupSessionPrivate::pickle
std::string pickle() const
Definition: inbound-group-session.cpp:50
Kazv::operator!=
bool operator!=(BaseJob a, BaseJob b)
Definition: basejob.cpp:292
Kazv::InboundGroupSessionPrivate
Definition: inbound-group-session-p.hpp:48
Kazv::InboundGroupSessionPrivate::InboundGroupSessionPrivate
InboundGroupSessionPrivate()
Definition: inbound-group-session.cpp:18
Kazv::operator==
bool operator==(BaseJob a, BaseJob b)
Definition: basejob.cpp:280
Kazv::InboundGroupSessionPrivate::ed25519Key
std::string ed25519Key
Definition: inbound-group-session-p.hpp:57
Kazv
Definition: location.hpp:10
Kazv::Timestamp
std::int_fast64_t Timestamp
Definition: event.hpp:18
Kazv::KeyOfDecryptedEvent::originServerTs
Timestamp originServerTs
Definition: inbound-group-session-p.hpp:21
Kazv::InboundGroupSessionPrivate::error
std::string error() const
Kazv::InboundGroupSessionPrivate::session
std::optional< rust::Box< vodozemac::megolm::InboundGroupSession > > session
Definition: inbound-group-session-p.hpp:55
inbound-group-session.hpp
Kazv::from_json
void from_json(const nlohmann::json &j, KeyOfGroupSession &k)
Definition: crypto-util.hpp:36
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::InboundGroupSessionPrivate::decryptedEvents
immer::map< std::uint32_t, KeyOfDecryptedEvent > decryptedEvents
Definition: inbound-group-session-p.hpp:61
Kazv::KeyOfDecryptedEvent
Definition: inbound-group-session-p.hpp:18
Kazv::InboundGroupSessionPrivate::unpickleFromLibolm
bool unpickleFromLibolm(std::string pickleData)
Definition: inbound-group-session.cpp:65
Kazv::to_json
void to_json(nlohmann::json &j, const KeyOfGroupSession &k)
Definition: crypto-util.hpp:42
Kazv::InboundGroupSessionPrivate::unpickle
bool unpickle(std::string pickleData)
Definition: inbound-group-session.cpp:57
Kazv::InboundGroupSessionPrivate::checkError
std::size_t checkError(std::size_t code) const
Kazv::KeyOfDecryptedEvent::eventId
std::string eventId
Definition: inbound-group-session-p.hpp:20
libkazv-config.hpp
Kazv::InboundGroupSessionPrivate::valid
bool valid
Definition: inbound-group-session-p.hpp:59
Kazv::InboundGroupSessionPrivate::~InboundGroupSessionPrivate
~InboundGroupSessionPrivate()=default