aboutsummaryrefslogtreecommitdiff
path: root/gtad
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
committern-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
commit08632625e1a04257b5c7d4a9db2246ac07436748 (patch)
tree9ddadf219a7e352ddd3549ad1683282c944adfb6 /gtad
parente9c2e2a26d3711e755aa5eb8a8478917c71d612b (diff)
parentd911b207f49e936b3e992200796110f0749ed150 (diff)
downloadlibquotient-08632625e1a04257b5c7d4a9db2246ac07436748.tar.gz
libquotient-08632625e1a04257b5c7d4a9db2246ac07436748.zip
Update upstream source from tag 'upstream/0.7.0'
Update to upstream version '0.7.0' with Debian dir 30dcb77a77433e4a54eab77c0b82ae925dead2d8
Diffstat (limited to 'gtad')
-rw-r--r--gtad/data.h.mustache5
-rw-r--r--gtad/gtad.yaml74
-rw-r--r--gtad/operation.cpp.mustache23
-rw-r--r--gtad/operation.h.mustache7
4 files changed, 69 insertions, 40 deletions
diff --git a/gtad/data.h.mustache b/gtad/data.h.mustache
index 32ea85ee..1b511262 100644
--- a/gtad/data.h.mustache
+++ b/gtad/data.h.mustache
@@ -1,4 +1,7 @@
-{{>preamble}}
+{{!
+SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
+SPDX-License-Identifier: LGPL-2.1-or-later
+}}{{>preamble}}
#pragma once
#include "converters.h"
diff --git a/gtad/gtad.yaml b/gtad/gtad.yaml
index e56c394d..4b05d2d4 100644
--- a/gtad/gtad.yaml
+++ b/gtad/gtad.yaml
@@ -29,6 +29,8 @@ analyzer:
login>/user: ""
login>/medium: ""
login>/address: ""
+ login</home_server: ""
+ register</home_server: ""
# Structure inside `types`:
# - swaggerType: <targetTypeSpec>
@@ -45,7 +47,7 @@ analyzer:
types:
- +set: &UseOmittable
useOmittable:
- omittedValue: 'none' # Quotient::none in lib/util.h
+ omittedValue: 'none' # Quotient::none in lib/omittable.h
+on:
- integer:
- int64: qint64
@@ -68,6 +70,9 @@ analyzer:
- dateTime:
type: QDateTime
initializer: QDateTime::fromString("{{defaultValue}}")
+ - uri:
+ type: QUrl
+ initializer: QUrl::fromEncoded("{{defaultValue}}")
- //: &QString
type: QString
initializer: QStringLiteral("{{defaultValue}}")
@@ -79,14 +84,19 @@ analyzer:
- $ref:
- +set:
moveOnly:
- imports: '"events/eventloader.h"'
+on:
- - /state_event.yaml$/: StateEventPtr
- - /room_event.yaml$/: RoomEventPtr
- - /event.yaml$/: EventPtr
- - /m\.room\.member/: void # Skip resolving; see EventsArray<> below
+ - /state_event.yaml$/:
+ type: StateEventPtr
+ imports: '"events/stateevent.h"'
+ - /(room|client)_event.yaml$/:
+ type: RoomEventPtr
+ imports: '"events/roomevent.h"'
+ - /event(_without_room_id)?.yaml$/:
+ type: EventPtr
+ imports: '"events/event.h"'
- +set:
- # This renderer actually applies to all $ref things
+ # This renderer applies to everything actually $ref'ed
+ # (not substituted)
_importRenderer: '"{{#segments}}{{_}}{{#_join}}/{{/_join}}{{/segments}}.h"'
+on:
- '/^(\./)?definitions/request_email_validation.yaml$/':
@@ -94,49 +104,64 @@ analyzer:
- '/^(\./)?definitions/request_msisdn_validation.yaml$/':
title: MsisdnValidationData
- /_filter.yaml$/: # Event/RoomEventFilters do NOT need Omittable<>
+
+ # Despite being used in two calls, it's more practical to have those
+ # fields available as getters right from the respective job classes
- /public_rooms_response.yaml$/: { _inline: true }
+
+ # list_public_rooms.yaml (via public_rooms_response.yaml) and
+ # space_hierarchy.yaml use public_rooms_chunk.yaml as a common base
+ # structure, adding (space_hiearchy) or overriding
+ # (public_rooms_response) fields for their purposes. The spec text
+ # confusingly ends up with having two different structures named
+ # "PublicRoomsChunk". To make sure the types are distinct in
+ # libQuotient, this common base is inlined into the actually used
+ # data structures (that have distinct names) defined
+ # in space_hierarchy.h and public_rooms_response.h, respectively
+ - /public_rooms_chunk.yaml$/: { _inline: true }
- //: *UseOmittable # Also apply "avoidCopy" to all other ref'ed types
- schema:
- getTurnServer<: *QJsonObject # It's used as an opaque JSON object
- - PublicRoomResponse: { _inline: true }
# - defineFilter>: &Filter # Force folding into a structure
# type: Filter
# imports: '"csapi/definitions/sync_filter.h"'
# - getFilter<: *Filter
+ - StrippedChildStateEvent: void # only used in an array, see below
- RoomFilter: # A structure inside Filter, same story as with *_filter.yaml
+ - OneTimeKeys:
+ type: OneTimeKeys
+ imports: '"e2ee/e2ee.h"'
- //: *UseOmittable
- array:
- string: QStringList
- +set: { moveOnly: }
+on:
- - /^Notification|Result$/:
- type: "std::vector<{{1}}>"
- imports: '"events/eventloader.h"'
- - /m\.room\.member/: # Only used in an array (see also above)
- type: "EventsArray<RoomMemberEvent>"
- imports: '"events/roommemberevent.h"'
- - /state_event.yaml$/: StateEvents
- - /room_event.yaml$/: RoomEvents
- - /event.yaml$/: Events
+ - /^Notification|Result|ChildRoomsChunk$/: "std::vector<{{1}}>"
+ - /^StrippedChildStateEvent$|state_event.yaml$/:
+ type: StateEvents
+ imports: '"events/stateevent.h"' # For StrippedChildStateEvent
+ - /(room|client)_event.yaml$/: RoomEvents
+ - /event(_without_room_id)?.yaml$/: Events
- //: "QVector<{{1}}>"
- map: # `additionalProperties` in OpenAPI
- RoomState:
type: "UnorderedMap<QString, {{1}}>"
moveOnly:
- /.+/: "QHash<QString, {{1}}>"
- - //: QVariantHash
- - variant: # A sequence `type` (multitype) in OpenAPI
+ - //: QVariantHash # QJsonObject?..
+ - variant: # A sequence `type` or a 'oneOf' group in OpenAPI
- /^string,null|null,string$/: *QString
- //: QVariant
#operations:
mustache:
+# delimiter: '%| |%' # or something else instead of '{{ }}'
constants:
# Syntax elements used by GTAD
# _quote: '"' # Common quote for left and right
# _leftQuote: '"'
-# _rightQuote: '"'
+# _rightQuote: '"_ls'
_comment: '//'
copyrightName: Kitsune Ral
copyrightEmail: <kitsune-ral@users.sf.net>
@@ -160,11 +185,8 @@ mustache:
qualifiedMaybeOmittableType:
"{{>openOmittable}}{{dataType.qualifiedName}}{{>closeOmittable}}"
- ref: "{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}"
maybeCrefType:
- "{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{>ref}}"
- qualifiedMaybeCrefType:
- "{{#avoidCopy}}const {{/avoidCopy}}{{>qualifiedMaybeOmittableType}}{{>ref}}"
+ "{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}"
maybeCrefJsonObject:
"{{^propertyMap}}const QJsonObject&{{/propertyMap}}\
@@ -186,8 +208,8 @@ mustache:
joinedParamDef: "{{>maybeCrefType}} {{paramName}}{{>cjoin}}"
passPathAndMaybeQuery: >-
- QStringLiteral("{{basePathWithoutHost}}")
- {{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}},
+ makePath("{{basePathWithoutHost}}"{{#pathParts}},
+ {{_}}{{/pathParts}}){{#queryParams?}},
queryTo{{camelCaseOperationId}}(
{{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}){{/queryParams?}}
diff --git a/gtad/operation.cpp.mustache b/gtad/operation.cpp.mustache
index 3c3396e9..4b75434c 100644
--- a/gtad/operation.cpp.mustache
+++ b/gtad/operation.cpp.mustache
@@ -1,8 +1,9 @@
-{{>preamble}}
+{{!
+SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
+SPDX-License-Identifier: LGPL-2.1-or-later
+}}{{>preamble}}
#include "{{filenameBase}}.h"
-#include <QtCore/QStringBuilder>
-
using namespace Quotient;
{{#operations}}{{#operation}}
{{#queryParams?}}
@@ -10,7 +11,7 @@ using namespace Quotient;
auto queryTo{{camelCaseOperationId}}(
{{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
{
- BaseJob::Query _q;{{#queryParams}}
+ QUrlQuery _q;{{#queryParams}}
addParam<{{^required?}}IfNotEmpty{{/required?}}>(_q,
QStringLiteral("{{baseName}}"), {{paramName}});{{/queryParams}}
return _q;
@@ -33,20 +34,20 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}},
{ {{#headerParams}}
setRequestHeader("{{baseName}}", {{paramName}}.toLatin1());
{{/headerParams}}{{#inlineBody}}{{^propertyMap}}{{^bodyParams?}}
- setRequestData(Data({{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson?
- }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}}));
+ setRequestData({ {{#consumesNonJson?}}{{nameCamelCase}}{{/consumesNonJson?
+ }}{{^consumesNonJson?}}toJson({{nameCamelCase}}){{/consumesNonJson?}} });
{{/bodyParams?}}{{/propertyMap}}{{/inlineBody
}}{{^consumesNonJson?}}{{#bodyParams?}}
- QJsonObject _data;
+ QJsonObject _dataJson;
{{#propertyMap}}
- fillJson(_data, {{nameCamelCase}});
+ fillJson(_dataJson, {{nameCamelCase}});
{{/propertyMap}}{{#inlineBody}}
- fillJson<{{>maybeOmittableType}}>(_data, {{paramName}});
+ fillJson<{{>maybeOmittableType}}>(_dataJson, {{paramName}});
{{/inlineBody}}{{#bodyParams}}
- addParam<{{^required?}}IfNotEmpty{{/required?}}>(_data,
+ addParam<{{^required?}}IfNotEmpty{{/required?}}>(_dataJson,
QStringLiteral("{{baseName}}"), {{paramName}});
{{/bodyParams}}
- setRequestData(std::move(_data));
+ setRequestData({ _dataJson });
{{/bodyParams?}}{{/consumesNonJson?}}{{#producesNonJson?}}
setExpectedContentTypes({ {{#produces}}"{{_}}"{{>cjoin}}{{/produces}} });
{{/producesNonJson?}}{{^producesNonJson?
diff --git a/gtad/operation.h.mustache b/gtad/operation.h.mustache
index 36963b9a..063f0bbd 100644
--- a/gtad/operation.h.mustache
+++ b/gtad/operation.h.mustache
@@ -1,4 +1,7 @@
-{{>preamble}}
+{{!
+SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
+SPDX-License-Identifier: LGPL-2.1-or-later
+}}{{>preamble}}
#pragma once
#include "jobs/basejob.h"
@@ -13,7 +16,7 @@ namespace Quotient {
/*!{{>docCommentSummary}}{{#description}}
* {{_}}{{/description}}
*/
-class {{camelCaseOperationId}}Job : public BaseJob {
+class QUOTIENT_API {{camelCaseOperationId}}Job : public BaseJob {
public:
{{#models}}
// Inner data structures