aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/csapi/definitions/event_filter.cpp37
-rw-r--r--lib/csapi/definitions/event_filter.h32
-rw-r--r--lib/csapi/definitions/room_event_filter.cpp31
-rw-r--r--lib/csapi/definitions/room_event_filter.h31
-rw-r--r--lib/csapi/definitions/sync_filter.cpp72
-rw-r--r--lib/csapi/definitions/sync_filter.h52
-rw-r--r--lib/csapi/filter.cpp78
-rw-r--r--lib/csapi/filter.h59
8 files changed, 392 insertions, 0 deletions
diff --git a/lib/csapi/definitions/event_filter.cpp b/lib/csapi/definitions/event_filter.cpp
new file mode 100644
index 00000000..b16b082d
--- /dev/null
+++ b/lib/csapi/definitions/event_filter.cpp
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "event_filter.h"
+
+using namespace QMatrixClient;
+
+QJsonObject QMatrixClient::toJson(const Filter& pod)
+{
+ QJsonObject _json;
+ addToJson<IfNotEmpty>(_json, "limit", pod.limit);
+ addToJson<IfNotEmpty>(_json, "not_senders", pod.notSenders);
+ addToJson<IfNotEmpty>(_json, "not_types", pod.notTypes);
+ addToJson<IfNotEmpty>(_json, "senders", pod.senders);
+ addToJson<IfNotEmpty>(_json, "types", pod.types);
+ return _json;
+}
+
+Filter FromJson<Filter>::operator()(const QJsonValue& jv)
+{
+ const auto& _json = jv.toObject();
+ Filter result;
+ result.limit =
+ fromJson<int>(_json.value("limit"));
+ result.notSenders =
+ fromJson<QStringList>(_json.value("not_senders"));
+ result.notTypes =
+ fromJson<QStringList>(_json.value("not_types"));
+ result.senders =
+ fromJson<QStringList>(_json.value("senders"));
+ result.types =
+ fromJson<QStringList>(_json.value("types"));
+
+ return result;
+}
+
diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h
new file mode 100644
index 00000000..407ef7c5
--- /dev/null
+++ b/lib/csapi/definitions/event_filter.h
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+
+#include "converters.h"
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Data structures
+
+ struct Filter
+ {
+ Omittable<int> limit;
+ QStringList notSenders;
+ QStringList notTypes;
+ QStringList senders;
+ QStringList types;
+ };
+
+ QJsonObject toJson(const Filter& pod);
+
+ template <> struct FromJson<Filter>
+ {
+ Filter operator()(const QJsonValue& jv);
+ };
+
+} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/room_event_filter.cpp b/lib/csapi/definitions/room_event_filter.cpp
new file mode 100644
index 00000000..68e56f4c
--- /dev/null
+++ b/lib/csapi/definitions/room_event_filter.cpp
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_event_filter.h"
+
+using namespace QMatrixClient;
+
+QJsonObject QMatrixClient::toJson(const RoomEventFilter& pod)
+{
+ QJsonObject _json;
+ addToJson<IfNotEmpty>(_json, "not_rooms", pod.notRooms);
+ addToJson<IfNotEmpty>(_json, "rooms", pod.rooms);
+ addToJson<IfNotEmpty>(_json, "contains_url", pod.containsUrl);
+ return _json;
+}
+
+RoomEventFilter FromJson<RoomEventFilter>::operator()(const QJsonValue& jv)
+{
+ const auto& _json = jv.toObject();
+ RoomEventFilter result;
+ result.notRooms =
+ fromJson<QStringList>(_json.value("not_rooms"));
+ result.rooms =
+ fromJson<QStringList>(_json.value("rooms"));
+ result.containsUrl =
+ fromJson<bool>(_json.value("contains_url"));
+
+ return result;
+}
+
diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h
new file mode 100644
index 00000000..b503ec3a
--- /dev/null
+++ b/lib/csapi/definitions/room_event_filter.h
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+
+#include "csapi/definitions/event_filter.h"
+#include "converters.h"
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Data structures
+
+ struct RoomEventFilter : Filter
+ {
+ QStringList notRooms;
+ QStringList rooms;
+ bool containsUrl;
+ };
+
+ QJsonObject toJson(const RoomEventFilter& pod);
+
+ template <> struct FromJson<RoomEventFilter>
+ {
+ RoomEventFilter operator()(const QJsonValue& jv);
+ };
+
+} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/sync_filter.cpp b/lib/csapi/definitions/sync_filter.cpp
new file mode 100644
index 00000000..7ca389b4
--- /dev/null
+++ b/lib/csapi/definitions/sync_filter.cpp
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "sync_filter.h"
+
+using namespace QMatrixClient;
+
+QJsonObject QMatrixClient::toJson(const RoomFilter& pod)
+{
+ QJsonObject _json;
+ addToJson<IfNotEmpty>(_json, "not_rooms", pod.notRooms);
+ addToJson<IfNotEmpty>(_json, "rooms", pod.rooms);
+ addToJson<IfNotEmpty>(_json, "ephemeral", pod.ephemeral);
+ addToJson<IfNotEmpty>(_json, "include_leave", pod.includeLeave);
+ addToJson<IfNotEmpty>(_json, "state", pod.state);
+ addToJson<IfNotEmpty>(_json, "timeline", pod.timeline);
+ addToJson<IfNotEmpty>(_json, "account_data", pod.accountData);
+ return _json;
+}
+
+RoomFilter FromJson<RoomFilter>::operator()(const QJsonValue& jv)
+{
+ const auto& _json = jv.toObject();
+ RoomFilter result;
+ result.notRooms =
+ fromJson<QStringList>(_json.value("not_rooms"));
+ result.rooms =
+ fromJson<QStringList>(_json.value("rooms"));
+ result.ephemeral =
+ fromJson<RoomEventFilter>(_json.value("ephemeral"));
+ result.includeLeave =
+ fromJson<bool>(_json.value("include_leave"));
+ result.state =
+ fromJson<RoomEventFilter>(_json.value("state"));
+ result.timeline =
+ fromJson<RoomEventFilter>(_json.value("timeline"));
+ result.accountData =
+ fromJson<RoomEventFilter>(_json.value("account_data"));
+
+ return result;
+}
+
+QJsonObject QMatrixClient::toJson(const SyncFilter& pod)
+{
+ QJsonObject _json;
+ addToJson<IfNotEmpty>(_json, "event_fields", pod.eventFields);
+ addToJson<IfNotEmpty>(_json, "event_format", pod.eventFormat);
+ addToJson<IfNotEmpty>(_json, "presence", pod.presence);
+ addToJson<IfNotEmpty>(_json, "account_data", pod.accountData);
+ addToJson<IfNotEmpty>(_json, "room", pod.room);
+ return _json;
+}
+
+SyncFilter FromJson<SyncFilter>::operator()(const QJsonValue& jv)
+{
+ const auto& _json = jv.toObject();
+ SyncFilter result;
+ result.eventFields =
+ fromJson<QStringList>(_json.value("event_fields"));
+ result.eventFormat =
+ fromJson<QString>(_json.value("event_format"));
+ result.presence =
+ fromJson<Filter>(_json.value("presence"));
+ result.accountData =
+ fromJson<Filter>(_json.value("account_data"));
+ result.room =
+ fromJson<RoomFilter>(_json.value("room"));
+
+ return result;
+}
+
diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h
new file mode 100644
index 00000000..f7428c0d
--- /dev/null
+++ b/lib/csapi/definitions/sync_filter.h
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+
+#include "csapi/definitions/room_event_filter.h"
+#include "converters.h"
+#include "csapi/definitions/event_filter.h"
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Data structures
+
+ struct RoomFilter
+ {
+ QStringList notRooms;
+ QStringList rooms;
+ Omittable<RoomEventFilter> ephemeral;
+ bool includeLeave;
+ Omittable<RoomEventFilter> state;
+ Omittable<RoomEventFilter> timeline;
+ Omittable<RoomEventFilter> accountData;
+ };
+
+ QJsonObject toJson(const RoomFilter& pod);
+
+ template <> struct FromJson<RoomFilter>
+ {
+ RoomFilter operator()(const QJsonValue& jv);
+ };
+
+ struct SyncFilter
+ {
+ QStringList eventFields;
+ QString eventFormat;
+ Omittable<Filter> presence;
+ Omittable<Filter> accountData;
+ Omittable<RoomFilter> room;
+ };
+
+ QJsonObject toJson(const SyncFilter& pod);
+
+ template <> struct FromJson<SyncFilter>
+ {
+ SyncFilter operator()(const QJsonValue& jv);
+ };
+
+} // namespace QMatrixClient
diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp
new file mode 100644
index 00000000..a1546923
--- /dev/null
+++ b/lib/csapi/filter.cpp
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "filter.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class DefineFilterJob::Private
+{
+ public:
+ QString filterId;
+};
+
+DefineFilterJob::DefineFilterJob(const QString& userId, const SyncFilter& filter)
+ : BaseJob(HttpVerb::Post, "DefineFilterJob",
+ basePath % "/user/" % userId % "/filter")
+ , d(new Private)
+{
+ setRequestData(Data(toJson(filter)));
+}
+
+DefineFilterJob::~DefineFilterJob() = default;
+
+const QString& DefineFilterJob::filterId() const
+{
+ return d->filterId;
+}
+
+BaseJob::Status DefineFilterJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->filterId = fromJson<QString>(json.value("filter_id"));
+ return Success;
+}
+
+class GetFilterJob::Private
+{
+ public:
+ SyncFilter data;
+};
+
+QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/user/" % userId % "/filter/" % filterId);
+}
+
+GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId)
+ : BaseJob(HttpVerb::Get, "GetFilterJob",
+ basePath % "/user/" % userId % "/filter/" % filterId)
+ , d(new Private)
+{
+}
+
+GetFilterJob::~GetFilterJob() = default;
+
+const SyncFilter& GetFilterJob::data() const
+{
+ return d->data;
+}
+
+BaseJob::Status GetFilterJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("data"))
+ return { JsonParseError,
+ "The key 'data' not found in the response" };
+ d->data = fromJson<SyncFilter>(json.value("data"));
+ return Success;
+}
+
diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h
new file mode 100644
index 00000000..92e9c737
--- /dev/null
+++ b/lib/csapi/filter.h
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "jobs/basejob.h"
+
+#include "converters.h"
+#include "csapi/definitions/sync_filter.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class DefineFilterJob : public BaseJob
+ {
+ public:
+ explicit DefineFilterJob(const QString& userId, const SyncFilter& filter);
+ ~DefineFilterJob() override;
+
+ // Result properties
+
+ const QString& filterId() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ class GetFilterJob : public BaseJob
+ {
+ public:
+ explicit GetFilterJob(const QString& userId, const QString& filterId);
+
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * GetFilterJob. This function can be used when
+ * a URL for GetFilterJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId);
+
+ ~GetFilterJob() override;
+
+ // Result properties
+
+ const SyncFilter& data() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient