Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/inbound-group-session.hpp
| Show All 15 Lines | |||||
| namespace Kazv | namespace Kazv | ||||
| { | { | ||||
| struct InboundGroupSessionPrivate; | struct InboundGroupSessionPrivate; | ||||
| class InboundGroupSession | class InboundGroupSession | ||||
| { | { | ||||
| public: | public: | ||||
| struct ImportTag {}; | |||||
| explicit InboundGroupSession(); | explicit InboundGroupSession(); | ||||
| explicit InboundGroupSession(std::string sessionKey, std::string ed25519Key); | explicit InboundGroupSession(std::string sessionKey, std::string ed25519Key); | ||||
| InboundGroupSession(const InboundGroupSession &that); | InboundGroupSession(const InboundGroupSession &that); | ||||
| InboundGroupSession(InboundGroupSession &&that); | InboundGroupSession(InboundGroupSession &&that); | ||||
| InboundGroupSession &operator=(const InboundGroupSession &that); | InboundGroupSession &operator=(const InboundGroupSession &that); | ||||
| InboundGroupSession &operator=(InboundGroupSession &&that); | InboundGroupSession &operator=(InboundGroupSession &&that); | ||||
| ~InboundGroupSession(); | ~InboundGroupSession(); | ||||
| MaybeString decrypt(std::string message, std::string eventId, Timestamp originServerTs); | MaybeString decrypt(std::string message, std::string eventId, Timestamp originServerTs); | ||||
| bool valid() const; | bool valid() const; | ||||
| /** | |||||
| * Check whether this session is imported (from the session-export format). | |||||
| * | |||||
| * Precondition: valid() is true. | |||||
| * | |||||
| * @return true iff this session is imported. | |||||
| */ | |||||
| bool isImported() const; | |||||
| std::string ed25519Key() const; | std::string ed25519Key() const; | ||||
| /** | /** | ||||
| * Try to merge this session with another session. | * Try to merge this session with another session. | ||||
| * | * | ||||
| * @param that The other session to merge with. | * @param that The other session to merge with. | ||||
| * @return true iff the two sessions are mergeable. | * @return true iff the two sessions are mergeable. | ||||
| */ | */ | ||||
| bool merge(InboundGroupSession &that); | bool merge(InboundGroupSession &that); | ||||
| /** | |||||
| * Export the session to session-export format. | |||||
| * | |||||
| * Precondition: valid() is true. | |||||
| * | |||||
| * @return The base64 encoded session-export format. | |||||
| */ | |||||
| std::string toExportFormat() const; | |||||
| private: | private: | ||||
| friend void to_json(nlohmann::json &j, const InboundGroupSession &s); | friend void to_json(nlohmann::json &j, const InboundGroupSession &s); | ||||
| friend void from_json(const nlohmann::json &j, InboundGroupSession &s); | friend void from_json(const nlohmann::json &j, InboundGroupSession &s); | ||||
| std::unique_ptr<InboundGroupSessionPrivate> m_d; | std::unique_ptr<InboundGroupSessionPrivate> m_d; | ||||
| }; | }; | ||||
| } | } | ||||