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/definitions/push_rule.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index 5f52876d..05328b8b 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -34,12 +34,10 @@ namespace QMatrixClient /// rules. QString pattern; }; - - QJsonObject toJson(const PushRule& pod); - - template <> struct FromJsonObject + template <> struct JsonObjectConverter { - PushRule operator()(const QJsonObject& jo) const; + static void dumpTo(QJsonObject& jo, const PushRule& pod); + static void fillFrom(const QJsonObject& jo, PushRule& pod); }; } // namespace QMatrixClient -- 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/definitions/push_rule.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index 5f52876d..2ab68cb1 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -7,10 +7,10 @@ #include "converters.h" #include "csapi/definitions/push_condition.h" -#include "converters.h" +#include #include #include -#include +#include "converters.h" namespace QMatrixClient { -- 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/definitions/push_rule.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index bea13e96..d8d2cc0f 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -6,18 +6,16 @@ #include "converters.h" +#include "converters.h" #include "csapi/definitions/push_condition.h" #include -#include #include -#include "converters.h" +#include -namespace QMatrixClient -{ +namespace QMatrixClient { // Data structures - struct PushRule - { + struct PushRule { /// The actions to perform when this rule is matched. QVector actions; /// Whether this is a default rule, or has been set explicitly. @@ -26,16 +24,15 @@ namespace QMatrixClient bool enabled; /// The ID of this rule. QString ruleId; - /// The conditions that must hold true for an event in order for a rule to be - /// applied to an event. A rule with no conditions always matches. Only - /// applicable to ``underride`` and ``override`` rules. + /// The conditions that must hold true for an event in order for a rule + /// to be applied to an event. A rule with no conditions always matches. + /// Only applicable to ``underride`` and ``override`` rules. QVector conditions; - /// The glob-style pattern to match against. Only applicable to ``content`` - /// rules. + /// The glob-style pattern to match against. Only applicable to + /// ``content`` rules. QString pattern; }; - template <> struct JsonObjectConverter - { + template <> struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PushRule& pod); static void fillFrom(const QJsonObject& jo, PushRule& pod); }; -- cgit v1.2.3 From 9e96bc9b8dec6613e3e2f2fd564e9f6bee9bbce4 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 24 Jun 2019 07:38:50 +0900 Subject: csapi/*/**: clang-format contents of csapi subdirs as well --- lib/csapi/definitions/push_rule.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index 98bd904d..fe6eb0e6 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -4,14 +4,12 @@ #pragma once - - #include "converters.h" -#include "converters.h" -#include #include "csapi/definitions/push_condition.h" + #include +#include #include namespace QMatrixClient @@ -19,7 +17,6 @@ namespace QMatrixClient // Data structures - struct PushRule { /// The actions to perform when this rule is matched. @@ -30,19 +27,20 @@ struct PushRule bool enabled; /// The ID of this rule. QString ruleId; - /// The conditions that must hold true for an event in order for a rule to beapplied to an event. A rule with no conditions always matches. Onlyapplicable to ``underride`` and ``override`` rules. + /// The conditions that must hold true for an event in order for a rule to + /// beapplied to an event. A rule with no conditions always matches. + /// Onlyapplicable to ``underride`` and ``override`` rules. QVector conditions; - /// The glob-style pattern to match against. Only applicable to ``content``rules. + /// The glob-style pattern to match against. Only applicable to + /// ``content``rules. QString pattern; - - }; -template <> struct JsonObjectConverter +template <> +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PushRule& pod); - static void fillFrom(const QJsonObject& jo, PushRule& pod);}; - - + static void fillFrom(const QJsonObject& jo, PushRule& pod); +}; } // namespace QMatrixClient -- 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/definitions/push_rule.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index fe6eb0e6..e64d6ba8 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -12,7 +12,7 @@ #include #include -namespace QMatrixClient +namespace Quotient { // Data structures @@ -43,4 +43,4 @@ struct JsonObjectConverter static void fillFrom(const QJsonObject& jo, PushRule& pod); }; -} // namespace QMatrixClient +} // namespace Quotient -- 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/definitions/push_rule.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index e64d6ba8..c09d063f 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -12,33 +12,35 @@ #include #include -namespace Quotient -{ +namespace Quotient { // Data structures -struct PushRule -{ +struct PushRule { /// The actions to perform when this rule is matched. QVector actions; + /// Whether this is a default rule, or has been set explicitly. bool isDefault; + /// Whether the push rule is enabled or not. bool enabled; + /// The ID of this rule. QString ruleId; + /// The conditions that must hold true for an event in order for a rule to - /// beapplied to an event. A rule with no conditions always matches. - /// Onlyapplicable to ``underride`` and ``override`` rules. + /// be applied to an event. A rule with no conditions always matches. Only + /// applicable to ``underride`` and ``override`` rules. QVector conditions; - /// The glob-style pattern to match against. Only applicable to - /// ``content``rules. + + /// The glob-style pattern to match against. Only applicable to ``content`` + /// rules. QString pattern; }; template <> -struct JsonObjectConverter -{ +struct JsonObjectConverter { static void dumpTo(QJsonObject& jo, const PushRule& pod); static void fillFrom(const QJsonObject& jo, PushRule& pod); }; -- 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/definitions/push_rule.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index c09d063f..43749bae 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -8,14 +8,8 @@ #include "csapi/definitions/push_condition.h" -#include -#include -#include - namespace Quotient { -// Data structures - struct PushRule { /// The actions to perform when this rule is matched. QVector actions; @@ -41,8 +35,24 @@ struct PushRule { template <> struct JsonObjectConverter { - static void dumpTo(QJsonObject& jo, const PushRule& pod); - static void fillFrom(const QJsonObject& jo, PushRule& pod); + static void dumpTo(QJsonObject& jo, const PushRule& pod) + { + addParam<>(jo, QStringLiteral("actions"), pod.actions); + addParam<>(jo, QStringLiteral("default"), pod.isDefault); + addParam<>(jo, QStringLiteral("enabled"), pod.enabled); + addParam<>(jo, QStringLiteral("rule_id"), pod.ruleId); + addParam(jo, QStringLiteral("conditions"), pod.conditions); + addParam(jo, QStringLiteral("pattern"), pod.pattern); + } + static void fillFrom(const QJsonObject& jo, PushRule& pod) + { + fromJson(jo.value("actions"_ls), pod.actions); + fromJson(jo.value("default"_ls), pod.isDefault); + fromJson(jo.value("enabled"_ls), pod.enabled); + fromJson(jo.value("rule_id"_ls), pod.ruleId); + fromJson(jo.value("conditions"_ls), pod.conditions); + fromJson(jo.value("pattern"_ls), pod.pattern); + } }; } // namespace Quotient -- cgit v1.2.3 From 0d4315008374d9a4dfb11f934875b1a16670ec74 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 23 Jun 2021 19:12:38 +0200 Subject: Re-generate API files --- lib/csapi/definitions/push_rule.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/csapi/definitions/push_rule.h') diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index 43749bae..135537c1 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -25,10 +25,10 @@ struct PushRule { /// The conditions that must hold true for an event in order for a rule to /// be applied to an event. A rule with no conditions always matches. Only - /// applicable to ``underride`` and ``override`` rules. + /// applicable to `underride` and `override` rules. QVector conditions; - /// The glob-style pattern to match against. Only applicable to ``content`` + /// The glob-style pattern to match against. Only applicable to `content` /// rules. QString pattern; }; -- cgit v1.2.3