aboutsummaryrefslogtreecommitdiff
path: root/lib/syncdata.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/syncdata.h')
-rw-r--r--lib/syncdata.h76
1 files changed, 44 insertions, 32 deletions
diff --git a/lib/syncdata.h b/lib/syncdata.h
index 67d04557..9358ec8f 100644
--- a/lib/syncdata.h
+++ b/lib/syncdata.h
@@ -1,28 +1,19 @@
-/******************************************************************************
- * Copyright (C) 2018 Kitsune Ral <kitsune-ral@users.sf.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * 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
- */
+// SPDX-FileCopyrightText: 2018 Kitsune Ral <kitsune-ral@users.sf.net>
+// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
-#include "joinstate.h"
+#include "quotient_common.h"
#include "events/stateevent.h"
namespace Quotient {
+
+constexpr auto UnreadNotificationsKey = "unread_notifications"_ls;
+constexpr auto PartiallyReadCountKey = "x-quotient.since_fully_read_count"_ls;
+constexpr auto NewUnreadCountKey = "org.matrix.msc2654.unread_count"_ls;
+constexpr auto HighlightCountKey = "highlight_count"_ls;
+
/// Room summary, as defined in MSC688
/**
* Every member of this structure is an Omittable; as per the MSC, only
@@ -31,7 +22,7 @@ namespace Quotient {
* 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 QUOTIENT_API RoomSummary {
Omittable<int> joinedMemberCount;
Omittable<int> invitedMemberCount;
Omittable<QStringList> heroes; //< mxids of users to take part in the room
@@ -44,13 +35,33 @@ struct RoomSummary {
};
QDebug operator<<(QDebug dbg, const RoomSummary& rs);
-
template <>
struct JsonObjectConverter<RoomSummary> {
static void dumpTo(QJsonObject& jo, const RoomSummary& rs);
static void fillFrom(const QJsonObject& jo, RoomSummary& rs);
};
+/// Information on e2e device updates. Note: only present on an
+/// incremental sync.
+struct DevicesList {
+ /// List of users who have updated their device identity keys, or who
+ /// now share an encrypted room with the client since the previous
+ /// sync response.
+ QStringList changed;
+
+ /// List of users with whom we do not share any encrypted rooms
+ /// anymore since the previous sync response.
+ QStringList left;
+};
+
+QDebug operator<<(QDebug dhg, const DevicesList& devicesList);
+
+template <>
+struct JsonObjectConverter<DevicesList> {
+ static void dumpTo(QJsonObject &jo, const DevicesList &dev);
+ static void fillFrom(const QJsonObject& jo, DevicesList& rs);
+};
+
class SyncRoomData {
public:
QString roomId;
@@ -63,16 +74,14 @@ public:
bool timelineLimited;
QString timelinePrevBatch;
- int unreadCount;
- int highlightCount;
- int notificationCount;
+ Omittable<int> partiallyReadCount;
+ Omittable<int> unreadCount;
+ Omittable<int> highlightCount;
- SyncRoomData(const QString& roomId, JoinState joinState_,
- const QJsonObject& room_);
+ SyncRoomData(QString roomId, JoinState joinState,
+ const QJsonObject& roomJson);
SyncRoomData(SyncRoomData&&) = default;
SyncRoomData& operator=(SyncRoomData&&) = default;
-
- static const QString UnreadCountKey;
};
// QVector cannot work with non-copyable objects, std::vector can.
@@ -89,20 +98,22 @@ public:
*/
void parseJson(const QJsonObject& json, const QString& baseDir = {});
- Events&& takePresenceData();
- Events&& takeAccountData();
- Events&& takeToDeviceEvents();
+ Events takePresenceData();
+ Events takeAccountData();
+ Events takeToDeviceEvents();
const QHash<QString, int>& deviceOneTimeKeysCount() const
{
return deviceOneTimeKeysCount_;
}
- SyncDataList&& takeRoomData();
+ SyncDataList takeRoomData();
+ DevicesList takeDevicesList();
QString nextBatch() const { return nextBatch_; }
QStringList unresolvedRooms() const { return unresolvedRoomIds; }
- static std::pair<int, int> cacheVersion() { return { 11, 0 }; }
+ static constexpr int MajorCacheVersion = 11;
+ static std::pair<int, int> cacheVersion();
static QString fileNameForRoom(QString roomId);
private:
@@ -113,6 +124,7 @@ private:
SyncDataList roomData;
QStringList unresolvedRoomIds;
QHash<QString, int> deviceOneTimeKeysCount_;
+ DevicesList devicesList;
static QJsonObject loadJson(const QString& fileName);
};