aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-12-24 14:29:07 +0100
committerTobias Fella <fella@posteo.de>2021-12-24 14:29:07 +0100
commitaeed7f3bada2cefcb52d4418b5ed76f19980d702 (patch)
tree44502e2036c2a292a9f37e17d66971d17e3d3a8f /lib/connection.cpp
parent31bb962f36c31621b311f1aee654e36ea09e8d77 (diff)
downloadlibquotient-aeed7f3bada2cefcb52d4418b5ed76f19980d702.tar.gz
libquotient-aeed7f3bada2cefcb52d4418b5ed76f19980d702.zip
Cache deviceslist to binary when possible
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r--lib/connection.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 8b9f9688..e28ffb22 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -1982,9 +1982,16 @@ void Connection::Private::saveDevicesList()
rootObj.insert(QStringLiteral("sync_token"), q->nextBatchToken());
}
-
- QJsonDocument json { rootObj };
- const auto data = json.toJson();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+ const auto data =
+ cacheToBinary
+ ? QCborValue::fromJsonValue(rootObj).toCbor()
+ : QJsonDocument(rootObj).toJson(QJsonDocument::Compact);
+#else
+ QJsonDocument json { rootObj };
+ const auto data = cacheToBinary ? json.toBinaryData()
+ : json.toJson(QJsonDocument::Compact);
+#endif
qCDebug(PROFILER) << "DeviceList generated in" << et;
outFile.write(data.data(), data.size());