aboutsummaryrefslogtreecommitdiff
path: root/lib/jobs/syncjob.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-02 17:58:34 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 20:13:43 +0900
commit3dd6b5e6cc50aafce74b21b5a0bf4b26a9fcf6ee (patch)
treea647fa5328e04b20a84e46d29d420555d9c56cde /lib/jobs/syncjob.cpp
parented467d27b07781fdd2f7ddef043568954ce50b69 (diff)
downloadlibquotient-3dd6b5e6cc50aafce74b21b5a0bf4b26a9fcf6ee.tar.gz
libquotient-3dd6b5e6cc50aafce74b21b5a0bf4b26a9fcf6ee.zip
Use QStringLiteral() and operator"" _ls() in network jobs
Diffstat (limited to 'lib/jobs/syncjob.cpp')
-rw-r--r--lib/jobs/syncjob.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/lib/jobs/syncjob.cpp b/lib/jobs/syncjob.cpp
index cbdc37b4..7e5f2e0f 100644
--- a/lib/jobs/syncjob.cpp
+++ b/lib/jobs/syncjob.cpp
@@ -32,13 +32,13 @@ SyncJob::SyncJob(const QString& since, const QString& filter, int timeout,
setLoggingCategory(SYNCJOB);
QUrlQuery query;
if( !filter.isEmpty() )
- query.addQueryItem("filter", filter);
+ query.addQueryItem(QStringLiteral("filter"), filter);
if( !presence.isEmpty() )
- query.addQueryItem("set_presence", presence);
+ query.addQueryItem(QStringLiteral("set_presence"), presence);
if( timeout >= 0 )
- query.addQueryItem("timeout", QString::number(timeout));
+ query.addQueryItem(QStringLiteral("timeout"), QString::number(timeout));
if( !since.isEmpty() )
- query.addQueryItem("since", since);
+ query.addQueryItem(QStringLiteral("since"), since);
setRequestQuery(query);
setMaxRetries(std::numeric_limits<int>::max());
@@ -72,7 +72,7 @@ Events&&SyncData::takeToDeviceEvents()
template <typename EventsArrayT, typename StrT>
inline EventsArrayT load(const QJsonObject& batches, StrT keyName)
{
- return fromJson<EventsArrayT>(batches[keyName].toObject().value("events"));
+ return fromJson<EventsArrayT>(batches[keyName].toObject().value("events"_ls));
}
BaseJob::Status SyncJob::parseJson(const QJsonDocument& data)
@@ -85,12 +85,12 @@ BaseJob::Status SyncData::parseJson(const QJsonDocument &data)
QElapsedTimer et; et.start();
auto json = data.object();
- nextBatch_ = json.value("next_batch").toString();
- presenceData = load<Events>(json, "presence");
- accountData = load<Events>(json, "account_data");
- toDeviceEvents = load<Events>(json, "to_device");
+ nextBatch_ = json.value("next_batch"_ls).toString();
+ presenceData = load<Events>(json, "presence"_ls);
+ accountData = load<Events>(json, "account_data"_ls);
+ toDeviceEvents = load<Events>(json, "to_device"_ls);
- QJsonObject rooms = json.value("rooms").toObject();
+ auto rooms = json.value("rooms"_ls).toObject();
JoinStates::Int ii = 1; // ii is used to make a JoinState value
auto totalRooms = 0;
auto totalEvents = 0;
@@ -123,30 +123,31 @@ SyncRoomData::SyncRoomData(const QString& roomId_, JoinState joinState_,
: roomId(roomId_)
, joinState(joinState_)
, state(load<StateEvents>(room_,
- joinState == JoinState::Invite ? "invite_state" : "state"))
+ joinState == JoinState::Invite ? "invite_state"_ls : "state"_ls))
{
switch (joinState) {
case JoinState::Join:
- ephemeral = load<Events>(room_, "ephemeral");
- accountData = load<Events>(room_, "account_data");
+ ephemeral = load<Events>(room_, "ephemeral"_ls);
+ accountData = load<Events>(room_, "account_data"_ls);
FALLTHROUGH;
case JoinState::Leave:
{
- timeline = load<RoomEvents>(room_, "timeline");
- auto timelineJson = room_.value("timeline").toObject();
- timelineLimited = timelineJson.value("limited").toBool();
- timelinePrevBatch = timelineJson.value("prev_batch").toString();
+ timeline = load<RoomEvents>(room_, "timeline"_ls);
+ const auto timelineJson = room_.value("timeline"_ls).toObject();
+ timelineLimited = timelineJson.value("limited"_ls).toBool();
+ timelinePrevBatch = timelineJson.value("prev_batch"_ls).toString();
break;
}
default: /* nothing on top of state */;
}
- auto unreadJson = room_.value("unread_notifications").toObject();
+ const auto unreadJson = room_.value("unread_notifications"_ls).toObject();
unreadCount = unreadJson.value(UnreadCountKey).toInt(-2);
- highlightCount = unreadJson.value("highlight_count").toInt();
- notificationCount = unreadJson.value("notification_count").toInt();
+ highlightCount = unreadJson.value("highlight_count"_ls).toInt();
+ notificationCount = unreadJson.value("notification_count"_ls).toInt();
if (highlightCount > 0 || notificationCount > 0)
- qCDebug(SYNCJOB) << "Highlights: " << highlightCount
- << " Notifications:" << notificationCount;
+ qCDebug(SYNCJOB) << "Room" << roomId_
+ << "has highlights:" << highlightCount
+ << "and notifications:" << notificationCount;
}