From d9ff200ff62fb7f5b6b51082dc3979d5454a1bec Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 25 Aug 2018 22:40:15 +0900 Subject: Update to the recent CS API (watch out for breakage) Breaking changes: * guest_can_join is no more a thing - neither in Connection::createRoom, nor even in CreateRoomJob (it turned out that Synapse didn't really process this flag); * LoginJob has changed its list of arguments. If you use Connection to do logins (and you really should), you shouldn't be affected. * GetPublicRoomsJob now returns PublicRoomsResponse instead of providing all the response parts within the job Watch other changes in the diff. --- lib/csapi/definitions/public_rooms_response.cpp | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lib/csapi/definitions/public_rooms_response.cpp (limited to 'lib/csapi/definitions/public_rooms_response.cpp') diff --git a/lib/csapi/definitions/public_rooms_response.cpp b/lib/csapi/definitions/public_rooms_response.cpp new file mode 100644 index 00000000..7cdf16af --- /dev/null +++ b/lib/csapi/definitions/public_rooms_response.cpp @@ -0,0 +1,75 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "public_rooms_response.h" + +using namespace QMatrixClient; + +QJsonObject QMatrixClient::toJson(const PublicRoomsChunk& pod) +{ + QJsonObject _json; + addParam(_json, QStringLiteral("aliases"), pod.aliases); + addParam(_json, QStringLiteral("canonical_alias"), pod.canonicalAlias); + addParam(_json, QStringLiteral("name"), pod.name); + addParam<>(_json, QStringLiteral("num_joined_members"), pod.numJoinedMembers); + addParam<>(_json, QStringLiteral("room_id"), pod.roomId); + addParam(_json, QStringLiteral("topic"), pod.topic); + addParam<>(_json, QStringLiteral("world_readable"), pod.worldReadable); + addParam<>(_json, QStringLiteral("guest_can_join"), pod.guestCanJoin); + addParam(_json, QStringLiteral("avatar_url"), pod.avatarUrl); + return _json; +} + +PublicRoomsChunk FromJson::operator()(const QJsonValue& jv) +{ + const auto& _json = jv.toObject(); + PublicRoomsChunk result; + result.aliases = + fromJson(_json.value("aliases"_ls)); + result.canonicalAlias = + fromJson(_json.value("canonical_alias"_ls)); + result.name = + fromJson(_json.value("name"_ls)); + result.numJoinedMembers = + fromJson(_json.value("num_joined_members"_ls)); + result.roomId = + fromJson(_json.value("room_id"_ls)); + result.topic = + fromJson(_json.value("topic"_ls)); + result.worldReadable = + fromJson(_json.value("world_readable"_ls)); + result.guestCanJoin = + fromJson(_json.value("guest_can_join"_ls)); + result.avatarUrl = + fromJson(_json.value("avatar_url"_ls)); + + return result; +} + +QJsonObject QMatrixClient::toJson(const PublicRoomsResponse& pod) +{ + QJsonObject _json; + addParam<>(_json, QStringLiteral("chunk"), pod.chunk); + addParam(_json, QStringLiteral("next_batch"), pod.nextBatch); + addParam(_json, QStringLiteral("prev_batch"), pod.prevBatch); + addParam(_json, QStringLiteral("total_room_count_estimate"), pod.totalRoomCountEstimate); + return _json; +} + +PublicRoomsResponse FromJson::operator()(const QJsonValue& jv) +{ + const auto& _json = jv.toObject(); + PublicRoomsResponse result; + result.chunk = + fromJson>(_json.value("chunk"_ls)); + result.nextBatch = + fromJson(_json.value("next_batch"_ls)); + result.prevBatch = + fromJson(_json.value("prev_batch"_ls)); + result.totalRoomCountEstimate = + fromJson(_json.value("total_room_count_estimate"_ls)); + + return result; +} + -- cgit v1.2.3