From aacc4bcb4a487871daae6717f77605aaba444341 Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Sat, 2 Mar 2019 12:26:57 +0100 Subject: style: apply .clang-format to all .cpp and .h files --- lib/syncdata.h | 104 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 53 deletions(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index 8694626e..139af130 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -13,13 +13,13 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once -#include "joinstate.h" #include "events/stateevent.h" +#include "joinstate.h" namespace QMatrixClient { /// Room summary, as defined in MSC688 @@ -30,11 +30,11 @@ namespace QMatrixClient { * means that nothing has come from the server; heroes.value().isEmpty() * means a peculiar case of a room with the only member - the current user. */ - struct RoomSummary - { + struct RoomSummary { Omittable joinedMemberCount; Omittable invitedMemberCount; - Omittable heroes; //< mxids of users to take part in the room name + Omittable + heroes; //< mxids of users to take part in the room name bool isEmpty() const; /// Merge the contents of another RoomSummary object into this one @@ -44,9 +44,7 @@ namespace QMatrixClient { friend QDebug operator<<(QDebug dbg, const RoomSummary& rs); }; - template <> - struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RoomSummary& rs); static void fillFrom(const QJsonObject& jo, RoomSummary& rs); }; @@ -54,26 +52,26 @@ namespace QMatrixClient { class SyncRoomData { public: - QString roomId; - JoinState joinState; - RoomSummary summary; - StateEvents state; - RoomEvents timeline; - Events ephemeral; - Events accountData; - - bool timelineLimited; - QString timelinePrevBatch; - int unreadCount; - int highlightCount; - int notificationCount; - - SyncRoomData(const QString& roomId, JoinState joinState_, - const QJsonObject& room_); - SyncRoomData(SyncRoomData&&) = default; - SyncRoomData& operator=(SyncRoomData&&) = default; - - static const QString UnreadCountKey; + QString roomId; + JoinState joinState; + RoomSummary summary; + StateEvents state; + RoomEvents timeline; + Events ephemeral; + Events accountData; + + bool timelineLimited; + QString timelinePrevBatch; + int unreadCount; + int highlightCount; + int notificationCount; + + SyncRoomData(const QString& roomId, JoinState joinState_, + const QJsonObject& room_); + SyncRoomData(SyncRoomData&&) = default; + SyncRoomData& operator=(SyncRoomData&&) = default; + + static const QString UnreadCountKey; }; // QVector cannot work with non-copiable objects, std::vector can. @@ -82,35 +80,35 @@ namespace QMatrixClient { class SyncData { public: - SyncData() = default; - explicit SyncData(const QString& cacheFileName); - /** Parse sync response into room events - * \param json response from /sync or a room state cache - * \return the list of rooms with missing cache files; always - * empty when parsing response from /sync - */ - void parseJson(const QJsonObject& json, const QString& baseDir = {}); + SyncData() = default; + explicit SyncData(const QString& cacheFileName); + /** Parse sync response into room events + * \param json response from /sync or a room state cache + * \return the list of rooms with missing cache files; always + * empty when parsing response from /sync + */ + void parseJson(const QJsonObject& json, const QString& baseDir = {}); - Events&& takePresenceData(); - Events&& takeAccountData(); - Events&& takeToDeviceEvents(); - SyncDataList&& takeRoomData(); + Events&& takePresenceData(); + Events&& takeAccountData(); + Events&& takeToDeviceEvents(); + SyncDataList&& takeRoomData(); - QString nextBatch() const { return nextBatch_; } + QString nextBatch() const { return nextBatch_; } - QStringList unresolvedRooms() const { return unresolvedRoomIds; } + QStringList unresolvedRooms() const { return unresolvedRoomIds; } - static std::pair cacheVersion() { return { 10, 0 }; } - static QString fileNameForRoom(QString roomId); + static std::pair cacheVersion() { return { 10, 0 }; } + static QString fileNameForRoom(QString roomId); private: - QString nextBatch_; - Events presenceData; - Events accountData; - Events toDeviceEvents; - SyncDataList roomData; - QStringList unresolvedRoomIds; - - static QJsonObject loadJson(const QString& fileName); + QString nextBatch_; + Events presenceData; + Events accountData; + Events toDeviceEvents; + SyncDataList roomData; + QStringList unresolvedRoomIds; + + static QJsonObject loadJson(const QString& fileName); }; -} // namespace QMatrixClient +} // namespace QMatrixClient -- cgit v1.2.3 From c05ade838f0fce81f2bbe80a3295618a8a26ff52 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 2 Aug 2019 19:59:40 +0900 Subject: Apply the new brace wrapping to source files --- lib/syncdata.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index 6932878d..ad9902e4 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -22,8 +22,7 @@ #include "events/stateevent.h" -namespace QMatrixClient -{ +namespace QMatrixClient { /// Room summary, as defined in MSC688 /** * Every member of this structure is an Omittable; as per the MSC, only @@ -32,8 +31,7 @@ namespace QMatrixClient * means that nothing has come from the server; heroes.value().isEmpty() * means a peculiar case of a room with the only member - the current user. */ -struct RoomSummary -{ +struct RoomSummary { Omittable joinedMemberCount; Omittable invitedMemberCount; Omittable heroes; //< mxids of users to take part in the room @@ -48,14 +46,12 @@ struct RoomSummary }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const RoomSummary& rs); static void fillFrom(const QJsonObject& jo, RoomSummary& rs); }; -class SyncRoomData -{ +class SyncRoomData { public: QString roomId; JoinState joinState; @@ -82,8 +78,7 @@ public: // QVector cannot work with non-copiable objects, std::vector can. using SyncDataList = std::vector; -class SyncData -{ +class SyncData { public: SyncData() = default; explicit SyncData(const QString& cacheFileName); -- cgit v1.2.3 From 27ca32a1e5a56e09b9cc1d94224d2831004dcf3d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jul 2019 19:32:34 +0900 Subject: Namespace: QMatrixClient -> Quotient (with back comp alias) --- lib/syncdata.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index ad9902e4..d55438d7 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -22,7 +22,7 @@ #include "events/stateevent.h" -namespace QMatrixClient { +namespace Quotient { /// Room summary, as defined in MSC688 /** * Every member of this structure is an Omittable; as per the MSC, only @@ -111,4 +111,4 @@ private: static QJsonObject loadJson(const QString& fileName); }; -} // namespace QMatrixClient +} // namespace Quotient -- cgit v1.2.3 From 283208f8f891aafaaa0ae573bd8b9fcda783da12 Mon Sep 17 00:00:00 2001 From: Alexey Andreyev Date: Fri, 23 Aug 2019 17:03:14 +0300 Subject: E2EE: implement SyncData::deviceOneTimeKeysCount Signed-off-by: Alexey Andreev --- lib/syncdata.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index d55438d7..6e7183ee 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -92,6 +92,10 @@ public: Events&& takePresenceData(); Events&& takeAccountData(); Events&& takeToDeviceEvents(); + const QHash& deviceOneTimeKeysCount() const + { + return deviceOneTimeKeysCount_; + } SyncDataList&& takeRoomData(); QString nextBatch() const { return nextBatch_; } @@ -108,6 +112,7 @@ private: Events toDeviceEvents; SyncDataList roomData; QStringList unresolvedRoomIds; + QHash deviceOneTimeKeysCount_; static QJsonObject loadJson(const QString& fileName); }; -- cgit v1.2.3 From cf4d3d7ed82e62b57a11fbc7f491535a761dc75c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 27 May 2020 19:03:52 +0200 Subject: Move around and format code No functional changes here. --- lib/syncdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index 6e7183ee..41b8186e 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -75,7 +75,7 @@ public: static const QString UnreadCountKey; }; -// QVector cannot work with non-copiable objects, std::vector can. +// QVector cannot work with non-copyable objects, std::vector can. using SyncDataList = std::vector; class SyncData { -- cgit v1.2.3 From db8b9569f83ba3643c9005359ba556f2c3e357f4 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 5 Jun 2020 07:42:33 +0200 Subject: Use CBOR for binary JSON caching on Qt 5.15+ Qt 5.15 deprecates binary JSON format in favour of CBOR now used as a backend for its JSON classes. --- lib/syncdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index 41b8186e..752dd485 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -102,7 +102,7 @@ public: QStringList unresolvedRooms() const { return unresolvedRoomIds; } - static std::pair cacheVersion() { return { 10, 0 }; } + static std::pair cacheVersion() { return { 11, 0 }; } static QString fileNameForRoom(QString roomId); private: -- cgit v1.2.3 From 9fc2c15dc021b2fddcb24bbc367c02639ec1256b Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 10 Jun 2020 21:27:17 +0200 Subject: syncdata.h: fix an old warning about operator<< The warning has been that it is declared as a friend but not exactly in namespace Quotient (though all compilers still could find and link it but only as long as it is defined in the namespace). Now instead of being declared as a friend it's just declared in the namespace :) --- lib/syncdata.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/syncdata.h') diff --git a/lib/syncdata.h b/lib/syncdata.h index 752dd485..67d04557 100644 --- a/lib/syncdata.h +++ b/lib/syncdata.h @@ -41,9 +41,9 @@ struct RoomSummary { /// Merge the contents of another RoomSummary object into this one /// \return true, if the current object has changed; false otherwise bool merge(const RoomSummary& other); - - friend QDebug operator<<(QDebug dbg, const RoomSummary& rs); }; +QDebug operator<<(QDebug dbg, const RoomSummary& rs); + template <> struct JsonObjectConverter { -- cgit v1.2.3