aboutsummaryrefslogtreecommitdiff
path: root/lib/syncdata.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-26 12:57:08 +0100
committerGitHub <noreply@github.com>2022-02-26 12:57:08 +0100
commit62039b527507aa6c45fbf7ac787da6234d2faac3 (patch)
treebe84dde38d9328f6278fce1b4f9e900d7e9dce2a /lib/syncdata.cpp
parent2aab2a0c95bbd3f12890badb58a825bb57d8e613 (diff)
parentb0e1455989405ef46eb6d9ed2cd559a1164d04f4 (diff)
downloadlibquotient-62039b527507aa6c45fbf7ac787da6234d2faac3.tar.gz
libquotient-62039b527507aa6c45fbf7ac787da6234d2faac3.zip
Merge pull request #477 from TobiasFella/work/readencryptedmessages
Diffstat (limited to 'lib/syncdata.cpp')
-rw-r--r--lib/syncdata.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp
index b0cd8e4d..78957cbe 100644
--- a/lib/syncdata.cpp
+++ b/lib/syncdata.cpp
@@ -99,6 +99,34 @@ SyncRoomData::SyncRoomData(QString roomId_, JoinState joinState,
fromJson(unreadJson.value(HighlightCountKey), highlightCount);
}
+QDebug Quotient::operator<<(QDebug dbg, const DevicesList& devicesList)
+{
+ QDebugStateSaver _(dbg);
+ QStringList sl;
+ if (!devicesList.changed.isEmpty())
+ sl << QStringLiteral("changed: %1").arg(devicesList.changed.join(", "));
+ if (!devicesList.left.isEmpty())
+ sl << QStringLiteral("left %1").arg(devicesList.left.join(", "));
+ dbg.nospace().noquote() << sl.join(QStringLiteral("; "));
+ return dbg;
+}
+
+void JsonObjectConverter<DevicesList>::dumpTo(QJsonObject& jo,
+ const DevicesList& rs)
+{
+ addParam<IfNotEmpty>(jo, QStringLiteral("changed"),
+ rs.changed);
+ addParam<IfNotEmpty>(jo, QStringLiteral("left"),
+ rs.left);
+}
+
+void JsonObjectConverter<DevicesList>::fillFrom(const QJsonObject& jo,
+ DevicesList& rs)
+{
+ fromJson(jo["changed"_ls], rs.changed);
+ fromJson(jo["left"_ls], rs.left);
+}
+
SyncData::SyncData(const QString& cacheFileName)
{
QFileInfo cacheFileInfo { cacheFileName };
@@ -133,6 +161,8 @@ std::pair<int, int> SyncData::cacheVersion()
return { MajorCacheVersion, 2 };
}
+DevicesList&& SyncData::takeDevicesList() { return std::move(devicesList); }
+
QJsonObject SyncData::loadJson(const QString& fileName)
{
QFile roomFile { fileName };
@@ -175,6 +205,10 @@ void SyncData::parseJson(const QJsonObject& json, const QString& baseDir)
fromJson(json.value("device_one_time_keys_count"_ls),
deviceOneTimeKeysCount_);
+ if(json.contains("device_lists")) {
+ fromJson(json.value("device_lists"), devicesList);
+ }
+
auto rooms = json.value("rooms"_ls).toObject();
auto totalRooms = 0;
auto totalEvents = 0;