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 <olm/olm.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 
56  OlmInboundGroupSession *session;
57 
58  std::string ed25519Key;
59 
60  bool valid{false};
61 
62  immer::map<std::uint32_t /* index */, KeyOfDecryptedEvent> decryptedEvents;
63 
64  std::size_t checkError(std::size_t code) const;
65  std::string error() const;
66 
67  std::string pickle() const;
68  bool unpickle(std::string pickleData);
69  };
70 
71 }
Kazv::InboundGroupSessionPrivate::pickle
std::string pickle() const
Definition: inbound-group-session.cpp:60
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:33
Kazv::operator==
bool operator==(BaseJob a, BaseJob b)
Definition: basejob.cpp:280
Kazv::InboundGroupSessionPrivate::ed25519Key
std::string ed25519Key
Definition: inbound-group-session-p.hpp:58
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
Definition: inbound-group-session.cpp:27
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::sessionData
ByteArray sessionData
Definition: inbound-group-session-p.hpp:55
Kazv::InboundGroupSessionPrivate::decryptedEvents
immer::map< std::uint32_t, KeyOfDecryptedEvent > decryptedEvents
Definition: inbound-group-session-p.hpp:62
Kazv::KeyOfDecryptedEvent
Definition: inbound-group-session-p.hpp:18
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:70
Kazv::ByteArray
std::vector< unsigned char > ByteArray
Definition: crypto-util.hpp:21
Kazv::InboundGroupSessionPrivate::session
OlmInboundGroupSession * session
Definition: inbound-group-session-p.hpp:56
Kazv::InboundGroupSessionPrivate::checkError
std::size_t checkError(std::size_t code) const
Definition: inbound-group-session.cpp:18
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:60
Kazv::InboundGroupSessionPrivate::~InboundGroupSessionPrivate
~InboundGroupSessionPrivate()=default