| 1 | #pragma once |
| 2 | |
| 3 | /// @file |
| 4 | /// @brief Enumeration of all event types |
| 5 | |
| 6 | #if __has_include(<nlohmann/json_fwd.hpp>) |
| 7 | #include <nlohmann/json_fwd.hpp> |
| 8 | #else |
| 9 | #include <nlohmann/json.hpp> |
| 10 | #endif |
| 11 | |
| 12 | #include <string> |
| 13 | namespace mtx { |
| 14 | namespace events { |
| 15 | |
| 16 | //! The type of an event. |
| 17 | enum class EventType |
| 18 | { |
| 19 | /// m.key.verification.cancel |
| 20 | KeyVerificationCancel, |
| 21 | /// m.key.verification.request |
| 22 | KeyVerificationRequest, |
| 23 | /// m.key.verification.start |
| 24 | KeyVerificationStart, |
| 25 | /// m.key.verification.accept |
| 26 | KeyVerificationAccept, |
| 27 | /// m.key.verification.key |
| 28 | KeyVerificationKey, |
| 29 | /// m.key.verification.mac |
| 30 | KeyVerificationMac, |
| 31 | /// m.key.verification.ready, |
| 32 | KeyVerificationReady, |
| 33 | /// m.key.verification.done, |
| 34 | KeyVerificationDone, |
| 35 | /// m.reaction, |
| 36 | Reaction, |
| 37 | /// m.room_key |
| 38 | RoomKey, |
| 39 | /// m.forwarded_room_key |
| 40 | ForwardedRoomKey, |
| 41 | /// m.room_key_request |
| 42 | RoomKeyRequest, |
| 43 | /// m.room.aliases |
| 44 | RoomAliases, |
| 45 | /// m.room.avatar |
| 46 | RoomAvatar, |
| 47 | /// m.room.canonical_alias |
| 48 | RoomCanonicalAlias, |
| 49 | /// m.room.create |
| 50 | RoomCreate, |
| 51 | /// m.room.encrypted. |
| 52 | RoomEncrypted, |
| 53 | /// m.room.encryption. |
| 54 | RoomEncryption, |
| 55 | /// m.room.guest_access |
| 56 | RoomGuestAccess, |
| 57 | /// m.room.history_visibility |
| 58 | RoomHistoryVisibility, |
| 59 | /// m.room.join_rules |
| 60 | RoomJoinRules, |
| 61 | /// m.room.member |
| 62 | RoomMember, |
| 63 | /// m.room.message |
| 64 | RoomMessage, |
| 65 | /// m.room.name |
| 66 | RoomName, |
| 67 | /// m.room.power_levels |
| 68 | RoomPowerLevels, |
| 69 | /// m.room.topic |
| 70 | RoomTopic, |
| 71 | /// m.room.redaction |
| 72 | RoomRedaction, |
| 73 | /// m.room.pinned_events |
| 74 | RoomPinnedEvents, |
| 75 | /// m.room.tombstone |
| 76 | RoomTombstone, |
| 77 | // m.sticker |
| 78 | Sticker, |
| 79 | // m.tag |
| 80 | Tag, |
| 81 | // m.presence |
| 82 | Presence, |
| 83 | // m.push_rules |
| 84 | PushRules, |
| 85 | |
| 86 | //! m.widget |
| 87 | Widget, |
| 88 | //! im.vector.modular.widgets |
| 89 | VectorWidget, |
| 90 | |
| 91 | //! m.policy.rule.user |
| 92 | PolicyRuleUser, |
| 93 | //! m.policy.rule.room |
| 94 | PolicyRuleRoom, |
| 95 | //! m.policy.rule.server |
| 96 | PolicyRuleServer, |
| 97 | |
| 98 | // m.space.child |
| 99 | SpaceChild, |
| 100 | // m.space.parent |
| 101 | SpaceParent, |
| 102 | |
| 103 | // m.call.invite |
| 104 | CallInvite, |
| 105 | // m.call.candidates |
| 106 | CallCandidates, |
| 107 | // m.call.answer |
| 108 | CallAnswer, |
| 109 | // m.call.hangup |
| 110 | CallHangUp, |
| 111 | // m.call.select_answer |
| 112 | CallSelectAnswer, |
| 113 | // m.call.reject |
| 114 | CallReject, |
| 115 | // m.call.negotiate |
| 116 | CallNegotiate, |
| 117 | |
| 118 | // m.secret.request |
| 119 | SecretRequest, |
| 120 | // m.secret.send |
| 121 | SecretSend, |
| 122 | |
| 123 | //! m.typing |
| 124 | Typing, |
| 125 | //! m.receipt |
| 126 | Receipt, |
| 127 | //! m.fully_read |
| 128 | FullyRead, |
| 129 | //! m.direct |
| 130 | Direct, |
| 131 | |
| 132 | // custom events |
| 133 | // im.nheko.hidden_events |
| 134 | NhekoHiddenEvents, |
| 135 | |
| 136 | // MSCs |
| 137 | //! m.image_pack, currently im.ponies.room_emotes |
| 138 | ImagePackInRoom, |
| 139 | //! m.image_pack, currently im.ponies.user_emotes |
| 140 | ImagePackInAccountData, |
| 141 | //! m.image_pack.rooms, currently im.ponies.emote_rooms |
| 142 | ImagePackRooms, |
| 143 | |
| 144 | //! `m.dummy`, used in crypto for example |
| 145 | Dummy, |
| 146 | |
| 147 | //! Unsupported event |
| 148 | Unsupported, |
| 149 | }; |
| 150 | |
| 151 | //! Turn an event into a string |
| 152 | std::string |
| 153 | to_string(EventType type); |
| 154 | |
| 155 | //! Parse a string into an event type. |
| 156 | EventType |
| 157 | getEventType(const std::string &type); |
| 158 | |
| 159 | //! Get the event type of an event. |
| 160 | EventType |
| 161 | getEventType(const nlohmann::json &obj); |
| 162 | } |
| 163 | } |
| 164 | |