| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <QDateTime> |
| 8 |
#include <QImage> |
| 9 |
#include <QString> |
| 10 |
|
| 11 |
#include <string> |
| 12 |
|
| 13 |
#include <mtx/events/join_rules.hpp> |
| 14 |
#include <mtx/events/mscs/image_packs.hpp> |
| 15 |
|
| 16 |
namespace cache { |
| 17 |
enum class CacheVersion : int |
| 18 |
{ |
| 19 |
Older = -1, |
| 20 |
Current = 0, |
| 21 |
Newer = 1, |
| 22 |
}; |
| 23 |
} |
| 24 |
|
| 25 |
struct RoomMember |
| 26 |
{ |
| 27 |
QString user_id; |
| 28 |
QString display_name; |
| 29 |
QString avatar_url; |
| 30 |
bool is_direct = false; |
| 31 |
}; |
| 32 |
|
| 33 |
|
| 34 |
struct ReadReceiptKey |
| 35 |
{ |
| 36 |
std::string event_id; |
| 37 |
std::string room_id; |
| 38 |
}; |
| 39 |
|
| 40 |
void |
| 41 |
to_json(nlohmann::json &j, const ReadReceiptKey &key); |
| 42 |
|
| 43 |
void |
| 44 |
from_json(const nlohmann::json &j, ReadReceiptKey &key); |
| 45 |
|
| 46 |
struct DescInfo |
| 47 |
{ |
| 48 |
QString event_id; |
| 49 |
QString userid; |
| 50 |
QString body; |
| 51 |
QString descriptiveTime; |
| 52 |
uint64_t timestamp = 0; |
| 53 |
QDateTime datetime; |
| 54 |
}; |
| 55 |
|
| 56 |
inline bool |
| 57 |
operator==(const DescInfo &a, const DescInfo &b) |
| 58 |
{ |
| 59 |
return std::tie(a.timestamp, a.event_id, a.userid, a.body, a.descriptiveTime) == |
| 60 |
std::tie(b.timestamp, b.event_id, b.userid, b.body, b.descriptiveTime); |
| 61 |
} |
| 62 |
inline bool |
| 63 |
operator!=(const DescInfo &a, const DescInfo &b) |
| 64 |
{ |
| 65 |
return std::tie(a.timestamp, a.event_id, a.userid, a.body, a.descriptiveTime) != |
| 66 |
std::tie(b.timestamp, b.event_id, b.userid, b.body, b.descriptiveTime); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
struct RoomInfo |
| 71 |
{ |
| 72 |
|
| 73 |
std::string name; |
| 74 |
|
| 75 |
std::string topic; |
| 76 |
|
| 77 |
std::string avatar_url; |
| 78 |
|
| 79 |
std::string version; |
| 80 |
|
| 81 |
bool is_invite = false; |
| 82 |
|
| 83 |
bool is_space = false; |
| 84 |
|
| 85 |
bool is_tombstoned = false; |
| 86 |
|
| 87 |
size_t member_count = 0; |
| 88 |
|
| 89 |
mtx::events::state::JoinRule join_rule = mtx::events::state::JoinRule::Public; |
| 90 |
bool guest_access = false; |
| 91 |
|
| 92 |
std::vector<std::string> tags; |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
uint64_t approximate_last_modification_ts = 0; |
| 97 |
|
| 98 |
uint64_t highlight_count = 0; |
| 99 |
uint64_t notification_count = 0; |
| 100 |
}; |
| 101 |
|
| 102 |
void |
| 103 |
to_json(nlohmann::json &j, const RoomInfo &info); |
| 104 |
void |
| 105 |
from_json(const nlohmann::json &j, RoomInfo &info); |
| 106 |
|
| 107 |
|
| 108 |
struct RoomNameAlias |
| 109 |
{ |
| 110 |
std::string id, name, alias; |
| 111 |
std::uint64_t recent_activity; |
| 112 |
bool is_tombstoned; |
| 113 |
bool is_space; |
| 114 |
}; |
| 115 |
|
| 116 |
|
| 117 |
struct MemberInfo |
| 118 |
{ |
| 119 |
std::string name; |
| 120 |
std::string avatar_url; |
| 121 |
std::string inviter = ""; |
| 122 |
std::string reason = ""; |
| 123 |
bool is_direct = false; |
| 124 |
}; |
| 125 |
|
| 126 |
void |
| 127 |
to_json(nlohmann::json &j, const MemberInfo &info); |
| 128 |
void |
| 129 |
from_json(const nlohmann::json &j, MemberInfo &info); |
| 130 |
|
| 131 |
struct RoomSearchResult |
| 132 |
{ |
| 133 |
std::string room_id; |
| 134 |
RoomInfo info; |
| 135 |
}; |
| 136 |
|
| 137 |
struct ImagePackInfo |
| 138 |
{ |
| 139 |
mtx::events::msc2545::ImagePack pack; |
| 140 |
std::string source_room; |
| 141 |
std::string state_key; |
| 142 |
bool from_space = false; |
| 143 |
}; |