aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/joining.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/csapi/joining.cpp
parented467d27b07781fdd2f7ddef043568954ce50b69 (diff)
downloadlibquotient-3dd6b5e6cc50aafce74b21b5a0bf4b26a9fcf6ee.tar.gz
libquotient-3dd6b5e6cc50aafce74b21b5a0bf4b26a9fcf6ee.zip
Use QStringLiteral() and operator"" _ls() in network jobs
Diffstat (limited to 'lib/csapi/joining.cpp')
-rw-r--r--lib/csapi/joining.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp
index f2d6fbf7..0a4618af 100644
--- a/lib/csapi/joining.cpp
+++ b/lib/csapi/joining.cpp
@@ -19,10 +19,10 @@ namespace QMatrixClient
QJsonObject toJson(const JoinRoomByIdJob::ThirdPartySigned& pod)
{
QJsonObject _json;
- addParam<>(_json, "sender", pod.sender);
- addParam<>(_json, "mxid", pod.mxid);
- addParam<>(_json, "token", pod.token);
- addParam<>(_json, "signatures", pod.signatures);
+ addParam<>(_json, QStringLiteral("sender"), pod.sender);
+ addParam<>(_json, QStringLiteral("mxid"), pod.mxid);
+ addParam<>(_json, QStringLiteral("token"), pod.token);
+ addParam<>(_json, QStringLiteral("signatures"), pod.signatures);
return _json;
}
} // namespace QMatrixClient
@@ -33,13 +33,15 @@ class JoinRoomByIdJob::Private
QString roomId;
};
+static const auto JoinRoomByIdJobName = QStringLiteral("JoinRoomByIdJob");
+
JoinRoomByIdJob::JoinRoomByIdJob(const QString& roomId, const Omittable<ThirdPartySigned>& thirdPartySigned)
- : BaseJob(HttpVerb::Post, "JoinRoomByIdJob",
+ : BaseJob(HttpVerb::Post, JoinRoomByIdJobName,
basePath % "/rooms/" % roomId % "/join")
, d(new Private)
{
QJsonObject _data;
- addParam<IfNotEmpty>(_data, "third_party_signed", thirdPartySigned);
+ addParam<IfNotEmpty>(_data, QStringLiteral("third_party_signed"), thirdPartySigned);
setRequestData(_data);
}
@@ -53,10 +55,10 @@ const QString& JoinRoomByIdJob::roomId() const
BaseJob::Status JoinRoomByIdJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
- if (!json.contains("room_id"))
+ if (!json.contains("room_id"_ls))
return { JsonParseError,
"The key 'room_id' not found in the response" };
- d->roomId = fromJson<QString>(json.value("room_id"));
+ d->roomId = fromJson<QString>(json.value("room_id"_ls));
return Success;
}
@@ -67,17 +69,17 @@ namespace QMatrixClient
QJsonObject toJson(const JoinRoomJob::Signed& pod)
{
QJsonObject _json;
- addParam<>(_json, "sender", pod.sender);
- addParam<>(_json, "mxid", pod.mxid);
- addParam<>(_json, "token", pod.token);
- addParam<>(_json, "signatures", pod.signatures);
+ addParam<>(_json, QStringLiteral("sender"), pod.sender);
+ addParam<>(_json, QStringLiteral("mxid"), pod.mxid);
+ addParam<>(_json, QStringLiteral("token"), pod.token);
+ addParam<>(_json, QStringLiteral("signatures"), pod.signatures);
return _json;
}
QJsonObject toJson(const JoinRoomJob::ThirdPartySigned& pod)
{
QJsonObject _json;
- addParam<>(_json, "signed", pod.signedData);
+ addParam<>(_json, QStringLiteral("signed"), pod.signedData);
return _json;
}
} // namespace QMatrixClient
@@ -88,13 +90,15 @@ class JoinRoomJob::Private
QString roomId;
};
+static const auto JoinRoomJobName = QStringLiteral("JoinRoomJob");
+
JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const Omittable<ThirdPartySigned>& thirdPartySigned)
- : BaseJob(HttpVerb::Post, "JoinRoomJob",
+ : BaseJob(HttpVerb::Post, JoinRoomJobName,
basePath % "/join/" % roomIdOrAlias)
, d(new Private)
{
QJsonObject _data;
- addParam<IfNotEmpty>(_data, "third_party_signed", thirdPartySigned);
+ addParam<IfNotEmpty>(_data, QStringLiteral("third_party_signed"), thirdPartySigned);
setRequestData(_data);
}
@@ -108,10 +112,10 @@ const QString& JoinRoomJob::roomId() const
BaseJob::Status JoinRoomJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
- if (!json.contains("room_id"))
+ if (!json.contains("room_id"_ls))
return { JsonParseError,
"The key 'room_id' not found in the response" };
- d->roomId = fromJson<QString>(json.value("room_id"));
+ d->roomId = fromJson<QString>(json.value("room_id"_ls));
return Success;
}