aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml23
-rw-r--r--CMakeLists.txt35
-rw-r--r--lib/jobs/basejob.cpp1
-rw-r--r--lib/jobs/generated/account-data.cpp4
-rw-r--r--lib/jobs/generated/administrative_contact.cpp36
-rw-r--r--lib/jobs/generated/administrative_contact.h2
-rw-r--r--lib/jobs/generated/create_room.cpp38
-rw-r--r--lib/jobs/generated/create_room.h2
-rw-r--r--lib/jobs/generated/list_joined_rooms.cpp50
-rw-r--r--lib/jobs/generated/list_joined_rooms.h38
-rw-r--r--lib/jobs/generated/list_public_rooms.cpp142
-rw-r--r--lib/jobs/generated/list_public_rooms.h46
-rw-r--r--lib/jobs/generated/pusher.cpp156
-rw-r--r--lib/jobs/generated/pusher.h78
-rw-r--r--lib/jobs/generated/receipts.cpp2
-rw-r--r--lib/jobs/generated/room_send.cpp42
-rw-r--r--lib/jobs/generated/room_send.h31
-rw-r--r--lib/jobs/generated/tags.cpp66
-rw-r--r--lib/jobs/generated/tags.h57
-rw-r--r--lib/jobs/generated/to_device.cpp23
-rw-r--r--lib/jobs/generated/to_device.h21
-rw-r--r--lib/jobs/generated/users.cpp86
-rw-r--r--lib/jobs/generated/users.h45
-rw-r--r--lib/jobs/gtad.yaml98
-rw-r--r--lib/jobs/preamble.mustache3
-rw-r--r--lib/jobs/{{base}}.cpp.mustache122
-rw-r--r--lib/jobs/{{base}}.h.mustache67
-rw-r--r--libqmatrixclient.pri2
28 files changed, 1207 insertions, 109 deletions
diff --git a/.travis.yml b/.travis.yml
index 45db175a..531eec3e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,14 +24,25 @@ before_install:
- eval "${ENV_EVAL}"
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then VALGRIND="valgrind $VALGRIND_OPTIONS"; . /opt/qt56/bin/qt56-env.sh; fi
-script:
-# Build and install with CMake
+install:
+- git clone https://github.com/QMatrixClient/matrix-doc.git
+- git clone --recursive https://github.com/KitsuneRal/gtad.git
+- pushd gtad
+- cmake -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} .
+- cmake --build .
+- popd
+
+before_script:
- mkdir build && pushd build
-- cmake -DCMAKE_INSTALL_PREFIX=../install ..
-- cmake --build . --target all
-- cmake --build . --target install
+- cmake -DMATRIX_DOC_PATH="matrix-doc" -DGTAD_PATH="gtad/gtad" -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_PREFIX=../install ..
+- cmake --build . --target update-api
+- popd
+
+script:
+- cmake --build build --target all
+- cmake --build build --target install
# Build qmc-example with the installed library
-- popd && mkdir build-example && pushd build-example
+- mkdir build-example && pushd build-example
- cmake -DCMAKE_PREFIX_PATH=../install ../examples
- cmake --build . --target all
- popd
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93cb16fd..49608f95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,11 @@ if (CMAKE_BUILD_TYPE)
endif(CMAKE_BUILD_TYPE)
message( STATUS "Using compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
message( STATUS "Using Qt ${Qt5_VERSION} at ${Qt5_Prefix}" )
+if (MATRIX_DOC_PATH AND GTAD_PATH)
+ message( STATUS "Generating API stubs enabled" )
+ message( STATUS " Using GTAD at ${GTAD_PATH}" )
+ message( STATUS " Using CS API files at ${MATRIX_DOC_PATH}/api/client-server" )
+endif ()
message( STATUS "=============================================================================" )
message( STATUS )
@@ -86,11 +91,37 @@ set(libqmatrixclient_SRCS
lib/jobs/downloadfilejob.cpp
)
-aux_source_directory(lib/jobs/generated libqmatrixclient_job_SRCS)
+set(API_DEF_PATH ${MATRIX_DOC_PATH}/api/client-server)
+file(GLOB_RECURSE API_DEFS RELATIVE ${PROJECT_SOURCE_DIR}
+ ${API_DEF_PATH}/*.yaml
+ ${API_DEF_PATH}/definitions/*.yaml
+ ${MATRIX_DOC_PATH}/event-schemas/schema/*
+)
+set(GTAD_CONFIG_DIR lib/jobs)
+set(GEN_SRC_DIR lib/jobs/generated)
+if (MATRIX_DOC_PATH AND GTAD_PATH)
+ add_custom_target(update-api
+ ${GTAD_PATH} --config ${GTAD_CONFIG_DIR}/gtad.yaml --out ${GEN_SRC_DIR}
+ ${API_DEF_PATH}
+ cas_login_redirect.yaml- cas_login_ticket.yaml-
+ old_sync.yaml- room_initial_sync.yaml- # deprecated
+ sync.yaml-
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ SOURCES ${GTAD_CONFIG_DIR}/gtad.yaml
+ ${GTAD_CONFIG_DIR}/{{base}}.h.mustache
+ ${GTAD_CONFIG_DIR}/{{base}}.cpp.mustache
+ ${API_DEFS}
+ VERBATIM
+ )
+endif()
+
+aux_source_directory(${GEN_SRC_DIR} libqmatrixclient_job_SRCS)
+aux_source_directory(${GEN_SRC_DIR}/definitions libqmatrixclient_def_SRCS)
set(example_SRCS examples/qmc-example.cpp)
-add_library(QMatrixClient ${libqmatrixclient_SRCS} ${libqmatrixclient_job_SRCS})
+add_library(QMatrixClient ${libqmatrixclient_SRCS}
+ ${libqmatrixclient_job_SRCS} ${libqmatrixclient_def_SRCS})
set(API_VERSION "0.2")
set_property(TARGET QMatrixClient PROPERTY VERSION "${API_VERSION}.0")
set_property(TARGET QMatrixClient PROPERTY SOVERSION 0 )
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index 56565859..2d41650a 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -25,7 +25,6 @@
#include <QtNetwork/QNetworkReply>
#include <QtCore/QTimer>
#include <QtCore/QRegularExpression>
-//#include <QtCore/QStringBuilder>
#include <array>
diff --git a/lib/jobs/generated/account-data.cpp b/lib/jobs/generated/account-data.cpp
index 35ee94c0..ac45cb85 100644
--- a/lib/jobs/generated/account-data.cpp
+++ b/lib/jobs/generated/account-data.cpp
@@ -16,13 +16,13 @@ SetAccountDataJob::SetAccountDataJob(const QString& userId, const QString& type,
: BaseJob(HttpVerb::Put, "SetAccountDataJob",
basePath % "/user/" % userId % "/account_data/" % type)
{
- setRequestData(Data(content));
+ setRequestData(Data(toJson(content)));
}
SetAccountDataPerRoomJob::SetAccountDataPerRoomJob(const QString& userId, const QString& roomId, const QString& type, const QJsonObject& content)
: BaseJob(HttpVerb::Put, "SetAccountDataPerRoomJob",
basePath % "/user/" % userId % "/rooms/" % roomId % "/account_data/" % type)
{
- setRequestData(Data(content));
+ setRequestData(Data(toJson(content)));
}
diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp
index bd74490c..b003c92d 100644
--- a/lib/jobs/generated/administrative_contact.cpp
+++ b/lib/jobs/generated/administrative_contact.cpp
@@ -10,16 +10,17 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
-GetAccount3PIDsJob::ThirdPartyIdentifier::operator QJsonObject() const
-{
- QJsonObject o;
- o.insert("medium", toJson(medium));
- o.insert("address", toJson(address));
-
- return o;
-}
namespace QMatrixClient
{
+ QJsonObject toJson(const GetAccount3PIDsJob::ThirdPartyIdentifier& pod)
+ {
+ QJsonObject o;
+ o.insert("medium", toJson(pod.medium));
+ o.insert("address", toJson(pod.address));
+
+ return o;
+ }
+
template <> struct FromJson<GetAccount3PIDsJob::ThirdPartyIdentifier>
{
GetAccount3PIDsJob::ThirdPartyIdentifier operator()(const QJsonValue& jv)
@@ -69,17 +70,18 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data)
return Success;
}
-Post3PIDsJob::ThreePidCredentials::operator QJsonObject() const
-{
- QJsonObject o;
- o.insert("client_secret", toJson(clientSecret));
- o.insert("id_server", toJson(idServer));
- o.insert("sid", toJson(sid));
-
- return o;
-}
namespace QMatrixClient
{
+ QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod)
+ {
+ QJsonObject o;
+ o.insert("client_secret", toJson(pod.clientSecret));
+ o.insert("id_server", toJson(pod.idServer));
+ o.insert("sid", toJson(pod.sid));
+
+ return o;
+ }
+
template <> struct FromJson<Post3PIDsJob::ThreePidCredentials>
{
Post3PIDsJob::ThreePidCredentials operator()(const QJsonValue& jv)
diff --git a/lib/jobs/generated/administrative_contact.h b/lib/jobs/generated/administrative_contact.h
index c8429d39..bd70f07b 100644
--- a/lib/jobs/generated/administrative_contact.h
+++ b/lib/jobs/generated/administrative_contact.h
@@ -24,7 +24,6 @@ namespace QMatrixClient
QString medium;
QString address;
- operator QJsonObject() const;
};
// End of inner data structures
@@ -60,7 +59,6 @@ namespace QMatrixClient
QString idServer;
QString sid;
- operator QJsonObject() const;
};
// End of inner data structures
diff --git a/lib/jobs/generated/create_room.cpp b/lib/jobs/generated/create_room.cpp
index 6e582791..4fc75974 100644
--- a/lib/jobs/generated/create_room.cpp
+++ b/lib/jobs/generated/create_room.cpp
@@ -10,17 +10,18 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
-CreateRoomJob::Invite3pid::operator QJsonObject() const
-{
- QJsonObject o;
- o.insert("id_server", toJson(idServer));
- o.insert("medium", toJson(medium));
- o.insert("address", toJson(address));
-
- return o;
-}
namespace QMatrixClient
{
+ QJsonObject toJson(const CreateRoomJob::Invite3pid& pod)
+ {
+ QJsonObject o;
+ o.insert("id_server", toJson(pod.idServer));
+ o.insert("medium", toJson(pod.medium));
+ o.insert("address", toJson(pod.address));
+
+ return o;
+ }
+
template <> struct FromJson<CreateRoomJob::Invite3pid>
{
CreateRoomJob::Invite3pid operator()(const QJsonValue& jv)
@@ -39,17 +40,18 @@ namespace QMatrixClient
};
} // namespace QMatrixClient
-CreateRoomJob::StateEvent::operator QJsonObject() const
-{
- QJsonObject o;
- o.insert("type", toJson(type));
- o.insert("state_key", toJson(stateKey));
- o.insert("content", toJson(content));
-
- return o;
-}
namespace QMatrixClient
{
+ QJsonObject toJson(const CreateRoomJob::StateEvent& pod)
+ {
+ QJsonObject o;
+ o.insert("type", toJson(pod.type));
+ o.insert("state_key", toJson(pod.stateKey));
+ o.insert("content", toJson(pod.content));
+
+ return o;
+ }
+
template <> struct FromJson<CreateRoomJob::StateEvent>
{
CreateRoomJob::StateEvent operator()(const QJsonValue& jv)
diff --git a/lib/jobs/generated/create_room.h b/lib/jobs/generated/create_room.h
index b479615a..fdb11ada 100644
--- a/lib/jobs/generated/create_room.h
+++ b/lib/jobs/generated/create_room.h
@@ -26,7 +26,6 @@ namespace QMatrixClient
QString medium;
QString address;
- operator QJsonObject() const;
};
struct StateEvent
@@ -35,7 +34,6 @@ namespace QMatrixClient
QString stateKey;
QJsonObject content;
- operator QJsonObject() const;
};
// End of inner data structures
diff --git a/lib/jobs/generated/list_joined_rooms.cpp b/lib/jobs/generated/list_joined_rooms.cpp
new file mode 100644
index 00000000..8ea44721
--- /dev/null
+++ b/lib/jobs/generated/list_joined_rooms.cpp
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "list_joined_rooms.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class GetJoinedRoomsJob::Private
+{
+ public:
+ QVector<QString> joinedRooms;
+};
+
+QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/joined_rooms");
+}
+
+GetJoinedRoomsJob::GetJoinedRoomsJob()
+ : BaseJob(HttpVerb::Get, "GetJoinedRoomsJob",
+ basePath % "/joined_rooms")
+ , d(new Private)
+{
+}
+
+GetJoinedRoomsJob::~GetJoinedRoomsJob() = default;
+
+const QVector<QString>& GetJoinedRoomsJob::joinedRooms() const
+{
+ return d->joinedRooms;
+}
+
+BaseJob::Status GetJoinedRoomsJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("joined_rooms"))
+ return { JsonParseError,
+ "The key 'joined_rooms' not found in the response" };
+ d->joinedRooms = fromJson<QVector<QString>>(json.value("joined_rooms"));
+ return Success;
+}
+
diff --git a/lib/jobs/generated/list_joined_rooms.h b/lib/jobs/generated/list_joined_rooms.h
new file mode 100644
index 00000000..768f5166
--- /dev/null
+++ b/lib/jobs/generated/list_joined_rooms.h
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QVector>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class GetJoinedRoomsJob : public BaseJob
+ {
+ public:
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * GetJoinedRoomsJob. This function can be used when
+ * a URL for GetJoinedRoomsJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl);
+
+ explicit GetJoinedRoomsJob();
+ ~GetJoinedRoomsJob() override;
+
+ const QVector<QString>& joinedRooms() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/list_public_rooms.cpp b/lib/jobs/generated/list_public_rooms.cpp
index 1e3c4ed8..9b4174cb 100644
--- a/lib/jobs/generated/list_public_rooms.cpp
+++ b/lib/jobs/generated/list_public_rooms.cpp
@@ -10,23 +10,67 @@ using namespace QMatrixClient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
-GetPublicRoomsJob::PublicRoomsChunk::operator QJsonObject() const
+class GetRoomVisibilityOnDirectoryJob::Private
{
- QJsonObject o;
- o.insert("aliases", toJson(aliases));
- o.insert("canonical_alias", toJson(canonicalAlias));
- o.insert("name", toJson(name));
- o.insert("num_joined_members", toJson(numJoinedMembers));
- o.insert("room_id", toJson(roomId));
- o.insert("topic", toJson(topic));
- o.insert("world_readable", toJson(worldReadable));
- o.insert("guest_can_join", toJson(guestCanJoin));
- o.insert("avatar_url", toJson(avatarUrl));
-
- return o;
+ public:
+ QString visibility;
+};
+
+QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, const QString& roomId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/directory/list/room/" % roomId);
+}
+
+GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(const QString& roomId)
+ : BaseJob(HttpVerb::Get, "GetRoomVisibilityOnDirectoryJob",
+ basePath % "/directory/list/room/" % roomId, false)
+ , d(new Private)
+{
+}
+
+GetRoomVisibilityOnDirectoryJob::~GetRoomVisibilityOnDirectoryJob() = default;
+
+const QString& GetRoomVisibilityOnDirectoryJob::visibility() const
+{
+ return d->visibility;
+}
+
+BaseJob::Status GetRoomVisibilityOnDirectoryJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->visibility = fromJson<QString>(json.value("visibility"));
+ return Success;
}
+
+SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility)
+ : BaseJob(HttpVerb::Put, "SetRoomVisibilityOnDirectoryJob",
+ basePath % "/directory/list/room/" % roomId)
+{
+ QJsonObject _data;
+ if (!visibility.isEmpty())
+ _data.insert("visibility", toJson(visibility));
+ setRequestData(_data);
+}
+
namespace QMatrixClient
{
+ QJsonObject toJson(const GetPublicRoomsJob::PublicRoomsChunk& pod)
+ {
+ QJsonObject o;
+ o.insert("aliases", toJson(pod.aliases));
+ o.insert("canonical_alias", toJson(pod.canonicalAlias));
+ o.insert("name", toJson(pod.name));
+ o.insert("num_joined_members", toJson(pod.numJoinedMembers));
+ o.insert("room_id", toJson(pod.roomId));
+ o.insert("topic", toJson(pod.topic));
+ o.insert("world_readable", toJson(pod.worldReadable));
+ o.insert("guest_can_join", toJson(pod.guestCanJoin));
+ o.insert("avatar_url", toJson(pod.avatarUrl));
+
+ return o;
+ }
+
template <> struct FromJson<GetPublicRoomsJob::PublicRoomsChunk>
{
GetPublicRoomsJob::PublicRoomsChunk operator()(const QJsonValue& jv)
@@ -40,7 +84,7 @@ namespace QMatrixClient
result.name =
fromJson<QString>(o.value("name"));
result.numJoinedMembers =
- fromJson<double>(o.value("num_joined_members"));
+ fromJson<qint64>(o.value("num_joined_members"));
result.roomId =
fromJson<QString>(o.value("room_id"));
result.topic =
@@ -63,10 +107,10 @@ class GetPublicRoomsJob::Private
QVector<PublicRoomsChunk> chunk;
QString nextBatch;
QString prevBatch;
- double totalRoomCountEstimate;
+ qint64 totalRoomCountEstimate;
};
-BaseJob::Query queryToGetPublicRooms(double limit, const QString& since, const QString& server)
+BaseJob::Query queryToGetPublicRooms(int limit, const QString& since, const QString& server)
{
BaseJob::Query _q;
_q.addQueryItem("limit", QString("%1").arg(limit));
@@ -77,14 +121,14 @@ BaseJob::Query queryToGetPublicRooms(double limit, const QString& since, const Q
return _q;
}
-QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, double limit, const QString& since, const QString& server)
+QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, int limit, const QString& since, const QString& server)
{
- return BaseJob::makeRequestUrl(baseUrl,
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
basePath % "/publicRooms",
queryToGetPublicRooms(limit, since, server));
}
-GetPublicRoomsJob::GetPublicRoomsJob(double limit, const QString& since, const QString& server)
+GetPublicRoomsJob::GetPublicRoomsJob(int limit, const QString& since, const QString& server)
: BaseJob(HttpVerb::Get, "GetPublicRoomsJob",
basePath % "/publicRooms",
queryToGetPublicRooms(limit, since, server),
@@ -110,7 +154,7 @@ const QString& GetPublicRoomsJob::prevBatch() const
return d->prevBatch;
}
-double GetPublicRoomsJob::totalRoomCountEstimate() const
+qint64 GetPublicRoomsJob::totalRoomCountEstimate() const
{
return d->totalRoomCountEstimate;
}
@@ -124,19 +168,20 @@ BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data)
d->chunk = fromJson<QVector<PublicRoomsChunk>>(json.value("chunk"));
d->nextBatch = fromJson<QString>(json.value("next_batch"));
d->prevBatch = fromJson<QString>(json.value("prev_batch"));
- d->totalRoomCountEstimate = fromJson<double>(json.value("total_room_count_estimate"));
+ d->totalRoomCountEstimate = fromJson<qint64>(json.value("total_room_count_estimate"));
return Success;
}
-QueryPublicRoomsJob::Filter::operator QJsonObject() const
-{
- QJsonObject o;
- o.insert("generic_search_term", toJson(genericSearchTerm));
-
- return o;
-}
namespace QMatrixClient
{
+ QJsonObject toJson(const QueryPublicRoomsJob::Filter& pod)
+ {
+ QJsonObject o;
+ o.insert("generic_search_term", toJson(pod.genericSearchTerm));
+
+ return o;
+ }
+
template <> struct FromJson<QueryPublicRoomsJob::Filter>
{
QueryPublicRoomsJob::Filter operator()(const QJsonValue& jv)
@@ -151,23 +196,24 @@ namespace QMatrixClient
};
} // namespace QMatrixClient
-QueryPublicRoomsJob::PublicRoomsChunk::operator QJsonObject() const
-{
- QJsonObject o;
- o.insert("aliases", toJson(aliases));
- o.insert("canonical_alias", toJson(canonicalAlias));
- o.insert("name", toJson(name));
- o.insert("num_joined_members", toJson(numJoinedMembers));
- o.insert("room_id", toJson(roomId));
- o.insert("topic", toJson(topic));
- o.insert("world_readable", toJson(worldReadable));
- o.insert("guest_can_join", toJson(guestCanJoin));
- o.insert("avatar_url", toJson(avatarUrl));
-
- return o;
-}
namespace QMatrixClient
{
+ QJsonObject toJson(const QueryPublicRoomsJob::PublicRoomsChunk& pod)
+ {
+ QJsonObject o;
+ o.insert("aliases", toJson(pod.aliases));
+ o.insert("canonical_alias", toJson(pod.canonicalAlias));
+ o.insert("name", toJson(pod.name));
+ o.insert("num_joined_members", toJson(pod.numJoinedMembers));
+ o.insert("room_id", toJson(pod.roomId));
+ o.insert("topic", toJson(pod.topic));
+ o.insert("world_readable", toJson(pod.worldReadable));
+ o.insert("guest_can_join", toJson(pod.guestCanJoin));
+ o.insert("avatar_url", toJson(pod.avatarUrl));
+
+ return o;
+ }
+
template <> struct FromJson<QueryPublicRoomsJob::PublicRoomsChunk>
{
QueryPublicRoomsJob::PublicRoomsChunk operator()(const QJsonValue& jv)
@@ -181,7 +227,7 @@ namespace QMatrixClient
result.name =
fromJson<QString>(o.value("name"));
result.numJoinedMembers =
- fromJson<double>(o.value("num_joined_members"));
+ fromJson<qint64>(o.value("num_joined_members"));
result.roomId =
fromJson<QString>(o.value("room_id"));
result.topic =
@@ -204,7 +250,7 @@ class QueryPublicRoomsJob::Private
QVector<PublicRoomsChunk> chunk;
QString nextBatch;
QString prevBatch;
- double totalRoomCountEstimate;
+ qint64 totalRoomCountEstimate;
};
BaseJob::Query queryToQueryPublicRooms(const QString& server)
@@ -215,7 +261,7 @@ BaseJob::Query queryToQueryPublicRooms(const QString& server)
return _q;
}
-QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, double limit, const QString& since, const Filter& filter)
+QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, int limit, const QString& since, const Filter& filter)
: BaseJob(HttpVerb::Post, "QueryPublicRoomsJob",
basePath % "/publicRooms",
queryToQueryPublicRooms(server))
@@ -246,7 +292,7 @@ const QString& QueryPublicRoomsJob::prevBatch() const
return d->prevBatch;
}
-double QueryPublicRoomsJob::totalRoomCountEstimate() const
+qint64 QueryPublicRoomsJob::totalRoomCountEstimate() const
{
return d->totalRoomCountEstimate;
}
@@ -260,7 +306,7 @@ BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data)
d->chunk = fromJson<QVector<PublicRoomsChunk>>(json.value("chunk"));
d->nextBatch = fromJson<QString>(json.value("next_batch"));
d->prevBatch = fromJson<QString>(json.value("prev_batch"));
- d->totalRoomCountEstimate = fromJson<double>(json.value("total_room_count_estimate"));
+ d->totalRoomCountEstimate = fromJson<qint64>(json.value("total_room_count_estimate"));
return Success;
}
diff --git a/lib/jobs/generated/list_public_rooms.h b/lib/jobs/generated/list_public_rooms.h
index 5c281de3..1e44e8b2 100644
--- a/lib/jobs/generated/list_public_rooms.h
+++ b/lib/jobs/generated/list_public_rooms.h
@@ -14,6 +14,35 @@ namespace QMatrixClient
{
// Operations
+ class GetRoomVisibilityOnDirectoryJob : public BaseJob
+ {
+ public:
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * GetRoomVisibilityOnDirectoryJob. This function can be used when
+ * a URL for GetRoomVisibilityOnDirectoryJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId);
+
+ explicit GetRoomVisibilityOnDirectoryJob(const QString& roomId);
+ ~GetRoomVisibilityOnDirectoryJob() override;
+
+ const QString& visibility() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ class SetRoomVisibilityOnDirectoryJob : public BaseJob
+ {
+ public:
+ explicit SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility = {});
+ };
+
class GetPublicRoomsJob : public BaseJob
{
public:
@@ -24,14 +53,13 @@ namespace QMatrixClient
QVector<QString> aliases;
QString canonicalAlias;
QString name;
- double numJoinedMembers;
+ qint64 numJoinedMembers;
QString roomId;
QString topic;
bool worldReadable;
bool guestCanJoin;
QString avatarUrl;
- operator QJsonObject() const;
};
// End of inner data structures
@@ -41,15 +69,15 @@ namespace QMatrixClient
* a URL for GetPublicRoomsJob is necessary but the job
* itself isn't.
*/
- static QUrl makeRequestUrl(QUrl baseUrl, double limit = {}, const QString& since = {}, const QString& server = {});
+ static QUrl makeRequestUrl(QUrl baseUrl, int limit = {}, const QString& since = {}, const QString& server = {});
- explicit GetPublicRoomsJob(double limit = {}, const QString& since = {}, const QString& server = {});
+ explicit GetPublicRoomsJob(int limit = {}, const QString& since = {}, const QString& server = {});
~GetPublicRoomsJob() override;
const QVector<PublicRoomsChunk>& chunk() const;
const QString& nextBatch() const;
const QString& prevBatch() const;
- double totalRoomCountEstimate() const;
+ qint64 totalRoomCountEstimate() const;
protected:
Status parseJson(const QJsonDocument& data) override;
@@ -68,7 +96,6 @@ namespace QMatrixClient
{
QString genericSearchTerm;
- operator QJsonObject() const;
};
struct PublicRoomsChunk
@@ -76,25 +103,24 @@ namespace QMatrixClient
QVector<QString> aliases;
QString canonicalAlias;
QString name;
- double numJoinedMembers;
+ qint64 numJoinedMembers;
QString roomId;
QString topic;
bool worldReadable;
bool guestCanJoin;
QString avatarUrl;
- operator QJsonObject() const;
};
// End of inner data structures
- explicit QueryPublicRoomsJob(const QString& server = {}, double limit = {}, const QString& since = {}, const Filter& filter = {});
+ explicit QueryPublicRoomsJob(const QString& server = {}, int limit = {}, const QString& since = {}, const Filter& filter = {});
~QueryPublicRoomsJob() override;
const QVector<PublicRoomsChunk>& chunk() const;
const QString& nextBatch() const;
const QString& prevBatch() const;
- double totalRoomCountEstimate() const;
+ qint64 totalRoomCountEstimate() const;
protected:
Status parseJson(const QJsonDocument& data) override;
diff --git a/lib/jobs/generated/pusher.cpp b/lib/jobs/generated/pusher.cpp
new file mode 100644
index 00000000..7d5e80d1
--- /dev/null
+++ b/lib/jobs/generated/pusher.cpp
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "pusher.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+namespace QMatrixClient
+{
+ QJsonObject toJson(const GetPushersJob::PusherData& pod)
+ {
+ QJsonObject o;
+ o.insert("url", toJson(pod.url));
+
+ return o;
+ }
+
+ template <> struct FromJson<GetPushersJob::PusherData>
+ {
+ GetPushersJob::PusherData operator()(const QJsonValue& jv)
+ {
+ const auto& o = jv.toObject();
+ GetPushersJob::PusherData result;
+ result.url =
+ fromJson<QString>(o.value("url"));
+
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+
+namespace QMatrixClient
+{
+ QJsonObject toJson(const GetPushersJob::Pusher& pod)
+ {
+ QJsonObject o;
+ o.insert("pushkey", toJson(pod.pushkey));
+ o.insert("kind", toJson(pod.kind));
+ o.insert("app_id", toJson(pod.appId));
+ o.insert("app_display_name", toJson(pod.appDisplayName));
+ o.insert("device_display_name", toJson(pod.deviceDisplayName));
+ o.insert("profile_tag", toJson(pod.profileTag));
+ o.insert("lang", toJson(pod.lang));
+ o.insert("data", toJson(pod.data));
+
+ return o;
+ }
+
+ template <> struct FromJson<GetPushersJob::Pusher>
+ {
+ GetPushersJob::Pusher operator()(const QJsonValue& jv)
+ {
+ const auto& o = jv.toObject();
+ GetPushersJob::Pusher result;
+ result.pushkey =
+ fromJson<QString>(o.value("pushkey"));
+ result.kind =
+ fromJson<QString>(o.value("kind"));
+ result.appId =
+ fromJson<QString>(o.value("app_id"));
+ result.appDisplayName =
+ fromJson<QString>(o.value("app_display_name"));
+ result.deviceDisplayName =
+ fromJson<QString>(o.value("device_display_name"));
+ result.profileTag =
+ fromJson<QString>(o.value("profile_tag"));
+ result.lang =
+ fromJson<QString>(o.value("lang"));
+ result.data =
+ fromJson<GetPushersJob::PusherData>(o.value("data"));
+
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+
+class GetPushersJob::Private
+{
+ public:
+ QVector<Pusher> pushers;
+};
+
+QUrl GetPushersJob::makeRequestUrl(QUrl baseUrl)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/pushers");
+}
+
+GetPushersJob::GetPushersJob()
+ : BaseJob(HttpVerb::Get, "GetPushersJob",
+ basePath % "/pushers")
+ , d(new Private)
+{
+}
+
+GetPushersJob::~GetPushersJob() = default;
+
+const QVector<GetPushersJob::Pusher>& GetPushersJob::pushers() const
+{
+ return d->pushers;
+}
+
+BaseJob::Status GetPushersJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->pushers = fromJson<QVector<Pusher>>(json.value("pushers"));
+ return Success;
+}
+
+namespace QMatrixClient
+{
+ QJsonObject toJson(const PostPusherJob::PusherData& pod)
+ {
+ QJsonObject o;
+ o.insert("url", toJson(pod.url));
+
+ return o;
+ }
+
+ template <> struct FromJson<PostPusherJob::PusherData>
+ {
+ PostPusherJob::PusherData operator()(const QJsonValue& jv)
+ {
+ const auto& o = jv.toObject();
+ PostPusherJob::PusherData result;
+ result.url =
+ fromJson<QString>(o.value("url"));
+
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+
+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, bool append)
+ : BaseJob(HttpVerb::Post, "PostPusherJob",
+ basePath % "/pushers/set")
+{
+ QJsonObject _data;
+ _data.insert("pushkey", toJson(pushkey));
+ _data.insert("kind", toJson(kind));
+ _data.insert("app_id", toJson(appId));
+ _data.insert("app_display_name", toJson(appDisplayName));
+ _data.insert("device_display_name", toJson(deviceDisplayName));
+ if (!profileTag.isEmpty())
+ _data.insert("profile_tag", toJson(profileTag));
+ _data.insert("lang", toJson(lang));
+ _data.insert("data", toJson(data));
+ _data.insert("append", toJson(append));
+ setRequestData(_data);
+}
+
diff --git a/lib/jobs/generated/pusher.h b/lib/jobs/generated/pusher.h
new file mode 100644
index 00000000..23cd3fb6
--- /dev/null
+++ b/lib/jobs/generated/pusher.h
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QVector>
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class GetPushersJob : public BaseJob
+ {
+ public:
+ // Inner data structures
+
+ struct PusherData
+ {
+ QString url;
+
+ };
+
+ struct Pusher
+ {
+ QString pushkey;
+ QString kind;
+ QString appId;
+ QString appDisplayName;
+ QString deviceDisplayName;
+ QString profileTag;
+ QString lang;
+ PusherData data;
+
+ };
+
+ // End of inner data structures
+
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * GetPushersJob. This function can be used when
+ * a URL for GetPushersJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl);
+
+ explicit GetPushersJob();
+ ~GetPushersJob() override;
+
+ const QVector<Pusher>& pushers() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ class PostPusherJob : public BaseJob
+ {
+ public:
+ // Inner data structures
+
+ struct PusherData
+ {
+ QString url;
+
+ };
+
+ // End of inner data structures
+
+ explicit 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 = {}, bool append = {});
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/receipts.cpp b/lib/jobs/generated/receipts.cpp
index 83c38b6f..945e8673 100644
--- a/lib/jobs/generated/receipts.cpp
+++ b/lib/jobs/generated/receipts.cpp
@@ -16,6 +16,6 @@ PostReceiptJob::PostReceiptJob(const QString& roomId, const QString& receiptType
: BaseJob(HttpVerb::Post, "PostReceiptJob",
basePath % "/rooms/" % roomId % "/receipt/" % receiptType % "/" % eventId)
{
- setRequestData(Data(receipt));
+ setRequestData(Data(toJson(receipt)));
}
diff --git a/lib/jobs/generated/room_send.cpp b/lib/jobs/generated/room_send.cpp
new file mode 100644
index 00000000..9637a205
--- /dev/null
+++ b/lib/jobs/generated/room_send.cpp
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_send.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class SendMessageJob::Private
+{
+ public:
+ QString eventId;
+};
+
+SendMessageJob::SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body)
+ : BaseJob(HttpVerb::Put, "SendMessageJob",
+ basePath % "/rooms/" % roomId % "/send/" % eventType % "/" % txnId)
+ , d(new Private)
+{
+ setRequestData(Data(toJson(body)));
+}
+
+SendMessageJob::~SendMessageJob() = default;
+
+const QString& SendMessageJob::eventId() const
+{
+ return d->eventId;
+}
+
+BaseJob::Status SendMessageJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->eventId = fromJson<QString>(json.value("event_id"));
+ return Success;
+}
+
diff --git a/lib/jobs/generated/room_send.h b/lib/jobs/generated/room_send.h
new file mode 100644
index 00000000..d20ce523
--- /dev/null
+++ b/lib/jobs/generated/room_send.h
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QJsonObject>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class SendMessageJob : public BaseJob
+ {
+ public:
+ explicit SendMessageJob(const QString& roomId, const QString& eventType, const QString& txnId, const QJsonObject& body = {});
+ ~SendMessageJob() override;
+
+ const QString& eventId() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/tags.cpp b/lib/jobs/generated/tags.cpp
new file mode 100644
index 00000000..9cd78aec
--- /dev/null
+++ b/lib/jobs/generated/tags.cpp
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "tags.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class GetRoomTagsJob::Private
+{
+ public:
+ QJsonObject tags;
+};
+
+QUrl GetRoomTagsJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/user/" % userId % "/rooms/" % roomId % "/tags");
+}
+
+GetRoomTagsJob::GetRoomTagsJob(const QString& userId, const QString& roomId)
+ : BaseJob(HttpVerb::Get, "GetRoomTagsJob",
+ basePath % "/user/" % userId % "/rooms/" % roomId % "/tags")
+ , d(new Private)
+{
+}
+
+GetRoomTagsJob::~GetRoomTagsJob() = default;
+
+const QJsonObject& GetRoomTagsJob::tags() const
+{
+ return d->tags;
+}
+
+BaseJob::Status GetRoomTagsJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ d->tags = fromJson<QJsonObject>(json.value("tags"));
+ return Success;
+}
+
+SetRoomTagJob::SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, const QJsonObject& body)
+ : BaseJob(HttpVerb::Put, "SetRoomTagJob",
+ basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag)
+{
+ setRequestData(Data(toJson(body)));
+}
+
+QUrl DeleteRoomTagJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag);
+}
+
+DeleteRoomTagJob::DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag)
+ : BaseJob(HttpVerb::Delete, "DeleteRoomTagJob",
+ basePath % "/user/" % userId % "/rooms/" % roomId % "/tags/" % tag)
+{
+}
+
diff --git a/lib/jobs/generated/tags.h b/lib/jobs/generated/tags.h
new file mode 100644
index 00000000..7a375527
--- /dev/null
+++ b/lib/jobs/generated/tags.h
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QJsonObject>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class GetRoomTagsJob : public BaseJob
+ {
+ public:
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * GetRoomTagsJob. This function can be used when
+ * a URL for GetRoomTagsJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId);
+
+ explicit GetRoomTagsJob(const QString& userId, const QString& roomId);
+ ~GetRoomTagsJob() override;
+
+ const QJsonObject& tags() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+
+ class SetRoomTagJob : public BaseJob
+ {
+ public:
+ explicit SetRoomTagJob(const QString& userId, const QString& roomId, const QString& tag, const QJsonObject& body = {});
+ };
+
+ class DeleteRoomTagJob : public BaseJob
+ {
+ public:
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * DeleteRoomTagJob. This function can be used when
+ * a URL for DeleteRoomTagJob is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& roomId, const QString& tag);
+
+ explicit DeleteRoomTagJob(const QString& userId, const QString& roomId, const QString& tag);
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/to_device.cpp b/lib/jobs/generated/to_device.cpp
new file mode 100644
index 00000000..cfb860c7
--- /dev/null
+++ b/lib/jobs/generated/to_device.cpp
@@ -0,0 +1,23 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "to_device.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+SendToDeviceJob::SendToDeviceJob(const QString& eventType, const QString& txnId, const QJsonObject& messages)
+ : BaseJob(HttpVerb::Put, "SendToDeviceJob",
+ basePath % "/sendToDevice/" % eventType % "/" % txnId)
+{
+ QJsonObject _data;
+ _data.insert("messages", toJson(messages));
+ setRequestData(_data);
+}
+
diff --git a/lib/jobs/generated/to_device.h b/lib/jobs/generated/to_device.h
new file mode 100644
index 00000000..0de8fb0a
--- /dev/null
+++ b/lib/jobs/generated/to_device.h
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QJsonObject>
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class SendToDeviceJob : public BaseJob
+ {
+ public:
+ explicit SendToDeviceJob(const QString& eventType, const QString& txnId, const QJsonObject& messages = {});
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/generated/users.cpp b/lib/jobs/generated/users.cpp
new file mode 100644
index 00000000..f82a2a64
--- /dev/null
+++ b/lib/jobs/generated/users.cpp
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "users.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+namespace QMatrixClient
+{
+ QJsonObject toJson(const SearchUserDirectoryJob::User& pod)
+ {
+ QJsonObject o;
+ o.insert("user_id", toJson(pod.userId));
+ o.insert("display_name", toJson(pod.displayName));
+ o.insert("avatar_url", toJson(pod.avatarUrl));
+
+ return o;
+ }
+
+ template <> struct FromJson<SearchUserDirectoryJob::User>
+ {
+ SearchUserDirectoryJob::User operator()(const QJsonValue& jv)
+ {
+ const auto& o = jv.toObject();
+ SearchUserDirectoryJob::User result;
+ result.userId =
+ fromJson<QString>(o.value("user_id"));
+ result.displayName =
+ fromJson<QString>(o.value("display_name"));
+ result.avatarUrl =
+ fromJson<QString>(o.value("avatar_url"));
+
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+
+class SearchUserDirectoryJob::Private
+{
+ public:
+ QVector<User> results;
+ bool limited;
+};
+
+SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, int limit)
+ : BaseJob(HttpVerb::Post, "SearchUserDirectoryJob",
+ basePath % "/user_directory/search")
+ , d(new Private)
+{
+ QJsonObject _data;
+ _data.insert("search_term", toJson(searchTerm));
+ _data.insert("limit", toJson(limit));
+ setRequestData(_data);
+}
+
+SearchUserDirectoryJob::~SearchUserDirectoryJob() = default;
+
+const QVector<SearchUserDirectoryJob::User>& SearchUserDirectoryJob::results() const
+{
+ return d->results;
+}
+
+bool SearchUserDirectoryJob::limited() const
+{
+ return d->limited;
+}
+
+BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("results"))
+ return { JsonParseError,
+ "The key 'results' not found in the response" };
+ d->results = fromJson<QVector<User>>(json.value("results"));
+ if (!json.contains("limited"))
+ return { JsonParseError,
+ "The key 'limited' not found in the response" };
+ d->limited = fromJson<bool>(json.value("limited"));
+ return Success;
+}
+
diff --git a/lib/jobs/generated/users.h b/lib/jobs/generated/users.h
new file mode 100644
index 00000000..bfa688c8
--- /dev/null
+++ b/lib/jobs/generated/users.h
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "../basejob.h"
+
+#include <QtCore/QVector>
+
+#include "converters.h"
+
+namespace QMatrixClient
+{
+ // Operations
+
+ class SearchUserDirectoryJob : public BaseJob
+ {
+ public:
+ // Inner data structures
+
+ struct User
+ {
+ QString userId;
+ QString displayName;
+ QString avatarUrl;
+
+ };
+
+ // End of inner data structures
+
+ explicit SearchUserDirectoryJob(const QString& searchTerm, int limit = {});
+ ~SearchUserDirectoryJob() override;
+
+ const QVector<User>& results() const;
+ bool limited() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient
diff --git a/lib/jobs/gtad.yaml b/lib/jobs/gtad.yaml
new file mode 100644
index 00000000..052d8301
--- /dev/null
+++ b/lib/jobs/gtad.yaml
@@ -0,0 +1,98 @@
+analyzer:
+ subst:
+ "%CLIENT_RELEASE_LABEL%": r0
+ "%CLIENT_MAJOR_VERSION%": r0
+ identifiers:
+ signed: signedData
+ unsigned: unsignedData
+ default: isDefault
+ origin_server_ts: originServerTimestamp
+
+ types:
+ # Structure:
+ # swaggerType: <targetTypeSpec>
+ # OR
+ # swaggerType:
+ # - swaggerFormat: <targetTypeSpec>
+ # - /swaggerFormatRegEx/: <targetTypeSpec>
+ # - //: <targetTypeSpec> # default, if the format doesn't mach anything above
+ # WHERE
+ # targetTypeSpec = targetType OR
+ # { type: targetType, imports: <filename OR [ filenames... ]>, <other attributes...> }
+ integer:
+ - int64: qint64
+ - int32: qint32
+ - //: int
+ number:
+ - float: float
+ - //: double
+ boolean: { type: bool, initializer: false }
+ string:
+ - byte: &ByteStream
+ type: QIODevice*
+ #initializer: '"{{defaultValue}}"'
+ #string?: true
+ imports: <QtCore/QIODevice>
+ - binary: *ByteStream
+ - date:
+ type: QDate
+ initializer: QDate::fromString("{{defaultValue}}")
+ avoidCopy?: true
+ imports: <QtCore/QDate>
+ - dateTime:
+ type: QDateTime
+ initializer: QDateTime::fromString("{{defaultValue}}")
+ avoidCopy?: true
+ imports: <QtCore/QDateTime>
+ - //:
+ type: QString
+ initializer: QStringLiteral("{{defaultValue}}")
+ string?: true
+ avoidCopy?: true
+ file: *ByteStream
+ object:
+ - definitions/event.yaml:
+ type: EventPtr
+ imports: '"events/event.h"'
+ - //:
+ type: QJsonObject
+ avoidCopy?: true
+ imports: <QtCore/QJsonObject>
+ array:
+ - Notification:
+ type: "std::vector<{{1}}>"
+ avoidCopy?: true
+ imports: <vector>
+ - /.+/:
+ type: "QVector<{{1}}>"
+ avoidCopy?: true
+ imports: <QtCore/QVector>
+ - //: { type: QJsonArray, "avoidCopy?": true, imports: <QtCore/QJsonArray> }
+ variant: { type: QVariant, "avoidCopy?": true, imports: <QtCore/QVariant> }
+ schema:
+ avoidCopy?: true
+
+ #operations:
+
+mustache:
+ definitions:
+ _scopeRenderer: "{{scopeCamelCase}}Job::"
+ _literalQuote: '"'
+ maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}"
+ qualifiedMaybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}"
+ initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}"
+ joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}'
+ joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}'
+ passQueryParams: '{{#queryParams}}{{paramName}}{{#@join}}, {{/@join}}{{/queryParams}}'
+ paramToString: '{{#string?}}{{nameCamelCase}}{{/string?}}{{^string?}}QString("%1").arg({{nameCamelCase}}){{/string?}}'
+ # preamble: preamble.mustache
+ copyrightName: Kitsune Ral
+ copyrightEmail: <kitsune-ral@users.sf.net>
+ # imports: { set: }
+
+ templates:
+ - "{{base}}.h.mustache"
+ - "{{base}}.cpp.mustache"
+
+ #outFilesList: apifiles.txt
+
diff --git a/lib/jobs/preamble.mustache b/lib/jobs/preamble.mustache
new file mode 100644
index 00000000..3ba87d61
--- /dev/null
+++ b/lib/jobs/preamble.mustache
@@ -0,0 +1,3 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache
new file mode 100644
index 00000000..1ca23799
--- /dev/null
+++ b/lib/jobs/{{base}}.cpp.mustache
@@ -0,0 +1,122 @@
+{{#@filePartial}}preamble{{/@filePartial}}
+#include "{{filenameBase}}.h"
+{{^allModels}}
+#include "converters.h"
+{{/allModels}}{{#operations}}
+{{#producesNonJson?}}#include <QtNetwork/QNetworkReply>
+{{/producesNonJson?}}#include <QtCore/QStringBuilder>
+{{/operations}}
+using namespace QMatrixClient;
+{{#models.model}}{{^trivial?}}
+namespace QMatrixClient
+{
+ QJsonObject toJson(const {{qualifiedName}}& pod)
+ {
+ QJsonObject o;
+ {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}}));
+ {{/vars}}
+ return o;
+ }
+}
+
+{{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(const QJsonValue& jv)
+{
+ const auto& o = jv.toObject();
+ {{qualifiedName}} result;
+ {{#vars}}result.{{nameCamelCase}} =
+ fromJson<{{dataType.name}}>(o.value("{{baseName}}"));
+ {{/vars}}
+ return result;
+}
+{{/trivial?}}{{/models.model}}{{#operations}}
+static const auto basePath = QStringLiteral("{{basePathWithoutHost}}");
+{{# operation}}{{#models.model}}{{^trivial?}}
+namespace QMatrixClient
+{
+ QJsonObject toJson(const {{qualifiedName}}& pod)
+ {
+ QJsonObject o;
+ {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}}));
+ {{/vars}}
+ return o;
+ }
+
+ template <> struct FromJson<{{qualifiedName}}>
+ {
+ {{qualifiedName}} operator()(const QJsonValue& jv)
+ {
+ const auto& o = jv.toObject();
+ {{qualifiedName}} result;
+ {{#vars}}result.{{nameCamelCase}} =
+ fromJson<{{dataType.qualifiedName}}>(o.value("{{baseName}}"));
+ {{/vars}}
+ return result;
+ }
+ };
+} // namespace QMatrixClient
+{{/ trivial?}}{{/models.model}}{{#responses}}{{#normalResponse?}}{{#allProperties?}}
+class {{camelCaseOperationId}}Job::Private
+{
+ public:{{#allProperties}}
+ {{dataType.name}} {{paramName}};{{/allProperties}}
+};
+{{/ allProperties?}}{{/normalResponse?}}{{/responses}}{{#queryParams?}}
+BaseJob::Query queryTo{{camelCaseOperationId}}({{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
+{
+ BaseJob::Query _q;{{#queryParams}}
+{{^required?}}{{#string?}} if (!{{nameCamelCase}}.isEmpty())
+ {{/string?}}{{/required?}} _q.addQueryItem("{{baseName}}", {{>paramToString}});{{/queryParams}}
+ return _q;
+}
+{{/queryParams?}}{{^bodyParams}}
+QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDef}}{{/allParams}}{{/allParams?}})
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}},
+ queryTo{{camelCaseOperationId}}({{>passQueryParams}}){{/queryParams?}});
+}
+{{/ bodyParams}}
+{{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDef}}{{/allParams}})
+ : BaseJob(HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{camelCaseOperationId}}Job",
+ basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}},
+ queryTo{{camelCaseOperationId}}({{>passQueryParams}}){{/queryParams?}}{{#skipAuth}}{{#queryParams?}},
+ {}{{/queryParams?}}, false{{/skipAuth}}){{#responses}}{{#normalResponse?}}{{#allProperties?}}
+ , d(new Private){{/allProperties?}}{{/normalResponse?}}{{/responses}}
+{
+{{#headerParams?}}{{#headerParams}} setRequestHeader("{{baseName}}", {{paramName}}.toLatin1());
+{{/headerParams}}
+{{/headerParams?
+}}{{#bodyParams?
+}}{{#inlineBody}} setRequestData(Data({{!
+ }}{{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson?
+ }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}}));{{/inlineBody
+}}{{^inlineBody}} QJsonObject _data;{{#bodyParams}}
+{{^required?}}{{#string?}} if (!{{paramName}}.isEmpty())
+ {{/string?}}{{/required?}} _data.insert("{{baseName}}", toJson({{paramName}}));{{/bodyParams}}
+ setRequestData(_data);{{/inlineBody}}
+{{/bodyParams?}}{{#producesNonJson?}} setExpectedContentTypes({ {{#produces}}"{{_}}"{{#@join}}, {{/@join}}{{/produces}} });
+{{/producesNonJson?}}}{{!<- mind the actual brace}}
+{{# responses}}{{#normalResponse?}}{{#allProperties?}}
+{{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() = default;
+{{# allProperties}}
+{{>qualifiedMaybeCrefType}} {{camelCaseOperationId}}Job::{{paramName}}() const
+{
+ return d->{{paramName}};
+}
+{{/ allProperties}}{{#producesNonJson?}}
+BaseJob::Status {{camelCaseOperationId}}Job::parseReply(QNetworkReply* reply)
+{
+ {{#headers}}d->{{paramName}} = reply->rawHeader("{{baseName}}"); {{! We don't check for required headers yet }}
+ {{/headers}}{{#properties}}d->{{paramName}} = reply;{{/properties}}
+ return Success;
+}{{/ producesNonJson?}}{{^producesNonJson?}}
+BaseJob::Status {{camelCaseOperationId}}Job::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ {{# properties}}{{#required?}}if (!json.contains("{{baseName}}"))
+ return { JsonParseError,
+ "The key '{{baseName}}' not found in the response" };
+ {{/required?}}d->{{paramName}} = fromJson<{{dataType.name}}>(json.value("{{baseName}}"));
+ {{/ properties}}return Success;
+}{{/ producesNonJson?}}
+{{/allProperties?}}{{/normalResponse?}}{{/responses}}{{/operation}}{{/operations}}
diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache
new file mode 100644
index 00000000..f49945d4
--- /dev/null
+++ b/lib/jobs/{{base}}.h.mustache
@@ -0,0 +1,67 @@
+{{#@filePartial}}preamble{{/@filePartial}}
+#pragma once
+
+{{#operations}}#include "../basejob.h"
+{{/operations}}
+{{#imports}}#include {{_}}
+{{/imports}}
+{{#allModels}}#include "converters.h"
+{{/allModels}}
+namespace QMatrixClient
+{
+{{#models}} // Data structures
+{{# model}}{{#trivial?}}
+ using {{name}} = {{parent.name}};
+{{/ trivial?}}{{^trivial?}}
+ struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}}
+ {
+ {{#vars}}{{dataType.name}} {{nameCamelCase}};
+ {{/vars}}{{!
+}} };
+
+ QJsonObject toJson(const {{name}}& pod);
+
+ template <> struct FromJson<{{name}}>
+ {
+ {{name}} operator()(const QJsonValue& jv);
+ };
+{{/ trivial?}}{{/model}}
+{{/models}}{{#operations}} // Operations
+{{# operation}}
+ class {{camelCaseOperationId}}Job : public BaseJob
+ {
+ public:{{# models}}
+ // Inner data structures
+{{# model}}{{#trivial?}}
+ using {{name}} = {{parent.name}};
+{{/ trivial?}}{{^trivial?}}
+ struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}}
+ {
+ {{#vars}}{{dataType.name}} {{nameCamelCase}};
+ {{/vars}}
+ };
+{{/ trivial?}}{{/model}}
+ // End of inner data structures
+{{/models}}{{^bodyParams}}
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * {{camelCaseOperationId}}Job. This function can be used when
+ * a URL for {{camelCaseOperationId}}Job is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDecl}}{{/allParams}}{{/allParams?}});
+{{/bodyParams}}
+ explicit {{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDecl}}{{/allParams}});{{!skip EOL
+}}{{# responses}}{{#normalResponse?}}{{#allProperties?}}
+ ~{{camelCaseOperationId}}Job() override;
+{{#allProperties}}
+ {{>maybeCrefType}} {{paramName}}() const;{{/allProperties}}
+
+ protected:
+ Status {{#producesNonJson?}}parseReply(QNetworkReply* reply){{/producesNonJson?}}{{^producesNonJson?}}parseJson(const QJsonDocument& data){{/producesNonJson?}} override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;{{/allProperties?}}{{/normalResponse?}}{{/responses}}
+ };
+{{/operation}}{{/operations}}{{!skip EOL
+}}} // namespace QMatrixClient
diff --git a/libqmatrixclient.pri b/libqmatrixclient.pri
index edba623e..4a0928b0 100644
--- a/libqmatrixclient.pri
+++ b/libqmatrixclient.pri
@@ -42,6 +42,7 @@ HEADERS += \
$$SRCPATH/jobs/downloadfilejob.h \
$$SRCPATH/jobs/postreadmarkersjob.h \
$$files($$SRCPATH/jobs/generated/*.h, false) \
+ $$files($$SRCPATH/jobs/generated/definitions/*.h, false) \
$$SRCPATH/logging.h \
$$SRCPATH/settings.h \
$$SRCPATH/networksettings.h \
@@ -73,6 +74,7 @@ SOURCES += \
$$SRCPATH/jobs/setroomstatejob.cpp \
$$SRCPATH/jobs/downloadfilejob.cpp \
$$files($$SRCPATH/jobs/generated/*.cpp, false) \
+ $$files($$SRCPATH/jobs/generated/definitions/*.cpp, false) \
$$SRCPATH/logging.cpp \
$$SRCPATH/settings.cpp \
$$SRCPATH/networksettings.cpp \