From 6ca6dde46b9c72fc8833bc6fb81614fb705424f2 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 11 Nov 2018 15:24:13 +0900 Subject: Improvements in comments - registerEventType(): comment the cryptic _ variable - Room::postEvent: document the return value - Room::Private: upgrade comments to doc-comments - even though in Private, they still are helpful to show hints in IDEs. - General cleanup --- lib/room.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index f1566ac5..a9ed9647 100644 --- a/lib/room.h +++ b/lib/room.h @@ -323,6 +323,7 @@ namespace QMatrixClient * * Takes ownership of the event, deleting it once the matching one * arrives with the sync + * \return transaction id associated with the event. */ QString postEvent(RoomEvent* event); QString postJson(const QString& matrixType, -- cgit v1.2.3 From 2a72a0ad0f8b4a0d24c9c2262917ff658ca5fec4 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 11 Nov 2018 15:33:03 +0900 Subject: Room: historyEdge(), syncEdge, Private::timelineBase() Also: make moveEventsToTimeline() always put historical events from position -1 rather than 0 so that Private::baseState could always correspond to the before-0 position. --- lib/room.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index a9ed9647..0a0eb878 100644 --- a/lib/room.h +++ b/lib/room.h @@ -177,9 +177,16 @@ namespace QMatrixClient const Timeline& messageEvents() const; const PendingEvents& pendingEvents() const; /** - * A convenience method returning the read marker to - * the before-oldest message + * A convenience method returning the read marker to the position + * before the "oldest" event; same as messageEvents().crend() */ + rev_iter_t historyEdge() const; + /** + * A convenience method returning the iterator beyond the latest + * arrived event; same as messageEvents().cend() + */ + Timeline::const_iterator syncEdge() const; + /// \deprecated Use historyEdge instead rev_iter_t timelineEdge() const; Q_INVOKABLE TimelineItem::index_t minTimelineIndex() const; Q_INVOKABLE TimelineItem::index_t maxTimelineIndex() const; -- cgit v1.2.3 From 82c78b63cdd093853fd058740e7038e3c8a1cbbd Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 18 Nov 2018 20:18:10 +0900 Subject: Room: expose eventsHistoryJob as a Q_PROPERTY --- lib/room.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 0a0eb878..633d19dd 100644 --- a/lib/room.h +++ b/lib/room.h @@ -19,6 +19,7 @@ #pragma once #include "jobs/syncjob.h" +#include "csapi/message_pagination.h" #include "events/roommessageevent.h" #include "events/accountdataevents.h" #include "eventitem.h" @@ -95,6 +96,8 @@ namespace QMatrixClient Q_PROPERTY(bool isFavourite READ isFavourite NOTIFY tagsChanged) Q_PROPERTY(bool isLowPriority READ isLowPriority NOTIFY tagsChanged) + Q_PROPERTY(GetRoomEventsJob* eventsHistoryJob READ eventsHistoryJob NOTIFY eventsHistoryJobChanged) + public: using Timeline = std::deque; using PendingEvents = std::vector; @@ -126,6 +129,8 @@ namespace QMatrixClient int timelineSize() const; bool usesEncryption() const; + GetRoomEventsJob* eventsHistoryJob() const; + /** * Returns a square room avatar with the given size and requests it * from the network if needed @@ -364,6 +369,7 @@ namespace QMatrixClient void markAllMessagesAsRead(); signals: + void eventsHistoryJobChanged(); void aboutToAddHistoricalMessages(RoomEventsRange events); void aboutToAddNewMessages(RoomEventsRange events); void addedMessages(int fromIndex, int toIndex); -- cgit v1.2.3 From dc3d6bd3b46ae7a9e8d9b9f62e50db982ef2b004 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 20 Nov 2018 13:24:40 +0900 Subject: Make SyncData more self-contained and prepare for cache splitting SyncData now resides in its own pair of files and is capable to load either from file or from JSON. There is also (yet untested) capability to load rooms from files if a file name stands is the value for a given room id. This allows to store the master cache file separately from cache files for each room, massively easing the problem of bulky accounts that can overflow the poor capacity of Qt's JSON engine. --- lib/room.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 633d19dd..b741e229 100644 --- a/lib/room.h +++ b/lib/room.h @@ -18,7 +18,6 @@ #pragma once -#include "jobs/syncjob.h" #include "csapi/message_pagination.h" #include "events/roommessageevent.h" #include "events/accountdataevents.h" @@ -34,6 +33,7 @@ namespace QMatrixClient { class Event; + class SyncRoomData; class RoomMemberEvent; class Connection; class User; -- cgit v1.2.3 From 0c3a45356a803baa0eb5e553262a85cac897ac4f Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 22 Nov 2018 13:00:33 +0900 Subject: Room: Change enum, Changes flag set, and changed() signal This allows to batch updates into signals being emitted only once per sync. Also supercedes emitNamesChanged flag used in a few places. --- lib/room.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index b741e229..ab8298d4 100644 --- a/lib/room.h +++ b/lib/room.h @@ -104,6 +104,24 @@ namespace QMatrixClient using rev_iter_t = Timeline::const_reverse_iterator; using timeline_iter_t = Timeline::const_iterator; + enum Change : uint { + NoChange = 0x0, + NameChange = 0x1, + CanonicalAliasChange = 0x2, + TopicChange = 0x4, + UnreadNotifsChange = 0x8, + AvatarChange = 0x10, + JoinStateChange = 0x20, + TagsChange = 0x40, + MembersChange = 0x80, + EncryptionOn = 0x100, + AccountDataChange = 0x200, + OtherChange = 0x1000, + AnyChange = 0x1FFF + }; + Q_DECLARE_FLAGS(Changes, Change) + Q_FLAG(Changes) + Room(Connection* connection, QString id, JoinState initialJoinState); ~Room() override; @@ -382,6 +400,13 @@ namespace QMatrixClient void pendingEventDiscarded(); void pendingEventChanged(int pendingEventIndex); + /** A common signal for various kinds of changes in the room + * Aside from all changes in the room state + * @param changes a set of flags describing what changes occured + * upon the last sync + * \sa StateChange + */ + void changed(Changes changes); /** * \brief The room name, the canonical alias or other aliases changed * @@ -441,7 +466,7 @@ namespace QMatrixClient protected: /// Returns true if any of room names/aliases has changed - virtual bool processStateEvent(const RoomEvent& e); + virtual Changes processStateEvent(const RoomEvent& e); virtual void processEphemeralEvent(EventPtr&& event); virtual void processAccountDataEvent(EventPtr&& event); virtual void onAddNewTimelineEvents(timeline_iter_t /*from*/) { } @@ -474,3 +499,4 @@ namespace QMatrixClient }; } // namespace QMatrixClient Q_DECLARE_METATYPE(QMatrixClient::FileTransferInfo) +Q_DECLARE_OPERATORS_FOR_FLAGS(QMatrixClient::Room::Changes) -- cgit v1.2.3 From 49ad563550ba9d2d03fc7a519ccb857a6d08791c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 23 Nov 2018 15:38:59 +0900 Subject: Room/Connection: don't save the just loaded room cache --- lib/room.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index ab8298d4..480de6fe 100644 --- a/lib/room.h +++ b/lib/room.h @@ -456,14 +456,6 @@ namespace QMatrixClient /// The room is about to be deleted void beforeDestruction(Room*); - public: // Used by Connection - not a part of the client API - QJsonObject toJson() const; - void updateData(SyncRoomData&& data ); - - // Clients should use Connection::joinRoom() and Room::leaveRoom() - // to change the room state - void setJoinState( JoinState state ); - protected: /// Returns true if any of room names/aliases has changed virtual Changes processStateEvent(const RoomEvent& e); @@ -473,10 +465,19 @@ namespace QMatrixClient virtual void onAddHistoricalTimelineEvents(rev_iter_t /*from*/) { } virtual void onRedaction(const RoomEvent& /*prevEvent*/, const RoomEvent& /*after*/) { } + virtual QJsonObject toJson() const; + virtual void updateData(SyncRoomData&& data, bool fromCache = false); private: + friend class Connection; + class Private; Private* d; + + // This is called from Connection, reflecting a state change that + // arrived from the server. Clients should use + // Connection::joinRoom() and Room::leaveRoom() to change the state. + void setJoinState(JoinState state); }; class MemberSorter -- cgit v1.2.3 From 52081fe91724e5f2a82c55f0e6230d8841dd859a Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 23 Nov 2018 15:53:16 +0900 Subject: Room: track more Changes --- lib/room.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 480de6fe..9d4561e5 100644 --- a/lib/room.h +++ b/lib/room.h @@ -460,7 +460,7 @@ namespace QMatrixClient /// Returns true if any of room names/aliases has changed virtual Changes processStateEvent(const RoomEvent& e); virtual void processEphemeralEvent(EventPtr&& event); - virtual void processAccountDataEvent(EventPtr&& event); + virtual Changes processAccountDataEvent(EventPtr&& event); virtual void onAddNewTimelineEvents(timeline_iter_t /*from*/) { } virtual void onAddHistoricalTimelineEvents(rev_iter_t /*from*/) { } virtual void onRedaction(const RoomEvent& /*prevEvent*/, -- cgit v1.2.3 From 9272d21ce6e5439444794e6da58e08421e8973db Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 8 Dec 2018 15:37:16 +0900 Subject: Room summaries --- lib/room.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 9d4561e5..97d8454a 100644 --- a/lib/room.h +++ b/lib/room.h @@ -84,6 +84,9 @@ namespace QMatrixClient Q_PROPERTY(int timelineSize READ timelineSize NOTIFY addedMessages) Q_PROPERTY(QStringList memberNames READ memberNames NOTIFY memberListChanged) Q_PROPERTY(int memberCount READ memberCount NOTIFY memberListChanged) + Q_PROPERTY(int joinedCount READ joinedCount NOTIFY memberListChanged) + Q_PROPERTY(int invitedCount READ invitedCount NOTIFY memberListChanged) + Q_PROPERTY(int totalMemberCount READ totalMemberCount NOTIFY memberListChanged) Q_PROPERTY(bool displayed READ displayed WRITE setDisplayed NOTIFY displayedChanged) Q_PROPERTY(QString firstDisplayedEventId READ firstDisplayedEventId WRITE setFirstDisplayedEventId NOTIFY firstDisplayedEventChanged) @@ -116,6 +119,7 @@ namespace QMatrixClient MembersChange = 0x80, EncryptionOn = 0x100, AccountDataChange = 0x200, + SummaryChange = 0x400, OtherChange = 0x1000, AnyChange = 0x1FFF }; @@ -143,9 +147,13 @@ namespace QMatrixClient Q_INVOKABLE QList users() const; QStringList memberNames() const; + [[deprecated("Use joinedCount(), invitedCount(), totalMemberCount()")]] int memberCount() const; int timelineSize() const; bool usesEncryption() const; + int joinedCount() const; + int invitedCount() const; + int totalMemberCount() const; GetRoomEventsJob* eventsHistoryJob() const; -- cgit v1.2.3 From 9225eaec426ecd44a1c203e11e1aafe7772c46d7 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 9 Dec 2018 19:55:14 +0900 Subject: Room: track more changes; fix cache smashing upon restart Commit fd52459 introduced a regression rendering the cache unusable after a client restart (an empty state overwrites whatever state was in the cache). This commit contains the fix, along with more room change tracking. --- lib/room.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 97d8454a..7b5be331 100644 --- a/lib/room.h +++ b/lib/room.h @@ -120,8 +120,9 @@ namespace QMatrixClient EncryptionOn = 0x100, AccountDataChange = 0x200, SummaryChange = 0x400, - OtherChange = 0x1000, - AnyChange = 0x1FFF + ReadMarkerChange = 0x800, + OtherChange = 0x8000, + AnyChange = 0xFFFF }; Q_DECLARE_FLAGS(Changes, Change) Q_FLAG(Changes) @@ -467,7 +468,7 @@ namespace QMatrixClient protected: /// Returns true if any of room names/aliases has changed virtual Changes processStateEvent(const RoomEvent& e); - virtual void processEphemeralEvent(EventPtr&& event); + virtual Changes processEphemeralEvent(EventPtr&& event); virtual Changes processAccountDataEvent(EventPtr&& event); virtual void onAddNewTimelineEvents(timeline_iter_t /*from*/) { } virtual void onAddHistoricalTimelineEvents(rev_iter_t /*from*/) { } -- cgit v1.2.3 From 095444aff98ac56663bb205837a57e746d950f3b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 12 Dec 2018 13:20:05 +0900 Subject: Room::allMembersLoaded(); more doc-comments --- lib/room.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 7b5be331..ba1eaa48 100644 --- a/lib/room.h +++ b/lib/room.h @@ -228,6 +228,13 @@ namespace QMatrixClient rev_iter_t findInTimeline(const QString& evtId) const; bool displayed() const; + /// Mark the room as currently displayed to the user + /** + * Marking the room displayed causes the room to obtain the full + * list of members if it's been lazy-loaded before; in the future + * it may do more things bound to "screen time" of the room, e.g. + * measure that "screen time". + */ void setDisplayed(bool displayed = true); QString firstDisplayedEventId() const; rev_iter_t firstDisplayedMarker() const; @@ -431,6 +438,9 @@ namespace QMatrixClient void memberAboutToRename(User* user, QString newName); void memberRenamed(User* user); void memberListChanged(); + /// The previously lazy-loaded members list is now loaded entirely + /// \sa setDisplayed + void allMembersLoaded(); void encryption(); void joinStateChanged(JoinState oldState, JoinState newState); -- cgit v1.2.3 From 393485594b2bb7ab3a7ddc7e49c8cae1105bf77e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 12 Dec 2018 13:37:50 +0900 Subject: Room: more doc-comments --- lib/room.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index ba1eaa48..f7eb224e 100644 --- a/lib/room.h +++ b/lib/room.h @@ -437,6 +437,13 @@ namespace QMatrixClient void userRemoved(User* user); void memberAboutToRename(User* user, QString newName); void memberRenamed(User* user); + /// The list of members has changed + /** Emitted no more than once per sync, this is a good signal to + * for cases when some action should be done upon any change in + * the member list. If you need per-item granularity you should use + * userAdded, userRemoved and memberAboutToRename / memberRenamed + * instead. + */ void memberListChanged(); /// The previously lazy-loaded members list is now loaded entirely /// \sa setDisplayed -- cgit v1.2.3 From 6276e6694a8fe2f8b37374ac8080a92721064eba Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 16 Dec 2018 14:11:51 +0900 Subject: Room: messageSent(), better pendingEventAboutToAdd(), more doc-comments --- lib/room.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index f7eb224e..6384b706 100644 --- a/lib/room.h +++ b/lib/room.h @@ -407,14 +407,35 @@ namespace QMatrixClient void aboutToAddHistoricalMessages(RoomEventsRange events); void aboutToAddNewMessages(RoomEventsRange events); void addedMessages(int fromIndex, int toIndex); - void pendingEventAboutToAdd(); + /// The event is about to be appended to the list of pending events + void pendingEventAboutToAdd(RoomEvent* event); + /// An event has been appended to the list of pending events void pendingEventAdded(); + /// The remote echo has arrived with the sync and will be merged + /// with its local counterpart + /** NB: Requires a sync loop to be emitted */ void pendingEventAboutToMerge(RoomEvent* serverEvent, int pendingEventIndex); + /// The remote and local copies of the event have been merged + /** NB: Requires a sync loop to be emitted */ void pendingEventMerged(); + /// An event will be removed from the list of pending events void pendingEventAboutToDiscard(int pendingEventIndex); + /// An event has just been removed from the list of pending events void pendingEventDiscarded(); + /// The status of a pending event has changed + /** \sa PendingEventItem::deliveryStatus */ void pendingEventChanged(int pendingEventIndex); + /// The server accepted the message + /** This is emitted when an event sending request has successfully + * completed. This does not mean that the event is already in the + * local timeline, only that the server has accepted it. + * \param txnId transaction id assigned by the client during sending + * \param eventId event id assigned by the server upon acceptance + * \sa postEvent, postPlainText, postMessage, postHtmlMessage + * \sa pendingEventMerged, aboutToAddNewMessages + */ + void messageSent(QString txnId, QString eventId); /** A common signal for various kinds of changes in the room * Aside from all changes in the room state -- cgit v1.2.3 From e017dd42637071687f88f5a36e7e03f1536332be Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 28 Dec 2018 12:53:01 +0900 Subject: FileTransferInfo: new properties: isUpload and started Also: use constructors instead of list-based initialisation in FileTransferPrivateInfo to enable a case of "invalid/empty" FileTransferPrivateInfo with status == None. --- lib/room.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 6384b706..b832977f 100644 --- a/lib/room.h +++ b/lib/room.h @@ -42,10 +42,17 @@ namespace QMatrixClient class SetRoomStateWithKeyJob; class RedactEventJob; + /** The data structure used to expose file transfer information to views + * + * This is specifically tuned to work with QML exposing all traits as + * Q_PROPERTY values. + */ class FileTransferInfo { Q_GADGET + Q_PROPERTY(bool isUpload MEMBER isUpload CONSTANT) Q_PROPERTY(bool active READ active CONSTANT) + Q_PROPERTY(bool started READ started CONSTANT) Q_PROPERTY(bool completed READ completed CONSTANT) Q_PROPERTY(bool failed READ failed CONSTANT) Q_PROPERTY(int progress MEMBER progress CONSTANT) @@ -55,14 +62,15 @@ namespace QMatrixClient public: enum Status { None, Started, Completed, Failed }; Status status = None; + bool isUpload = false; int progress = 0; int total = -1; QUrl localDir { }; QUrl localPath { }; - bool active() const - { return status == Started || status == Completed; } + bool started() const { return status == Started; } bool completed() const { return status == Completed; } + bool active() const { return started() || completed(); } bool failed() const { return status == Failed; } }; -- cgit v1.2.3 From 143fffcf3962184befbbe37bebc5544d25bc7c39 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 28 Dec 2018 12:55:21 +0900 Subject: Room::fileSource Also: const'ified other methods related to file urls. --- lib/room.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index b832977f..a166be37 100644 --- a/lib/room.h +++ b/lib/room.h @@ -342,10 +342,11 @@ namespace QMatrixClient /// Get the list of users this room is a direct chat with QList directChatUsers() const; - Q_INVOKABLE QUrl urlToThumbnail(const QString& eventId); - Q_INVOKABLE QUrl urlToDownload(const QString& eventId); - Q_INVOKABLE QString fileNameToDownload(const QString& eventId); + Q_INVOKABLE QUrl urlToThumbnail(const QString& eventId) const; + Q_INVOKABLE QUrl urlToDownload(const QString& eventId) const; + Q_INVOKABLE QString fileNameToDownload(const QString& eventId) const; Q_INVOKABLE FileTransferInfo fileTransferInfo(const QString& id) const; + Q_INVOKABLE QUrl fileSource(const QString& id) const; /** Pretty-prints plain text into HTML * As of now, it's exactly the same as QMatrixClient::prettyPrint(); -- cgit v1.2.3 From 3dcf0d3fd1e64d64b57976e400888fe8a02c4451 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 28 Dec 2018 15:00:08 +0900 Subject: Room::postFile() and supplementary things in Room::Private --- lib/room.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index a166be37..ce1c3dd3 100644 --- a/lib/room.h +++ b/lib/room.h @@ -374,6 +374,7 @@ namespace QMatrixClient QString postHtmlMessage(const QString& plainText, const QString& html, MessageEventType type); QString postHtmlText(const QString& plainText, const QString& html); + QString postFile(const QString& plainText, const QUrl& localPath); /** Post a pre-created room message event * * Takes ownership of the event, deleting it once the matching one -- cgit v1.2.3 From e3c1b93483eafbb94f1224b57e562984f4100538 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 29 Dec 2018 23:12:46 +0900 Subject: Support file events in Room::retryMessage/discardMessage --- lib/room.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index ce1c3dd3..2b6a2172 100644 --- a/lib/room.h +++ b/lib/room.h @@ -60,7 +60,7 @@ namespace QMatrixClient Q_PROPERTY(QUrl localDir MEMBER localDir CONSTANT) Q_PROPERTY(QUrl localPath MEMBER localPath CONSTANT) public: - enum Status { None, Started, Completed, Failed }; + enum Status { None, Started, Completed, Failed, Cancelled }; Status status = None; bool isUpload = false; int progress = 0; -- cgit v1.2.3 From fb46c2d2a6e53557452837c2690f32a56387fcac Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 Jan 2019 22:28:09 +0900 Subject: Room: findPendingEvent; fixes for postFile() --- lib/room.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 2b6a2172..029f87b7 100644 --- a/lib/room.h +++ b/lib/room.h @@ -234,6 +234,8 @@ namespace QMatrixClient rev_iter_t findInTimeline(TimelineItem::index_t index) const; rev_iter_t findInTimeline(const QString& evtId) const; + PendingEvents::iterator findPendingEvent(const QString & txnId); + PendingEvents::const_iterator findPendingEvent(const QString & txnId) const; bool displayed() const; /// Mark the room as currently displayed to the user @@ -374,7 +376,8 @@ namespace QMatrixClient QString postHtmlMessage(const QString& plainText, const QString& html, MessageEventType type); QString postHtmlText(const QString& plainText, const QString& html); - QString postFile(const QString& plainText, const QUrl& localPath); + QString postFile(const QString& plainText, const QUrl& localPath, + bool asGenericFile = false); /** Post a pre-created room message event * * Takes ownership of the event, deleting it once the matching one -- cgit v1.2.3 From 87018c0a180248df4a2f61665efbfb3af84bbfea Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 15 Feb 2019 11:44:29 +0900 Subject: Room::baseStateLoaded Mirroring Connection::loadedRoomState but for each single room (will be used as a NOTIFY signal for one-time-set events). --- lib/room.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 029f87b7..7e30a671 100644 --- a/lib/room.h +++ b/lib/room.h @@ -416,6 +416,15 @@ namespace QMatrixClient void markAllMessagesAsRead(); signals: + /// Initial set of state events has been loaded + /** + * The initial set is what comes from the initial sync for the room. + * This includes all basic things like RoomCreateEvent, + * RoomNameEvent, a (lazy-loaded, not full) set of RoomMemberEvents + * etc. This is a per-room reflection of Connection::loadedRoomState + * \sa Connection::loadedRoomState + */ + void baseStateLoaded(); void eventsHistoryJobChanged(); void aboutToAddHistoricalMessages(RoomEventsRange events); void aboutToAddNewMessages(RoomEventsRange events); -- cgit v1.2.3 From f3ec748689db531df787d19bcfe76b0a40665b67 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 15 Feb 2019 11:49:40 +0900 Subject: Room: version(), predecessorId(), successorId() Use RoomCreateEvent and RoomTombstoneEvent in the backend, covering most of #235. --- lib/room.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 7e30a671..ef832d1a 100644 --- a/lib/room.h +++ b/lib/room.h @@ -80,6 +80,9 @@ namespace QMatrixClient Q_PROPERTY(Connection* connection READ connection CONSTANT) Q_PROPERTY(User* localUser READ localUser CONSTANT) Q_PROPERTY(QString id READ id CONSTANT) + Q_PROPERTY(QString version READ version NOTIFY baseStateLoaded) + Q_PROPERTY(QString predecessorId READ predecessorId NOTIFY baseStateLoaded) + Q_PROPERTY(QString successorId READ successorId NOTIFY upgraded) Q_PROPERTY(QString name READ name NOTIFY namesChanged) Q_PROPERTY(QStringList aliases READ aliases NOTIFY namesChanged) Q_PROPERTY(QString canonicalAlias READ canonicalAlias NOTIFY namesChanged) @@ -143,6 +146,9 @@ namespace QMatrixClient Connection* connection() const; User* localUser() const; const QString& id() const; + QString version() const; + QString predecessorId() const; + QString successorId() const; QString name() const; QStringList aliases() const; QString canonicalAlias() const; -- cgit v1.2.3 From 5ac901775c5ebd39338ae7854d2c3391cf9084fa Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 15 Feb 2019 12:24:41 +0900 Subject: Room::upgraded() A signal emitted when the room receives a tombstone event from the server. --- lib/room.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index ef832d1a..137b383d 100644 --- a/lib/room.h +++ b/lib/room.h @@ -528,6 +528,10 @@ namespace QMatrixClient void fileTransferCancelled(QString id); void callEvent(Room* room, const RoomEvent* event); + + /// This room has been upgraded and won't receive updates anymore + void upgraded(QString serverMessage, QString successorId); + /// The room is about to be deleted void beforeDestruction(Room*); -- cgit v1.2.3 From ac7d2ad8b0942cc465c0d340f159cb0b343008ab Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 15 Feb 2019 12:29:02 +0900 Subject: Room::checkVersion() and Room::unstableVersion() Initial (sans power levels checking) implementation of the check that room should be upgraded. Closes most of #236. --- lib/room.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 137b383d..246206d4 100644 --- a/lib/room.h +++ b/lib/room.h @@ -377,6 +377,9 @@ namespace QMatrixClient Q_INVOKABLE bool supportsCalls() const; public slots: + /** Check whether the room should be upgraded */ + void checkVersion(); + QString postMessage(const QString& plainText, MessageEventType type); QString postPlainText(const QString& plainText); QString postHtmlMessage(const QString& plainText, @@ -529,6 +532,9 @@ namespace QMatrixClient void callEvent(Room* room, const RoomEvent* event); + /// The room's version is considered unstable; upgrade recommended + void unstableVersion(QString recommendedDefault, + QStringList stableVersions); /// This room has been upgraded and won't receive updates anymore void upgraded(QString serverMessage, QString successorId); -- cgit v1.2.3 From 5460bf4024999b78fb3837ffc14ca818a71dd4dc Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 15 Feb 2019 15:45:18 +0900 Subject: Use Changes enum properly Don't use distinct items for each type of event; only for repeated/ combinable ones. --- lib/room.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 246206d4..0569a0c0 100644 --- a/lib/room.h +++ b/lib/room.h @@ -128,7 +128,7 @@ namespace QMatrixClient JoinStateChange = 0x20, TagsChange = 0x40, MembersChange = 0x80, - EncryptionOn = 0x100, + /*blank*/ = 0x100, AccountDataChange = 0x200, SummaryChange = 0x400, ReadMarkerChange = 0x800, -- cgit v1.2.3 From 0130d9646af5530180158854dbedc35d7c01fd4f Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 15 Feb 2019 16:46:53 +0900 Subject: Fix FTBFS --- lib/room.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 0569a0c0..0636ba17 100644 --- a/lib/room.h +++ b/lib/room.h @@ -128,7 +128,7 @@ namespace QMatrixClient JoinStateChange = 0x20, TagsChange = 0x40, MembersChange = 0x80, - /*blank*/ = 0x100, + /* = 0x100, */ AccountDataChange = 0x200, SummaryChange = 0x400, ReadMarkerChange = 0x800, -- cgit v1.2.3 From 11b1bfe8f3640bfb1e2dd1710624c67aedb4f98b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 16 Feb 2019 17:27:39 +0900 Subject: Room::switchVersion() Closes #236. --- lib/room.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 0636ba17..e09da94c 100644 --- a/lib/room.h +++ b/lib/room.h @@ -424,6 +424,9 @@ namespace QMatrixClient /// Mark all messages in the room as read void markAllMessagesAsRead(); + /// Switch the room's version (aka upgrade) + void switchVersion(QString newVersion); + signals: /// Initial set of state events has been loaded /** -- cgit v1.2.3 From 7e9bf3911e0457bf5af21672d4325882584b78ad Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 16 Feb 2019 20:00:46 +0900 Subject: Room::canSwitchVersions() --- lib/room.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index e09da94c..f12627f3 100644 --- a/lib/room.h +++ b/lib/room.h @@ -424,6 +424,9 @@ namespace QMatrixClient /// Mark all messages in the room as read void markAllMessagesAsRead(); + /// Whether the current user is allowed to upgrade the room + bool canSwitchVersions() const; + /// Switch the room's version (aka upgrade) void switchVersion(QString newVersion); -- cgit v1.2.3 From 061c6a69fd55696e7dd82854ace9aa67915628d7 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 17 Feb 2019 17:46:26 +0900 Subject: Room: emit room, not id in upgraded(); add upgradeFailed() --- lib/room.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index f12627f3..933a8dd9 100644 --- a/lib/room.h +++ b/lib/room.h @@ -542,7 +542,9 @@ namespace QMatrixClient void unstableVersion(QString recommendedDefault, QStringList stableVersions); /// This room has been upgraded and won't receive updates anymore - void upgraded(QString serverMessage, QString successorId); + void upgraded(QString serverMessage, Room* successor); + /// An attempted room upgrade has failed + void upgradeFailed(QString errorMessage); /// The room is about to be deleted void beforeDestruction(Room*); -- cgit v1.2.3 From ad5d44f31b3ab7e582b84ab05161c97cbc7eefc8 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 17 Feb 2019 18:54:52 +0900 Subject: Room: add isUnstable(); unstableVersion() -> stabilityUpdated() --- lib/room.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 933a8dd9..197926e7 100644 --- a/lib/room.h +++ b/lib/room.h @@ -81,6 +81,7 @@ namespace QMatrixClient Q_PROPERTY(User* localUser READ localUser CONSTANT) Q_PROPERTY(QString id READ id CONSTANT) Q_PROPERTY(QString version READ version NOTIFY baseStateLoaded) + Q_PROPERTY(bool isUnstable READ isUnstable NOTIFY stabilityUpdated) Q_PROPERTY(QString predecessorId READ predecessorId NOTIFY baseStateLoaded) Q_PROPERTY(QString successorId READ successorId NOTIFY upgraded) Q_PROPERTY(QString name READ name NOTIFY namesChanged) @@ -147,6 +148,7 @@ namespace QMatrixClient User* localUser() const; const QString& id() const; QString version() const; + bool isUnstable() const; QString predecessorId() const; QString successorId() const; QString name() const; @@ -538,9 +540,9 @@ namespace QMatrixClient void callEvent(Room* room, const RoomEvent* event); - /// The room's version is considered unstable; upgrade recommended - void unstableVersion(QString recommendedDefault, - QStringList stableVersions); + /// The room's version stability may have changed + void stabilityUpdated(QString recommendedDefault, + QStringList stableVersions); /// This room has been upgraded and won't receive updates anymore void upgraded(QString serverMessage, Room* successor); /// An attempted room upgrade has failed -- cgit v1.2.3 From 297216e95c0802248110403f1b8fdcd5eb02fae6 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 1 Feb 2019 07:30:09 +0900 Subject: Room::setAliases, Connection: roomByAlias, updateRoomAliases --- lib/room.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 197926e7..808c6074 100644 --- a/lib/room.h +++ b/lib/room.h @@ -402,6 +402,7 @@ namespace QMatrixClient void discardMessage(const QString& txnId); void setName(const QString& newName); void setCanonicalAlias(const QString& newAlias); + void setAliases(const QStringList& aliases); void setTopic(const QString& newTopic); void getPreviousContent(int limit = 10); -- cgit v1.2.3 From 93876f06b6a1929dc757595ba4410b742402b7ab Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 25 Feb 2019 11:27:24 +0900 Subject: Room::postHtmlMessage: default message type to m.text postHtmlText becomes just a synonym for 2-arg postHtmlMessage (hopefully at least this doesn't confuse QML that is generally terrible at resolving overloads). --- lib/room.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 808c6074..a9341bd2 100644 --- a/lib/room.h +++ b/lib/room.h @@ -385,7 +385,8 @@ namespace QMatrixClient QString postMessage(const QString& plainText, MessageEventType type); QString postPlainText(const QString& plainText); QString postHtmlMessage(const QString& plainText, - const QString& html, MessageEventType type); + const QString& html, + MessageEventType type = MessageEventType::Text); QString postHtmlText(const QString& plainText, const QString& html); QString postFile(const QString& plainText, const QUrl& localPath, bool asGenericFile = false); -- cgit v1.2.3 From a78ae0e75225629563ce253308e9b88383b0ea4d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 26 Feb 2019 14:11:37 +0900 Subject: Room::avatarObject Closes #268. --- lib/room.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index a9341bd2..f4ecef42 100644 --- a/lib/room.h +++ b/lib/room.h @@ -33,6 +33,7 @@ namespace QMatrixClient { class Event; + class Avatar; class SyncRoomData; class RoomMemberEvent; class Connection; @@ -158,6 +159,7 @@ namespace QMatrixClient QString topic() const; QString avatarMediaId() const; QUrl avatarUrl() const; + const Avatar& avatarObject() const; Q_INVOKABLE JoinState joinState() const; Q_INVOKABLE QList usersTyping() const; QList membersLeft() const; -- cgit v1.2.3 From 9e0897ed1c1b4bbec6333bd6674bd8db737b13cb Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 21 Mar 2019 15:41:06 +0900 Subject: Room::displayName: fix NOTIFY signal for Q_PROPERTY --- lib/room.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index f4ecef42..3da2d4e7 100644 --- a/lib/room.h +++ b/lib/room.h @@ -88,7 +88,7 @@ namespace QMatrixClient Q_PROPERTY(QString name READ name NOTIFY namesChanged) Q_PROPERTY(QStringList aliases READ aliases NOTIFY namesChanged) Q_PROPERTY(QString canonicalAlias READ canonicalAlias NOTIFY namesChanged) - Q_PROPERTY(QString displayName READ displayName NOTIFY namesChanged) + Q_PROPERTY(QString displayName READ displayName NOTIFY displaynameChanged) Q_PROPERTY(QString topic READ topic NOTIFY topicChanged) Q_PROPERTY(QString avatarMediaId READ avatarMediaId NOTIFY avatarChanged STORED false) Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY avatarChanged) -- cgit v1.2.3 From 07827998c5ffe495ce83e4b1034d9e016f7296e8 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 31 Mar 2019 18:41:12 +0900 Subject: Room::refreshDisplayName() - for debugging purposes only Clients should not need to call this method explicitly. --- lib/room.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 3da2d4e7..adec7650 100644 --- a/lib/room.h +++ b/lib/room.h @@ -408,6 +408,9 @@ namespace QMatrixClient void setAliases(const QStringList& aliases); void setTopic(const QString& newTopic); + /// You shouldn't normally call this method; it's here for debugging + void refreshDisplayName(); + void getPreviousContent(int limit = 10); void inviteToRoom(const QString& memberId); -- cgit v1.2.3 From 27386af703974154256cf755712bb46099500847 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 3 Apr 2019 19:33:24 +0900 Subject: room.h: more doc-comments --- lib/room.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index adec7650..33d1f4ea 100644 --- a/lib/room.h +++ b/lib/room.h @@ -356,8 +356,28 @@ namespace QMatrixClient Q_INVOKABLE QUrl urlToThumbnail(const QString& eventId) const; Q_INVOKABLE QUrl urlToDownload(const QString& eventId) const; + + /// Get a file name for downloading for a given event id + /*! + * The event MUST be RoomMessageEvent and have content + * for downloading. \sa RoomMessageEvent::hasContent + */ Q_INVOKABLE QString fileNameToDownload(const QString& eventId) const; + + /// Get information on file upload/download + /*! + * \param id uploads are identified by the corresponding event's + * transactionId (because uploads are done before + * the event is even sent), while downloads are using + * the normal event id for identifier. + */ Q_INVOKABLE FileTransferInfo fileTransferInfo(const QString& id) const; + + /// Get the URL to the actual file source in a unified way + /*! + * For uploads it will return a URL to a local file; for downloads + * the URL will be taken from the corresponding room event. + */ Q_INVOKABLE QUrl fileSource(const QString& id) const; /** Pretty-prints plain text into HTML -- cgit v1.2.3