diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-08-03 17:29:52 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-03 17:29:52 +0900 |
commit | 66e116b7b1e848e80577a0229c8995db0a54932e (patch) | |
tree | 763340439a0f4034e9c829d76cb1ffe9766b83c5 /lib/csapi/administrative_contact.cpp | |
parent | 5b236dfe895c7766002559570aa29c9033009228 (diff) | |
parent | c05ade838f0fce81f2bbe80a3295618a8a26ff52 (diff) | |
download | libquotient-66e116b7b1e848e80577a0229c8995db0a54932e.tar.gz libquotient-66e116b7b1e848e80577a0229c8995db0a54932e.zip |
Merge pull request #295 from marcdeop/140_impose_coding_standard
140 impose coding standard
Diffstat (limited to 'lib/csapi/administrative_contact.cpp')
-rw-r--r-- | lib/csapi/administrative_contact.cpp | 112 |
1 files changed, 60 insertions, 52 deletions
diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 11385dff..067fb68a 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -12,46 +12,48 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); +// Converters namespace QMatrixClient { - // Converters - template <> struct JsonObjectConverter<GetAccount3PIDsJob::ThirdPartyIdentifier> +template <> +struct JsonObjectConverter<GetAccount3PIDsJob::ThirdPartyIdentifier> +{ + static void fillFrom(const QJsonObject& jo, + GetAccount3PIDsJob::ThirdPartyIdentifier& result) { - static void fillFrom(const QJsonObject& jo, GetAccount3PIDsJob::ThirdPartyIdentifier& result) - { - fromJson(jo.value("medium"_ls), result.medium); - fromJson(jo.value("address"_ls), result.address); - fromJson(jo.value("validated_at"_ls), result.validatedAt); - fromJson(jo.value("added_at"_ls), result.addedAt); - } - }; + fromJson(jo.value("medium"_ls), result.medium); + fromJson(jo.value("address"_ls), result.address); + fromJson(jo.value("validated_at"_ls), result.validatedAt); + fromJson(jo.value("added_at"_ls), result.addedAt); + } +}; + } // namespace QMatrixClient class GetAccount3PIDsJob::Private { - public: - QVector<ThirdPartyIdentifier> threepids; +public: + QVector<ThirdPartyIdentifier> threepids; }; QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/account/3pid"); + basePath % "/account/3pid"); } static const auto GetAccount3PIDsJobName = QStringLiteral("GetAccount3PIDsJob"); GetAccount3PIDsJob::GetAccount3PIDsJob() - : BaseJob(HttpVerb::Get, GetAccount3PIDsJobName, - basePath % "/account/3pid") + : BaseJob(HttpVerb::Get, GetAccount3PIDsJobName, basePath % "/account/3pid") , d(new Private) -{ -} +{} GetAccount3PIDsJob::~GetAccount3PIDsJob() = default; -const QVector<GetAccount3PIDsJob::ThirdPartyIdentifier>& GetAccount3PIDsJob::threepids() const +const QVector<GetAccount3PIDsJob::ThirdPartyIdentifier>& +GetAccount3PIDsJob::threepids() const { return d->threepids; } @@ -60,29 +62,33 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) { auto json = data.object(); fromJson(json.value("threepids"_ls), d->threepids); + return Success; } +// Converters namespace QMatrixClient { - // Converters - template <> struct JsonObjectConverter<Post3PIDsJob::ThreePidCredentials> +template <> +struct JsonObjectConverter<Post3PIDsJob::ThreePidCredentials> +{ + static void dumpTo(QJsonObject& jo, + const Post3PIDsJob::ThreePidCredentials& pod) { - static void dumpTo(QJsonObject& jo, const Post3PIDsJob::ThreePidCredentials& pod) - { - addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); - addParam<>(jo, QStringLiteral("id_server"), pod.idServer); - addParam<>(jo, QStringLiteral("sid"), pod.sid); - } - }; + addParam<>(jo, QStringLiteral("client_secret"), pod.clientSecret); + addParam<>(jo, QStringLiteral("id_server"), pod.idServer); + addParam<>(jo, QStringLiteral("sid"), pod.sid); + } +}; + } // namespace QMatrixClient static const auto Post3PIDsJobName = QStringLiteral("Post3PIDsJob"); -Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, Omittable<bool> bind) - : BaseJob(HttpVerb::Post, Post3PIDsJobName, - basePath % "/account/3pid") +Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, + Omittable<bool> bind) + : BaseJob(HttpVerb::Post, Post3PIDsJobName, basePath % "/account/3pid") { QJsonObject _data; addParam<>(_data, QStringLiteral("three_pid_creds"), threePidCreds); @@ -90,11 +96,13 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, Omittable<b setRequestData(_data); } -static const auto Delete3pidFromAccountJobName = QStringLiteral("Delete3pidFromAccountJob"); +static const auto Delete3pidFromAccountJobName = + QStringLiteral("Delete3pidFromAccountJob"); -Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const QString& address) +Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, + const QString& address) : BaseJob(HttpVerb::Post, Delete3pidFromAccountJobName, - basePath % "/account/3pid/delete") + basePath % "/account/3pid/delete") { QJsonObject _data; addParam<>(_data, QStringLiteral("medium"), medium); @@ -104,15 +112,18 @@ Delete3pidFromAccountJob::Delete3pidFromAccountJob(const QString& medium, const class RequestTokenTo3PIDEmailJob::Private { - public: - Sid data; +public: + Sid data; }; -static const auto RequestTokenTo3PIDEmailJobName = QStringLiteral("RequestTokenTo3PIDEmailJob"); +static const auto RequestTokenTo3PIDEmailJobName = + QStringLiteral("RequestTokenTo3PIDEmailJob"); -RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob(const QString& clientSecret, const QString& email, int sendAttempt, const QString& idServer, const QString& nextLink) +RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob( + const QString& clientSecret, const QString& email, int sendAttempt, + const QString& idServer, const QString& nextLink) : BaseJob(HttpVerb::Post, RequestTokenTo3PIDEmailJobName, - basePath % "/account/3pid/email/requestToken", false) + basePath % "/account/3pid/email/requestToken", false) , d(new Private) { QJsonObject _data; @@ -126,10 +137,7 @@ RequestTokenTo3PIDEmailJob::RequestTokenTo3PIDEmailJob(const QString& clientSecr RequestTokenTo3PIDEmailJob::~RequestTokenTo3PIDEmailJob() = default; -const Sid& RequestTokenTo3PIDEmailJob::data() const -{ - return d->data; -} +const Sid& RequestTokenTo3PIDEmailJob::data() const { return d->data; } BaseJob::Status RequestTokenTo3PIDEmailJob::parseJson(const QJsonDocument& data) { @@ -139,15 +147,19 @@ BaseJob::Status RequestTokenTo3PIDEmailJob::parseJson(const QJsonDocument& data) class RequestTokenTo3PIDMSISDNJob::Private { - public: - Sid data; +public: + Sid data; }; -static const auto RequestTokenTo3PIDMSISDNJobName = QStringLiteral("RequestTokenTo3PIDMSISDNJob"); +static const auto RequestTokenTo3PIDMSISDNJobName = + QStringLiteral("RequestTokenTo3PIDMSISDNJob"); -RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob(const QString& clientSecret, const QString& country, const QString& phoneNumber, int sendAttempt, const QString& idServer, const QString& nextLink) +RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob( + const QString& clientSecret, const QString& country, + const QString& phoneNumber, int sendAttempt, const QString& idServer, + const QString& nextLink) : BaseJob(HttpVerb::Post, RequestTokenTo3PIDMSISDNJobName, - basePath % "/account/3pid/msisdn/requestToken", false) + basePath % "/account/3pid/msisdn/requestToken", false) , d(new Private) { QJsonObject _data; @@ -162,14 +174,10 @@ RequestTokenTo3PIDMSISDNJob::RequestTokenTo3PIDMSISDNJob(const QString& clientSe RequestTokenTo3PIDMSISDNJob::~RequestTokenTo3PIDMSISDNJob() = default; -const Sid& RequestTokenTo3PIDMSISDNJob::data() const -{ - return d->data; -} +const Sid& RequestTokenTo3PIDMSISDNJob::data() const { return d->data; } BaseJob::Status RequestTokenTo3PIDMSISDNJob::parseJson(const QJsonDocument& data) { fromJson(data, d->data); return Success; } - |