diff options
Diffstat (limited to 'lib/csapi/definitions')
-rw-r--r-- | lib/csapi/definitions/auth_data.h | 2 | ||||
-rw-r--r-- | lib/csapi/definitions/public_rooms_response.cpp | 75 | ||||
-rw-r--r-- | lib/csapi/definitions/public_rooms_response.h | 72 | ||||
-rw-r--r-- | lib/csapi/definitions/push_rule.cpp | 18 | ||||
-rw-r--r-- | lib/csapi/definitions/push_rule.h | 27 | ||||
-rw-r--r-- | lib/csapi/definitions/user_identifier.cpp | 26 | ||||
-rw-r--r-- | lib/csapi/definitions/user_identifier.h | 31 |
7 files changed, 208 insertions, 43 deletions
diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h index 0ad72b87..dce55396 100644 --- a/lib/csapi/definitions/auth_data.h +++ b/lib/csapi/definitions/auth_data.h @@ -6,6 +6,8 @@ #include "converters.h" +#include <QtCore/QJsonObject> +#include <QtCore/QHash> namespace QMatrixClient { 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<IfNotEmpty>(_json, QStringLiteral("aliases"), pod.aliases); + addParam<IfNotEmpty>(_json, QStringLiteral("canonical_alias"), pod.canonicalAlias); + addParam<IfNotEmpty>(_json, QStringLiteral("name"), pod.name); + addParam<>(_json, QStringLiteral("num_joined_members"), pod.numJoinedMembers); + addParam<>(_json, QStringLiteral("room_id"), pod.roomId); + addParam<IfNotEmpty>(_json, QStringLiteral("topic"), pod.topic); + addParam<>(_json, QStringLiteral("world_readable"), pod.worldReadable); + addParam<>(_json, QStringLiteral("guest_can_join"), pod.guestCanJoin); + addParam<IfNotEmpty>(_json, QStringLiteral("avatar_url"), pod.avatarUrl); + return _json; +} + +PublicRoomsChunk FromJson<PublicRoomsChunk>::operator()(const QJsonValue& jv) +{ + const auto& _json = jv.toObject(); + PublicRoomsChunk result; + result.aliases = + fromJson<QStringList>(_json.value("aliases"_ls)); + result.canonicalAlias = + fromJson<QString>(_json.value("canonical_alias"_ls)); + result.name = + fromJson<QString>(_json.value("name"_ls)); + result.numJoinedMembers = + fromJson<qint64>(_json.value("num_joined_members"_ls)); + result.roomId = + fromJson<QString>(_json.value("room_id"_ls)); + result.topic = + fromJson<QString>(_json.value("topic"_ls)); + result.worldReadable = + fromJson<bool>(_json.value("world_readable"_ls)); + result.guestCanJoin = + fromJson<bool>(_json.value("guest_can_join"_ls)); + result.avatarUrl = + fromJson<QString>(_json.value("avatar_url"_ls)); + + return result; +} + +QJsonObject QMatrixClient::toJson(const PublicRoomsResponse& pod) +{ + QJsonObject _json; + addParam<>(_json, QStringLiteral("chunk"), pod.chunk); + addParam<IfNotEmpty>(_json, QStringLiteral("next_batch"), pod.nextBatch); + addParam<IfNotEmpty>(_json, QStringLiteral("prev_batch"), pod.prevBatch); + addParam<IfNotEmpty>(_json, QStringLiteral("total_room_count_estimate"), pod.totalRoomCountEstimate); + return _json; +} + +PublicRoomsResponse FromJson<PublicRoomsResponse>::operator()(const QJsonValue& jv) +{ + const auto& _json = jv.toObject(); + PublicRoomsResponse result; + result.chunk = + fromJson<QVector<PublicRoomsChunk>>(_json.value("chunk"_ls)); + result.nextBatch = + fromJson<QString>(_json.value("next_batch"_ls)); + result.prevBatch = + fromJson<QString>(_json.value("prev_batch"_ls)); + result.totalRoomCountEstimate = + fromJson<qint64>(_json.value("total_room_count_estimate"_ls)); + + return result; +} + diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h new file mode 100644 index 00000000..eea4bc5e --- /dev/null +++ b/lib/csapi/definitions/public_rooms_response.h @@ -0,0 +1,72 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +#include <QtCore/QVector> +#include "converters.h" + +namespace QMatrixClient +{ + // Data structures + + struct PublicRoomsChunk + { + /// Aliases of the room. May be empty. + QStringList aliases; + /// The canonical alias of the room, if any. + QString canonicalAlias; + /// The name of the room, if any. + QString name; + /// The number of members joined to the room. + qint64 numJoinedMembers; + /// The ID of the room. + QString roomId; + /// The topic of the room, if any. + QString topic; + /// Whether the room may be viewed by guest users without joining. + bool worldReadable; + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + bool guestCanJoin; + /// The URL for the room's avatar, if one is set. + QString avatarUrl; + }; + + QJsonObject toJson(const PublicRoomsChunk& pod); + + template <> struct FromJson<PublicRoomsChunk> + { + PublicRoomsChunk operator()(const QJsonValue& jv); + }; + + /// A list of the rooms on the server. + struct PublicRoomsResponse + { + /// A paginated chunk of public rooms. + QVector<PublicRoomsChunk> chunk; + /// A pagination token for the response. The absence of this token + /// means there are no more results to fetch and the client should + /// stop paginating. + QString nextBatch; + /// A pagination token that allows fetching previous results. The + /// absence of this token means there are no results before this + /// batch, i.e. this is the first batch. + QString prevBatch; + /// An estimate on the total number of public rooms, if the + /// server has an estimate. + Omittable<qint64> totalRoomCountEstimate; + }; + + QJsonObject toJson(const PublicRoomsResponse& pod); + + template <> struct FromJson<PublicRoomsResponse> + { + PublicRoomsResponse operator()(const QJsonValue& jv); + }; + +} // namespace QMatrixClient diff --git a/lib/csapi/definitions/push_rule.cpp b/lib/csapi/definitions/push_rule.cpp index 1ee57945..833135ec 100644 --- a/lib/csapi/definitions/push_rule.cpp +++ b/lib/csapi/definitions/push_rule.cpp @@ -6,24 +6,6 @@ using namespace QMatrixClient; -QJsonObject QMatrixClient::toJson(const SetTweakAction& pod) -{ - QJsonObject _json = toJson(pod.additionalProperties); - addParam<>(_json, QStringLiteral("set_tweak"), pod.setTweak); - return _json; -} - -SetTweakAction FromJson<SetTweakAction>::operator()(const QJsonValue& jv) -{ - auto _json = jv.toObject(); - SetTweakAction result; - result.setTweak = - fromJson<QString>(_json.take("set_tweak"_ls)); - - result.additionalProperties = fromJson<QVariantHash>(_json); - return result; -} - QJsonObject QMatrixClient::toJson(const PushRule& pod) { QJsonObject _json; diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h index 6959e9d1..c6542aa6 100644 --- a/lib/csapi/definitions/push_rule.h +++ b/lib/csapi/definitions/push_rule.h @@ -7,38 +7,15 @@ #include "converters.h" #include "csapi/definitions/push_condition.h" +#include "converters.h" #include <QtCore/QVector> #include <QtCore/QVariant> -#include "converters.h" +#include <QtCore/QJsonObject> namespace QMatrixClient { // Data structures - /// Specifies an entry to the 'tweaks' dictionary sent in - /// the notification request to the Push Gateway. - /// Tweak parameters, if any, are provided as additional - /// key-value pairs in this structure. - struct SetTweakAction - { - /// The tweak type. Two predefined types are `sound` - /// and `highlight`; client applications and Push Gateways - /// may agree on additional tweak types. - QString setTweak; - /// Specifies an entry to the 'tweaks' dictionary sent in - /// the notification request to the Push Gateway. - /// Tweak parameters, if any, are provided as additional - /// key-value pairs in this structure. - QVariantHash additionalProperties; - }; - - QJsonObject toJson(const SetTweakAction& pod); - - template <> struct FromJson<SetTweakAction> - { - SetTweakAction operator()(const QJsonValue& jv); - }; - struct PushRule { /// The actions to perform when this rule is matched. diff --git a/lib/csapi/definitions/user_identifier.cpp b/lib/csapi/definitions/user_identifier.cpp new file mode 100644 index 00000000..3d3acaba --- /dev/null +++ b/lib/csapi/definitions/user_identifier.cpp @@ -0,0 +1,26 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#include "user_identifier.h" + +using namespace QMatrixClient; + +QJsonObject QMatrixClient::toJson(const UserIdentifier& pod) +{ + QJsonObject _json = toJson(pod.additionalProperties); + addParam<>(_json, QStringLiteral("type"), pod.type); + return _json; +} + +UserIdentifier FromJson<UserIdentifier>::operator()(const QJsonValue& jv) +{ + auto _json = jv.toObject(); + UserIdentifier result; + result.type = + fromJson<QString>(_json.take("type"_ls)); + + result.additionalProperties = fromJson<QVariantHash>(_json); + return result; +} + diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h new file mode 100644 index 00000000..edc254d3 --- /dev/null +++ b/lib/csapi/definitions/user_identifier.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN + */ + +#pragma once + +#include "converters.h" + +#include <QtCore/QVariant> + +namespace QMatrixClient +{ + // Data structures + + /// Identification information for a user + struct UserIdentifier + { + /// The type of identification. See `Identifier types`_ for supported values and additional property descriptions. + QString type; + /// Identification information for a user + QVariantHash additionalProperties; + }; + + QJsonObject toJson(const UserIdentifier& pod); + + template <> struct FromJson<UserIdentifier> + { + UserIdentifier operator()(const QJsonValue& jv); + }; + +} // namespace QMatrixClient |