diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-09-02 16:08:13 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-09-29 22:00:06 +0900 |
commit | 1e6510790dab6b9141ae52993987b406399668cd (patch) | |
tree | 1a45c0ccfec8f5f7ba37eb4385cdc7f61afa0c97 /lib/csapi/list_public_rooms.cpp | |
parent | 4244cee8d5e0f760cccd2b45ad587670573ef03c (diff) | |
download | libquotient-1e6510790dab6b9141ae52993987b406399668cd.tar.gz libquotient-1e6510790dab6b9141ae52993987b406399668cd.zip |
Support CS API 0.4.0
Numerous changes in CS (and now also AS) API, including compatibility-breaking ones - see the diff for details.
Diffstat (limited to 'lib/csapi/list_public_rooms.cpp')
-rw-r--r-- | lib/csapi/list_public_rooms.cpp | 65 |
1 files changed, 7 insertions, 58 deletions
diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 4466dc5b..2fdb2005 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -114,43 +114,12 @@ namespace QMatrixClient addParam<IfNotEmpty>(jo, QStringLiteral("generic_search_term"), pod.genericSearchTerm); return jo; } - - template <> struct FromJsonObject<QueryPublicRoomsJob::PublicRoomsChunk> - { - QueryPublicRoomsJob::PublicRoomsChunk operator()(const QJsonObject& jo) const - { - QueryPublicRoomsJob::PublicRoomsChunk result; - result.aliases = - fromJson<QStringList>(jo.value("aliases"_ls)); - result.canonicalAlias = - fromJson<QString>(jo.value("canonical_alias"_ls)); - result.name = - fromJson<QString>(jo.value("name"_ls)); - result.numJoinedMembers = - fromJson<qint64>(jo.value("num_joined_members"_ls)); - result.roomId = - fromJson<QString>(jo.value("room_id"_ls)); - result.topic = - fromJson<QString>(jo.value("topic"_ls)); - result.worldReadable = - fromJson<bool>(jo.value("world_readable"_ls)); - result.guestCanJoin = - fromJson<bool>(jo.value("guest_can_join"_ls)); - result.avatarUrl = - fromJson<QString>(jo.value("avatar_url"_ls)); - - return result; - } - }; } // namespace QMatrixClient class QueryPublicRoomsJob::Private { public: - QVector<PublicRoomsChunk> chunk; - QString nextBatch; - QString prevBatch; - Omittable<qint64> totalRoomCountEstimate; + PublicRoomsResponse data; }; BaseJob::Query queryToQueryPublicRooms(const QString& server) @@ -162,7 +131,7 @@ BaseJob::Query queryToQueryPublicRooms(const QString& server) static const auto QueryPublicRoomsJobName = QStringLiteral("QueryPublicRoomsJob"); -QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable<int> limit, const QString& since, const Omittable<Filter>& filter) +QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable<int> limit, const QString& since, const Omittable<Filter>& filter, bool includeAllNetworks, const QString& thirdPartyInstanceId) : BaseJob(HttpVerb::Post, QueryPublicRoomsJobName, basePath % "/publicRooms", queryToQueryPublicRooms(server)) @@ -172,41 +141,21 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable<int> l addParam<IfNotEmpty>(_data, QStringLiteral("limit"), limit); addParam<IfNotEmpty>(_data, QStringLiteral("since"), since); addParam<IfNotEmpty>(_data, QStringLiteral("filter"), filter); + addParam<IfNotEmpty>(_data, QStringLiteral("include_all_networks"), includeAllNetworks); + addParam<IfNotEmpty>(_data, QStringLiteral("third_party_instance_id"), thirdPartyInstanceId); setRequestData(_data); } QueryPublicRoomsJob::~QueryPublicRoomsJob() = default; -const QVector<QueryPublicRoomsJob::PublicRoomsChunk>& QueryPublicRoomsJob::chunk() const -{ - return d->chunk; -} - -const QString& QueryPublicRoomsJob::nextBatch() const +const PublicRoomsResponse& QueryPublicRoomsJob::data() const { - return d->nextBatch; -} - -const QString& QueryPublicRoomsJob::prevBatch() const -{ - return d->prevBatch; -} - -Omittable<qint64> QueryPublicRoomsJob::totalRoomCountEstimate() const -{ - return d->totalRoomCountEstimate; + return d->data; } BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data) { - auto json = data.object(); - if (!json.contains("chunk"_ls)) - return { JsonParseError, - "The key 'chunk' not found in the response" }; - d->chunk = fromJson<QVector<PublicRoomsChunk>>(json.value("chunk"_ls)); - d->nextBatch = fromJson<QString>(json.value("next_batch"_ls)); - d->prevBatch = fromJson<QString>(json.value("prev_batch"_ls)); - d->totalRoomCountEstimate = fromJson<qint64>(json.value("total_room_count_estimate"_ls)); + d->data = fromJson<PublicRoomsResponse>(data); return Success; } |