aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/login.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-14 23:32:16 +0900
committerGitHub <noreply@github.com>2018-12-14 23:32:16 +0900
commitfcc8d2ca615fce6e42bf1cf6585d60f94a2db926 (patch)
treeb0dd17b632a5c5775f2221fd0b53b21a8c02ce58 /lib/csapi/login.cpp
parent50571a92b4e9f634c4daf546222fa082120db6c7 (diff)
parent12a0b95fdcfea15cd0ef313aec8868656629b986 (diff)
downloadlibquotient-fcc8d2ca615fce6e42bf1cf6585d60f94a2db926.tar.gz
libquotient-fcc8d2ca615fce6e42bf1cf6585d60f94a2db926.zip
Merge pull request #263 from QMatrixClient/kitsune-lazy-loading
Lazy loading members
Diffstat (limited to 'lib/csapi/login.cpp')
-rw-r--r--lib/csapi/login.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp
index 4d15a30b..ee33dac2 100644
--- a/lib/csapi/login.cpp
+++ b/lib/csapi/login.cpp
@@ -16,15 +16,11 @@ namespace QMatrixClient
{
// Converters
- template <> struct FromJsonObject<GetLoginFlowsJob::LoginFlow>
+ template <> struct JsonObjectConverter<GetLoginFlowsJob::LoginFlow>
{
- GetLoginFlowsJob::LoginFlow operator()(const QJsonObject& jo) const
+ static void fillFrom(const QJsonObject& jo, GetLoginFlowsJob::LoginFlow& result)
{
- GetLoginFlowsJob::LoginFlow result;
- result.type =
- fromJson<QString>(jo.value("type"_ls));
-
- return result;
+ fromJson(jo.value("type"_ls), result.type);
}
};
} // namespace QMatrixClient
@@ -60,7 +56,7 @@ const QVector<GetLoginFlowsJob::LoginFlow>& GetLoginFlowsJob::flows() const
BaseJob::Status GetLoginFlowsJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
- d->flows = fromJson<QVector<LoginFlow>>(json.value("flows"_ls));
+ fromJson(json.value("flows"_ls), d->flows);
return Success;
}
@@ -118,10 +114,10 @@ const QString& LoginJob::deviceId() const
BaseJob::Status LoginJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
- d->userId = fromJson<QString>(json.value("user_id"_ls));
- d->accessToken = fromJson<QString>(json.value("access_token"_ls));
- d->homeServer = fromJson<QString>(json.value("home_server"_ls));
- d->deviceId = fromJson<QString>(json.value("device_id"_ls));
+ fromJson(json.value("user_id"_ls), d->userId);
+ fromJson(json.value("access_token"_ls), d->accessToken);
+ fromJson(json.value("home_server"_ls), d->homeServer);
+ fromJson(json.value("device_id"_ls), d->deviceId);
return Success;
}