| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <QAbstractListModel> |
| 8 |
#include <QColor> |
| 9 |
#include <QDate> |
| 10 |
#include <QSet> |
| 11 |
#include <QTimer> |
| 12 |
#include <QVariant> |
| 13 |
|
| 14 |
#include <mtx/responses/common.hpp> |
| 15 |
#include <mtxclient/http/errors.hpp> |
| 16 |
|
| 17 |
#include "CacheCryptoStructs.h" |
| 18 |
#include "CacheStructs.h" |
| 19 |
#include "EventStore.h" |
| 20 |
#include "InputBar.h" |
| 21 |
#include "Permissions.h" |
| 22 |
#include "Reaction.h" |
| 23 |
#include "ui/RoomSummary.h" |
| 24 |
|
| 25 |
namespace mtx::http { |
| 26 |
using RequestErr = const std::optional<mtx::http::ClientError> &; |
| 27 |
} |
| 28 |
namespace mtx::responses { |
| 29 |
struct Timeline; |
| 30 |
struct Messages; |
| 31 |
struct ClaimKeys; |
| 32 |
struct StateEvents; |
| 33 |
} |
| 34 |
struct RelatedInfo; |
| 35 |
class ReadReceiptsProxy; |
| 36 |
|
| 37 |
namespace qml_mtx_events { |
| 38 |
Q_NAMESPACE |
| 39 |
QML_NAMED_ELEMENT(MtxEvent) |
| 40 |
|
| 41 |
enum EventType |
| 42 |
{ |
| 43 |
|
| 44 |
Unsupported, |
| 45 |
|
| 46 |
KeyRequest, |
| 47 |
|
| 48 |
Reaction, |
| 49 |
|
| 50 |
Aliases, |
| 51 |
|
| 52 |
Avatar, |
| 53 |
|
| 54 |
CallInvite, |
| 55 |
|
| 56 |
CallAnswer, |
| 57 |
|
| 58 |
CallHangUp, |
| 59 |
|
| 60 |
CallCandidates, |
| 61 |
|
| 62 |
CallSelectAnswer, |
| 63 |
|
| 64 |
CallReject, |
| 65 |
|
| 66 |
CallNegotiate, |
| 67 |
|
| 68 |
CanonicalAlias, |
| 69 |
|
| 70 |
RoomCreate, |
| 71 |
|
| 72 |
Encrypted, |
| 73 |
|
| 74 |
Encryption, |
| 75 |
|
| 76 |
RoomGuestAccess, |
| 77 |
|
| 78 |
RoomHistoryVisibility, |
| 79 |
|
| 80 |
RoomJoinRules, |
| 81 |
|
| 82 |
Member, |
| 83 |
|
| 84 |
Name, |
| 85 |
|
| 86 |
PowerLevels, |
| 87 |
|
| 88 |
Tombstone, |
| 89 |
|
| 90 |
ServerAcl, |
| 91 |
|
| 92 |
Topic, |
| 93 |
|
| 94 |
Redaction, |
| 95 |
|
| 96 |
PinnedEvents, |
| 97 |
|
| 98 |
Sticker, |
| 99 |
|
| 100 |
Tag, |
| 101 |
|
| 102 |
Widget, |
| 103 |
|
| 104 |
AudioMessage, |
| 105 |
ElementEffectMessage, |
| 106 |
EmoteMessage, |
| 107 |
FileMessage, |
| 108 |
ImageMessage, |
| 109 |
LocationMessage, |
| 110 |
NoticeMessage, |
| 111 |
TextMessage, |
| 112 |
UnknownMessage, |
| 113 |
VideoMessage, |
| 114 |
Redacted, |
| 115 |
UnknownEvent, |
| 116 |
KeyVerificationRequest, |
| 117 |
KeyVerificationStart, |
| 118 |
KeyVerificationMac, |
| 119 |
KeyVerificationAccept, |
| 120 |
KeyVerificationCancel, |
| 121 |
KeyVerificationKey, |
| 122 |
KeyVerificationDone, |
| 123 |
KeyVerificationReady, |
| 124 |
|
| 125 |
ImagePackInRoom, |
| 126 |
|
| 127 |
ImagePackInAccountData, |
| 128 |
|
| 129 |
ImagePackRooms, |
| 130 |
|
| 131 |
PolicyRuleUser, |
| 132 |
|
| 133 |
PolicyRuleRoom, |
| 134 |
|
| 135 |
PolicyRuleServer, |
| 136 |
|
| 137 |
SpaceParent, |
| 138 |
|
| 139 |
SpaceChild, |
| 140 |
}; |
| 141 |
Q_ENUM_NS(EventType) |
| 142 |
mtx::events::EventType fromRoomEventType(qml_mtx_events::EventType); |
| 143 |
qml_mtx_events::EventType |
| 144 |
toRoomEventType(mtx::events::EventType e); |
| 145 |
|
| 146 |
enum EventState |
| 147 |
{ |
| 148 |
|
| 149 |
Received, |
| 150 |
|
| 151 |
Read, |
| 152 |
|
| 153 |
Sent, |
| 154 |
|
| 155 |
Failed, |
| 156 |
|
| 157 |
Empty, |
| 158 |
}; |
| 159 |
Q_ENUM_NS(EventState) |
| 160 |
|
| 161 |
enum NotificationLevel |
| 162 |
{ |
| 163 |
Nothing, |
| 164 |
Notify, |
| 165 |
Highlight, |
| 166 |
}; |
| 167 |
Q_ENUM_NS(NotificationLevel) |
| 168 |
} |
| 169 |
|
| 170 |
class StateKeeper |
| 171 |
{ |
| 172 |
public: |
| 173 |
StateKeeper(std::function<void()> &&fn) |
| 174 |
: fn_(std::move(fn)) |
| 175 |
{ |
| 176 |
} |
| 177 |
|
| 178 |
~StateKeeper() { fn_(); } |
| 179 |
|
| 180 |
private: |
| 181 |
std::function<void()> fn_; |
| 182 |
}; |
| 183 |
|
| 184 |
struct DecryptionResult |
| 185 |
{ |
| 186 |
|
| 187 |
mtx::events::collections::TimelineEvents event; |
| 188 |
|
| 189 |
bool isDecrypted = false; |
| 190 |
}; |
| 191 |
|
| 192 |
class TimelineViewManager; |
| 193 |
|
| 194 |
class TimelineModel final : public QAbstractListModel |
| 195 |
{ |
| 196 |
Q_OBJECT |
| 197 |
QML_NAMED_ELEMENT(Room) |
| 198 |
QML_UNCREATABLE("") |
| 199 |
|
| 200 |
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) |
| 201 |
Q_PROPERTY( |
| 202 |
QStringList typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY typingUsersChanged) |
| 203 |
Q_PROPERTY(QString scrollTarget READ scrollTarget NOTIFY scrollTargetChanged) |
| 204 |
Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply) |
| 205 |
Q_PROPERTY(QString edit READ edit WRITE setEdit NOTIFY editChanged RESET resetEdit) |
| 206 |
Q_PROPERTY(QString thread READ thread WRITE setThread NOTIFY threadChanged RESET resetThread) |
| 207 |
Q_PROPERTY( |
| 208 |
bool paginationInProgress READ paginationInProgress NOTIFY paginationInProgressChanged) |
| 209 |
Q_PROPERTY(QString roomId READ roomId CONSTANT) |
| 210 |
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged) |
| 211 |
Q_PROPERTY(QString plainRoomName READ plainRoomName NOTIFY roomNameChanged) |
| 212 |
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged) |
| 213 |
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged) |
| 214 |
Q_PROPERTY(QStringList pinnedMessages READ pinnedMessages NOTIFY pinnedMessagesChanged) |
| 215 |
Q_PROPERTY(QStringList widgetLinks READ widgetLinks NOTIFY widgetLinksChanged) |
| 216 |
Q_PROPERTY(int roomMemberCount READ roomMemberCount NOTIFY roomMemberCountChanged) |
| 217 |
Q_PROPERTY(bool isEncrypted READ isEncrypted NOTIFY encryptionChanged) |
| 218 |
Q_PROPERTY(QString fullyReadEventId READ fullyReadEventId NOTIFY fullyReadEventIdChanged) |
| 219 |
Q_PROPERTY(bool isSpace READ isSpace CONSTANT) |
| 220 |
Q_PROPERTY(int trustlevel READ trustlevel NOTIFY trustlevelChanged) |
| 221 |
Q_PROPERTY(bool isDirect READ isDirect NOTIFY isDirectChanged) |
| 222 |
Q_PROPERTY( |
| 223 |
QString directChatOtherUserId READ directChatOtherUserId NOTIFY directChatOtherUserIdChanged) |
| 224 |
Q_PROPERTY(InputBar *input READ input CONSTANT) |
| 225 |
Q_PROPERTY(Permissions *permissions READ permissions NOTIFY permissionsChanged) |
| 226 |
Q_PROPERTY(RoomSummary *parentSpace READ parentSpace NOTIFY parentSpaceChanged) |
| 227 |
|
| 228 |
public: |
| 229 |
explicit TimelineModel(TimelineViewManager *manager, |
| 230 |
QString room_id, |
| 231 |
QObject *parent = nullptr); |
| 232 |
|
| 233 |
enum Roles |
| 234 |
{ |
| 235 |
Type, |
| 236 |
TypeString, |
| 237 |
IsOnlyEmoji, |
| 238 |
Body, |
| 239 |
FormattedBody, |
| 240 |
FormattedStateEvent, |
| 241 |
IsSender, |
| 242 |
UserId, |
| 243 |
UserName, |
| 244 |
UserPowerlevel, |
| 245 |
Day, |
| 246 |
Timestamp, |
| 247 |
Url, |
| 248 |
ThumbnailUrl, |
| 249 |
Duration, |
| 250 |
Blurhash, |
| 251 |
Filename, |
| 252 |
Filesize, |
| 253 |
MimeType, |
| 254 |
OriginalHeight, |
| 255 |
OriginalWidth, |
| 256 |
ProportionalHeight, |
| 257 |
EventId, |
| 258 |
State, |
| 259 |
IsEdited, |
| 260 |
IsEditable, |
| 261 |
IsEncrypted, |
| 262 |
IsStateEvent, |
| 263 |
Trustlevel, |
| 264 |
Notificationlevel, |
| 265 |
EncryptionError, |
| 266 |
ReplyTo, |
| 267 |
ThreadId, |
| 268 |
Reactions, |
| 269 |
Room, |
| 270 |
RoomId, |
| 271 |
RoomName, |
| 272 |
RoomTopic, |
| 273 |
CallType, |
| 274 |
Dump, |
| 275 |
RelatedEventCacheBuster, |
| 276 |
}; |
| 277 |
Q_ENUM(Roles); |
| 278 |
|
| 279 |
enum SpecialEffect |
| 280 |
{ |
| 281 |
Confetti, |
| 282 |
Rainfall, |
| 283 |
}; |
| 284 |
Q_DECLARE_FLAGS(SpecialEffects, SpecialEffect) |
| 285 |
|
| 286 |
QHash<int, QByteArray> roleNames() const override; |
| 287 |
int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
| 288 |
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
| 289 |
void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const override; |
| 290 |
void |
| 291 |
multiData(const QString &id, const QString &relatedTo, QModelRoleDataSpan roleDataSpan) const; |
| 292 |
QVariant data(const mtx::events::collections::TimelineEvents &event, int role) const; |
| 293 |
Q_INVOKABLE QVariant dataById(const QString &id, int role, const QString &relatedTo); |
| 294 |
Q_INVOKABLE QVariant dataByIndex(int i, int role = Qt::DisplayRole) const |
| 295 |
{ |
| 296 |
return data(index(i), role); |
| 297 |
} |
| 298 |
|
| 299 |
bool canFetchMore(const QModelIndex &) const override; |
| 300 |
void fetchMore(const QModelIndex &) override; |
| 301 |
|
| 302 |
static QString getBareRoomLink(const QString &); |
| 303 |
static QString getRoomVias(const QString &); |
| 304 |
|
| 305 |
Q_INVOKABLE QString displayName(const QString &id) const; |
| 306 |
Q_INVOKABLE QString avatarUrl(const QString &id) const; |
| 307 |
Q_INVOKABLE QString formatDateSeparator(QDate date) const; |
| 308 |
Q_INVOKABLE QString formatLaterSeparator(QDateTime prevDate, QDateTime date) const; |
| 309 |
Q_INVOKABLE QString formatTypingUsers(const QStringList &users, const QColor &bg); |
| 310 |
Q_INVOKABLE bool showAcceptKnockButton(const QString &id); |
| 311 |
Q_INVOKABLE void acceptKnock(const QString &id); |
| 312 |
Q_INVOKABLE void joinReplacementRoom(const QString &id); |
| 313 |
Q_INVOKABLE QString |
| 314 |
formatMemberEvent(const mtx::events::StateEvent<mtx::events::state::Member> &event) const; |
| 315 |
QString |
| 316 |
formatJoinRuleEvent(const mtx::events::StateEvent<mtx::events::state::JoinRules> &event) const; |
| 317 |
QString formatHistoryVisibilityEvent( |
| 318 |
const mtx::events::StateEvent<mtx::events::state::HistoryVisibility> &event) const; |
| 319 |
QString |
| 320 |
formatGuestAccessEvent(const mtx::events::StateEvent<mtx::events::state::GuestAccess> &) const; |
| 321 |
QString formatPowerLevelEvent( |
| 322 |
const mtx::events::StateEvent<mtx::events::state::PowerLevels> &event) const; |
| 323 |
QString formatImagePackEvent( |
| 324 |
const mtx::events::StateEvent<mtx::events::msc2545::ImagePack> &event) const; |
| 325 |
Q_INVOKABLE QString formatPolicyRule(const QString &id) const; |
| 326 |
Q_INVOKABLE QVariantMap formatRedactedEvent(const QString &id); |
| 327 |
Q_INVOKABLE bool showImage() const; |
| 328 |
|
| 329 |
Q_INVOKABLE void viewRawMessage(const QString &id); |
| 330 |
Q_INVOKABLE void forwardMessage(const QString &eventId, QString roomId); |
| 331 |
Q_INVOKABLE void viewDecryptedRawMessage(const QString &id); |
| 332 |
Q_INVOKABLE void openUserProfile(QString userid); |
| 333 |
Q_INVOKABLE void unpin(const QString &id); |
| 334 |
Q_INVOKABLE void pin(const QString &id); |
| 335 |
Q_INVOKABLE void showReadReceipts(const QString &id); |
| 336 |
Q_INVOKABLE void redactEvent(const QString &id, const QString &reason = ""); |
| 337 |
Q_INVOKABLE void redactAllFromUser(const QString &userid, const QString &reason = ""); |
| 338 |
Q_INVOKABLE void |
| 339 |
reportEvent(const QString &eventId, const QString &reason = {}, const int score = -50); |
| 340 |
Q_INVOKABLE int idToIndex(const QString &id) const; |
| 341 |
Q_INVOKABLE QString indexToId(int index) const; |
| 342 |
Q_INVOKABLE void openMedia(const QString &eventId); |
| 343 |
Q_INVOKABLE void cacheMedia(const QString &eventId); |
| 344 |
Q_INVOKABLE bool saveMedia(const QString &eventId) const; |
| 345 |
Q_INVOKABLE bool copyMedia(const QString &eventId) const; |
| 346 |
Q_INVOKABLE void showEvent(QString eventId); |
| 347 |
Q_INVOKABLE void copyLinkToEvent(const QString &eventId) const; |
| 348 |
|
| 349 |
void |
| 350 |
cacheMedia(const QString &eventId, const std::function<void(const QString filename)> &callback); |
| 351 |
Q_INVOKABLE void sendReset() |
| 352 |
{ |
| 353 |
beginResetModel(); |
| 354 |
endResetModel(); |
| 355 |
} |
| 356 |
|
| 357 |
Q_INVOKABLE void requestKeyForEvent(const QString &id); |
| 358 |
|
| 359 |
std::vector<::Reaction> reactions(const std::string &event_id) |
| 360 |
{ |
| 361 |
auto list = events.reactions(event_id); |
| 362 |
std::vector<::Reaction> vec; |
| 363 |
vec.reserve(list.size()); |
| 364 |
for (const auto &r : std::as_const(list)) |
| 365 |
vec.push_back(r.value<Reaction>()); |
| 366 |
return vec; |
| 367 |
} |
| 368 |
|
| 369 |
void updateLastMessage(); |
| 370 |
void sync(const mtx::responses::JoinedRoom &room); |
| 371 |
void addEvents(const mtx::responses::Timeline &events); |
| 372 |
void syncState(const mtx::responses::State &state); |
| 373 |
template<class T> |
| 374 |
void sendMessageEvent(const T &content, mtx::events::EventType eventType); |
| 375 |
RelatedInfo relatedInfo(const QString &id); |
| 376 |
|
| 377 |
DescInfo lastMessage() const; |
| 378 |
uint64_t lastMessageTimestamp() const { return lastMessage_.timestamp; } |
| 379 |
|
| 380 |
bool isSpace() const { return isSpace_; } |
| 381 |
bool isEncrypted() const { return isEncrypted_; } |
| 382 |
QString fullyReadEventId() const { return QString::fromStdString(fullyReadEventId_); } |
| 383 |
crypto::Trust trustlevel() const; |
| 384 |
int roomMemberCount() const; |
| 385 |
bool isDirect() const { return roomMemberCount() <= 2; } |
| 386 |
QString directChatOtherUserId() const; |
| 387 |
|
| 388 |
mtx::pushrules::PushRuleEvaluator::RoomContext pushrulesRoomContext() const; |
| 389 |
|
| 390 |
std::optional<mtx::events::collections::TimelineEvents> eventById(const QString &id) |
| 391 |
{ |
| 392 |
auto e = events.get(id.toStdString(), ""); |
| 393 |
if (e) |
| 394 |
return *e; |
| 395 |
else |
| 396 |
return std::nullopt; |
| 397 |
} |
| 398 |
|
| 399 |
void refetchOnlineKeyBackupKeys() { events.refetchOnlineKeyBackupKeys(); }; |
| 400 |
|
| 401 |
public slots: |
| 402 |
void setCurrentIndex(int index); |
| 403 |
void setCurrentIndex(int index, bool ignoreInactiveState); |
| 404 |
int currentIndex() const { return idToIndex(currentId); } |
| 405 |
void eventShown(); |
| 406 |
void markEventsAsRead(const std::vector<QString> &event_ids); |
| 407 |
void markRoomAsRead(); |
| 408 |
void updateLastReadId(const QString ¤tRoomId); |
| 409 |
void lastReadIdOnWindowFocus(); |
| 410 |
void checkAfterFetch(); |
| 411 |
QVariantMap getDump(const QString &eventId, const QString &relatedTo) const; |
| 412 |
void updateTypingUsers(const QStringList &users) |
| 413 |
{ |
| 414 |
if (this->typingUsers_ != users) { |
| 415 |
this->typingUsers_ = users; |
| 416 |
emit typingUsersChanged(typingUsers_); |
| 417 |
} |
| 418 |
} |
| 419 |
QStringList typingUsers() const { return typingUsers_; } |
| 420 |
bool paginationInProgress() const { return m_paginationInProgress; } |
| 421 |
QString reply() const { return reply_; } |
| 422 |
void setReply(const QString &newReply); |
| 423 |
void resetReply() |
| 424 |
{ |
| 425 |
if (!reply_.isEmpty()) { |
| 426 |
reply_ = QLatin1String(""); |
| 427 |
emit replyChanged(reply_); |
| 428 |
} |
| 429 |
} |
| 430 |
QString edit() const { return edit_; } |
| 431 |
void setEdit(const QString &newEdit); |
| 432 |
void resetEdit(); |
| 433 |
QString thread() const { return thread_; } |
| 434 |
void setThread(const QString &newThread); |
| 435 |
void resetThread(); |
| 436 |
void setDecryptDescription(bool decrypt) { decryptDescription = decrypt; } |
| 437 |
void clearTimeline() |
| 438 |
{ |
| 439 |
events.clearTimeline(); |
| 440 |
setPaginationInProgress(false); |
| 441 |
} |
| 442 |
void resetState(); |
| 443 |
void receivedSessionKey(const std::string &session_key) |
| 444 |
{ |
| 445 |
events.receivedSessionKey(session_key); |
| 446 |
} |
| 447 |
|
| 448 |
QString roomName() const; |
| 449 |
QString plainRoomName() const; |
| 450 |
QString roomTopic() const; |
| 451 |
QStringList pinnedMessages() const; |
| 452 |
QStringList widgetLinks() const; |
| 453 |
InputBar *input() { return &input_; } |
| 454 |
Permissions *permissions() { return &permissions_; } |
| 455 |
QString roomAvatarUrl() const; |
| 456 |
QString roomId() const { return room_id_; } |
| 457 |
RoomSummary *parentSpace(); |
| 458 |
|
| 459 |
bool hasMentions() const { return highlight_count > 0; } |
| 460 |
int notificationCount() const { return static_cast<int>(notification_count); } |
| 461 |
|
| 462 |
QString scrollTarget() const; |
| 463 |
|
| 464 |
void triggerSpecialEffects(); |
| 465 |
void markSpecialEffectsDone(); |
| 466 |
|
| 467 |
private slots: |
| 468 |
void addPendingMessage(mtx::events::collections::TimelineEvents event); |
| 469 |
void scrollTimerEvent(); |
| 470 |
|
| 471 |
signals: |
| 472 |
void dataAtIdChanged(QString id); |
| 473 |
void currentIndexChanged(int index); |
| 474 |
void redactionFailed(QString id); |
| 475 |
void mediaCached(QString mxcUrl, QString cacheUrl); |
| 476 |
void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); |
| 477 |
void typingUsersChanged(QStringList users); |
| 478 |
void replyChanged(QString reply); |
| 479 |
void editChanged(QString reply); |
| 480 |
void threadChanged(QString id); |
| 481 |
void openReadReceiptsDialog(ReadReceiptsProxy *rr); |
| 482 |
void showRawMessageDialog(QString rawMessage); |
| 483 |
void paginationInProgressChanged(const bool); |
| 484 |
void newCallEvent(const mtx::events::collections::TimelineEvents &event); |
| 485 |
void scrollToIndex(int index); |
| 486 |
void confetti(); |
| 487 |
void confettiDone(); |
| 488 |
void rainfall(); |
| 489 |
void rainfallDone(); |
| 490 |
|
| 491 |
void lastMessageChanged(); |
| 492 |
void notificationsChanged(); |
| 493 |
|
| 494 |
void newState(const mtx::responses::StateEvents &events); |
| 495 |
|
| 496 |
void newMessageToSend(mtx::events::collections::TimelineEvents event); |
| 497 |
void addPendingMessageToStore(mtx::events::collections::TimelineEvents event); |
| 498 |
void updateFlowEventId(std::string event_id); |
| 499 |
|
| 500 |
void parentSpaceChanged(); |
| 501 |
void encryptionChanged(); |
| 502 |
void fullyReadEventIdChanged(); |
| 503 |
void trustlevelChanged(); |
| 504 |
void roomNameChanged(); |
| 505 |
void roomTopicChanged(); |
| 506 |
void pinnedMessagesChanged(); |
| 507 |
void widgetLinksChanged(); |
| 508 |
void roomAvatarUrlChanged(); |
| 509 |
void roomMemberCountChanged(); |
| 510 |
void isDirectChanged(); |
| 511 |
void directChatOtherUserIdChanged(); |
| 512 |
void permissionsChanged(); |
| 513 |
void forwardToRoom(mtx::events::collections::TimelineEvents const *e, QString roomId); |
| 514 |
|
| 515 |
void scrollTargetChanged(); |
| 516 |
|
| 517 |
void fetchedMore(); |
| 518 |
|
| 519 |
private: |
| 520 |
template<typename T> |
| 521 |
void |
| 522 |
sendEncryptedMessage(const mtx::events::RoomEvent<T> &msg, mtx::events::EventType eventType); |
| 523 |
void readEvent(const std::string &id); |
| 524 |
|
| 525 |
void setPaginationInProgress(const bool paginationInProgress); |
| 526 |
|
| 527 |
QString room_id_; |
| 528 |
|
| 529 |
QSet<QString> read; |
| 530 |
|
| 531 |
mutable EventStore events; |
| 532 |
|
| 533 |
QString currentId, currentReadId; |
| 534 |
QString reply_, edit_, thread_; |
| 535 |
QString replyBeforeEdit; |
| 536 |
QStringList typingUsers_; |
| 537 |
|
| 538 |
TimelineViewManager *manager_; |
| 539 |
|
| 540 |
InputBar input_{this}; |
| 541 |
Permissions permissions_; |
| 542 |
|
| 543 |
QTimer showEventTimer{this}; |
| 544 |
QString eventIdToShow; |
| 545 |
int showEventTimerCounter = 0; |
| 546 |
|
| 547 |
DescInfo lastMessage_{}; |
| 548 |
|
| 549 |
friend struct SendMessageVisitor; |
| 550 |
|
| 551 |
uint64_t notification_count = 0, highlight_count = 0; |
| 552 |
|
| 553 |
unsigned int relatedEventCacheBuster = 0; |
| 554 |
|
| 555 |
bool decryptDescription = true; |
| 556 |
bool m_paginationInProgress = false; |
| 557 |
bool isSpace_ = false; |
| 558 |
bool isEncrypted_ = false; |
| 559 |
std::string last_event_id; |
| 560 |
std::string fullyReadEventId_; |
| 561 |
|
| 562 |
bool needsSpecialEffects_ = false; |
| 563 |
QFlags<SpecialEffect> specialEffects_; |
| 564 |
|
| 565 |
std::unique_ptr<RoomSummary, DeleteLaterDeleter> parentSummary = nullptr; |
| 566 |
bool parentChecked = false; |
| 567 |
}; |
| 568 |
|
| 569 |
Q_DECLARE_OPERATORS_FOR_FLAGS(TimelineModel::SpecialEffects) |
| 570 |
|
| 571 |
template<class T> |
| 572 |
void |
| 573 |
TimelineModel::sendMessageEvent(const T &content, mtx::events::EventType eventType) |
| 574 |
{ |
| 575 |
if constexpr (std::is_same_v<T, mtx::events::msg::StickerImage>) { |
| 576 |
mtx::events::Sticker msgCopy = {}; |
| 577 |
msgCopy.content = content; |
| 578 |
msgCopy.type = eventType; |
| 579 |
emit newMessageToSend(msgCopy); |
| 580 |
} else { |
| 581 |
mtx::events::RoomEvent<T> msgCopy = {}; |
| 582 |
msgCopy.content = content; |
| 583 |
msgCopy.type = eventType; |
| 584 |
emit newMessageToSend(msgCopy); |
| 585 |
} |
| 586 |
|
| 587 |
resetReply(); |
| 588 |
resetEdit(); |
| 589 |
} |