aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/csapi/peeking_events.cpp75
-rw-r--r--lib/csapi/peeking_events.h43
-rw-r--r--lib/csapi/presence.cpp127
-rw-r--r--lib/csapi/presence.h82
-rw-r--r--lib/csapi/report_content.cpp24
-rw-r--r--lib/csapi/report_content.h20
6 files changed, 371 insertions, 0 deletions
diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp
new file mode 100644
index 00000000..884abe00
--- /dev/null
+++ b/lib/csapi/peeking_events.cpp
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "peeking_events.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class PeekEventsJob::Private
+{
+ public:
+ QString begin;
+ QString end;
+ RoomEvents chunk;
+};
+
+BaseJob::Query queryToPeekEvents(const QString& from, Omittable<int> timeout, const QString& roomId)
+{
+ BaseJob::Query _q;
+ if (!from.isEmpty())
+ _q.addQueryItem("from", from);
+ if (timeout)
+ _q.addQueryItem("timeout", QString("%1").arg(timeout.value()));
+ if (!roomId.isEmpty())
+ _q.addQueryItem("room_id", roomId);
+ return _q;
+}
+
+QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable<int> timeout, const QString& roomId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/events",
+ queryToPeekEvents(from, timeout, roomId));
+}
+
+PeekEventsJob::PeekEventsJob(const QString& from, Omittable<int> timeout, const QString& roomId)
+ : BaseJob(HttpVerb::Get, "PeekEventsJob",
+ basePath % "/events",
+ queryToPeekEvents(from, timeout, roomId))
+ , d(new Private)
+{
+}
+
+PeekEventsJob::~PeekEventsJob() = default;
+
+const QString& PeekEventsJob::begin() const
+{
+ return d->begin;
+}
+
+const QString& PeekEventsJob::end() const
+{
+ return d->end;
+}
+
+RoomEvents&& PeekEventsJob::chunk()
+{
+ return std::move(d->chunk);
+}
+
+BaseJob::Status PeekEventsJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->begin = fromJson<QString>(json.value("start"));
+ d->end = fromJson<QString>(json.value("end"));
+ d->chunk = fromJson<RoomEvents>(json.value("chunk"));
+ return Success;
+}
+
diff --git a/lib/csapi/peeking_events.h b/lib/csapi/peeking_events.h
new file mode 100644
index 00000000..f8876bf1
--- /dev/null
+++ b/lib/csapi/peeking_events.h
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "jobs/basejob.h"
+
+#include "events/event.h"
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class PeekEventsJob : public BaseJob
+ {
+ public:
+ explicit PeekEventsJob(const QString& from = {}, Omittable<int> timeout = none, const QString& roomId = {});
+
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * PeekEventsJob. This function can be used when
+ * a URL for PeekEventsJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, Omittable<int> timeout = none, const QString& roomId = {});
+
+ ~PeekEventsJob() override;
+
+ // Result properties
+
+ const QString& begin() const;
+ const QString& end() const;
+ RoomEvents&& chunk();
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp
new file mode 100644
index 00000000..707d48d0
--- /dev/null
+++ b/lib/csapi/presence.cpp
@@ -0,0 +1,127 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "presence.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg)
+ : BaseJob(HttpVerb::Put, "SetPresenceJob",
+ basePath % "/presence/" % userId % "/status")
+{
+ QJsonObject _data;
+ addToJson<>(_data, "presence", presence);
+ addToJson<IfNotEmpty>(_data, "status_msg", statusMsg);
+ setRequestData(_data);
+}
+
+class GetPresenceJob::Private
+{
+ public:
+ QString presence;
+ Omittable<int> lastActiveAgo;
+ QString statusMsg;
+ bool currentlyActive;
+};
+
+QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/presence/" % userId % "/status");
+}
+
+GetPresenceJob::GetPresenceJob(const QString& userId)
+ : BaseJob(HttpVerb::Get, "GetPresenceJob",
+ basePath % "/presence/" % userId % "/status", false)
+ , d(new Private)
+{
+}
+
+GetPresenceJob::~GetPresenceJob() = default;
+
+const QString& GetPresenceJob::presence() const
+{
+ return d->presence;
+}
+
+Omittable<int> GetPresenceJob::lastActiveAgo() const
+{
+ return d->lastActiveAgo;
+}
+
+const QString& GetPresenceJob::statusMsg() const
+{
+ return d->statusMsg;
+}
+
+bool GetPresenceJob::currentlyActive() const
+{
+ return d->currentlyActive;
+}
+
+BaseJob::Status GetPresenceJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("presence"))
+ return { JsonParseError,
+ "The key 'presence' not found in the response" };
+ d->presence = fromJson<QString>(json.value("presence"));
+ d->lastActiveAgo = fromJson<int>(json.value("last_active_ago"));
+ d->statusMsg = fromJson<QString>(json.value("status_msg"));
+ d->currentlyActive = fromJson<bool>(json.value("currently_active"));
+ return Success;
+}
+
+ModifyPresenceListJob::ModifyPresenceListJob(const QString& userId, const QStringList& invite, const QStringList& drop)
+ : BaseJob(HttpVerb::Post, "ModifyPresenceListJob",
+ basePath % "/presence/list/" % userId)
+{
+ QJsonObject _data;
+ addToJson<IfNotEmpty>(_data, "invite", invite);
+ addToJson<IfNotEmpty>(_data, "drop", drop);
+ setRequestData(_data);
+}
+
+class GetPresenceForListJob::Private
+{
+ public:
+ Events data;
+};
+
+QUrl GetPresenceForListJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/presence/list/" % userId);
+}
+
+GetPresenceForListJob::GetPresenceForListJob(const QString& userId)
+ : BaseJob(HttpVerb::Get, "GetPresenceForListJob",
+ basePath % "/presence/list/" % userId, false)
+ , d(new Private)
+{
+}
+
+GetPresenceForListJob::~GetPresenceForListJob() = default;
+
+Events&& GetPresenceForListJob::data()
+{
+ return std::move(d->data);
+}
+
+BaseJob::Status GetPresenceForListJob::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<Events>(json.value("data"));
+ return Success;
+}
+
diff --git a/lib/csapi/presence.h b/lib/csapi/presence.h
new file mode 100644
index 00000000..2def94ba
--- /dev/null
+++ b/lib/csapi/presence.h
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "jobs/basejob.h"
+
+#include "events/event.h"
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class SetPresenceJob : public BaseJob
+ {
+ public:
+ explicit SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg = {});
+ };
+
+ class GetPresenceJob : public BaseJob
+ {
+ public:
+ explicit GetPresenceJob(const QString& userId);
+
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * GetPresenceJob. This function can be used when
+ * a URL for GetPresenceJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);
+
+ ~GetPresenceJob() override;
+
+ // Result properties
+
+ const QString& presence() const;
+ Omittable<int> lastActiveAgo() const;
+ const QString& statusMsg() const;
+ bool currentlyActive() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ class ModifyPresenceListJob : public BaseJob
+ {
+ public:
+ explicit ModifyPresenceListJob(const QString& userId, const QStringList& invite = {}, const QStringList& drop = {});
+ };
+
+ class GetPresenceForListJob : public BaseJob
+ {
+ public:
+ explicit GetPresenceForListJob(const QString& userId);
+
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * GetPresenceForListJob. This function can be used when
+ * a URL for GetPresenceForListJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId);
+
+ ~GetPresenceForListJob() override;
+
+ // Result properties
+
+ Events&& data();
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp
new file mode 100644
index 00000000..9d19e012
--- /dev/null
+++ b/lib/csapi/report_content.cpp
@@ -0,0 +1,24 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "report_content.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId, int score, const QString& reason)
+ : BaseJob(HttpVerb::Post, "ReportContentJob",
+ basePath % "/rooms/" % roomId % "/report/" % eventId)
+{
+ QJsonObject _data;
+ addToJson<>(_data, "score", score);
+ addToJson<>(_data, "reason", reason);
+ setRequestData(_data);
+}
+
diff --git a/lib/csapi/report_content.h b/lib/csapi/report_content.h
new file mode 100644
index 00000000..9d59db00
--- /dev/null
+++ b/lib/csapi/report_content.h
@@ -0,0 +1,20 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "jobs/basejob.h"
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class ReportContentJob : public BaseJob
+ {
+ public:
+ explicit ReportContentJob(const QString& roomId, const QString& eventId, int score, const QString& reason);
+ };
+} // namespace QMatrixClient