aboutsummaryrefslogtreecommitdiff
path: root/lib/syncdata.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-06-24 07:21:13 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-06-24 07:21:13 +0900
commit63ae79c3e2820efc2ba60d33e2caf2d7b9b3c408 (patch)
tree2552f5049a6ef7ba0034483b25ca4ab33d1fcb13 /lib/syncdata.cpp
parente083d327e6f6581210f8d077d8bbe1151e81e82c (diff)
parent93f0c8fe89f448d1d58caa757573f17102369471 (diff)
downloadlibquotient-63ae79c3e2820efc2ba60d33e2caf2d7b9b3c408.tar.gz
libquotient-63ae79c3e2820efc2ba60d33e2caf2d7b9b3c408.zip
Merge branch 'master' into clang-format
# Conflicts: # CMakeLists.txt # lib/avatar.cpp # lib/connection.cpp # lib/connection.h # lib/connectiondata.cpp # lib/csapi/account-data.cpp # lib/csapi/account-data.h # lib/csapi/capabilities.cpp # lib/csapi/capabilities.h # lib/csapi/content-repo.cpp # lib/csapi/create_room.cpp # lib/csapi/filter.cpp # lib/csapi/joining.cpp # lib/csapi/keys.cpp # lib/csapi/list_joined_rooms.cpp # lib/csapi/notifications.cpp # lib/csapi/openid.cpp # lib/csapi/presence.cpp # lib/csapi/pushrules.cpp # lib/csapi/registration.cpp # lib/csapi/room_upgrades.cpp # lib/csapi/room_upgrades.h # lib/csapi/search.cpp # lib/csapi/users.cpp # lib/csapi/versions.cpp # lib/csapi/whoami.cpp # lib/csapi/{{base}}.cpp.mustache # lib/events/accountdataevents.h # lib/events/eventcontent.h # lib/events/roommemberevent.cpp # lib/events/stateevent.cpp # lib/jobs/basejob.cpp # lib/jobs/basejob.h # lib/networkaccessmanager.cpp # lib/networksettings.cpp # lib/room.cpp # lib/room.h # lib/settings.cpp # lib/settings.h # lib/syncdata.cpp # lib/user.cpp # lib/user.h # lib/util.cpp
Diffstat (limited to 'lib/syncdata.cpp')
-rw-r--r--lib/syncdata.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp
index d8fb7bb6..0c39b438 100644
--- a/lib/syncdata.cpp
+++ b/lib/syncdata.cpp
@@ -26,20 +26,20 @@
using namespace QMatrixClient;
const QString SyncRoomData::UnreadCountKey =
- QStringLiteral("x-qmatrixclient.unread_count");
+ QStringLiteral("x-qmatrixclient.unread_count");
bool RoomSummary::isEmpty() const
{
return joinedMemberCount.omitted() && invitedMemberCount.omitted()
- && heroes.omitted();
+ && heroes.omitted();
}
bool RoomSummary::merge(const RoomSummary& other)
{
// Using bitwise OR to prevent computation shortcut.
return joinedMemberCount.merge(other.joinedMemberCount)
- | invitedMemberCount.merge(other.invitedMemberCount)
- | heroes.merge(other.heroes);
+ | invitedMemberCount.merge(other.invitedMemberCount)
+ | heroes.merge(other.heroes);
}
QDebug QMatrixClient::operator<<(QDebug dbg, const RoomSummary& rs)
@@ -71,24 +71,23 @@ void JsonObjectConverter<RoomSummary>::fillFrom(const QJsonObject& jo,
{
fromJson(jo["m.joined_member_count"_ls], rs.joinedMemberCount);
fromJson(jo["m.invited_member_count"_ls], rs.invitedMemberCount);
- fromJson(jo["m.heroes"], rs.heroes);
+ fromJson(jo["m.heroes"_ls], rs.heroes);
}
template <typename EventsArrayT, typename StrT>
inline EventsArrayT load(const QJsonObject& batches, StrT keyName)
{
- return fromJson<EventsArrayT>(
- batches[keyName].toObject().value("events"_ls));
+ return fromJson<EventsArrayT>(batches[keyName].toObject().value("events"_ls));
}
SyncRoomData::SyncRoomData(const QString& roomId_, JoinState joinState_,
const QJsonObject& room_)
- : roomId(roomId_),
- joinState(joinState_),
- summary(fromJson<RoomSummary>(room_["summary"])),
- state(load<StateEvents>(room_,
- joinState == JoinState::Invite ? "invite_state"_ls
- : "state"_ls))
+ : roomId(roomId_)
+ , joinState(joinState_)
+ , summary(fromJson<RoomSummary>(room_["summary"_ls]))
+ , state(load<StateEvents>(room_, joinState == JoinState::Invite
+ ? "invite_state"_ls
+ : "state"_ls))
{
switch (joinState) {
case JoinState::Join:
@@ -122,7 +121,7 @@ SyncData::SyncData(const QString& cacheFileName)
auto json = loadJson(cacheFileName);
auto requiredVersion = std::get<0>(cacheVersion());
auto actualVersion =
- json.value("cache_version").toObject().value("major").toInt();
+ json.value("cache_version"_ls).toObject().value("major"_ls).toInt();
if (actualVersion == requiredVersion)
parseJson(json, cacheFileInfo.absolutePath() + '/');
else
@@ -159,10 +158,10 @@ QJsonObject SyncData::loadJson(const QString& fileName)
}
auto data = roomFile.readAll();
- const auto json =
- (data.startsWith('{') ? QJsonDocument::fromJson(data)
- : QJsonDocument::fromBinaryData(data))
- .object();
+ const auto json = (data.startsWith('{')
+ ? QJsonDocument::fromJson(data)
+ : QJsonDocument::fromBinaryData(data))
+ .object();
if (json.isEmpty()) {
qCWarning(MAIN) << "State cache in" << fileName
<< "is broken or empty, discarding";
@@ -189,7 +188,8 @@ void SyncData::parseJson(const QJsonObject& json, const QString& baseDir)
// We have a Qt container on the right and an STL one on the left
roomData.reserve(static_cast<size_t>(rs.size()));
for (auto roomIt = rs.begin(); roomIt != rs.end(); ++roomIt) {
- auto roomJson = roomIt->isObject()
+ auto roomJson =
+ roomIt->isObject()
? roomIt->toObject()
: loadJson(baseDir + fileNameForRoom(roomIt.key()));
if (roomJson.isEmpty()) {
@@ -199,7 +199,7 @@ void SyncData::parseJson(const QJsonObject& json, const QString& baseDir)
roomData.emplace_back(roomIt.key(), JoinState(ii), roomJson);
const auto& r = roomData.back();
totalEvents += r.state.size() + r.ephemeral.size()
- + r.accountData.size() + r.timeline.size();
+ + r.accountData.size() + r.timeline.size();
}
totalRooms += rs.size();
}