#pragma once /// @file /// @brief Collections to store multiple events of different types #include #include "mtx/events.hpp" #include "mtx/events/account_data/direct.hpp" #include "mtx/events/account_data/fully_read.hpp" #include "mtx/events/account_data/ignored_users.hpp" #include "mtx/events/aliases.hpp" #include "mtx/events/avatar.hpp" #include "mtx/events/canonical_alias.hpp" #include "mtx/events/create.hpp" #include "mtx/events/encrypted.hpp" #include "mtx/events/encryption.hpp" #include "mtx/events/ephemeral/receipt.hpp" #include "mtx/events/ephemeral/typing.hpp" #include "mtx/events/guest_access.hpp" #include "mtx/events/history_visibility.hpp" #include "mtx/events/join_rules.hpp" #include "mtx/events/member.hpp" #include "mtx/events/mscs/image_packs.hpp" #include "mtx/events/name.hpp" #include "mtx/events/nheko_extensions/event_expiry.hpp" #include "mtx/events/nheko_extensions/hidden_events.hpp" #include "mtx/events/nheko_extensions/invite_permissions.hpp" #include "mtx/events/pinned_events.hpp" #include "mtx/events/policy_rules.hpp" #include "mtx/events/power_levels.hpp" #include "mtx/events/reaction.hpp" #include "mtx/events/redaction.hpp" #include "mtx/events/server_acl.hpp" #include "mtx/events/spaces.hpp" #include "mtx/events/tag.hpp" #include "mtx/events/tombstone.hpp" #include "mtx/events/topic.hpp" #include "mtx/events/unknown.hpp" #include "mtx/events/voip.hpp" #include "mtx/events/widget.hpp" #include "mtx/pushrules.hpp" #include "mtx/events/messages/audio.hpp" #include "mtx/events/messages/elementeffect.hpp" #include "mtx/events/messages/emote.hpp" #include "mtx/events/messages/file.hpp" #include "mtx/events/messages/image.hpp" #include "mtx/events/messages/location.hpp" #include "mtx/events/messages/notice.hpp" #include "mtx/events/messages/text.hpp" #include "mtx/events/messages/unknown.hpp" #include "mtx/events/messages/video.hpp" namespace mtx { namespace events { //! Contains heterogeneous collections of events using std::variant. namespace collections { //! Collection of key verification events struct DeviceEvents : public std::variant, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent, mtx::events::DeviceEvent> { using variant::variant; }; //! Collection of room specific account data struct RoomAccountDataEvents : public std::variant< mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent, mtx::events::AccountDataEvent> { using variant::variant; }; //! Collection of @p StateEvent only. struct StateEvents : public std::variant, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent> { using variant::variant; }; //! Collection of @p StrippedEvent only. struct StrippedEvents : public std::variant, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent, mtx::events::StrippedEvent> { using variant::variant; }; //! Collection of @p StateEvent and @p RoomEvent. Those events would be //! available on the returned timeline. struct TimelineEvents : public std::variant, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::StateEvent, mtx::events::EncryptedEvent, mtx::events::RedactionEvent, mtx::events::Sticker, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent, mtx::events::RoomEvent> { using variant::variant; // The Qt MOC chokes on this, because the default implementation from the variant gets into some // conflict with the variant types not having an operator==. Being explicit fixes that. bool operator==(const TimelineEvents &) const = delete; bool operator<(const TimelineEvents &) const = delete; friend void from_json(const nlohmann::json &obj, TimelineEvents &e); friend void to_json(nlohmann::json &obj, const TimelineEvents &e); }; struct EphemeralEvents : public std::variant, mtx::events::EphemeralEvent, mtx::events::EphemeralEvent> { using variant::variant; }; } // namespace collections //! Get the right event type for some type of message content. template constexpr inline EventType message_content_to_type = EventType::Unsupported; template<> constexpr inline EventType message_content_to_type = EventType::RoomEncrypted; template<> constexpr inline EventType message_content_to_type = EventType::Reaction; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::RoomMessage; template<> constexpr inline EventType message_content_to_type = EventType::Sticker; template<> constexpr inline EventType message_content_to_type = EventType::CallInvite; template<> constexpr inline EventType message_content_to_type = EventType::CallCandidates; template<> constexpr inline EventType message_content_to_type = EventType::CallAnswer; template<> constexpr inline EventType message_content_to_type = EventType::CallHangUp; template<> constexpr inline EventType message_content_to_type = EventType::CallSelectAnswer; template<> constexpr inline EventType message_content_to_type = EventType::CallReject; template<> constexpr inline EventType message_content_to_type = EventType::CallNegotiate; //! Get the right event type for some type of state event content. template constexpr inline EventType state_content_to_type = EventType::Unsupported; template<> constexpr inline EventType state_content_to_type = EventType::RoomAliases; template<> constexpr inline EventType state_content_to_type = EventType::RoomAvatar; template<> constexpr inline EventType state_content_to_type = EventType::RoomCanonicalAlias; template<> constexpr inline EventType state_content_to_type = EventType::RoomCreate; template<> constexpr inline EventType state_content_to_type = EventType::RoomEncryption; template<> constexpr inline EventType state_content_to_type = EventType::RoomGuestAccess; template<> constexpr inline EventType state_content_to_type = EventType::RoomHistoryVisibility; template<> constexpr inline EventType state_content_to_type = EventType::RoomJoinRules; template<> constexpr inline EventType state_content_to_type = EventType::RoomMember; template<> constexpr inline EventType state_content_to_type = EventType::RoomName; template<> constexpr inline EventType state_content_to_type = EventType::RoomPinnedEvents; template<> constexpr inline EventType state_content_to_type = EventType::PolicyRuleUser; template<> constexpr inline EventType state_content_to_type = EventType::PolicyRuleRoom; template<> constexpr inline EventType state_content_to_type = EventType::PolicyRuleServer; template<> constexpr inline EventType state_content_to_type = EventType::RoomPowerLevels; template<> constexpr inline EventType state_content_to_type = EventType::RoomTombstone; template<> constexpr inline EventType state_content_to_type = EventType::RoomServerAcl; template<> constexpr inline EventType state_content_to_type = EventType::SpaceChild; template<> constexpr inline EventType state_content_to_type = EventType::SpaceParent; template<> constexpr inline EventType state_content_to_type = EventType::VectorWidget; template<> constexpr inline EventType state_content_to_type = EventType::RoomTopic; template<> constexpr inline EventType state_content_to_type = EventType::ImagePackInRoom; //! Get the right event type for some type of device message content. template constexpr inline EventType to_device_content_to_type = EventType::Unsupported; template<> constexpr inline EventType to_device_content_to_type = EventType::RoomKey; template<> constexpr inline EventType to_device_content_to_type = EventType::ForwardedRoomKey; template<> constexpr inline EventType to_device_content_to_type = EventType::RoomKeyRequest; template<> constexpr inline EventType to_device_content_to_type = EventType::RoomEncrypted; template<> constexpr inline EventType to_device_content_to_type = EventType::RoomEncrypted; template<> constexpr inline EventType to_device_content_to_type = EventType::Dummy; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationRequest; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationStart; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationReady; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationDone; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationAccept; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationCancel; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationKey; template<> constexpr inline EventType to_device_content_to_type = EventType::KeyVerificationMac; template<> constexpr inline EventType to_device_content_to_type = EventType::SecretSend; template<> constexpr inline EventType to_device_content_to_type = EventType::SecretRequest; //! Get the right event type for some type of account_data event content. template constexpr inline EventType account_data_content_to_type = EventType::Unsupported; template<> constexpr inline EventType account_data_content_to_type = EventType::ImagePackInAccountData; template<> constexpr inline EventType account_data_content_to_type = EventType::ImagePackRooms; template<> constexpr inline EventType account_data_content_to_type = EventType::Tag; template<> constexpr inline EventType account_data_content_to_type = EventType::Direct; template<> constexpr inline EventType account_data_content_to_type = EventType::IgnoredUsers; template<> constexpr inline EventType account_data_content_to_type = EventType::NhekoHiddenEvents; template<> constexpr inline EventType account_data_content_to_type = EventType::NhekoEventExpiry; template<> constexpr inline EventType account_data_content_to_type = EventType::NhekoInvitePermissions; } // namespace events } // namespace mtx