aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/pusher.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-08-03 17:29:52 +0900
committerGitHub <noreply@github.com>2019-08-03 17:29:52 +0900
commit66e116b7b1e848e80577a0229c8995db0a54932e (patch)
tree763340439a0f4034e9c829d76cb1ffe9766b83c5 /lib/csapi/pusher.cpp
parent5b236dfe895c7766002559570aa29c9033009228 (diff)
parentc05ade838f0fce81f2bbe80a3295618a8a26ff52 (diff)
downloadlibquotient-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/pusher.cpp')
-rw-r--r--lib/csapi/pusher.cpp90
1 files changed, 48 insertions, 42 deletions
diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp
index 664959f4..41a0cffe 100644
--- a/lib/csapi/pusher.cpp
+++ b/lib/csapi/pusher.cpp
@@ -12,55 +12,56 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
+// Converters
namespace QMatrixClient
{
- // Converters
- template <> struct JsonObjectConverter<GetPushersJob::PusherData>
+template <>
+struct JsonObjectConverter<GetPushersJob::PusherData>
+{
+ static void fillFrom(const QJsonObject& jo,
+ GetPushersJob::PusherData& result)
{
- static void fillFrom(const QJsonObject& jo, GetPushersJob::PusherData& result)
- {
- fromJson(jo.value("url"_ls), result.url);
- fromJson(jo.value("format"_ls), result.format);
- }
- };
-
- template <> struct JsonObjectConverter<GetPushersJob::Pusher>
+ fromJson(jo.value("url"_ls), result.url);
+ fromJson(jo.value("format"_ls), result.format);
+ }
+};
+
+template <>
+struct JsonObjectConverter<GetPushersJob::Pusher>
+{
+ static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result)
{
- static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result)
- {
- fromJson(jo.value("pushkey"_ls), result.pushkey);
- fromJson(jo.value("kind"_ls), result.kind);
- fromJson(jo.value("app_id"_ls), result.appId);
- fromJson(jo.value("app_display_name"_ls), result.appDisplayName);
- fromJson(jo.value("device_display_name"_ls), result.deviceDisplayName);
- fromJson(jo.value("profile_tag"_ls), result.profileTag);
- fromJson(jo.value("lang"_ls), result.lang);
- fromJson(jo.value("data"_ls), result.data);
- }
- };
+ fromJson(jo.value("pushkey"_ls), result.pushkey);
+ fromJson(jo.value("kind"_ls), result.kind);
+ fromJson(jo.value("app_id"_ls), result.appId);
+ fromJson(jo.value("app_display_name"_ls), result.appDisplayName);
+ fromJson(jo.value("device_display_name"_ls), result.deviceDisplayName);
+ fromJson(jo.value("profile_tag"_ls), result.profileTag);
+ fromJson(jo.value("lang"_ls), result.lang);
+ fromJson(jo.value("data"_ls), result.data);
+ }
+};
+
} // namespace QMatrixClient
class GetPushersJob::Private
{
- public:
- QVector<Pusher> pushers;
+public:
+ QVector<Pusher> pushers;
};
QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl)
{
- return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/pushers");
+ return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushers");
}
static const auto GetPushersJobName = QStringLiteral("GetPushersJob");
GetPushersJob::GetPushersJob()
- : BaseJob(HttpVerb::Get, GetPushersJobName,
- basePath % "/pushers")
+ : BaseJob(HttpVerb::Get, GetPushersJobName, basePath % "/pushers")
, d(new Private)
-{
-}
+{}
GetPushersJob::~GetPushersJob() = default;
@@ -73,28 +74,34 @@ BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
fromJson(json.value("pushers"_ls), d->pushers);
+
return Success;
}
+// Converters
namespace QMatrixClient
{
- // Converters
- template <> struct JsonObjectConverter<PostPusherJob::PusherData>
+template <>
+struct JsonObjectConverter<PostPusherJob::PusherData>
+{
+ static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod)
{
- static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod)
- {
- addParam<IfNotEmpty>(jo, QStringLiteral("url"), pod.url);
- addParam<IfNotEmpty>(jo, QStringLiteral("format"), pod.format);
- }
- };
+ addParam<IfNotEmpty>(jo, QStringLiteral("url"), pod.url);
+ addParam<IfNotEmpty>(jo, QStringLiteral("format"), pod.format);
+ }
+};
+
} // namespace QMatrixClient
static const auto PostPusherJobName = QStringLiteral("PostPusherJob");
-PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const QString& appId, const QString& appDisplayName, const QString& deviceDisplayName, const QString& lang, const PusherData& data, const QString& profileTag, Omittable<bool> append)
- : BaseJob(HttpVerb::Post, PostPusherJobName,
- basePath % "/pushers/set")
+PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind,
+ const QString& appId, const QString& appDisplayName,
+ const QString& deviceDisplayName,
+ const QString& lang, const PusherData& data,
+ const QString& profileTag, Omittable<bool> append)
+ : BaseJob(HttpVerb::Post, PostPusherJobName, basePath % "/pushers/set")
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("pushkey"), pushkey);
@@ -108,4 +115,3 @@ PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const
addParam<IfNotEmpty>(_data, QStringLiteral("append"), append);
setRequestData(_data);
}
-