From 3392e66fd015e191b01f6e3fc6839edc3948e31f Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 8 Dec 2018 15:36:04 +0900 Subject: Refactor toJson/fillJson Both now use through a common JsonConverter<> template class with its base definition tuned for structs/QJsonObjects and specialisations for non-object types. This new implementation doesn't work with virtual fillJson functions yet (so EventContent classes still use toJson as a member function) and does not cope quite well with non-constructible objects (you have to specialise JsonConverter<> rather than, more intuitively, JsonObjectConverter<>), but overall is more streamlined compared to the previous implementation. It also fixes one important issue that pushed for a rewrite: the previous implementation was not working with structure hierarchies at all so (in particular) the Filter part of CS API was totally disfunctional. --- lib/csapi/registration.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 320ec796..2772cd57 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -76,10 +76,10 @@ BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) if (!json.contains("user_id"_ls)) return { JsonParseError, "The key 'user_id' not found in the response" }; - d->userId = fromJson(json.value("user_id"_ls)); - d->accessToken = fromJson(json.value("access_token"_ls)); - d->homeServer = fromJson(json.value("home_server"_ls)); - d->deviceId = fromJson(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; } @@ -114,7 +114,7 @@ const Sid& RequestTokenToRegisterEmailJob::data() const BaseJob::Status RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) { - d->data = fromJson(data); + fromJson(data, d->data); return Success; } @@ -150,7 +150,7 @@ const Sid& RequestTokenToRegisterMSISDNJob::data() const BaseJob::Status RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) { - d->data = fromJson(data); + fromJson(data, d->data); return Success; } @@ -197,7 +197,7 @@ const Sid& RequestTokenToResetPasswordEmailJob::data() const BaseJob::Status RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) { - d->data = fromJson(data); + fromJson(data, d->data); return Success; } @@ -233,7 +233,7 @@ const Sid& RequestTokenToResetPasswordMSISDNJob::data() const BaseJob::Status RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) { - d->data = fromJson(data); + fromJson(data, d->data); return Success; } @@ -289,7 +289,7 @@ bool CheckUsernameAvailabilityJob::available() const BaseJob::Status CheckUsernameAvailabilityJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - d->available = fromJson(json.value("available"_ls)); + fromJson(json.value("available"_ls), d->available); return Success; } -- cgit v1.2.3 From 8dcda23ed210151904c9137067626eddae683822 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 13 Dec 2018 07:47:58 +0900 Subject: Regenerate csapi/ --- lib/csapi/registration.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 320ec796..34c34861 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -30,7 +30,7 @@ BaseJob::Query queryToRegister(const QString& kind) static const auto RegisterJobName = QStringLiteral("RegisterJob"); -RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, bool bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, bool inhibitLogin) +RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, Omittable bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, Omittable inhibitLogin) : BaseJob(HttpVerb::Post, RegisterJobName, basePath % "/register", queryToRegister(kind), @@ -251,7 +251,7 @@ DeactivateAccountJob::DeactivateAccountJob(const Omittable& class CheckUsernameAvailabilityJob::Private { public: - bool available; + Omittable available; }; BaseJob::Query queryToCheckUsernameAvailability(const QString& username) @@ -281,7 +281,7 @@ CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& userna CheckUsernameAvailabilityJob::~CheckUsernameAvailabilityJob() = default; -bool CheckUsernameAvailabilityJob::available() const +Omittable CheckUsernameAvailabilityJob::available() const { return d->available; } -- cgit v1.2.3 From aacc4bcb4a487871daae6717f77605aaba444341 Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Sat, 2 Mar 2019 12:26:57 +0100 Subject: style: apply .clang-format to all .cpp and .h files --- lib/csapi/registration.cpp | 174 ++++++++++++++++++++++++--------------------- 1 file changed, 91 insertions(+), 83 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 5dc9c1e5..b5e7d985 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -15,10 +15,10 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); class RegisterJob::Private { public: - QString userId; - QString accessToken; - QString homeServer; - QString deviceId; + QString userId; + QString accessToken; + QString homeServer; + QString deviceId; }; BaseJob::Query queryToRegister(const QString& kind) @@ -30,12 +30,15 @@ BaseJob::Query queryToRegister(const QString& kind) static const auto RegisterJobName = QStringLiteral("RegisterJob"); -RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, Omittable bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, Omittable inhibitLogin) - : BaseJob(HttpVerb::Post, RegisterJobName, - basePath % "/register", - queryToRegister(kind), - {}, false) - , d(new Private) +RegisterJob::RegisterJob(const QString& kind, + const Omittable& auth, + Omittable bindEmail, const QString& username, + const QString& password, const QString& deviceId, + const QString& initialDeviceDisplayName, + Omittable inhibitLogin) + : BaseJob(HttpVerb::Post, RegisterJobName, basePath % "/register", + queryToRegister(kind), {}, false), + d(new Private) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -43,39 +46,28 @@ RegisterJob::RegisterJob(const QString& kind, const Omittable(_data, QStringLiteral("username"), username); addParam(_data, QStringLiteral("password"), password); addParam(_data, QStringLiteral("device_id"), deviceId); - addParam(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); + addParam(_data, QStringLiteral("initial_device_display_name"), + initialDeviceDisplayName); addParam(_data, QStringLiteral("inhibit_login"), inhibitLogin); setRequestData(_data); } RegisterJob::~RegisterJob() = default; -const QString& RegisterJob::userId() const -{ - return d->userId; -} +const QString& RegisterJob::userId() const { return d->userId; } -const QString& RegisterJob::accessToken() const -{ - return d->accessToken; -} +const QString& RegisterJob::accessToken() const { return d->accessToken; } -const QString& RegisterJob::homeServer() const -{ - return d->homeServer; -} +const QString& RegisterJob::homeServer() const { return d->homeServer; } -const QString& RegisterJob::deviceId() const -{ - return d->deviceId; -} +const QString& RegisterJob::deviceId() const { return d->deviceId; } BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) { auto json = data.object(); if (!json.contains("user_id"_ls)) return { JsonParseError, - "The key 'user_id' not found in the response" }; + "The key 'user_id' not found in the response" }; fromJson(json.value("user_id"_ls), d->userId); fromJson(json.value("access_token"_ls), d->accessToken); fromJson(json.value("home_server"_ls), d->homeServer); @@ -86,15 +78,18 @@ BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) class RequestTokenToRegisterEmailJob::Private { public: - Sid data; + Sid data; }; -static const auto RequestTokenToRegisterEmailJobName = QStringLiteral("RequestTokenToRegisterEmailJob"); +static const auto RequestTokenToRegisterEmailJobName = + QStringLiteral("RequestTokenToRegisterEmailJob"); -RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob(const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) +RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( + const QString& clientSecret, const QString& email, int sendAttempt, + const QString& idServer, const QString& nextLink) : BaseJob(HttpVerb::Post, RequestTokenToRegisterEmailJobName, - basePath % "/register/email/requestToken", false) - , d(new Private) + basePath % "/register/email/requestToken", false), + d(new Private) { QJsonObject _data; addParam<>(_data, QStringLiteral("client_secret"), clientSecret); @@ -107,12 +102,10 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob(const QString& cl RequestTokenToRegisterEmailJob::~RequestTokenToRegisterEmailJob() = default; -const Sid& RequestTokenToRegisterEmailJob::data() const -{ - return d->data; -} +const Sid& RequestTokenToRegisterEmailJob::data() const { return d->data; } -BaseJob::Status RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) +BaseJob::Status +RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; @@ -121,15 +114,19 @@ BaseJob::Status RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& d class RequestTokenToRegisterMSISDNJob::Private { public: - Sid data; + Sid data; }; -static const auto RequestTokenToRegisterMSISDNJobName = QStringLiteral("RequestTokenToRegisterMSISDNJob"); +static const auto RequestTokenToRegisterMSISDNJobName = + QStringLiteral("RequestTokenToRegisterMSISDNJob"); -RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob(const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) +RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( + const QString& clientSecret, const QString& country, + const QString& phoneNumber, int sendAttempt, const QString& idServer, + const QString& nextLink) : BaseJob(HttpVerb::Post, RequestTokenToRegisterMSISDNJobName, - basePath % "/register/msisdn/requestToken", false) - , d(new Private) + basePath % "/register/msisdn/requestToken", false), + d(new Private) { QJsonObject _data; addParam<>(_data, QStringLiteral("client_secret"), clientSecret); @@ -143,12 +140,10 @@ RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob(const QString& RequestTokenToRegisterMSISDNJob::~RequestTokenToRegisterMSISDNJob() = default; -const Sid& RequestTokenToRegisterMSISDNJob::data() const -{ - return d->data; -} +const Sid& RequestTokenToRegisterMSISDNJob::data() const { return d->data; } -BaseJob::Status RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) +BaseJob::Status +RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; @@ -156,9 +151,10 @@ BaseJob::Status RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& static const auto ChangePasswordJobName = QStringLiteral("ChangePasswordJob"); -ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const Omittable& auth) +ChangePasswordJob::ChangePasswordJob(const QString& newPassword, + const Omittable& auth) : BaseJob(HttpVerb::Post, ChangePasswordJobName, - basePath % "/account/password") + basePath % "/account/password") { QJsonObject _data; addParam<>(_data, QStringLiteral("new_password"), newPassword); @@ -169,15 +165,18 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const Omittable class RequestTokenToResetPasswordEmailJob::Private { public: - Sid data; + Sid data; }; -static const auto RequestTokenToResetPasswordEmailJobName = QStringLiteral("RequestTokenToResetPasswordEmailJob"); +static const auto RequestTokenToResetPasswordEmailJobName = + QStringLiteral("RequestTokenToResetPasswordEmailJob"); -RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob(const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) +RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( + const QString& clientSecret, const QString& email, int sendAttempt, + const QString& idServer, const QString& nextLink) : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordEmailJobName, - basePath % "/account/password/email/requestToken", false) - , d(new Private) + basePath % "/account/password/email/requestToken", false), + d(new Private) { QJsonObject _data; addParam<>(_data, QStringLiteral("client_secret"), clientSecret); @@ -188,14 +187,13 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob(const Q setRequestData(_data); } -RequestTokenToResetPasswordEmailJob::~RequestTokenToResetPasswordEmailJob() = default; +RequestTokenToResetPasswordEmailJob::~RequestTokenToResetPasswordEmailJob() = + default; -const Sid& RequestTokenToResetPasswordEmailJob::data() const -{ - return d->data; -} +const Sid& RequestTokenToResetPasswordEmailJob::data() const { return d->data; } -BaseJob::Status RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) +BaseJob::Status +RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; @@ -204,15 +202,19 @@ BaseJob::Status RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocume class RequestTokenToResetPasswordMSISDNJob::Private { public: - Sid data; + Sid data; }; -static const auto RequestTokenToResetPasswordMSISDNJobName = QStringLiteral("RequestTokenToResetPasswordMSISDNJob"); +static const auto RequestTokenToResetPasswordMSISDNJobName = + QStringLiteral("RequestTokenToResetPasswordMSISDNJob"); -RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob(const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) +RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( + const QString& clientSecret, const QString& country, + const QString& phoneNumber, int sendAttempt, const QString& idServer, + const QString& nextLink) : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordMSISDNJobName, - basePath % "/account/password/msisdn/requestToken", false) - , d(new Private) + basePath % "/account/password/msisdn/requestToken", false), + d(new Private) { QJsonObject _data; addParam<>(_data, QStringLiteral("client_secret"), clientSecret); @@ -224,24 +226,28 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob(const setRequestData(_data); } -RequestTokenToResetPasswordMSISDNJob::~RequestTokenToResetPasswordMSISDNJob() = default; +RequestTokenToResetPasswordMSISDNJob::~RequestTokenToResetPasswordMSISDNJob() = + default; const Sid& RequestTokenToResetPasswordMSISDNJob::data() const { return d->data; } -BaseJob::Status RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) +BaseJob::Status +RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; } -static const auto DeactivateAccountJobName = QStringLiteral("DeactivateAccountJob"); +static const auto DeactivateAccountJobName = + QStringLiteral("DeactivateAccountJob"); -DeactivateAccountJob::DeactivateAccountJob(const Omittable& auth) +DeactivateAccountJob::DeactivateAccountJob( + const Omittable& auth) : BaseJob(HttpVerb::Post, DeactivateAccountJobName, - basePath % "/account/deactivate") + basePath % "/account/deactivate") { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -251,7 +257,7 @@ DeactivateAccountJob::DeactivateAccountJob(const Omittable& class CheckUsernameAvailabilityJob::Private { public: - Omittable available; + Omittable available; }; BaseJob::Query queryToCheckUsernameAvailability(const QString& username) @@ -261,21 +267,23 @@ BaseJob::Query queryToCheckUsernameAvailability(const QString& username) return _q; } -QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, const QString& username) +QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, + const QString& username) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/register/available", - queryToCheckUsernameAvailability(username)); + basePath % "/register/available", + queryToCheckUsernameAvailability(username)); } -static const auto CheckUsernameAvailabilityJobName = QStringLiteral("CheckUsernameAvailabilityJob"); +static const auto CheckUsernameAvailabilityJobName = + QStringLiteral("CheckUsernameAvailabilityJob"); -CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) +CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob( + const QString& username) : BaseJob(HttpVerb::Get, CheckUsernameAvailabilityJobName, - basePath % "/register/available", - queryToCheckUsernameAvailability(username), - {}, false) - , d(new Private) + basePath % "/register/available", + queryToCheckUsernameAvailability(username), {}, false), + d(new Private) { } @@ -286,10 +294,10 @@ Omittable CheckUsernameAvailabilityJob::available() const return d->available; } -BaseJob::Status CheckUsernameAvailabilityJob::parseJson(const QJsonDocument& data) +BaseJob::Status +CheckUsernameAvailabilityJob::parseJson(const QJsonDocument& data) { auto json = data.object(); fromJson(json.value("available"_ls), d->available); return Success; } - -- cgit v1.2.3 From 93f0c8fe89f448d1d58caa757573f17102369471 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 7 Jun 2019 19:16:33 +0900 Subject: Generated files in csapi/: switch from now-deprecated JsonParserError to IncorrectResponse --- lib/csapi/registration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 5dc9c1e5..76741a50 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -74,7 +74,7 @@ BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) { auto json = data.object(); if (!json.contains("user_id"_ls)) - return { JsonParseError, + return { IncorrectResponse, "The key 'user_id' not found in the response" }; fromJson(json.value("user_id"_ls), d->userId); fromJson(json.value("access_token"_ls), d->accessToken); -- cgit v1.2.3 From 27ca32a1e5a56e09b9cc1d94224d2831004dcf3d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jul 2019 19:32:34 +0900 Subject: Namespace: QMatrixClient -> Quotient (with back comp alias) --- lib/csapi/registration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 52b4098d..270011e1 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -8,7 +8,7 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -- cgit v1.2.3 From 7036ed0dcb137cb5cbb6b426dd338c5e2e4c6424 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 17 Apr 2020 07:42:13 +0200 Subject: Regenerate API files using new GTAD and refreshed templates No functional changes. --- lib/csapi/registration.cpp | 64 +++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 43 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 270011e1..768617cc 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -12,8 +12,7 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -class RegisterJob::Private -{ +class RegisterJob::Private { public: QString userId; QString accessToken; @@ -28,16 +27,14 @@ BaseJob::Query queryToRegister(const QString& kind) return _q; } -static const auto RegisterJobName = QStringLiteral("RegisterJob"); - RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, Omittable bindEmail, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, Omittable inhibitLogin) - : BaseJob(HttpVerb::Post, RegisterJobName, basePath % "/register", - queryToRegister(kind), {}, false) + : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), + basePath % "/register", queryToRegister(kind), {}, false) , d(new Private) { QJsonObject _data; @@ -76,19 +73,15 @@ BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) return Success; } -class RequestTokenToRegisterEmailJob::Private -{ +class RequestTokenToRegisterEmailJob::Private { public: Sid data; }; -static const auto RequestTokenToRegisterEmailJobName = - QStringLiteral("RequestTokenToRegisterEmailJob"); - RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToRegisterEmailJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), basePath % "/register/email/requestToken", false) , d(new Private) { @@ -109,23 +102,20 @@ BaseJob::Status RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenToRegisterMSISDNJob::Private -{ +class RequestTokenToRegisterMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenToRegisterMSISDNJobName = - QStringLiteral("RequestTokenToRegisterMSISDNJob"); - RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToRegisterMSISDNJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), basePath % "/register/msisdn/requestToken", false) , d(new Private) { @@ -147,14 +137,13 @@ BaseJob::Status RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto ChangePasswordJobName = QStringLiteral("ChangePasswordJob"); - ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const Omittable& auth) - : BaseJob(HttpVerb::Post, ChangePasswordJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), basePath % "/account/password") { QJsonObject _data; @@ -163,19 +152,16 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, setRequestData(_data); } -class RequestTokenToResetPasswordEmailJob::Private -{ +class RequestTokenToResetPasswordEmailJob::Private { public: Sid data; }; -static const auto RequestTokenToResetPasswordEmailJobName = - QStringLiteral("RequestTokenToResetPasswordEmailJob"); - RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordEmailJobName, + : BaseJob(HttpVerb::Post, + QStringLiteral("RequestTokenToResetPasswordEmailJob"), basePath % "/account/password/email/requestToken", false) , d(new Private) { @@ -197,23 +183,21 @@ BaseJob::Status RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -class RequestTokenToResetPasswordMSISDNJob::Private -{ +class RequestTokenToResetPasswordMSISDNJob::Private { public: Sid data; }; -static const auto RequestTokenToResetPasswordMSISDNJobName = - QStringLiteral("RequestTokenToResetPasswordMSISDNJob"); - RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) - : BaseJob(HttpVerb::Post, RequestTokenToResetPasswordMSISDNJobName, + : BaseJob(HttpVerb::Post, + QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), basePath % "/account/password/msisdn/requestToken", false) , d(new Private) { @@ -239,15 +223,13 @@ BaseJob::Status RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); + return Success; } -static const auto DeactivateAccountJobName = - QStringLiteral("DeactivateAccountJob"); - DeactivateAccountJob::DeactivateAccountJob( const Omittable& auth) - : BaseJob(HttpVerb::Post, DeactivateAccountJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), basePath % "/account/deactivate") { QJsonObject _data; @@ -255,8 +237,7 @@ DeactivateAccountJob::DeactivateAccountJob( setRequestData(_data); } -class CheckUsernameAvailabilityJob::Private -{ +class CheckUsernameAvailabilityJob::Private { public: Omittable available; }; @@ -276,11 +257,8 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, queryToCheckUsernameAvailability(username)); } -static const auto CheckUsernameAvailabilityJobName = - QStringLiteral("CheckUsernameAvailabilityJob"); - CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) - : BaseJob(HttpVerb::Get, CheckUsernameAvailabilityJobName, + : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), basePath % "/register/available", queryToCheckUsernameAvailability(username), {}, false) , d(new Private) -- cgit v1.2.3 From 32729d9a7519cd2c4cddb0174b8329c6fd4a4a83 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jun 2020 19:46:40 +0200 Subject: Update generated files according to gtad/* changes --- lib/csapi/registration.cpp | 233 ++++++++------------------------------------- 1 file changed, 40 insertions(+), 193 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 768617cc..9f88ef28 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -4,23 +4,11 @@ #include "registration.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class RegisterJob::Private { -public: - QString userId; - QString accessToken; - QString homeServer; - QString deviceId; -}; - -BaseJob::Query queryToRegister(const QString& kind) +auto queryToRegister(const QString& kind) { BaseJob::Query _q; addParam(_q, QStringLiteral("kind"), kind); @@ -29,220 +17,94 @@ BaseJob::Query queryToRegister(const QString& kind) RegisterJob::RegisterJob(const QString& kind, const Omittable& auth, - Omittable bindEmail, const QString& username, - const QString& password, const QString& deviceId, + const QString& username, const QString& password, + const QString& deviceId, const QString& initialDeviceDisplayName, Omittable inhibitLogin) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), - basePath % "/register", queryToRegister(kind), {}, false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/register", + queryToRegister(kind), {}, false) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); - addParam(_data, QStringLiteral("bind_email"), bindEmail); addParam(_data, QStringLiteral("username"), username); addParam(_data, QStringLiteral("password"), password); addParam(_data, QStringLiteral("device_id"), deviceId); addParam(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); addParam(_data, QStringLiteral("inhibit_login"), inhibitLogin); - setRequestData(_data); -} - -RegisterJob::~RegisterJob() = default; - -const QString& RegisterJob::userId() const { return d->userId; } - -const QString& RegisterJob::accessToken() const { return d->accessToken; } - -const QString& RegisterJob::homeServer() const { return d->homeServer; } - -const QString& RegisterJob::deviceId() const { return d->deviceId; } - -BaseJob::Status RegisterJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("user_id"_ls)) - return { IncorrectResponse, - "The key 'user_id' not found in the response" }; - 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; + setRequestData(std::move(_data)); + addExpectedKey("user_id"); } -class RequestTokenToRegisterEmailJob::Private { -public: - Sid data; -}; - RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( - const QString& clientSecret, const QString& email, int sendAttempt, - const QString& idServer, const QString& nextLink) + const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), - basePath % "/register/email/requestToken", false) - , d(new Private) -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("email"), email); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToRegisterEmailJob::~RequestTokenToRegisterEmailJob() = default; - -const Sid& RequestTokenToRegisterEmailJob::data() const { return d->data; } - -BaseJob::Status -RequestTokenToRegisterEmailJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") + % "/register/email/requestToken", + false) { - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } -class RequestTokenToRegisterMSISDNJob::Private { -public: - Sid data; -}; - RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( - const QString& clientSecret, const QString& country, - const QString& phoneNumber, int sendAttempt, const QString& idServer, - const QString& nextLink) + const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), - basePath % "/register/msisdn/requestToken", false) - , d(new Private) + QStringLiteral("/_matrix/client/r0") + % "/register/msisdn/requestToken", + false) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("country"), country); - addParam<>(_data, QStringLiteral("phone_number"), phoneNumber); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToRegisterMSISDNJob::~RequestTokenToRegisterMSISDNJob() = default; - -const Sid& RequestTokenToRegisterMSISDNJob::data() const { return d->data; } - -BaseJob::Status -RequestTokenToRegisterMSISDNJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, + Omittable logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), - basePath % "/account/password") + QStringLiteral("/_matrix/client/r0") % "/account/password") { QJsonObject _data; addParam<>(_data, QStringLiteral("new_password"), newPassword); + addParam(_data, QStringLiteral("logout_devices"), logoutDevices); addParam(_data, QStringLiteral("auth"), auth); - setRequestData(_data); + setRequestData(std::move(_data)); } -class RequestTokenToResetPasswordEmailJob::Private { -public: - Sid data; -}; - RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( - const QString& clientSecret, const QString& email, int sendAttempt, - const QString& idServer, const QString& nextLink) + const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordEmailJob"), - basePath % "/account/password/email/requestToken", false) - , d(new Private) -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("email"), email); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToResetPasswordEmailJob::~RequestTokenToResetPasswordEmailJob() = - default; - -const Sid& RequestTokenToResetPasswordEmailJob::data() const { return d->data; } - -BaseJob::Status -RequestTokenToResetPasswordEmailJob::parseJson(const QJsonDocument& data) + QStringLiteral("/_matrix/client/r0") + % "/account/password/email/requestToken", + false) { - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } -class RequestTokenToResetPasswordMSISDNJob::Private { -public: - Sid data; -}; - RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( - const QString& clientSecret, const QString& country, - const QString& phoneNumber, int sendAttempt, const QString& idServer, - const QString& nextLink) + const RequestMsisdnValidation& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), - basePath % "/account/password/msisdn/requestToken", false) - , d(new Private) -{ - QJsonObject _data; - addParam<>(_data, QStringLiteral("client_secret"), clientSecret); - addParam<>(_data, QStringLiteral("country"), country); - addParam<>(_data, QStringLiteral("phone_number"), phoneNumber); - addParam<>(_data, QStringLiteral("send_attempt"), sendAttempt); - addParam(_data, QStringLiteral("next_link"), nextLink); - addParam<>(_data, QStringLiteral("id_server"), idServer); - setRequestData(_data); -} - -RequestTokenToResetPasswordMSISDNJob::~RequestTokenToResetPasswordMSISDNJob() = - default; - -const Sid& RequestTokenToResetPasswordMSISDNJob::data() const + QStringLiteral("/_matrix/client/r0") + % "/account/password/msisdn/requestToken", + false) { - return d->data; -} - -BaseJob::Status -RequestTokenToResetPasswordMSISDNJob::parseJson(const QJsonDocument& data) -{ - fromJson(data, d->data); - - return Success; + setRequestData(Data(toJson(body))); } DeactivateAccountJob::DeactivateAccountJob( - const Omittable& auth) + const Omittable& auth, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), - basePath % "/account/deactivate") + QStringLiteral("/_matrix/client/r0") % "/account/deactivate") { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); - setRequestData(_data); + addParam(_data, QStringLiteral("id_server"), idServer); + setRequestData(std::move(_data)); + addExpectedKey("id_server_unbind_result"); } -class CheckUsernameAvailabilityJob::Private { -public: - Omittable available; -}; - -BaseJob::Query queryToCheckUsernameAvailability(const QString& username) +auto queryToCheckUsernameAvailability(const QString& username) { BaseJob::Query _q; addParam<>(_q, QStringLiteral("username"), username); @@ -253,28 +115,13 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, const QString& username) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/register/available", + QStringLiteral("/_matrix/client/r0") + % "/register/available", queryToCheckUsernameAvailability(username)); } CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), - basePath % "/register/available", + QStringLiteral("/_matrix/client/r0") % "/register/available", queryToCheckUsernameAvailability(username), {}, false) - , d(new Private) {} - -CheckUsernameAvailabilityJob::~CheckUsernameAvailabilityJob() = default; - -Omittable CheckUsernameAvailabilityJob::available() const -{ - return d->available; -} - -BaseJob::Status CheckUsernameAvailabilityJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - fromJson(json.value("available"_ls), d->available); - - return Success; -} -- cgit v1.2.3 From e17764a1ae81393968dfb747c7b67353c109bc71 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 19 Jun 2020 15:01:33 +0200 Subject: csapi/: generated using the latest GTAD and matrix-doc For matrix-doc, specifically, it is master (5cb4b086) merged with https://github.com/matrix-org/matrix-doc/pull/2518. --- lib/csapi/registration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 9f88ef28..b80abc84 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -82,7 +82,7 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( } RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( - const RequestMsisdnValidation& body) + const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), QStringLiteral("/_matrix/client/r0") -- cgit v1.2.3 From 21fd088d207ee2c2724c5b250875a843b618497d Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 6 Nov 2020 14:11:49 +0100 Subject: ChangePasswordJob: logoutDevices doesn't need Omittable This is generated by GTAD 0.7.1 (to be released), based on the changed registration.yaml (to be committed and pulled). --- lib/csapi/registration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index b80abc84..33f61265 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -58,7 +58,7 @@ RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, - Omittable logoutDevices, + bool logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), QStringLiteral("/_matrix/client/r0") % "/account/password") -- cgit v1.2.3 From 7aa6e7c300779f652558397bcb7bb3b726d30cb9 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Fri, 2 Jul 2021 10:34:16 +0200 Subject: Abandon BaseJob::Query - generated API files --- lib/csapi/registration.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 33f61265..38649e63 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -10,7 +10,7 @@ using namespace Quotient; auto queryToRegister(const QString& kind) { - BaseJob::Query _q; + QUrlQuery _q; addParam(_q, QStringLiteral("kind"), kind); return _q; } @@ -106,7 +106,7 @@ DeactivateAccountJob::DeactivateAccountJob( auto queryToCheckUsernameAvailability(const QString& username) { - BaseJob::Query _q; + QUrlQuery _q; addParam<>(_q, QStringLiteral("username"), username); return _q; } -- cgit v1.2.3 From ed24065f2e9b8fce059c54137c04b790c6ce4fd1 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sun, 22 Aug 2021 20:05:41 +0200 Subject: Regenerate API files --- lib/csapi/registration.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 38649e63..c3617bfc 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -44,7 +44,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( % "/register/email/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( @@ -54,7 +54,7 @@ RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( % "/register/msisdn/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, @@ -78,7 +78,7 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( % "/account/password/email/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( @@ -89,7 +89,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( % "/account/password/msisdn/requestToken", false) { - setRequestData(Data(toJson(body))); + setRequestData(RequestData(toJson(body))); } DeactivateAccountJob::DeactivateAccountJob( -- cgit v1.2.3 From 1fd25fe944b67c55435ed4d4d8fd1cbb0989bb5f Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 4 Oct 2021 18:40:48 +0200 Subject: Regenerate CS API files upon the previous commit --- lib/csapi/registration.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index c3617bfc..153abcee 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -4,8 +4,6 @@ #include "registration.h" -#include - using namespace Quotient; auto queryToRegister(const QString& kind) @@ -22,7 +20,7 @@ RegisterJob::RegisterJob(const QString& kind, const QString& initialDeviceDisplayName, Omittable inhibitLogin) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), - QStringLiteral("/_matrix/client/r0") % "/register", + makePath("/_matrix/client/r0", "/register"), queryToRegister(kind), {}, false) { QJsonObject _data; @@ -40,8 +38,7 @@ RegisterJob::RegisterJob(const QString& kind, RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), - QStringLiteral("/_matrix/client/r0") - % "/register/email/requestToken", + makePath("/_matrix/client/r0", "/register/email/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -50,8 +47,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), - QStringLiteral("/_matrix/client/r0") - % "/register/msisdn/requestToken", + makePath("/_matrix/client/r0", "/register/msisdn/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -61,7 +57,7 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, bool logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), - QStringLiteral("/_matrix/client/r0") % "/account/password") + makePath("/_matrix/client/r0", "/account/password")) { QJsonObject _data; addParam<>(_data, QStringLiteral("new_password"), newPassword); @@ -74,8 +70,8 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordEmailJob"), - QStringLiteral("/_matrix/client/r0") - % "/account/password/email/requestToken", + makePath("/_matrix/client/r0", + "/account/password/email/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -85,8 +81,8 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), - QStringLiteral("/_matrix/client/r0") - % "/account/password/msisdn/requestToken", + makePath("/_matrix/client/r0", + "/account/password/msisdn/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -95,7 +91,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( DeactivateAccountJob::DeactivateAccountJob( const Omittable& auth, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), - QStringLiteral("/_matrix/client/r0") % "/account/deactivate") + makePath("/_matrix/client/r0", "/account/deactivate")) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -115,13 +111,13 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, const QString& username) { return BaseJob::makeRequestUrl(std::move(baseUrl), - QStringLiteral("/_matrix/client/r0") - % "/register/available", + makePath("/_matrix/client/r0", + "/register/available"), queryToCheckUsernameAvailability(username)); } CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), - QStringLiteral("/_matrix/client/r0") % "/register/available", + makePath("/_matrix/client/r0", "/register/available"), queryToCheckUsernameAvailability(username), {}, false) {} -- cgit v1.2.3 From 42811660094c88a4a1bfa8bd8ace5f4b148c246a Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 31 May 2022 18:24:53 +0200 Subject: Regenerate API files (FTBFS; see the next commit) --- lib/csapi/registration.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 153abcee..aa4b4fad 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -20,7 +20,7 @@ RegisterJob::RegisterJob(const QString& kind, const QString& initialDeviceDisplayName, Omittable inhibitLogin) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), - makePath("/_matrix/client/r0", "/register"), + makePath("/_matrix/client/v3", "/register"), queryToRegister(kind), {}, false) { QJsonObject _data; @@ -38,7 +38,7 @@ RegisterJob::RegisterJob(const QString& kind, RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterEmailJob"), - makePath("/_matrix/client/r0", "/register/email/requestToken"), + makePath("/_matrix/client/v3", "/register/email/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -47,7 +47,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToRegisterMSISDNJob"), - makePath("/_matrix/client/r0", "/register/msisdn/requestToken"), + makePath("/_matrix/client/v3", "/register/msisdn/requestToken"), false) { setRequestData(RequestData(toJson(body))); @@ -57,7 +57,7 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, bool logoutDevices, const Omittable& auth) : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), - makePath("/_matrix/client/r0", "/account/password")) + makePath("/_matrix/client/v3", "/account/password")) { QJsonObject _data; addParam<>(_data, QStringLiteral("new_password"), newPassword); @@ -70,7 +70,7 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( const EmailValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordEmailJob"), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/account/password/email/requestToken"), false) { @@ -81,7 +81,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( const MsisdnValidationData& body) : BaseJob(HttpVerb::Post, QStringLiteral("RequestTokenToResetPasswordMSISDNJob"), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/account/password/msisdn/requestToken"), false) { @@ -91,7 +91,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( DeactivateAccountJob::DeactivateAccountJob( const Omittable& auth, const QString& idServer) : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), - makePath("/_matrix/client/r0", "/account/deactivate")) + makePath("/_matrix/client/v3", "/account/deactivate")) { QJsonObject _data; addParam(_data, QStringLiteral("auth"), auth); @@ -111,13 +111,14 @@ QUrl CheckUsernameAvailabilityJob::makeRequestUrl(QUrl baseUrl, const QString& username) { return BaseJob::makeRequestUrl(std::move(baseUrl), - makePath("/_matrix/client/r0", + makePath("/_matrix/client/v3", "/register/available"), queryToCheckUsernameAvailability(username)); } -CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob(const QString& username) +CheckUsernameAvailabilityJob::CheckUsernameAvailabilityJob( + const QString& username) : BaseJob(HttpVerb::Get, QStringLiteral("CheckUsernameAvailabilityJob"), - makePath("/_matrix/client/r0", "/register/available"), + makePath("/_matrix/client/v3", "/register/available"), queryToCheckUsernameAvailability(username), {}, false) {} -- cgit v1.2.3 From ed05d9d589fe3d36bd3714e648016352179afbef Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sat, 11 Jun 2022 19:42:08 +0200 Subject: Regenerate API files using latest matrix-spec New: - refresh tokens support (changes in login.* and registration.*; RefreshJob); - GetRelatingEvents[WithRelType[AndEventType]]Job Changed space_hierarchy.*: - childrenState is of type StateEvents now; limit and maxDepth are (omittable) integers, not doubles. - no more unused `stripped_state.h` file inclusion. --- lib/csapi/registration.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index aa4b4fad..3541724b 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -18,7 +18,8 @@ RegisterJob::RegisterJob(const QString& kind, const QString& username, const QString& password, const QString& deviceId, const QString& initialDeviceDisplayName, - Omittable inhibitLogin) + Omittable inhibitLogin, + Omittable refreshToken) : BaseJob(HttpVerb::Post, QStringLiteral("RegisterJob"), makePath("/_matrix/client/v3", "/register"), queryToRegister(kind), {}, false) @@ -31,6 +32,7 @@ RegisterJob::RegisterJob(const QString& kind, addParam(_data, QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); addParam(_data, QStringLiteral("inhibit_login"), inhibitLogin); + addParam(_data, QStringLiteral("refresh_token"), refreshToken); setRequestData(std::move(_data)); addExpectedKey("user_id"); } -- cgit v1.2.3 From 2dd85770cbfd6d9c7506757f25765c05ef74987d Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Thu, 16 Jun 2022 13:29:02 +0200 Subject: Regenerate API files upon the previous commit --- lib/csapi/registration.cpp | 48 +++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'lib/csapi/registration.cpp') diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 3541724b..04c0fe12 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -24,16 +24,19 @@ RegisterJob::RegisterJob(const QString& kind, makePath("/_matrix/client/v3", "/register"), queryToRegister(kind), {}, false) { - QJsonObject _data; - addParam(_data, QStringLiteral("auth"), auth); - addParam(_data, QStringLiteral("username"), username); - addParam(_data, QStringLiteral("password"), password); - addParam(_data, QStringLiteral("device_id"), deviceId); - addParam(_data, QStringLiteral("initial_device_display_name"), + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("auth"), auth); + addParam(_dataJson, QStringLiteral("username"), username); + addParam(_dataJson, QStringLiteral("password"), password); + addParam(_dataJson, QStringLiteral("device_id"), deviceId); + addParam(_dataJson, + QStringLiteral("initial_device_display_name"), initialDeviceDisplayName); - addParam(_data, QStringLiteral("inhibit_login"), inhibitLogin); - addParam(_data, QStringLiteral("refresh_token"), refreshToken); - setRequestData(std::move(_data)); + addParam(_dataJson, QStringLiteral("inhibit_login"), + inhibitLogin); + addParam(_dataJson, QStringLiteral("refresh_token"), + refreshToken); + setRequestData({ _dataJson }); addExpectedKey("user_id"); } @@ -43,7 +46,7 @@ RequestTokenToRegisterEmailJob::RequestTokenToRegisterEmailJob( makePath("/_matrix/client/v3", "/register/email/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( @@ -52,7 +55,7 @@ RequestTokenToRegisterMSISDNJob::RequestTokenToRegisterMSISDNJob( makePath("/_matrix/client/v3", "/register/msisdn/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } ChangePasswordJob::ChangePasswordJob(const QString& newPassword, @@ -61,11 +64,12 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, : BaseJob(HttpVerb::Post, QStringLiteral("ChangePasswordJob"), makePath("/_matrix/client/v3", "/account/password")) { - QJsonObject _data; - addParam<>(_data, QStringLiteral("new_password"), newPassword); - addParam(_data, QStringLiteral("logout_devices"), logoutDevices); - addParam(_data, QStringLiteral("auth"), auth); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam<>(_dataJson, QStringLiteral("new_password"), newPassword); + addParam(_dataJson, QStringLiteral("logout_devices"), + logoutDevices); + addParam(_dataJson, QStringLiteral("auth"), auth); + setRequestData({ _dataJson }); } RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( @@ -76,7 +80,7 @@ RequestTokenToResetPasswordEmailJob::RequestTokenToResetPasswordEmailJob( "/account/password/email/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( @@ -87,7 +91,7 @@ RequestTokenToResetPasswordMSISDNJob::RequestTokenToResetPasswordMSISDNJob( "/account/password/msisdn/requestToken"), false) { - setRequestData(RequestData(toJson(body))); + setRequestData({ toJson(body) }); } DeactivateAccountJob::DeactivateAccountJob( @@ -95,10 +99,10 @@ DeactivateAccountJob::DeactivateAccountJob( : BaseJob(HttpVerb::Post, QStringLiteral("DeactivateAccountJob"), makePath("/_matrix/client/v3", "/account/deactivate")) { - QJsonObject _data; - addParam(_data, QStringLiteral("auth"), auth); - addParam(_data, QStringLiteral("id_server"), idServer); - setRequestData(std::move(_data)); + QJsonObject _dataJson; + addParam(_dataJson, QStringLiteral("auth"), auth); + addParam(_dataJson, QStringLiteral("id_server"), idServer); + setRequestData({ _dataJson }); addExpectedKey("id_server_unbind_result"); } -- cgit v1.2.3