From 46801080846d58ab1528e921bebcb14e651f7956 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 9 Jun 2018 22:53:29 +0900 Subject: csapi: Now really fix passing query parameters Also: GetContentThumbnailJob (again) requires width and height. --- lib/converters.cpp | 2 +- lib/converters.h | 125 ++++++++++++++-------------- lib/csapi/administrative_contact.cpp | 10 +-- lib/csapi/banning.cpp | 6 +- lib/csapi/content-repo.cpp | 24 +++--- lib/csapi/content-repo.h | 4 +- lib/csapi/create_room.cpp | 34 ++++---- lib/csapi/definitions/client_device.cpp | 8 +- lib/csapi/definitions/device_keys.cpp | 10 +-- lib/csapi/definitions/event_filter.cpp | 10 +-- lib/csapi/definitions/push_condition.cpp | 8 +- lib/csapi/definitions/push_rule.cpp | 12 +-- lib/csapi/definitions/push_ruleset.cpp | 10 +-- lib/csapi/definitions/room_event_filter.cpp | 6 +- lib/csapi/definitions/sync_filter.cpp | 24 +++--- lib/csapi/device_management.cpp | 8 +- lib/csapi/directory.cpp | 2 +- lib/csapi/event_context.cpp | 2 +- lib/csapi/inviting.cpp | 2 +- lib/csapi/joining.cpp | 22 ++--- lib/csapi/keys.cpp | 18 ++-- lib/csapi/kicking.cpp | 4 +- lib/csapi/list_public_rooms.cpp | 18 ++-- lib/csapi/login.cpp | 16 ++-- lib/csapi/message_pagination.cpp | 10 +-- lib/csapi/notifications.cpp | 6 +- lib/csapi/peeking_events.cpp | 6 +- lib/csapi/presence.cpp | 8 +- lib/csapi/profile.cpp | 4 +- lib/csapi/pusher.cpp | 20 ++--- lib/csapi/pushrules.cpp | 14 ++-- lib/csapi/redaction.cpp | 2 +- lib/csapi/registration.cpp | 30 +++---- lib/csapi/report_content.cpp | 4 +- lib/csapi/search.cpp | 30 +++---- lib/csapi/third_party_membership.cpp | 6 +- lib/csapi/to_device.cpp | 2 +- lib/csapi/typing.cpp | 4 +- lib/csapi/users.cpp | 4 +- lib/csapi/{{base}}.cpp.mustache | 8 +- 40 files changed, 270 insertions(+), 273 deletions(-) (limited to 'lib') diff --git a/lib/converters.cpp b/lib/converters.cpp index f09fe5c2..41a9a65e 100644 --- a/lib/converters.cpp +++ b/lib/converters.cpp @@ -22,7 +22,7 @@ using namespace QMatrixClient; -QJsonValue QMatrixClient::toJson(const QVariant& v) +QJsonValue QMatrixClient::variantToJson(const QVariant& v) { return QJsonValue::fromVariant(v); } diff --git a/lib/converters.h b/lib/converters.h index 711d0a7c..7de33c9b 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -82,22 +82,20 @@ namespace QMatrixClient T& value() { return _value; } T&& release() { _omitted = true; return std::move(_value); } - operator bool() const { return !_omitted; } + operator bool() const { return !omitted(); } private: T _value; bool _omitted; }; - // This catches anything implicitly convertible to QJsonValue/Object/Array inline auto toJson(const QJsonValue& val) { return val; } inline auto toJson(const QJsonObject& o) { return o; } inline auto toJson(const QJsonArray& arr) { return arr; } // Special-case QStrings and bools to avoid ambiguity between QJsonValue - // and QVariant (also, QString.isEmpty() is used in _impl::AddNote<> below) + // and QVariant (also, QString.isEmpty() is used in _impl::AddNode<> below) inline auto toJson(const QString& s) { return s; } - inline QJsonValue toJson(bool b) { return b; } inline QJsonArray toJson(const QStringList& strings) { @@ -109,7 +107,18 @@ namespace QMatrixClient return bytes.constData(); } - QJsonValue toJson(const QVariant& v); + // QVariant is outrageously omnivorous - it consumes whatever is not + // exactly matching the signature of other toJson overloads. The trick + // below disables implicit conversion to QVariant through its numerous + // non-explicit constructors. + QJsonValue variantToJson(const QVariant& v); + template + inline auto toJson(T&& var) + -> std::enable_if_t, QVariant>::value, + QJsonValue> + { + return variantToJson(var); + } QJsonObject toJson(const QMap& map); #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) QJsonObject toJson(const QHash& hMap); @@ -151,16 +160,6 @@ namespace QMatrixClient return json; } - template - inline auto toJson(const Omittable& omittable) - -> decltype(toJson(omittable.value())) - { - if (omittable) - return toJson(omittable.value()); - - return {}; - } - #if 0 template inline auto toJson(const optional& optVal) @@ -333,74 +332,72 @@ namespace QMatrixClient namespace _impl { + template + inline void addTo(QJsonObject& o, const QString& k, ValT&& v) + { o.insert(k, toJson(v)); } + + template + inline void addTo(QUrlQuery& q, const QString& k, ValT&& v) + { q.addQueryItem(k, QString("%1").arg(v)); } + + // OpenAPI is entirely JSON-based, which means representing bools as + // textual true/false, rather than 1/0. + template + inline void addTo(QUrlQuery& q, const QString& k, bool v) + { + q.addQueryItem(k, v ? QStringLiteral("true") + : QStringLiteral("false")); + } + // This one is for types that don't have isEmpty() - template + template struct AddNode { - static void impl(InserterT inserter, QString key, JsonT&& value) + template + static void impl(ContT& container, const QString& key, + ForwardedT&& value) { - inserter(std::move(key), std::forward(value)); + addTo(container, key, std::forward(value)); } }; // This one is for types that have isEmpty() - template - struct AddNode().isEmpty())> + template + struct AddNode().isEmpty())> { - static void impl(InserterT inserter, QString key, JsonT&& value) + template + static void impl(ContT& container, const QString& key, + ForwardedT&& value) { if (!value.isEmpty()) - inserter(std::move(key), std::forward(value)); + AddNode::impl(container, + key, std::forward(value)); } }; - template - inline void maybeAdd(InserterT inserter, QString key, ValT&& value) + // This is a special one that unfolds Omittable<> + template + struct AddNode, Force> { - auto&& json = toJson(std::forward(value)); - // QJsonValue doesn't have isEmpty and consumes all other types - // (QString, QJsonObject etc.). - AddNode> - ::impl(inserter, std::move(key), std::move(json)); - - } - + template + static void impl(ContT& container, + const QString& key, const OmittableT& value) + { + if (!value.omitted()) + AddNode::impl(container, key, value.value()); + else if (Force) // Edge case, no value but must put something + AddNode::impl(container, key, QString{}); + } + }; } // namespace _impl static constexpr bool IfNotEmpty = false; - template - inline void addToJson(QJsonObject& o, QString key, ValT&& value) - { - using namespace std::placeholders; - _impl::maybeAdd(bind(&QJsonObject::insert, o, _1, _2), - key, value); - } - - template - inline void addToQuery(QUrlQuery& query, QString key, ValT&& value) + template + inline void addParam(ContT& container, const QString& key, ValT&& value) { - using namespace std::placeholders; - _impl::maybeAdd( - [&query] (QString k, auto&& jsonValue) { - query.addQueryItem(k, jsonValue.toString()); - }, key, value); + _impl::AddNode, Force> + ::impl(container, key, std::forward(value)); } - - template - inline void addToQuery(QUrlQuery& query, QString key, QString value) - { - if (Force || !value.isEmpty()) - query.addQueryItem(key, value); - } - - template - inline void addToQuery(QUrlQuery& query, QString key, bool value) - { - query.addQueryItem(key, - value ? QStringLiteral("true") : QStringLiteral("false")); - } - } // namespace QMatrixClient diff --git a/lib/csapi/administrative_contact.cpp b/lib/csapi/administrative_contact.cpp index 14079179..e3dee8ed 100644 --- a/lib/csapi/administrative_contact.cpp +++ b/lib/csapi/administrative_contact.cpp @@ -72,9 +72,9 @@ namespace QMatrixClient QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod) { QJsonObject _json; - addToJson<>(_json, "client_secret", pod.clientSecret); - addToJson<>(_json, "id_server", pod.idServer); - addToJson<>(_json, "sid", pod.sid); + addParam<>(_json, "client_secret", pod.clientSecret); + addParam<>(_json, "id_server", pod.idServer); + addParam<>(_json, "sid", pod.sid); return _json; } } // namespace QMatrixClient @@ -84,8 +84,8 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) basePath % "/account/3pid") { QJsonObject _data; - addToJson<>(_data, "three_pid_creds", threePidCreds); - addToJson(_data, "bind", bind); + addParam<>(_data, "three_pid_creds", threePidCreds); + addParam(_data, "bind", bind); setRequestData(_data); } diff --git a/lib/csapi/banning.cpp b/lib/csapi/banning.cpp index 5f1df39f..4dbd8a7d 100644 --- a/lib/csapi/banning.cpp +++ b/lib/csapi/banning.cpp @@ -17,8 +17,8 @@ BanJob::BanJob(const QString& roomId, const QString& userId, const QString& reas basePath % "/rooms/" % roomId % "/ban") { QJsonObject _data; - addToJson<>(_data, "user_id", userId); - addToJson(_data, "reason", reason); + addParam<>(_data, "user_id", userId); + addParam(_data, "reason", reason); setRequestData(_data); } @@ -27,7 +27,7 @@ UnbanJob::UnbanJob(const QString& roomId, const QString& userId) basePath % "/rooms/" % roomId % "/unban") { QJsonObject _data; - addToJson<>(_data, "user_id", userId); + addParam<>(_data, "user_id", userId); setRequestData(_data); } diff --git a/lib/csapi/content-repo.cpp b/lib/csapi/content-repo.cpp index 81329345..4ce80d08 100644 --- a/lib/csapi/content-repo.cpp +++ b/lib/csapi/content-repo.cpp @@ -22,7 +22,7 @@ class UploadContentJob::Private BaseJob::Query queryToUploadContent(const QString& filename) { BaseJob::Query _q; - addToQuery(_q, "filename", filename); + addParam(_q, "filename", filename); return _q; } @@ -65,7 +65,7 @@ class GetContentJob::Private BaseJob::Query queryToGetContent(bool allowRemote) { BaseJob::Query _q; - addToQuery(_q, "allow_remote", allowRemote); + addParam(_q, "allow_remote", allowRemote); return _q; } @@ -122,7 +122,7 @@ class GetContentOverrideNameJob::Private BaseJob::Query queryToGetContentOverrideName(bool allowRemote) { BaseJob::Query _q; - addToQuery(_q, "allow_remote", allowRemote); + addParam(_q, "allow_remote", allowRemote); return _q; } @@ -175,24 +175,24 @@ class GetContentThumbnailJob::Private QIODevice* data; }; -BaseJob::Query queryToGetContentThumbnail(Omittable width, Omittable height, const QString& method, bool allowRemote) +BaseJob::Query queryToGetContentThumbnail(int width, int height, const QString& method, bool allowRemote) { BaseJob::Query _q; - addToQuery(_q, "width", width); - addToQuery(_q, "height", height); - addToQuery(_q, "method", method); - addToQuery(_q, "allow_remote", allowRemote); + addParam<>(_q, "width", width); + addParam<>(_q, "height", height); + addParam(_q, "method", method); + addParam(_q, "allow_remote", allowRemote); return _q; } -QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, Omittable width, Omittable height, const QString& method, bool allowRemote) +QUrl GetContentThumbnailJob::makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method, bool allowRemote) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote)); } -GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, Omittable width, Omittable height, const QString& method, bool allowRemote) +GetContentThumbnailJob::GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, int height, const QString& method, bool allowRemote) : BaseJob(HttpVerb::Get, "GetContentThumbnailJob", basePath % "/thumbnail/" % serverName % "/" % mediaId, queryToGetContentThumbnail(width, height, method, allowRemote), @@ -231,8 +231,8 @@ class GetUrlPreviewJob::Private BaseJob::Query queryToGetUrlPreview(const QString& url, Omittable ts) { BaseJob::Query _q; - addToQuery<>(_q, "url", url); - addToQuery(_q, "ts", ts); + addParam<>(_q, "url", url); + addParam(_q, "ts", ts); return _q; } diff --git a/lib/csapi/content-repo.h b/lib/csapi/content-repo.h index f3b90c9d..0883c776 100644 --- a/lib/csapi/content-repo.h +++ b/lib/csapi/content-repo.h @@ -90,14 +90,14 @@ namespace QMatrixClient class GetContentThumbnailJob : public BaseJob { public: - explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, Omittable width = none, Omittable height = none, const QString& method = {}, bool allowRemote = true); + explicit GetContentThumbnailJob(const QString& serverName, const QString& mediaId, int width, int height, const QString& method = {}, bool allowRemote = true); /** Construct a URL out of baseUrl and usual parameters passed to * GetContentThumbnailJob. This function can be used when * a URL for GetContentThumbnailJob is necessary but the job * itself isn't. */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, Omittable width = none, Omittable height = none, const QString& method = {}, bool allowRemote = true); + static QUrl makeRequestUrl(QUrl baseUrl, const QString& serverName, const QString& mediaId, int width, int height, const QString& method = {}, bool allowRemote = true); ~GetContentThumbnailJob() override; diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp index 17a9c60f..910210bc 100644 --- a/lib/csapi/create_room.cpp +++ b/lib/csapi/create_room.cpp @@ -19,18 +19,18 @@ namespace QMatrixClient QJsonObject toJson(const CreateRoomJob::Invite3pid& pod) { QJsonObject _json; - addToJson<>(_json, "id_server", pod.idServer); - addToJson<>(_json, "medium", pod.medium); - addToJson<>(_json, "address", pod.address); + addParam<>(_json, "id_server", pod.idServer); + addParam<>(_json, "medium", pod.medium); + addParam<>(_json, "address", pod.address); return _json; } QJsonObject toJson(const CreateRoomJob::StateEvent& pod) { QJsonObject _json; - addToJson(_json, "type", pod.type); - addToJson(_json, "state_key", pod.stateKey); - addToJson(_json, "content", pod.content); + addParam(_json, "type", pod.type); + addParam(_json, "state_key", pod.stateKey); + addParam(_json, "content", pod.content); return _json; } } // namespace QMatrixClient @@ -47,17 +47,17 @@ CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAlias , d(new Private) { QJsonObject _data; - addToJson(_data, "visibility", visibility); - addToJson(_data, "room_alias_name", roomAliasName); - addToJson(_data, "name", name); - addToJson(_data, "topic", topic); - addToJson(_data, "invite", invite); - addToJson(_data, "invite_3pid", invite3pid); - addToJson(_data, "creation_content", creationContent); - addToJson(_data, "initial_state", initialState); - addToJson(_data, "preset", preset); - addToJson(_data, "is_direct", isDirect); - addToJson(_data, "guest_can_join", guestCanJoin); + addParam(_data, "visibility", visibility); + addParam(_data, "room_alias_name", roomAliasName); + addParam(_data, "name", name); + addParam(_data, "topic", topic); + addParam(_data, "invite", invite); + addParam(_data, "invite_3pid", invite3pid); + addParam(_data, "creation_content", creationContent); + addParam(_data, "initial_state", initialState); + addParam(_data, "preset", preset); + addParam(_data, "is_direct", isDirect); + addParam(_data, "guest_can_join", guestCanJoin); setRequestData(_data); } diff --git a/lib/csapi/definitions/client_device.cpp b/lib/csapi/definitions/client_device.cpp index 60b3617c..7c3d7ea6 100644 --- a/lib/csapi/definitions/client_device.cpp +++ b/lib/csapi/definitions/client_device.cpp @@ -9,10 +9,10 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const Device& pod) { QJsonObject _json; - addToJson<>(_json, "device_id", pod.deviceId); - addToJson(_json, "display_name", pod.displayName); - addToJson(_json, "last_seen_ip", pod.lastSeenIp); - addToJson(_json, "last_seen_ts", pod.lastSeenTs); + addParam<>(_json, "device_id", pod.deviceId); + addParam(_json, "display_name", pod.displayName); + addParam(_json, "last_seen_ip", pod.lastSeenIp); + addParam(_json, "last_seen_ts", pod.lastSeenTs); return _json; } diff --git a/lib/csapi/definitions/device_keys.cpp b/lib/csapi/definitions/device_keys.cpp index 24357993..43cd5d2e 100644 --- a/lib/csapi/definitions/device_keys.cpp +++ b/lib/csapi/definitions/device_keys.cpp @@ -9,11 +9,11 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const DeviceKeys& pod) { QJsonObject _json; - addToJson<>(_json, "user_id", pod.userId); - addToJson<>(_json, "device_id", pod.deviceId); - addToJson<>(_json, "algorithms", pod.algorithms); - addToJson<>(_json, "keys", pod.keys); - addToJson<>(_json, "signatures", pod.signatures); + addParam<>(_json, "user_id", pod.userId); + addParam<>(_json, "device_id", pod.deviceId); + addParam<>(_json, "algorithms", pod.algorithms); + addParam<>(_json, "keys", pod.keys); + addParam<>(_json, "signatures", pod.signatures); return _json; } diff --git a/lib/csapi/definitions/event_filter.cpp b/lib/csapi/definitions/event_filter.cpp index b16b082d..21ee2b81 100644 --- a/lib/csapi/definitions/event_filter.cpp +++ b/lib/csapi/definitions/event_filter.cpp @@ -9,11 +9,11 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const Filter& pod) { QJsonObject _json; - addToJson(_json, "limit", pod.limit); - addToJson(_json, "not_senders", pod.notSenders); - addToJson(_json, "not_types", pod.notTypes); - addToJson(_json, "senders", pod.senders); - addToJson(_json, "types", pod.types); + addParam(_json, "limit", pod.limit); + addParam(_json, "not_senders", pod.notSenders); + addParam(_json, "not_types", pod.notTypes); + addParam(_json, "senders", pod.senders); + addParam(_json, "types", pod.types); return _json; } diff --git a/lib/csapi/definitions/push_condition.cpp b/lib/csapi/definitions/push_condition.cpp index 149419f4..b8595ec6 100644 --- a/lib/csapi/definitions/push_condition.cpp +++ b/lib/csapi/definitions/push_condition.cpp @@ -9,10 +9,10 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const PushCondition& pod) { QJsonObject _json; - addToJson<>(_json, "kind", pod.kind); - addToJson(_json, "key", pod.key); - addToJson(_json, "pattern", pod.pattern); - addToJson(_json, "is", pod.is); + addParam<>(_json, "kind", pod.kind); + addParam(_json, "key", pod.key); + addParam(_json, "pattern", pod.pattern); + addParam(_json, "is", pod.is); return _json; } diff --git a/lib/csapi/definitions/push_rule.cpp b/lib/csapi/definitions/push_rule.cpp index 3a44a385..98f5d788 100644 --- a/lib/csapi/definitions/push_rule.cpp +++ b/lib/csapi/definitions/push_rule.cpp @@ -9,12 +9,12 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const PushRule& pod) { QJsonObject _json; - addToJson<>(_json, "actions", pod.actions); - addToJson<>(_json, "default", pod.isDefault); - addToJson<>(_json, "enabled", pod.enabled); - addToJson<>(_json, "rule_id", pod.ruleId); - addToJson(_json, "conditions", pod.conditions); - addToJson(_json, "pattern", pod.pattern); + addParam<>(_json, "actions", pod.actions); + addParam<>(_json, "default", pod.isDefault); + addParam<>(_json, "enabled", pod.enabled); + addParam<>(_json, "rule_id", pod.ruleId); + addParam(_json, "conditions", pod.conditions); + addParam(_json, "pattern", pod.pattern); return _json; } diff --git a/lib/csapi/definitions/push_ruleset.cpp b/lib/csapi/definitions/push_ruleset.cpp index 98d79248..ca2bbc0d 100644 --- a/lib/csapi/definitions/push_ruleset.cpp +++ b/lib/csapi/definitions/push_ruleset.cpp @@ -9,11 +9,11 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const PushRuleset& pod) { QJsonObject _json; - addToJson(_json, "content", pod.content); - addToJson(_json, "override", pod.override); - addToJson(_json, "room", pod.room); - addToJson(_json, "sender", pod.sender); - addToJson(_json, "underride", pod.underride); + addParam(_json, "content", pod.content); + addParam(_json, "override", pod.override); + addParam(_json, "room", pod.room); + addParam(_json, "sender", pod.sender); + addParam(_json, "underride", pod.underride); return _json; } diff --git a/lib/csapi/definitions/room_event_filter.cpp b/lib/csapi/definitions/room_event_filter.cpp index 68e56f4c..1702be22 100644 --- a/lib/csapi/definitions/room_event_filter.cpp +++ b/lib/csapi/definitions/room_event_filter.cpp @@ -9,9 +9,9 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const RoomEventFilter& pod) { QJsonObject _json; - addToJson(_json, "not_rooms", pod.notRooms); - addToJson(_json, "rooms", pod.rooms); - addToJson(_json, "contains_url", pod.containsUrl); + addParam(_json, "not_rooms", pod.notRooms); + addParam(_json, "rooms", pod.rooms); + addParam(_json, "contains_url", pod.containsUrl); return _json; } diff --git a/lib/csapi/definitions/sync_filter.cpp b/lib/csapi/definitions/sync_filter.cpp index 7ca389b4..2b5cf8be 100644 --- a/lib/csapi/definitions/sync_filter.cpp +++ b/lib/csapi/definitions/sync_filter.cpp @@ -9,13 +9,13 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const RoomFilter& pod) { QJsonObject _json; - addToJson(_json, "not_rooms", pod.notRooms); - addToJson(_json, "rooms", pod.rooms); - addToJson(_json, "ephemeral", pod.ephemeral); - addToJson(_json, "include_leave", pod.includeLeave); - addToJson(_json, "state", pod.state); - addToJson(_json, "timeline", pod.timeline); - addToJson(_json, "account_data", pod.accountData); + addParam(_json, "not_rooms", pod.notRooms); + addParam(_json, "rooms", pod.rooms); + addParam(_json, "ephemeral", pod.ephemeral); + addParam(_json, "include_leave", pod.includeLeave); + addParam(_json, "state", pod.state); + addParam(_json, "timeline", pod.timeline); + addParam(_json, "account_data", pod.accountData); return _json; } @@ -44,11 +44,11 @@ RoomFilter FromJson::operator()(const QJsonValue& jv) QJsonObject QMatrixClient::toJson(const SyncFilter& pod) { QJsonObject _json; - addToJson(_json, "event_fields", pod.eventFields); - addToJson(_json, "event_format", pod.eventFormat); - addToJson(_json, "presence", pod.presence); - addToJson(_json, "account_data", pod.accountData); - addToJson(_json, "room", pod.room); + addParam(_json, "event_fields", pod.eventFields); + addParam(_json, "event_format", pod.eventFormat); + addParam(_json, "presence", pod.presence); + addParam(_json, "account_data", pod.accountData); + addParam(_json, "room", pod.room); return _json; } diff --git a/lib/csapi/device_management.cpp b/lib/csapi/device_management.cpp index 2248a0b4..a4b2daae 100644 --- a/lib/csapi/device_management.cpp +++ b/lib/csapi/device_management.cpp @@ -86,7 +86,7 @@ UpdateDeviceJob::UpdateDeviceJob(const QString& deviceId, const QString& display basePath % "/devices/" % deviceId) { QJsonObject _data; - addToJson(_data, "display_name", displayName); + addParam(_data, "display_name", displayName); setRequestData(_data); } @@ -95,7 +95,7 @@ DeleteDeviceJob::DeleteDeviceJob(const QString& deviceId, const QJsonObject& aut basePath % "/devices/" % deviceId) { QJsonObject _data; - addToJson(_data, "auth", auth); + addParam(_data, "auth", auth); setRequestData(_data); } @@ -104,8 +104,8 @@ DeleteDevicesJob::DeleteDevicesJob(const QStringList& devices, const QJsonObject basePath % "/delete_devices") { QJsonObject _data; - addToJson<>(_data, "devices", devices); - addToJson(_data, "auth", auth); + addParam<>(_data, "devices", devices); + addParam(_data, "auth", auth); setRequestData(_data); } diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp index d5c5882f..7e8b87b8 100644 --- a/lib/csapi/directory.cpp +++ b/lib/csapi/directory.cpp @@ -17,7 +17,7 @@ SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId basePath % "/room/" % roomAlias) { QJsonObject _data; - addToJson(_data, "room_id", roomId); + addParam(_data, "room_id", roomId); setRequestData(_data); } diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index 37de58ab..9e4c6963 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -26,7 +26,7 @@ class GetEventContextJob::Private BaseJob::Query queryToGetEventContext(Omittable limit) { BaseJob::Query _q; - addToQuery(_q, "limit", limit); + addParam(_q, "limit", limit); return _q; } diff --git a/lib/csapi/inviting.cpp b/lib/csapi/inviting.cpp index 6f180e6c..94e0910b 100644 --- a/lib/csapi/inviting.cpp +++ b/lib/csapi/inviting.cpp @@ -17,7 +17,7 @@ InviteUserJob::InviteUserJob(const QString& roomId, const QString& userId) basePath % "/rooms/" % roomId % "/invite") { QJsonObject _data; - addToJson<>(_data, "user_id", userId); + addParam<>(_data, "user_id", userId); setRequestData(_data); } diff --git a/lib/csapi/joining.cpp b/lib/csapi/joining.cpp index 90aa58c4..f2d6fbf7 100644 --- a/lib/csapi/joining.cpp +++ b/lib/csapi/joining.cpp @@ -19,10 +19,10 @@ namespace QMatrixClient QJsonObject toJson(const JoinRoomByIdJob::ThirdPartySigned& pod) { QJsonObject _json; - addToJson<>(_json, "sender", pod.sender); - addToJson<>(_json, "mxid", pod.mxid); - addToJson<>(_json, "token", pod.token); - addToJson<>(_json, "signatures", pod.signatures); + addParam<>(_json, "sender", pod.sender); + addParam<>(_json, "mxid", pod.mxid); + addParam<>(_json, "token", pod.token); + addParam<>(_json, "signatures", pod.signatures); return _json; } } // namespace QMatrixClient @@ -39,7 +39,7 @@ JoinRoomByIdJob::JoinRoomByIdJob(const QString& roomId, const Omittable(_data, "third_party_signed", thirdPartySigned); + addParam(_data, "third_party_signed", thirdPartySigned); setRequestData(_data); } @@ -67,17 +67,17 @@ namespace QMatrixClient QJsonObject toJson(const JoinRoomJob::Signed& pod) { QJsonObject _json; - addToJson<>(_json, "sender", pod.sender); - addToJson<>(_json, "mxid", pod.mxid); - addToJson<>(_json, "token", pod.token); - addToJson<>(_json, "signatures", pod.signatures); + addParam<>(_json, "sender", pod.sender); + addParam<>(_json, "mxid", pod.mxid); + addParam<>(_json, "token", pod.token); + addParam<>(_json, "signatures", pod.signatures); return _json; } QJsonObject toJson(const JoinRoomJob::ThirdPartySigned& pod) { QJsonObject _json; - addToJson<>(_json, "signed", pod.signedData); + addParam<>(_json, "signed", pod.signedData); return _json; } } // namespace QMatrixClient @@ -94,7 +94,7 @@ JoinRoomJob::JoinRoomJob(const QString& roomIdOrAlias, const Omittable(_data, "third_party_signed", thirdPartySigned); + addParam(_data, "third_party_signed", thirdPartySigned); setRequestData(_data); } diff --git a/lib/csapi/keys.cpp b/lib/csapi/keys.cpp index 88d6690b..4a76b7e2 100644 --- a/lib/csapi/keys.cpp +++ b/lib/csapi/keys.cpp @@ -24,8 +24,8 @@ UploadKeysJob::UploadKeysJob(const Omittable& deviceKeys, const QHas , d(new Private) { QJsonObject _data; - addToJson(_data, "device_keys", deviceKeys); - addToJson(_data, "one_time_keys", oneTimeKeys); + addParam(_data, "device_keys", deviceKeys); + addParam(_data, "one_time_keys", oneTimeKeys); setRequestData(_data); } @@ -90,9 +90,9 @@ QueryKeysJob::QueryKeysJob(const QHash& deviceKeys, Omitta , d(new Private) { QJsonObject _data; - addToJson(_data, "timeout", timeout); - addToJson<>(_data, "device_keys", deviceKeys); - addToJson(_data, "token", token); + addParam(_data, "timeout", timeout); + addParam<>(_data, "device_keys", deviceKeys); + addParam(_data, "token", token); setRequestData(_data); } @@ -129,8 +129,8 @@ ClaimKeysJob::ClaimKeysJob(const QHash>& oneTim , d(new Private) { QJsonObject _data; - addToJson(_data, "timeout", timeout); - addToJson<>(_data, "one_time_keys", oneTimeKeys); + addParam(_data, "timeout", timeout); + addParam<>(_data, "one_time_keys", oneTimeKeys); setRequestData(_data); } @@ -164,8 +164,8 @@ class GetKeysChangesJob::Private BaseJob::Query queryToGetKeysChanges(const QString& from, const QString& to) { BaseJob::Query _q; - addToQuery<>(_q, "from", from); - addToQuery<>(_q, "to", to); + addParam<>(_q, "from", from); + addParam<>(_q, "to", to); return _q; } diff --git a/lib/csapi/kicking.cpp b/lib/csapi/kicking.cpp index e143166a..73ef70ae 100644 --- a/lib/csapi/kicking.cpp +++ b/lib/csapi/kicking.cpp @@ -17,8 +17,8 @@ KickJob::KickJob(const QString& roomId, const QString& userId, const QString& re basePath % "/rooms/" % roomId % "/kick") { QJsonObject _data; - addToJson<>(_data, "user_id", userId); - addToJson(_data, "reason", reason); + addParam<>(_data, "user_id", userId); + addParam(_data, "reason", reason); setRequestData(_data); } diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index 5952fd6e..5d605bbb 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -50,7 +50,7 @@ SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& basePath % "/directory/list/room/" % roomId) { QJsonObject _data; - addToJson(_data, "visibility", visibility); + addParam(_data, "visibility", visibility); setRequestData(_data); } @@ -100,9 +100,9 @@ class GetPublicRoomsJob::Private BaseJob::Query queryToGetPublicRooms(Omittable limit, const QString& since, const QString& server) { BaseJob::Query _q; - addToQuery(_q, "limit", limit); - addToQuery(_q, "since", since); - addToQuery(_q, "server", server); + addParam(_q, "limit", limit); + addParam(_q, "since", since); + addParam(_q, "server", server); return _q; } @@ -164,7 +164,7 @@ namespace QMatrixClient QJsonObject toJson(const QueryPublicRoomsJob::Filter& pod) { QJsonObject _json; - addToJson(_json, "generic_search_term", pod.genericSearchTerm); + addParam(_json, "generic_search_term", pod.genericSearchTerm); return _json; } @@ -210,7 +210,7 @@ class QueryPublicRoomsJob::Private BaseJob::Query queryToQueryPublicRooms(const QString& server) { BaseJob::Query _q; - addToQuery(_q, "server", server); + addParam(_q, "server", server); return _q; } @@ -221,9 +221,9 @@ QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable l , d(new Private) { QJsonObject _data; - addToJson(_data, "limit", limit); - addToJson(_data, "since", since); - addToJson(_data, "filter", filter); + addParam(_data, "limit", limit); + addParam(_data, "since", since); + addParam(_data, "filter", filter); setRequestData(_data); } diff --git a/lib/csapi/login.cpp b/lib/csapi/login.cpp index 7e162871..e0795f8a 100644 --- a/lib/csapi/login.cpp +++ b/lib/csapi/login.cpp @@ -27,14 +27,14 @@ LoginJob::LoginJob(const QString& type, const QString& user, const QString& medi , d(new Private) { QJsonObject _data; - addToJson<>(_data, "type", type); - addToJson(_data, "user", user); - addToJson(_data, "medium", medium); - addToJson(_data, "address", address); - addToJson(_data, "password", password); - addToJson(_data, "token", token); - addToJson(_data, "device_id", deviceId); - addToJson(_data, "initial_device_display_name", initialDeviceDisplayName); + addParam<>(_data, "type", type); + addParam(_data, "user", user); + addParam(_data, "medium", medium); + addParam(_data, "address", address); + addParam(_data, "password", password); + addParam(_data, "token", token); + addParam(_data, "device_id", deviceId); + addParam(_data, "initial_device_display_name", initialDeviceDisplayName); setRequestData(_data); } diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp index 1a7d6ee9..1eb2aa07 100644 --- a/lib/csapi/message_pagination.cpp +++ b/lib/csapi/message_pagination.cpp @@ -23,11 +23,11 @@ class GetRoomEventsJob::Private BaseJob::Query queryToGetRoomEvents(const QString& from, const QString& to, const QString& dir, Omittable limit, const QString& filter) { BaseJob::Query _q; - addToQuery<>(_q, "from", from); - addToQuery(_q, "to", to); - addToQuery<>(_q, "dir", dir); - addToQuery(_q, "limit", limit); - addToQuery(_q, "filter", filter); + addParam<>(_q, "from", from); + addParam(_q, "to", to); + addParam<>(_q, "dir", dir); + addParam(_q, "limit", limit); + addParam(_q, "filter", filter); return _q; } diff --git a/lib/csapi/notifications.cpp b/lib/csapi/notifications.cpp index de5b41f2..39570991 100644 --- a/lib/csapi/notifications.cpp +++ b/lib/csapi/notifications.cpp @@ -50,9 +50,9 @@ class GetNotificationsJob::Private BaseJob::Query queryToGetNotifications(const QString& from, Omittable limit, const QString& only) { BaseJob::Query _q; - addToQuery(_q, "from", from); - addToQuery(_q, "limit", limit); - addToQuery(_q, "only", only); + addParam(_q, "from", from); + addParam(_q, "limit", limit); + addParam(_q, "only", only); return _q; } diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index 53f2d280..b3be7631 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -23,9 +23,9 @@ class PeekEventsJob::Private BaseJob::Query queryToPeekEvents(const QString& from, Omittable timeout, const QString& roomId) { BaseJob::Query _q; - addToQuery(_q, "from", from); - addToQuery(_q, "timeout", timeout); - addToQuery(_q, "room_id", roomId); + addParam(_q, "from", from); + addParam(_q, "timeout", timeout); + addParam(_q, "room_id", roomId); return _q; } diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 707d48d0..35b2c960 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -17,8 +17,8 @@ SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, c basePath % "/presence/" % userId % "/status") { QJsonObject _data; - addToJson<>(_data, "presence", presence); - addToJson(_data, "status_msg", statusMsg); + addParam<>(_data, "presence", presence); + addParam(_data, "status_msg", statusMsg); setRequestData(_data); } @@ -84,8 +84,8 @@ ModifyPresenceListJob::ModifyPresenceListJob(const QString& userId, const QStrin basePath % "/presence/list/" % userId) { QJsonObject _data; - addToJson(_data, "invite", invite); - addToJson(_data, "drop", drop); + addParam(_data, "invite", invite); + addParam(_data, "drop", drop); setRequestData(_data); } diff --git a/lib/csapi/profile.cpp b/lib/csapi/profile.cpp index 6b93d961..b08eb970 100644 --- a/lib/csapi/profile.cpp +++ b/lib/csapi/profile.cpp @@ -17,7 +17,7 @@ SetDisplayNameJob::SetDisplayNameJob(const QString& userId, const QString& displ basePath % "/profile/" % userId % "/displayname") { QJsonObject _data; - addToJson(_data, "displayname", displayname); + addParam(_data, "displayname", displayname); setRequestData(_data); } @@ -59,7 +59,7 @@ SetAvatarUrlJob::SetAvatarUrlJob(const QString& userId, const QString& avatarUrl basePath % "/profile/" % userId % "/avatar_url") { QJsonObject _data; - addToJson(_data, "avatar_url", avatarUrl); + addParam(_data, "avatar_url", avatarUrl); setRequestData(_data); } diff --git a/lib/csapi/pusher.cpp b/lib/csapi/pusher.cpp index ba5229d3..1a43900b 100644 --- a/lib/csapi/pusher.cpp +++ b/lib/csapi/pusher.cpp @@ -97,7 +97,7 @@ namespace QMatrixClient QJsonObject toJson(const PostPusherJob::PusherData& pod) { QJsonObject _json; - addToJson(_json, "url", pod.url); + addParam(_json, "url", pod.url); return _json; } } // namespace QMatrixClient @@ -107,15 +107,15 @@ PostPusherJob::PostPusherJob(const QString& pushkey, const QString& kind, const basePath % "/pushers/set") { QJsonObject _data; - addToJson<>(_data, "pushkey", pushkey); - addToJson<>(_data, "kind", kind); - addToJson<>(_data, "app_id", appId); - addToJson<>(_data, "app_display_name", appDisplayName); - addToJson<>(_data, "device_display_name", deviceDisplayName); - addToJson(_data, "profile_tag", profileTag); - addToJson<>(_data, "lang", lang); - addToJson<>(_data, "data", data); - addToJson(_data, "append", append); + addParam<>(_data, "pushkey", pushkey); + addParam<>(_data, "kind", kind); + addParam<>(_data, "app_id", appId); + addParam<>(_data, "app_display_name", appDisplayName); + addParam<>(_data, "device_display_name", deviceDisplayName); + addParam(_data, "profile_tag", profileTag); + addParam<>(_data, "lang", lang); + addParam<>(_data, "data", data); + addParam(_data, "append", append); setRequestData(_data); } diff --git a/lib/csapi/pushrules.cpp b/lib/csapi/pushrules.cpp index 807f1d0f..d7e416dc 100644 --- a/lib/csapi/pushrules.cpp +++ b/lib/csapi/pushrules.cpp @@ -99,8 +99,8 @@ DeletePushRuleJob::DeletePushRuleJob(const QString& scope, const QString& kind, BaseJob::Query queryToSetPushRule(const QString& before, const QString& after) { BaseJob::Query _q; - addToQuery(_q, "before", before); - addToQuery(_q, "after", after); + addParam(_q, "before", before); + addParam(_q, "after", after); return _q; } @@ -110,9 +110,9 @@ SetPushRuleJob::SetPushRuleJob(const QString& scope, const QString& kind, const queryToSetPushRule(before, after)) { QJsonObject _data; - addToJson<>(_data, "actions", actions); - addToJson(_data, "conditions", conditions); - addToJson(_data, "pattern", pattern); + addParam<>(_data, "actions", actions); + addParam(_data, "conditions", conditions); + addParam(_data, "pattern", pattern); setRequestData(_data); } @@ -157,7 +157,7 @@ SetPushRuleEnabledJob::SetPushRuleEnabledJob(const QString& scope, const QString basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/enabled") { QJsonObject _data; - addToJson<>(_data, "enabled", enabled); + addParam<>(_data, "enabled", enabled); setRequestData(_data); } @@ -202,7 +202,7 @@ SetPushRuleActionsJob::SetPushRuleActionsJob(const QString& scope, const QString basePath % "/pushrules/" % scope % "/" % kind % "/" % ruleId % "/actions") { QJsonObject _data; - addToJson<>(_data, "actions", actions); + addParam<>(_data, "actions", actions); setRequestData(_data); } diff --git a/lib/csapi/redaction.cpp b/lib/csapi/redaction.cpp index aa6e3b65..2c73800c 100644 --- a/lib/csapi/redaction.cpp +++ b/lib/csapi/redaction.cpp @@ -24,7 +24,7 @@ RedactEventJob::RedactEventJob(const QString& roomId, const QString& eventId, co , d(new Private) { QJsonObject _data; - addToJson(_data, "reason", reason); + addParam(_data, "reason", reason); setRequestData(_data); } diff --git a/lib/csapi/registration.cpp b/lib/csapi/registration.cpp index 85a3e256..4345635a 100644 --- a/lib/csapi/registration.cpp +++ b/lib/csapi/registration.cpp @@ -24,7 +24,7 @@ class RegisterJob::Private BaseJob::Query queryToRegister(const QString& kind) { BaseJob::Query _q; - addToQuery(_q, "kind", kind); + addParam(_q, "kind", kind); return _q; } @@ -36,12 +36,12 @@ RegisterJob::RegisterJob(const QString& kind, const QJsonObject& auth, bool bind , d(new Private) { QJsonObject _data; - addToJson(_data, "auth", auth); - addToJson(_data, "bind_email", bindEmail); - addToJson(_data, "username", username); - addToJson(_data, "password", password); - addToJson(_data, "device_id", deviceId); - addToJson(_data, "initial_device_display_name", initialDeviceDisplayName); + addParam(_data, "auth", auth); + addParam(_data, "bind_email", bindEmail); + addParam(_data, "username", username); + addParam(_data, "password", password); + addParam(_data, "device_id", deviceId); + addParam(_data, "initial_device_display_name", initialDeviceDisplayName); setRequestData(_data); } @@ -82,10 +82,10 @@ RequestTokenToRegisterJob::RequestTokenToRegisterJob(const QString& clientSecret basePath % "/register/email/requestToken", false) { QJsonObject _data; - addToJson(_data, "id_server", idServer); - addToJson<>(_data, "client_secret", clientSecret); - addToJson<>(_data, "email", email); - addToJson<>(_data, "send_attempt", sendAttempt); + addParam(_data, "id_server", idServer); + addParam<>(_data, "client_secret", clientSecret); + addParam<>(_data, "email", email); + addParam<>(_data, "send_attempt", sendAttempt); setRequestData(_data); } @@ -94,8 +94,8 @@ ChangePasswordJob::ChangePasswordJob(const QString& newPassword, const QJsonObje basePath % "/account/password") { QJsonObject _data; - addToJson<>(_data, "new_password", newPassword); - addToJson(_data, "auth", auth); + addParam<>(_data, "new_password", newPassword); + addParam(_data, "auth", auth); setRequestData(_data); } @@ -116,7 +116,7 @@ DeactivateAccountJob::DeactivateAccountJob(const QJsonObject& auth) basePath % "/account/deactivate") { QJsonObject _data; - addToJson(_data, "auth", auth); + addParam(_data, "auth", auth); setRequestData(_data); } @@ -129,7 +129,7 @@ class CheckUsernameAvailabilityJob::Private BaseJob::Query queryToCheckUsernameAvailability(const QString& username) { BaseJob::Query _q; - addToQuery<>(_q, "username", username); + addParam<>(_q, "username", username); return _q; } diff --git a/lib/csapi/report_content.cpp b/lib/csapi/report_content.cpp index 9d19e012..f1a1d6f2 100644 --- a/lib/csapi/report_content.cpp +++ b/lib/csapi/report_content.cpp @@ -17,8 +17,8 @@ ReportContentJob::ReportContentJob(const QString& roomId, const QString& eventId basePath % "/rooms/" % roomId % "/report/" % eventId) { QJsonObject _data; - addToJson<>(_data, "score", score); - addToJson<>(_data, "reason", reason); + addParam<>(_data, "score", score); + addParam<>(_data, "reason", reason); setRequestData(_data); } diff --git a/lib/csapi/search.cpp b/lib/csapi/search.cpp index d172dfbe..75748b38 100644 --- a/lib/csapi/search.cpp +++ b/lib/csapi/search.cpp @@ -19,43 +19,43 @@ namespace QMatrixClient QJsonObject toJson(const SearchJob::IncludeEventContext& pod) { QJsonObject _json; - addToJson(_json, "before_limit", pod.beforeLimit); - addToJson(_json, "after_limit", pod.afterLimit); - addToJson(_json, "include_profile", pod.includeProfile); + addParam(_json, "before_limit", pod.beforeLimit); + addParam(_json, "after_limit", pod.afterLimit); + addParam(_json, "include_profile", pod.includeProfile); return _json; } QJsonObject toJson(const SearchJob::Group& pod) { QJsonObject _json; - addToJson(_json, "key", pod.key); + addParam(_json, "key", pod.key); return _json; } QJsonObject toJson(const SearchJob::Groupings& pod) { QJsonObject _json; - addToJson(_json, "group_by", pod.groupBy); + addParam(_json, "group_by", pod.groupBy); return _json; } QJsonObject toJson(const SearchJob::RoomEventsCriteria& pod) { QJsonObject _json; - addToJson<>(_json, "search_term", pod.searchTerm); - addToJson(_json, "keys", pod.keys); - addToJson(_json, "filter", pod.filter); - addToJson(_json, "order_by", pod.orderBy); - addToJson(_json, "event_context", pod.eventContext); - addToJson(_json, "include_state", pod.includeState); - addToJson(_json, "groupings", pod.groupings); + addParam<>(_json, "search_term", pod.searchTerm); + addParam(_json, "keys", pod.keys); + addParam(_json, "filter", pod.filter); + addParam(_json, "order_by", pod.orderBy); + addParam(_json, "event_context", pod.eventContext); + addParam(_json, "include_state", pod.includeState); + addParam(_json, "groupings", pod.groupings); return _json; } QJsonObject toJson(const SearchJob::Categories& pod) { QJsonObject _json; - addToJson(_json, "room_events", pod.roomEvents); + addParam(_json, "room_events", pod.roomEvents); return _json; } @@ -173,7 +173,7 @@ class SearchJob::Private BaseJob::Query queryToSearch(const QString& nextBatch) { BaseJob::Query _q; - addToQuery(_q, "next_batch", nextBatch); + addParam(_q, "next_batch", nextBatch); return _q; } @@ -184,7 +184,7 @@ SearchJob::SearchJob(const Categories& searchCategories, const QString& nextBatc , d(new Private) { QJsonObject _data; - addToJson<>(_data, "search_categories", searchCategories); + addParam<>(_data, "search_categories", searchCategories); setRequestData(_data); } diff --git a/lib/csapi/third_party_membership.cpp b/lib/csapi/third_party_membership.cpp index 4cdad48b..2372f9d7 100644 --- a/lib/csapi/third_party_membership.cpp +++ b/lib/csapi/third_party_membership.cpp @@ -17,9 +17,9 @@ InviteBy3PIDJob::InviteBy3PIDJob(const QString& roomId, const QString& idServer, basePath % "/rooms/" % roomId % "/invite") { QJsonObject _data; - addToJson<>(_data, "id_server", idServer); - addToJson<>(_data, "medium", medium); - addToJson<>(_data, "address", address); + addParam<>(_data, "id_server", idServer); + addParam<>(_data, "medium", medium); + addParam<>(_data, "address", address); setRequestData(_data); } diff --git a/lib/csapi/to_device.cpp b/lib/csapi/to_device.cpp index dfc47ab5..1478a679 100644 --- a/lib/csapi/to_device.cpp +++ b/lib/csapi/to_device.cpp @@ -17,7 +17,7 @@ SendToDeviceJob::SendToDeviceJob(const QString& eventType, const QString& txnId, basePath % "/sendToDevice/" % eventType % "/" % txnId) { QJsonObject _data; - addToJson(_data, "messages", messages); + addParam(_data, "messages", messages); setRequestData(_data); } diff --git a/lib/csapi/typing.cpp b/lib/csapi/typing.cpp index 605e143a..6db522c4 100644 --- a/lib/csapi/typing.cpp +++ b/lib/csapi/typing.cpp @@ -17,8 +17,8 @@ SetTypingJob::SetTypingJob(const QString& userId, const QString& roomId, bool ty basePath % "/rooms/" % roomId % "/typing/" % userId) { QJsonObject _data; - addToJson<>(_data, "typing", typing); - addToJson(_data, "timeout", timeout); + addParam<>(_data, "typing", typing); + addParam(_data, "timeout", timeout); setRequestData(_data); } diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp index a27be93b..e7f68bda 100644 --- a/lib/csapi/users.cpp +++ b/lib/csapi/users.cpp @@ -47,8 +47,8 @@ SearchUserDirectoryJob::SearchUserDirectoryJob(const QString& searchTerm, Omitta , d(new Private) { QJsonObject _data; - addToJson<>(_data, "search_term", searchTerm); - addToJson(_data, "limit", limit); + addParam<>(_data, "search_term", searchTerm); + addParam(_data, "limit", limit); setRequestData(_data); } diff --git a/lib/csapi/{{base}}.cpp.mustache b/lib/csapi/{{base}}.cpp.mustache index 0955984d..0800fef7 100644 --- a/lib/csapi/{{base}}.cpp.mustache +++ b/lib/csapi/{{base}}.cpp.mustache @@ -11,7 +11,7 @@ using namespace QMatrixClient; QJsonObject QMatrixClient::toJson(const {{qualifiedName}}& pod) { QJsonObject _json;{{#vars}} - addToJson<{{^required?}}IfNotEmpty{{/required?}}>(_json, "{{baseName}}", pod.{{nameCamelCase}});{{/vars}} + addParam<{{^required?}}IfNotEmpty{{/required?}}>(_json, "{{baseName}}", pod.{{nameCamelCase}});{{/vars}} return _json; } {{/in?}}{{#out?}} @@ -34,7 +34,7 @@ namespace QMatrixClient QJsonObject toJson(const {{qualifiedName}}& pod) { QJsonObject _json;{{#vars}} - addToJson<{{^required?}}IfNotEmpty{{/required?}}>(_json, "{{baseName}}", pod.{{nameCamelCase}});{{/vars}} + addParam<{{^required?}}IfNotEmpty{{/required?}}>(_json, "{{baseName}}", pod.{{nameCamelCase}});{{/vars}} return _json; } {{/in?}}{{#out?}} @@ -61,7 +61,7 @@ class {{camelCaseOperationId}}Job::Private BaseJob::Query queryTo{{camelCaseOperationId}}({{#queryParams}}{{>joinedParamDef}}{{/queryParams}}) { BaseJob::Query _q;{{#queryParams}} - addToQuery<{{^required?}}IfNotEmpty{{/required?}}>(_q, "{{baseName}}", {{paramName}});{{/queryParams}} + addParam<{{^required?}}IfNotEmpty{{/required?}}>(_q, "{{baseName}}", {{paramName}});{{/queryParams}} return _q; } {{/queryParams?}}{{^bodyParams}} @@ -87,7 +87,7 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{ }}{{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson? }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}}));{{/inlineBody }}{{^inlineBody}} QJsonObject _data;{{#bodyParams}} - addToJson<{{^required?}}IfNotEmpty{{/required?}}>(_data, "{{baseName}}", {{paramName}});{{/bodyParams}} + addParam<{{^required?}}IfNotEmpty{{/required?}}>(_data, "{{baseName}}", {{paramName}});{{/bodyParams}} setRequestData(_data);{{/inlineBody}} {{/bodyParams?}}{{#producesNonJson?}} setExpectedContentTypes({ {{#produces}}"{{_}}"{{#@join}}, {{/@join}}{{/produces}} }); {{/producesNonJson?}}}{{!<- mind the actual brace}} -- cgit v1.2.3