Move the list iterating logic to the deserializeValue method. We
may detect the list type at the point when deserializing the
JSON-encoded repeated field. So it doesn't make sense to hold
this logic in list item deserializer, we may simply iterate over
list value there.
Pick-to: 6.7
Change-Id: I413993aed14971c8a1bc2c7bfd04aed6ad1cacda
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
QProtobufMessage::propertyOrdering now provides information
about the message property ordering. This allow us to use
the pointers to QProtobufMessage but not to the exact class
when (de)serializing messages.
This commit makes all private getter of message fields mutable.
If the message field is not initialized it will be initialized
at first access, like it's done in public getters.
This mechanism allows to hold the field allocation inside message
but not in the type deserializer. All serializers no should expect
that the message pointer that is passed to the deserialization
is valid message pointer.
To avoid unwanted message field allocation when using property
getter, QProtobufMessage::property method now accepts an extra argument.
If allowInitializeOptional is set to true, it skips checking the
'has<MessageField>' property before accessing the message field it self.
Protobuf messages that are used in oneof fields now require explicit
definition of operator=, since it's used when copying the data in
QVariant. Otherwise the warning related to the implicit definition of
operator= is produced.
Task-number: QTBUG-120931
Change-Id: I1b816295297e7ef8cd6d3f0abdcbe1e670597fd0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
QProtobufMessage::propertyOrdering now allows accessing the message
property ordering. So we can remove extra arguments from all interfaces
where the pointer or the reference to the related QProtobufMessage
is used as argument too.
[ChangeLog][Protobuf][QAbstractProtobufSerializer] The following
interfaces do not accept the QProtobufPropertyOrdering as an argument
anymore:
- serializeObject
- deserializeObject
- serializeListObject
- deserializeListObject
- serializeMessage
- deserializeMessage
Task-number: QTBUG-120931
Change-Id: I55cb8d3ceddd56751d542869e26aa0de73c22ebb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Use the package defined in a .proto file when generating the wrapping
namespace statements. This fixes the crash when .proto file contain no
message definitions.
Pick-to: 6.5 6.6 6.7
Fixes: QTBUG-122816
Change-Id: I0eb474217eb0126dee5919bbd7b12a20f8078124
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Because we back out and do not create the testserver target when we
don't find the grpc dependency we fail during the genex further down.
Pick-to: 6.7
Change-Id: Ia0415dc7ae09933503dabd2882b4643f087943ff
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Protobuf messages should have the explicit presence according to the
field presence specs. We should mark them with the respective field
flag to enable QProtobufMessage::property logic that verifies the
field presence according to the 'has<FieldName>' property value.
Add the ExplicitPresence field flag that now is generated for all
optional, message, and oneof fields.
[ChangeLog][Protobuf] All fields that have the message type now
generate the has<FieldName> property that indicates whether the field
is intialized or not.
[ChangeLog][Protobuf] All fields that have explcit presence now set
the 'ExplicitPresence' flag in their property ordering structures.
Task-number: QTBUG-120931
Change-Id: I962c38e1ebde04d393cafaa8b512a277d660b5fa
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
We should check whether the serialization was successful before
appending the value to the repeated field.
Fixes: QTBUG-121560
Pick-to: 6.7
Change-Id: I56583826ffc97e503348b0f8b86245f49b7f076e
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
The QGrpcSerializationFormat class allows using either predefined
QAbstractProtobufSerializers(Protobuf/Json) or user-defined
serializers.
The serialization format is the part of QGrpcChannelOptions.
gRPC channel implementations should rely on respective value provided
by QGrpcChannelOptions when choosing the serialization format for
protobuf messages.
QGrpcHttp2Channel got full support of QGrpcSerializationFormat. It's
still possible to set the serialization format using the
QGrpcChannelOptions metadata, but QGrpcSerializationFormat is
considered with higher priority.
[ChangeLog][GRPC][QGrpcChannelOptions] Added the
withSerializationFormat and serializationFormat methods. These methods
allow to set/get the QGrpcSerializationFormat that should be used by
gRPC channel.
[ChangeLog][GRPC] Added the QGrpcSerializationFormat class.
QGrpcSerializationFormat allows customizing the serialization format
that is used in QAbstractGrpcChannel implementations.
Task-number: QTBUG-113777
Change-Id: Id9c802d08fb325a5bd09e603bd0d505a85f1d80d
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
The server requires JSON serialization support for our testing purposes,
C++ API doesn't allow using JSON serialization in gRPC channels, but
the golang one allows. This introduces the different gRPC server
implementation that serve out needs. golang-base server only available
for the host Qt builds if QT_ALLOW_DOWNLOAD is enabled.
The reference C++ server is still used for cross-compiled Qt and
for the cases when go is not present in the system.
Task-number: QTBUG-113777
Change-Id: I9d821d56e5da629604e197707dbead2d5367f844
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
It's now possible to preselect the serialization format when creating
the channel using the 'Content-Type' metadata. Supported values for the
header:
- application/grpc(default)
- application/grpc+protobuf
- application/grpc+json
Note: Not all servers and clients support JSON serialization format.
Task-number: QTBUG-113777
Change-Id: Ia25b3382e3addb2306acce112489ea3427687c0d
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Add the support for the UNIX sockets to QGrpcHttp2Channel. The channel
only supports the non-encrypted communicatoin.
Pick-to: 6.7
Task-number: QTBUG-119074
Change-Id: Ie404999d7511a783e4d1504a0ac51e5fc97f23ba
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
The implementation uses the gRPC HTTP/2 channel private API from the
QtNetwork module. New implementation allows utlizing HTTP/2 streams to
not only receive data from server streams, but also to send data from
client size. This improvement unlocks implementation of client-side
streaming.
Pick-to: 6.7
Task-number: QTBUG-105494
Task-number: QTBUG-105493
Change-Id: Ida8b1b37b7c70f7130b1ff4dcf8d6114b2dfd089
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Make the generating of C++ exports common for both generators.
The confilicting generation should be resolved by the tools that
running the generators. Qt CMake API handles this situation.
Fixes: QTBUG-121856
Pick-to: 6.7
Change-Id: Ie2452f52d755ade2909107885dac774ff8678daa
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
- Rename options test to channeloptions, since the test is testing
QQmlGrpcChannelOptions class.
Pick-to: 6.7
Change-Id: I5b1643dd346fd71e5cecaf417cbb65b3587210a2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Consider the EXPORT_MACRO CMake argument of qt_add_<protobuf|grpc>
calls.
Add the support for the EXPORT_MACRO option extras to the
qt<protobuf|grpc>gen generators. The extras now allow setting:
- export file name
- boolean flag that indicates if export file needs to be generated
The EXPORT_MACRO option of the generators now has the following format:
EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
If export_filename is not set, then generators fall back to the previos
behavior and use the export_name as the export filename base, the file
will be generated unconditionally. If export_filename is set and the
follow boolean flag is not set or is set to false, generators skip the
generating of the export file.
[ChangeLog][Protobuf][qtprotobufgen] EXPORT_MACRO option now has the
following format:
EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
New option extras allow setting the generated export filename and
control if it should be generated at the generator run.
[ChangeLog][GRPC][qtgrpcgen] EXPORT_MACRO option now has the
following format:
EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]]
New option extras allow setting the generated export filename and
control if it should be generated at the generator run.
Pick-to: 6.7
Fixes: QTBUG-121854
Change-Id: Ifff6506ab363d18dc417f222e9929d7eba135d8a
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
- Add testcase for re-setting metadata property to value and back to
null for CallOptions and ChannelOptions
Pick-to: 6.7
Change-Id: I8762da40428c69cebea1c85ca8630d1099ea1be2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Add the missing comparison of the optional fields to the message
operator ==(). The oneof field condition was invalid.
Pick-to: 6.7
Change-Id: I7d6ba076cb44329faa7bf3c3fbf07183cf9dba82
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Add the missing copying of the optional fields to the message data
structure.
Add the missing tests and reorganize the existing optional tests,
split serialization/deserialization and generic part.
Fixes: QTBUG-121862
Pick-to: 6.7
Change-Id: I73a97481185868ea61615b2c02bada8cb153a8c2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
- Add ssl property creation that is depended on SSL support
Pick-to: 6.7
Change-Id: I67f66d2aae17f0303559497d5efe578adabc76fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Constructing a copy of QJSValue for gRPC callbacks look redundant.
Remove it. Same applicable for the result.
Pick-to: 6.6 6.7
Change-Id: I3b5c81e8373ca85ccd66e65555305c9dba020a6c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Move functionality related to the registration of the protobuf messages
to a separate header/source files.
Task-number: QTBUG-120931
Change-Id: I6076b41139d43982148e46f5f315808509c4db65
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
The include is not used in the generated code.
Pick-to: 6.6 6.7
Change-Id: I94c9649d7f9130b796b44de578b32ae4acd3655e
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Now we may get the property ordering information from QProtobufMessage
without the need of knowing the exact type of inherited message.
This allows us to remove template arguments from
QAbstractGrpcClient::call and QAbstractGrpcClient::startStream
methods.
Task-number: QTBUG-120931
Change-Id: I497b80f53f5680790211b71a53a9ddc75d113424
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Now when we store the pointer to the property ordering in each
QProtobufMessage instance, we may remove generating of redundant
(de)serialize functions from messages.
This adds the generic QProtobufMessage::serialize and
QProtobufMessage::deserialize methods. Also we don't need the
template serialize/deserilze methods in QAbstractProtobufSerializer
since ordering information can be retrieved from the protobuf message
base class.
[ChangeLog][Protobuf][QProtobufMessage] Added the serialize and
deserialize methods.
[ChangeLog][Protobuf][QAbstractProtobufSerializer] The serialize
and deserialize methods are now non-template.
[ChangeLog][Protobuf] The Q_DECLARE_PROTOBUF_SERIALIZERS macro
is removed from the API and is not generated anymore.
Task-number: QTBUG-120931
Change-Id: I8ba8e6bb83728e58f781f42520629e1a9be4f026
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
The tests is testing QGrpcHttp2Channel functionality. Let's move
it from client tests and rename.
Pick-to: 6.7
Change-Id: Ie21570689ca461e3661db61c0b6d3bf58dce02a1
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
The method allows accessing the protobuf message property ordering from
the base class.
[ChangeLog][Protobuf][QProtobufMessage] Added the propertyOrdering
method.
[ChangeLog][Protobuf][QProtobufMessage] Added the ordering argument
to the QProtobufMessage constructor.
Task-number: QTBUG-120931
Change-Id: I6fbc664c59ae4ff1da6266ca9e12cef0800c7457
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This frees the name for the respective getter function.
[ChangeLog][Protobuf] The 'propertyOrdering' static member is renamed
to 'staticPropertyOrdering'.
Task-number: QTBUG-120931
Change-Id: If5288ac58222529ef870f86dd09e58dce7287f10
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Make tst_grpc_client_unarycall_qml pass when the test call is finished
with the expected result, but not failed with no connection to server.
This adds the run of the test server int the
tst_grpc_client_unarycall_qml test.
Pick-to: 6.7
Change-Id: Id50dd962cf34325fe208eaa4b1e1147ba0487b22
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
All files generated by qtprotobuf plugin should be checked by the test
Also, added optional_protobuftyperegistrations.cpp file to expected_result for comparison
Pick-to: 6.6 6.7
Change-Id: I3fc34dd720b845ef870d4694e67133b5932e8838
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
It seems the only case when qRegisterProtobufTypes() should be called directly is registration in QML engine.
Pick-to: 6.6 6.7
Change-Id: Ifdd1875cfb10a328580ba4aa94e0af33b9886da5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Try to locate conformance_test_runner using the CMake find_programm
command when building the tst_protobuf_conformance manual test.
Pick-to: 6.6 6.7
Task-number: QTBUG-104064
Change-Id: I805d1a43ccd57b78aff1a94ff221e674175956f7
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Rename the test to tst_grpc_client_deadline. Use GrpcClientTestBase
as the test base. Add WithChannelDeadline channel to GrpcClientTestBase.
Pick-to: 6.6 6.7
Change-Id: I6125f68f40b26ba645a97721641123d01a5387b2
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Add the ssl channels to tests. Run the test server with SSL channel
enabled by default.
Add the --latency option to the test server. Server now uses the value
provided by test runner instead of using the global definition.
Rename the test server-related targets, so the have grpc_ prefix now.
The previous name was too generic.
Adjust SSL tests and use GrpcClientTestBase with SslNoCredentials
channels.
Pick-to: 6.6 6.7
Task-number: QTBUG-119207
Change-Id: Ib5cf9d05db62f542f5fc9bf4de1d5af93e6864e0
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
- During generation from command line --experimental_allow_proto3_optional
should be taken into account for versions: 3.12 <= protoc < 3.15
Change-Id: I88f73317c044b985b3f09e676b5bb78b92a37c32
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
If oneof message field is already present, we return the pointer
to the QVariant internals in the QProtobufOneof::value method. In
this case deserializer accesses the message that is stored in the
oneof field directly. So if pointer received in the oneof field
setter matches the one that is stored in oneof field we should omit
the setter completely, especially the "delete" part since it will
attempt to free the QVariant stored data.
Amends e9c80d43f7
Pick-to: 6.6 6.7
Task-number: QTBUG-118996
Change-Id: I08a3fb0d52cdcd4ed2156b8e2c5e43244394005d
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
It should be set to StandardError, since we expect the
'Server listening' log from stderr pipe.
Pick-to: 6.6 6.7
Task-number: QTBUG-119207
Change-Id: If4daadb1a2b4331550329054e7dcd69589e863db
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
If enum was not used as the owning message field, its registration
was skipped due to weak logic in the generator. Iterate over enums
but not rely on existing enum field when generating protobuf
registrations of nested enums.
Pick-to: 6.5 6.6 6.7
Fixes: QTBUG-120432
Change-Id: Ieae54793d872f7500c584b4f241fc4c50fe82cc6
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Register QML gRPC clients using the service specific names, to allow
using multiple clients in a single QML stack. Clients now are
registered in QML context as <ServiceName>Client.
[ChangeLog][QtGRPC][QML] gRPC clients now are registered as
<ServiceName>Client in QML context.
Pick-to: 6.7
Change-Id: I03481df93813309ec586f01999acb6f2da90b347
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Rename GrpcQuick tests directory to grpcquick to align the name with
the module name. Also rename test to match the test naming in the C++
module. This also make the test naming less generic.
Pick-to: 6.7
Change-Id: I57ee1a72022de96dffb7a2002cb4fdd56bc13697
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>