aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/login.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/login.cpp')
-rw-r--r--lib/csapi/login.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp
index 4d15a30b..5e369b9a 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;
}
@@ -71,6 +67,7 @@ class LoginJob::Private
QString accessToken;
QString homeServer;
QString deviceId;
+ Omittable<DiscoveryInformation> wellKnown;
};
static const auto LoginJobName = QStringLiteral("LoginJob");
@@ -115,13 +112,19 @@ const QString& LoginJob::deviceId() const
return d->deviceId;
}
+const Omittable<DiscoveryInformation>& LoginJob::wellKnown() const
+{
+ return d->wellKnown;
+}
+
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);
+ fromJson(json.value("well_known"_ls), d->wellKnown);
return Success;
}