From 1e6510790dab6b9141ae52993987b406399668cd Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 2 Sep 2018 16:08:13 +0900 Subject: Support CS API 0.4.0 Numerous changes in CS (and now also AS) API, including compatibility-breaking ones - see the diff for details. --- lib/csapi/wellknown.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/csapi/wellknown.cpp (limited to 'lib/csapi/wellknown.cpp') diff --git a/lib/csapi/wellknown.cpp b/lib/csapi/wellknown.cpp new file mode 100644 index 00000000..d42534a0 --- /dev/null +++ b/lib/csapi/wellknown.cpp @@ -0,0 +1,59 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "wellknown.h" + +#include "converters.h" + +#include + +using namespace QMatrixClient; + +static const auto basePath = QStringLiteral("/.well-known"); + +class GetWellknownJob::Private +{ + public: + HomeserverInformation homeserver; + Omittable identityServer; +}; + +QUrl GetWellknownJob::makeRequestUrl(QUrl baseUrl) +{ + return BaseJob::makeRequestUrl(std::move(baseUrl), + basePath % "/matrix/client"); +} + +static const auto GetWellknownJobName = QStringLiteral("GetWellknownJob"); + +GetWellknownJob::GetWellknownJob() + : BaseJob(HttpVerb::Get, GetWellknownJobName, + basePath % "/matrix/client", false) + , d(new Private) +{ +} + +GetWellknownJob::~GetWellknownJob() = default; + +const HomeserverInformation& GetWellknownJob::homeserver() const +{ + return d->homeserver; +} + +const Omittable& GetWellknownJob::identityServer() const +{ + return d->identityServer; +} + +BaseJob::Status GetWellknownJob::parseJson(const QJsonDocument& data) +{ + auto json = data.object(); + if (!json.contains("m.homeserver"_ls)) + return { JsonParseError, + "The key 'm.homeserver' not found in the response" }; + d->homeserver = fromJson(json.value("m.homeserver"_ls)); + d->identityServer = fromJson(json.value("m.identity_server"_ls)); + return Success; +} + -- cgit v1.2.3