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/users.cpp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'lib/csapi/users.cpp') diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 97d8962d..6d005915 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -12,13 +12,12 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -namespace QMatrixClient -{ +namespace QMatrixClient { // Converters - template <> struct JsonObjectConverter - { - static void fillFrom(const QJsonObject& jo, SearchUserDirectoryJob::User& result) + template <> struct JsonObjectConverter { + static void fillFrom(const QJsonObject& jo, + SearchUserDirectoryJob::User& result) { fromJson(jo.value("user_id"_ls), result.userId); fromJson(jo.value("display_name"_ls), result.displayName); @@ -30,16 +29,18 @@ namespace QMatrixClient class SearchUserDirectoryJob::Private { public: - QVector results; - bool limited; + QVector results; + bool limited; }; -static const auto SearchUserDirectoryJobName = QStringLiteral("SearchUserDirectoryJob"); +static const auto SearchUserDirectoryJobName = + QStringLiteral("SearchUserDirectoryJob"); -SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) +SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, + Omittable limit) : BaseJob(HttpVerb::Post, SearchUserDirectoryJobName, - basePath % "/user_directory/search") - , d(new Private) + basePath % "/user_directory/search"), + d(new Private) { QJsonObject _data; addParam<>(_data, QStringLiteral("search_term"), searchTerm); @@ -49,27 +50,24 @@ SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omitta SearchUserDirectoryJob::~SearchUserDirectoryJob() = default; -const QVector& SearchUserDirectoryJob::results() const +const QVector& +SearchUserDirectoryJob::results() const { return d->results; } -bool SearchUserDirectoryJob::limited() const -{ - return d->limited; -} +bool SearchUserDirectoryJob::limited() const { return d->limited; } BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data) { auto json = data.object(); if (!json.contains("results"_ls)) return { JsonParseError, - "The key 'results' not found in the response" }; + "The key 'results' not found in the response" }; fromJson(json.value("results"_ls), d->results); if (!json.contains("limited"_ls)) return { JsonParseError, - "The key 'limited' not found in the response" }; + "The key 'limited' not found in the response" }; fromJson(json.value("limited"_ls), d->limited); 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/users.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/csapi/users.cpp') diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 97d8962d..0d867145 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -63,11 +63,11 @@ BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data) { auto json = data.object(); if (!json.contains("results"_ls)) - return { JsonParseError, + return { IncorrectResponse, "The key 'results' not found in the response" }; fromJson(json.value("results"_ls), d->results); if (!json.contains("limited"_ls)) - return { JsonParseError, + return { IncorrectResponse, "The key 'limited' not found in the response" }; fromJson(json.value("limited"_ls), d->limited); return Success; -- 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/users.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/csapi/users.cpp') diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 39b05a77..77c297dd 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -8,12 +8,12 @@ #include -using namespace QMatrixClient; +using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace QMatrixClient +namespace Quotient { template <> @@ -28,7 +28,7 @@ struct JsonObjectConverter } }; -} // namespace QMatrixClient +} // namespace Quotient class SearchUserDirectoryJob::Private { -- 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/users.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/csapi/users.cpp') diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 77c297dd..5d2a6133 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -13,12 +13,10 @@ using namespace Quotient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); // Converters -namespace Quotient -{ +namespace Quotient { template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void fillFrom(const QJsonObject& jo, SearchUserDirectoryJob::User& result) { @@ -30,19 +28,15 @@ struct JsonObjectConverter } // namespace Quotient -class SearchUserDirectoryJob::Private -{ +class SearchUserDirectoryJob::Private { public: QVector results; bool limited; }; -static const auto SearchUserDirectoryJobName = - QStringLiteral("SearchUserDirectoryJob"); - SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) - : BaseJob(HttpVerb::Post, SearchUserDirectoryJobName, + : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), basePath % "/user_directory/search") , 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/users.cpp | 57 ++++------------------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) (limited to 'lib/csapi/users.cpp') diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index 5d2a6133..a0279d7e 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -4,68 +4,19 @@ #include "users.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -// Converters -namespace Quotient { - -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - SearchUserDirectoryJob::User& result) - { - fromJson(jo.value("user_id"_ls), result.userId); - fromJson(jo.value("display_name"_ls), result.displayName); - fromJson(jo.value("avatar_url"_ls), result.avatarUrl); - } -}; - -} // namespace Quotient - -class SearchUserDirectoryJob::Private { -public: - QVector results; - bool limited; -}; - SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omittable limit) : BaseJob(HttpVerb::Post, QStringLiteral("SearchUserDirectoryJob"), - basePath % "/user_directory/search") - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/user_directory/search") { QJsonObject _data; addParam<>(_data, QStringLiteral("search_term"), searchTerm); addParam(_data, QStringLiteral("limit"), limit); - setRequestData(_data); -} - -SearchUserDirectoryJob::~SearchUserDirectoryJob() = default; - -const QVector& SearchUserDirectoryJob::results() const -{ - return d->results; -} - -bool SearchUserDirectoryJob::limited() const { return d->limited; } - -BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("results"_ls)) - return { IncorrectResponse, - "The key 'results' not found in the response" }; - fromJson(json.value("results"_ls), d->results); - if (!json.contains("limited"_ls)) - return { IncorrectResponse, - "The key 'limited' not found in the response" }; - fromJson(json.value("limited"_ls), d->limited); - - return Success; + setRequestData(std::move(_data)); + addExpectedKey("results"); + addExpectedKey("limited"); } -- cgit v1.2.3