diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-07 19:46:40 +0200 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-07 19:46:40 +0200 |
commit | 32729d9a7519cd2c4cddb0174b8329c6fd4a4a83 (patch) | |
tree | 9a966d7dc0bf628f610d5de1ad64c8d29b6b26f8 /lib/csapi/login.cpp | |
parent | a0430b1fb722a77ad7cbd28f181727d46d92b3a2 (diff) | |
download | libquotient-32729d9a7519cd2c4cddb0174b8329c6fd4a4a83.tar.gz libquotient-32729d9a7519cd2c4cddb0174b8329c6fd4a4a83.zip |
Update generated files according to gtad/* changes
Diffstat (limited to 'lib/csapi/login.cpp')
-rw-r--r-- | lib/csapi/login.cpp | 94 |
1 files changed, 8 insertions, 86 deletions
diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 3e98f56b..a5bac9ea 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -4,77 +4,29 @@ #include "login.h" -#include "converters.h" - #include <QtCore/QStringBuilder> using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter<GetLoginFlowsJob::LoginFlow> { - static void fillFrom(const QJsonObject& jo, - GetLoginFlowsJob::LoginFlow& result) - { - fromJson(jo.value("type"_ls), result.type); - } -}; - -} // namespace Quotient - -class GetLoginFlowsJob::Private { -public: - QVector<LoginFlow> flows; -}; - QUrl GetLoginFlowsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/login"); + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/login"); } GetLoginFlowsJob::GetLoginFlowsJob() : BaseJob(HttpVerb::Get, QStringLiteral("GetLoginFlowsJob"), - basePath % "/login", false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/login", false) {} -GetLoginFlowsJob::~GetLoginFlowsJob() = default; - -const QVector<GetLoginFlowsJob::LoginFlow>& GetLoginFlowsJob::flows() const -{ - return d->flows; -} - -BaseJob::Status GetLoginFlowsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("flows"_ls), d->flows); - - return Success; -} - -class LoginJob::Private { -public: - QString userId; - QString accessToken; - QString homeServer; - QString deviceId; - Omittable<DiscoveryInformation> wellKnown; -}; - LoginJob::LoginJob(const QString& type, const Omittable<UserIdentifier>& identifier, const QString& password, const QString& token, const QString& deviceId, - const QString& initialDeviceDisplayName, const QString& user, - const QString& medium, const QString& address) - : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), basePath % "/login", - false) - , d(new Private) + const QString& initialDeviceDisplayName) + : BaseJob(HttpVerb::Post, QStringLiteral("LoginJob"), + QStringLiteral("/_matrix/client/r0") % "/login", false) { QJsonObject _data; addParam<>(_data, QStringLiteral("type"), type); @@ -84,35 +36,5 @@ LoginJob::LoginJob(const QString& type, addParam<IfNotEmpty>(_data, QStringLiteral("device_id"), deviceId); addParam<IfNotEmpty>(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); - addParam<IfNotEmpty>(_data, QStringLiteral("user"), user); - addParam<IfNotEmpty>(_data, QStringLiteral("medium"), medium); - addParam<IfNotEmpty>(_data, QStringLiteral("address"), address); - setRequestData(_data); -} - -LoginJob::~LoginJob() = default; - -const QString& LoginJob::userId() const { return d->userId; } - -const QString& LoginJob::accessToken() const { return d->accessToken; } - -const QString& LoginJob::homeServer() const { return d->homeServer; } - -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(); - 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; + setRequestData(std::move(_data)); } |