Component is used in Grpc/Protobuf Qml tests.
Pick-to: 6.7 6.6
Change-Id: I7bee61771c2a7cf230673ac9f7f91a7c7fafe51e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Access the data stored in previous value directly to avoid redundtant
copies of the QList and QHash values, when deserializing protobuf
repeated and map fields respectively.
Assert if the previous value doesn't contain the expected QList or
QHash metatype.
Change-Id: I8c513e83419b20d70e781745d92fa93b83b9690a
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
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>
A couple of things are needed to ensure examples can be built as
external projects.
Change FindWrapgRPCPlugin to look for a cache var in addition to _ROOT
env var, because we can't easily pass env vars to external projects.
Ensure one of the non-Qt test libraries is built with at least C++17
to avoid compilation errors.
Derive a path to absl_ROOT from gRPC_ROOT assuming they are in the
same parent directory.
Use the new QT_EXAMPLE_CMAKE_VARS_TO_PASS variable introduced in
qtbase to allow passing additional cmake variables to all examples
that are built as external projects.
We need to use it for all 3rd party dependencies that have to be
found by the examples.
Make sure to look for GrpcTools package for magic8ball example, to
ensure the public api is available when cross-compiling, but there
is no target native grpc library available.
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I4420b7348c6a3b02b5516f34a96b19cceaccc649
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Remove the usage of the private MaxByteArraySize constant.
Change-Id: I334aaba0a93dadc9f88cf5355830e7b1880faaea
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Since the Qt gRPC module does not ensure thread safety at the channel
level, we can include an example demonstrating multiple
QAbstractGrpcClients can communicate asynchronously.
Task-number: QTBUG-117370
Change-Id: I829a9000b405b2d2832cba496b21ec0082273ee2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Store the QHttp2Stream pointers as the QPointer in QGrpcHttp2Channel.
The memory of the streams is managed by the QHttp2Connection
implicitly, so we should make sure that we do not attempt to remove
the stream that was removed by QHttp2Connection.
We cannot use raw pointers here because we pass Http2Handler to lambdas
and assume that Http2Handler lifetime is binded to the QHttp2Stream
lifetime.
Also ensure that we clear all Http2Handler before deleting the
QHttp2Connection instance.
The previous implementation led to double-free issue since,
QHttp2Connection was deleting all QHttp2Stream s that belong to it
first, and then there was semi-explicit removal invoked by
std::unique_ptr.
Pick-to: 6.7
Fixes: QTBUG-122908
Change-Id: I659eb9fc3f33dccc3ce70ba05db61f58973ce7c7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
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>
To set the ref field to 1 in the copy.
Amends 573f0a5ba6
Pick-to: 6.7
Change-Id: I1e797c2077ae61b6d5fcfb968cd286c0763b5268
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
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>
It doesn't seem the previous version worked. Split documentation into
two.
Pick-to: 6.5 6.6 6.7
Change-Id: If800e2e4e444cb8210f63574dc950e8d84347960
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Use the extended QML/Installation example in command documentation
only. Add the \section2 title to the general example. Update the
supplying sentences in places where the examples are included.
Pick-to: 6.6 6.7
Change-Id: I32d1911d280cb9ce9c21e8b8451c57534737e13b
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Wrap the docinc bodies with snippet begin/end markers and include them
accordingly.
Pick-to: 6.5 6.6 6.7
Change-Id: I711c14c342d0553ac64712c61d1001137659f72b
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Add short overview on how to install the standalone Qt Protobuf
library. This documentation is an extended documentation for the
OUTPUT_HEADERS, and OUTPUT_TARGETS arguments of the qt_add_protobuf
function.
Pick-to: 6.7 6.6
Change-Id: I92272e839354ef498ebe823cbe68a0dd97a353b0
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@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>
Forward the OUTPUT_HEADERS and OUTPUT_TARGETS arguments to the
PARENT_SCOPE in qt_add_protobuf methods otherwise the variables remain
empty when calling versionless function.
Pick-to: 6.5 6.6 6.7
Fixes: QTBUG-122700
Change-Id: Iefcf802e51e995bdd9ab4f79c475bdb52a3bab4f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Attempt reconnecting to the server each time when calling any method.
Also clean the operations queue to avoid handling of the formally
'dead' operations when reconnection attemt was successful.
This fixes the general connection scenario that was missing. After the
first connection attempt channel never tried to connect again. This led
to regression introduced during the QGrpcHttp2Channel refactoring.
After making a call QGrpcReply stuck in noop state, since channel only
puts the assigned QGrpcChannelOperation to queue. This behaivor is
fixed by attempting to re-establish the connection to server if
QGrpcHttp2Channel is in the Error state. All the assigned
QGrpcChannelOperation will then either emit errorOccured signals if
connection is failed again or will complete the call if connection
is established.
Fixes: QTBUG-122677
Pick-to: 6.7
Change-Id: I92b8a1a707c5cb9e955d72100b19095564310a63
Reviewed-by: Mårten Nordheim <marten.nordheim@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>
When building static libraries or shared libraries on Windows platforms
we need to make sure that _protobuf_registration targets depend on the
generated cpp exports. This add the header file containing exports as
the source file to the _protobuf_registration targets and also
makes sure that we add the dependencies when using both qt_add_protobuf
and qt_add_grpc calls on the same target.
Pick-to: 6.7
Change-Id: Ibc6c04e363093c54dc7ff1725fc6e816b3c9ffdf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This aligns with the top-level formatting config.
Change-Id: Ifa6e256dcd55cba572f1a41c7a103edc9b63ba2e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Document how to use the gRPC service methods of the generated Qt
GRPC clients.
Pick-to: 6.7
Change-Id: I71e33baa628b27cea5cc310c4df1af576d9084f9
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Use the static variable trick to initialize the StatusCodeMap in
QGrpcHttp2ChannelPrivate.
Pick-to: 6.7
Change-Id: I13cf8b91029b71cd68b226421a66603d827f9b5f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Mandatory HTTP2 headers shouldn't be duplicated or overwritten by the
user headers. The following user-defined headers will be ignored
silently:
- :authority
- :method
- :path
- :scheme
Pick-to: 6.7
Change-Id: I3656b19b80dd8f9106f3ee97ce83abeac2954073
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
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>
Add documentation that describes the new format of EXPORT_MACRO
that we introduced in Qt 6.7 already but want make it public in
Qt 6.8 only.
Change-Id: I3431668c3f4949b493f18f0401183fbdcb18c827
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>