From 3dd6b5e6cc50aafce74b21b5a0bf4b26a9fcf6ee Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 2 Jul 2018 17:58:34 +0900 Subject: Use QStringLiteral() and operator"" _ls() in network jobs --- lib/csapi/rooms.cpp | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'lib/csapi/rooms.cpp') diff --git a/lib/csapi/rooms.cpp b/lib/csapi/rooms.cpp index 4b66b447..a70d9543 100644 --- a/lib/csapi/rooms.cpp +++ b/lib/csapi/rooms.cpp @@ -24,8 +24,10 @@ QUrl GetOneRoomEventJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, con basePath % "/rooms/" % roomId % "/event/" % eventId); } +static const auto GetOneRoomEventJobName = QStringLiteral("GetOneRoomEventJob"); + GetOneRoomEventJob::GetOneRoomEventJob(const QString& roomId, const QString& eventId) - : BaseJob(HttpVerb::Get, "GetOneRoomEventJob", + : BaseJob(HttpVerb::Get, GetOneRoomEventJobName, basePath % "/rooms/" % roomId % "/event/" % eventId) , d(new Private) { @@ -41,10 +43,10 @@ EventPtr&& GetOneRoomEventJob::data() BaseJob::Status GetOneRoomEventJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("data")) + if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data")); + d->data = fromJson(json.value("data"_ls)); return Success; } @@ -60,8 +62,10 @@ QUrl GetRoomStateWithKeyJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, basePath % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey); } +static const auto GetRoomStateWithKeyJobName = QStringLiteral("GetRoomStateWithKeyJob"); + GetRoomStateWithKeyJob::GetRoomStateWithKeyJob(const QString& roomId, const QString& eventType, const QString& stateKey) - : BaseJob(HttpVerb::Get, "GetRoomStateWithKeyJob", + : BaseJob(HttpVerb::Get, GetRoomStateWithKeyJobName, basePath % "/rooms/" % roomId % "/state/" % eventType % "/" % stateKey) , d(new Private) { @@ -77,10 +81,10 @@ StateEventPtr&& GetRoomStateWithKeyJob::data() BaseJob::Status GetRoomStateWithKeyJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("data")) + if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data")); + d->data = fromJson(json.value("data"_ls)); return Success; } @@ -96,8 +100,10 @@ QUrl GetRoomStateByTypeJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, basePath % "/rooms/" % roomId % "/state/" % eventType); } +static const auto GetRoomStateByTypeJobName = QStringLiteral("GetRoomStateByTypeJob"); + GetRoomStateByTypeJob::GetRoomStateByTypeJob(const QString& roomId, const QString& eventType) - : BaseJob(HttpVerb::Get, "GetRoomStateByTypeJob", + : BaseJob(HttpVerb::Get, GetRoomStateByTypeJobName, basePath % "/rooms/" % roomId % "/state/" % eventType) , d(new Private) { @@ -113,10 +119,10 @@ StateEventPtr&& GetRoomStateByTypeJob::data() BaseJob::Status GetRoomStateByTypeJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("data")) + if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data")); + d->data = fromJson(json.value("data"_ls)); return Success; } @@ -132,8 +138,10 @@ QUrl GetRoomStateJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/state"); } +static const auto GetRoomStateJobName = QStringLiteral("GetRoomStateJob"); + GetRoomStateJob::GetRoomStateJob(const QString& roomId) - : BaseJob(HttpVerb::Get, "GetRoomStateJob", + : BaseJob(HttpVerb::Get, GetRoomStateJobName, basePath % "/rooms/" % roomId % "/state") , d(new Private) { @@ -149,10 +157,10 @@ StateEvents&& GetRoomStateJob::data() BaseJob::Status GetRoomStateJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("data")) + if (!json.contains("data"_ls)) return { JsonParseError, "The key 'data' not found in the response" }; - d->data = fromJson(json.value("data")); + d->data = fromJson(json.value("data"_ls)); return Success; } @@ -168,8 +176,10 @@ QUrl GetMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& roomId) basePath % "/rooms/" % roomId % "/members"); } +static const auto GetMembersByRoomJobName = QStringLiteral("GetMembersByRoomJob"); + GetMembersByRoomJob::GetMembersByRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Get, "GetMembersByRoomJob", + : BaseJob(HttpVerb::Get, GetMembersByRoomJobName, basePath % "/rooms/" % roomId % "/members") , d(new Private) { @@ -185,7 +195,7 @@ EventsArray&& GetMembersByRoomJob::chunk() BaseJob::Status GetMembersByRoomJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->chunk = fromJson>(json.value("chunk")); + d->chunk = fromJson>(json.value("chunk"_ls)); return Success; } @@ -200,9 +210,9 @@ namespace QMatrixClient const auto& _json = jv.toObject(); GetJoinedMembersByRoomJob::RoomMember result; result.displayName = - fromJson(_json.value("display_name")); + fromJson(_json.value("display_name"_ls)); result.avatarUrl = - fromJson(_json.value("avatar_url")); + fromJson(_json.value("avatar_url"_ls)); return result; } @@ -221,8 +231,10 @@ QUrl GetJoinedMembersByRoomJob::makeRequestUrl(QUrl baseUrl, const QString& room basePath % "/rooms/" % roomId % "/joined_members"); } +static const auto GetJoinedMembersByRoomJobName = QStringLiteral("GetJoinedMembersByRoomJob"); + GetJoinedMembersByRoomJob::GetJoinedMembersByRoomJob(const QString& roomId) - : BaseJob(HttpVerb::Get, "GetJoinedMembersByRoomJob", + : BaseJob(HttpVerb::Get, GetJoinedMembersByRoomJobName, basePath % "/rooms/" % roomId % "/joined_members") , d(new Private) { @@ -238,7 +250,7 @@ const QHash& GetJoinedMembersByR BaseJob::Status GetJoinedMembersByRoomJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->joined = fromJson>(json.value("joined")); + d->joined = fromJson>(json.value("joined"_ls)); return Success; } -- cgit v1.2.3