aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/pushrules.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/pushrules.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/pushrules.cpp')
-rw-r--r--lib/csapi/pushrules.cpp159
1 files changed, 88 insertions, 71 deletions
diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp
index 9b5b7cd1..5842369f 100644
--- a/lib/csapi/pushrules.cpp
+++ b/lib/csapi/pushrules.cpp
@@ -14,69 +14,63 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0");
class GetPushRulesJob::Private
{
- public:
- PushRuleset global;
+public:
+ PushRuleset global;
};
QUrl GetPushRulesJob::makeRequestUrl(QUrl baseUrl)
{
- return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/pushrules");
+ return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules");
}
static const auto GetPushRulesJobName = QStringLiteral("GetPushRulesJob");
GetPushRulesJob::GetPushRulesJob()
- : BaseJob(HttpVerb::Get, GetPushRulesJobName,
- basePath % "/pushrules")
+ : BaseJob(HttpVerb::Get, GetPushRulesJobName, basePath % "/pushrules")
, d(new Private)
-{
-}
+{}
GetPushRulesJob::~GetPushRulesJob() = default;
-const PushRuleset& GetPushRulesJob::global() const
-{
- return d->global;
-}
+const PushRuleset& GetPushRulesJob::global() const { return d->global; }
BaseJob::Status GetPushRulesJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
if (!json.contains("global"_ls))
return { IncorrectResponse,
- "The key 'global' not found in the response" };
+ "The key 'global' not found in the response" };
fromJson(json.value("global"_ls), d->global);
+
return Success;
}
class GetPushRuleJob::Private
{
- public:
- PushRule data;
+public:
+ PushRule data;
};
-QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId)
+QUrl GetPushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope,
+ const QString& kind, const QString& ruleId)
{
- return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId);
+ return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules/"
+ % scope % "/" % kind
+ % "/" % ruleId);
}
static const auto GetPushRuleJobName = QStringLiteral("GetPushRuleJob");
-GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId)
+GetPushRuleJob::GetPushRuleJob(const QString& scope, const QString& kind,
+ const QString& ruleId)
: BaseJob(HttpVerb::Get, GetPushRuleJobName,
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId)
+ basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId)
, d(new Private)
-{
-}
+{}
GetPushRuleJob::~GetPushRuleJob() = default;
-const PushRule& GetPushRuleJob::data() const
-{
- return d->data;
-}
+const PushRule& GetPushRuleJob::data() const { return d->data; }
BaseJob::Status GetPushRuleJob::parseJson(const QJsonDocument& data)
{
@@ -84,19 +78,22 @@ BaseJob::Status GetPushRuleJob::parseJson(const QJsonDocument& data)
return Success;
}
-QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId)
+QUrl DeletePushRuleJob::makeRequestUrl(QUrl baseUrl, const QString& scope,
+ const QString& kind,
+ const QString& ruleId)
{
- return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId);
+ return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/pushrules/"
+ % scope % "/" % kind
+ % "/" % ruleId);
}
static const auto DeletePushRuleJobName = QStringLiteral("DeletePushRuleJob");
-DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, const QString& ruleId)
+DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind,
+ const QString& ruleId)
: BaseJob(HttpVerb::Delete, DeletePushRuleJobName,
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId)
-{
-}
+ basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId)
+{}
BaseJob::Query queryToSetPushRule(const QString& before, const QString& after)
{
@@ -108,10 +105,14 @@ BaseJob::Query queryToSetPushRule(const QString& before, const QString& after)
static const auto SetPushRuleJobName = QStringLiteral("SetPushRuleJob");
-SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions, const QString& before, const QString& after, const QVector<PushCondition>& conditions, const QString& pattern)
+SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind,
+ const QString& ruleId, const QStringList& actions,
+ const QString& before, const QString& after,
+ const QVector<PushCondition>& conditions,
+ const QString& pattern)
: BaseJob(HttpVerb::Put, SetPushRuleJobName,
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId,
- queryToSetPushRule(before, after))
+ basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId,
+ queryToSetPushRule(before, after))
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("actions"), actions);
@@ -122,47 +123,55 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const
class IsPushRuleEnabledJob::Private
{
- public:
- bool enabled;
+public:
+ bool enabled;
};
-QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId)
+QUrl IsPushRuleEnabledJob::makeRequestUrl(QUrl baseUrl, const QString& scope,
+ const QString& kind,
+ const QString& ruleId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled");
+ basePath % "/pushrules/" % scope % "/" % kind
+ % "/" % ruleId % "/enabled");
}
-static const auto IsPushRuleEnabledJobName = QStringLiteral("IsPushRuleEnabledJob");
+static const auto IsPushRuleEnabledJobName =
+ QStringLiteral("IsPushRuleEnabledJob");
-IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId)
+IsPushRuleEnabledJob::IsPushRuleEnabledJob(const QString& scope,
+ const QString& kind,
+ const QString& ruleId)
: BaseJob(HttpVerb::Get, IsPushRuleEnabledJobName,
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled")
+ basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId
+ % "/enabled")
, d(new Private)
-{
-}
+{}
IsPushRuleEnabledJob::~IsPushRuleEnabledJob() = default;
-bool IsPushRuleEnabledJob::enabled() const
-{
- return d->enabled;
-}
+bool IsPushRuleEnabledJob::enabled() const { return d->enabled; }
BaseJob::Status IsPushRuleEnabledJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
if (!json.contains("enabled"_ls))
return { IncorrectResponse,
- "The key 'enabled' not found in the response" };
+ "The key 'enabled' not found in the response" };
fromJson(json.value("enabled"_ls), d->enabled);
+
return Success;
}
-static const auto SetPushRuleEnabledJobName = QStringLiteral("SetPushRuleEnabledJob");
+static const auto SetPushRuleEnabledJobName =
+ QStringLiteral("SetPushRuleEnabledJob");
-SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString& kind, const QString& ruleId, bool enabled)
+SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope,
+ const QString& kind,
+ const QString& ruleId, bool enabled)
: BaseJob(HttpVerb::Put, SetPushRuleEnabledJobName,
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled")
+ basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId
+ % "/enabled")
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("enabled"), enabled);
@@ -171,50 +180,58 @@ SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString
class GetPushRuleActionsJob::Private
{
- public:
- QStringList actions;
+public:
+ QStringList actions;
};
-QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope, const QString& kind, const QString& ruleId)
+QUrl GetPushRuleActionsJob::makeRequestUrl(QUrl baseUrl, const QString& scope,
+ const QString& kind,
+ const QString& ruleId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions");
+ basePath % "/pushrules/" % scope % "/" % kind
+ % "/" % ruleId % "/actions");
}
-static const auto GetPushRuleActionsJobName = QStringLiteral("GetPushRuleActionsJob");
+static const auto GetPushRuleActionsJobName =
+ QStringLiteral("GetPushRuleActionsJob");
-GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId)
+GetPushRuleActionsJob::GetPushRuleActionsJob(const QString& scope,
+ const QString& kind,
+ const QString& ruleId)
: BaseJob(HttpVerb::Get, GetPushRuleActionsJobName,
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions")
+ basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId
+ % "/actions")
, d(new Private)
-{
-}
+{}
GetPushRuleActionsJob::~GetPushRuleActionsJob() = default;
-const QStringList& GetPushRuleActionsJob::actions() const
-{
- return d->actions;
-}
+const QStringList& GetPushRuleActionsJob::actions() const { return d->actions; }
BaseJob::Status GetPushRuleActionsJob::parseJson(const QJsonDocument& data)
{
auto json = data.object();
if (!json.contains("actions"_ls))
return { IncorrectResponse,
- "The key 'actions' not found in the response" };
+ "The key 'actions' not found in the response" };
fromJson(json.value("actions"_ls), d->actions);
+
return Success;
}
-static const auto SetPushRuleActionsJobName = QStringLiteral("SetPushRuleActionsJob");
+static const auto SetPushRuleActionsJobName =
+ QStringLiteral("SetPushRuleActionsJob");
-SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString& kind, const QString& ruleId, const QStringList& actions)
+SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope,
+ const QString& kind,
+ const QString& ruleId,
+ const QStringList& actions)
: BaseJob(HttpVerb::Put, SetPushRuleActionsJobName,
- basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions")
+ basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId
+ % "/actions")
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("actions"), actions);
setRequestData(_data);
}
-