When CMAKE_FIND_PACKAGE_PREFER_CONFIG is TRUE, find_package(OpenSSL)
prefers CONFIG mode and may bypass package manager wrappers that only
work in MODULE mode (e.g., vcpkg's wrapper).
This can lead to finding the wrong OpenSSL installation, such as
single-architecture system installations instead of the intended
universal binaries from the package manager, causing linker errors when
building for multiple architectures.
Fix this by finding OpenSSL before setting
CMAKE_FIND_PACKAGE_PREFER_CONFIG to TRUE. This ensures OpenSSL is found
via MODULE mode where package manager wrappers can properly control the
search. When gRPC's config file is loaded, it skips its own OpenSSL
search, using the already-found targets instead.
For test files, backup and restore the original
CMAKE_FIND_PACKAGE_PREFER_CONFIG value to limit the scope of the change.
For example files, keep the change simple without the backup/restore
pattern.
Change-Id: I985560fd5d57fa8036cc2ccb93c01a55e2efe1bc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Adding alt texts that were needed for QDoc
Pick-to: 6.8
Change-Id: I19b8800fc80d62c6d1996a434fb223cfc2a6e445
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This is a better place then the 'Application Examples' category that
should be reserved for higher-level examples that work out of the box.
Also highlight the example in the Networking category.
Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-137988
Change-Id: I75f630daeba350043f6d0aa3a90b30bee967e6b1
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
As part of reviewing the application examples and following a structure, this
change covers:
-Language changes
-Follows the strucutre
-Includes \sa link to All Qt Examples
Fixes: QTBUG-137964
Pick-to: 6.10 6.9 6.8
Change-Id: Ic14d7042e6db277c1584b69ba46f7748f53642ab
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This patch includes:
- Show available server ports dynamically. Qt built without SSL
support should not show the https port.
- Add an early note about the prerequisites for running the example so
that users are guided from early on.
- Use std::cout in combination with std::endl to flush the buffer.
QtCreator doesn't print when simply using "\n".
Pick-to: 6.10 6.9 6.8
Change-Id: I4eb7f6fbc1474508af2a88a3313cf94325a63657
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
gRPC doesn't provide the smart tool lookup when crosscompiling.
So gRPC lookup is unable to find the grpc_cpp_plugin plugin when
crosscompiling examples. Use find_program to find the plugin in
host paths.
Pick-to: 6.8 6.9
Fixes: QTBUG-134647
Change-Id: I961b180b348dee4f1b2f2523be225d3003847e4c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The previous approach was error-prone, as using TARGET_FILE_DIR
hard-coded the path to the build directory and ignored install locations
entirely.
Fix this by using a more reliable approach: embedding the certificate
strings directly into the application.
Pick-to: 6.9 6.9.0 6.8 6.8.3
Change-Id: Ifb883891fd55bb023e7f9828f9c422ea3e5d1c3e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Use the vcpkg manifest to configure and build QtGRPC the example.
This allows to automate the dependency installation using vcpkg.
Pick-to: 6.9
Task-number: QTBUG-132738
Change-Id: I7ba9d5a2c1186d1a70f3dc3a39117d86f2269271
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Use the vcpkg manifest to configure and build QtGRPC chat example.
This allows automating the dependency installation using vcpkg.
Pick-to: 6.9
Task-number: QTBUG-132738
Change-Id: Iafcb8e144d51f1af0d775869550f003c997d106a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Use the vcpkg manifest to configure and build QtProtobuf sensors
example. This allows automating the dependency installation using
vcpkg.
Pick-to: 6.9
Task-number: QTBUG-132738
Change-Id: Icae7acf46d97d834a064d7663623757a7ec35742
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Use the vcpkg manifest to configure and build QtGRPC Magic 8 Ball
example. This allows automating the dependency installation using
vcpkg.
Pick-to: 6.9
Task-number: QTBUG-132738
Change-Id: Idaf8ee948a0a304633e1fe9f63327391adec96d8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Remove deployment of the now static proto lib.
Amends 9437a1f2bd
Pick-to: 6.9
Change-Id: I5bdda6157842c665165ae9b14255778ce2ac0bc9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The deployment was incomplete. Fix it by:
* Building the dependent qtgrpc_chat_client_proto library as
a static library
* Add the server directory path for reading credentials universally
Amends: cb35d20adb.
Fixes: QTBUG-134266
Pick-to: 6.9.0 6.9 6.8.3 6.8
Change-Id: I0666c445fbce159436c5b084ffd77d4191e04213
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Server and client request/responce time format differs, since
std::chrono::time_point::time_since_epoch() output contains
undeterminated units. Make the explicit conversion to milliseconds,
to align the time format between server and client.
Pick-to: 6.8 6.9
Change-Id: I5914221d3b3b8043721f4d97705ccb54c679be9c
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The previous chat example was created many moons ago and much has
happened since then. These are the key improvements for the new qtchat:
- Server uses the Callback API
- Added support for Registering (stored in plain text on server side)
- Use long-lived bidirectional streaming for the ChatRoom method
- Any files can now be shared in any size with all chat users
- Use the Grpc client from a dedicated worker thread to have lag-free
UIs
- Use the generated protobuf QML-library declaratively in the app
- stylistic improvements
- Use SSL for safe communication
- Automatic reconnections
This is an advanced example showcasing many features of this module.
Pick-to: 6.9 6.8
Fixes: QTBUG-121871
Fixes: QTBUG-122625
Change-Id: I71114375fe91ffb20a235859b6ab51f7b3ab07a3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
It's not necessary that the server executable is located and named
always the same. We may try to hijack this using various CMake
OUTPUT tricks, but it's easier to utilize the actual file path in
the client executable using definition.
Amends dedd3edd3f
Pick-to: 6.8 6.9
Task-number: QTBUG-125406
Change-Id: Ice60e22caa6c5c14024f57fe133f2268ad96f574
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Sever uses WrapProtoc target to generate the reference protobuf and
grpc code.
Add the missing package lookup.
Amends dedd3edd3f
Pick-to: 6.8 6.9
Task-number: QTBUG-125406
Change-Id: I3cc93443170dcddfada3ddff266b958e86a2d460
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The call is mandatory for all CMakeLists.txt.
Amends dedd3edd3f
Pick-to: 6.8 6.9
Task-number: QTBUG-125406
Change-Id: Ib39843424c9215d809fe4380c1c80b8c87ac7e05
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
It contains in depth documentation to get started with Qt GRPC
and replaces the 'Client Methods of the Qt GRPC Service' guide.
This will enable users to also run the code, experiment with it and
show us the error directly in case they fail to compile.
Task-number: QTBUG-125406
Fixes: QTBUG-129588
Pick-to: 6.9 6.8
Change-Id: I8f16156a13da1683bce0e31001ee6b2ff57b1824
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
It will add the 'tm' logo to the first occurrence in the document. We
still add it to any mention of it since this will protect against
copy-paste issues when borrowing chunks of the documentation.
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I099633bcda78a1940c65c379328539190833d6f9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Generating the aliases for protobuf QList types leads to the name
clashing when users want ot introduce messages that have name
consisting of previously defined message name and Repeated suffix,
e.g.:
message MyMessage {
}
message MyMessageRepeated {
}
We shouldn't prohibit the above scheme in our generators and generate
the respective messages correctly. The only possible solution -
complete removal of the protobuf messages QList aliases.
Generator still generates the aliases guarded by the
QT_USE_PROTOBUF_LIST_ALIASES macro. The macro is enabled by
Qt::Protobuf when building using CMake, but can be disabled at any
time by setting QT_USE_PROTOBUF_LIST_ALIASES property on protobuf
target to avoid name clashing.
[ChangeLog][Protobuf] qtprotobufgen doesn't generate protobuf message
QList aliases. All usages of aliases should be replace by respective
QList types. Aliases are still generated and are guarded by the
QT_USE_PROTOBUF_LIST_ALIASES macro in the generated code. The macro
is enabled by default and can be disabled using
QT_USE_PROTOBUF_LIST_ALIASES target property.
Fixes: QTBUG-129652
Pick-to: 6.8 6.9
Change-Id: I026755b36985eef01a6851156d9c9cfff141d247
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This will work around the issue in debian-like platforms, where
relatively new protobuf doesn't deliver the proper config files.
The lookup still prefers looking for the config files, but not
the deprecated CMake module.
Change-Id: Ie1d5217e9023022976dd058be9dd7fd1ce37e39f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This is the idiomatic way of providing documentation files for our
examples.
Task-number: QTBUG-129571
Pick-to: 6.8
Change-Id: I821cf955371766ef473551607308f59c6c2e692b
Reviewed-by: Jaime Resano <Jaime.RESANO-AISA@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This is the idiomatic way of providing documentation files for our
examples.
Task-number: QTBUG-129571
Pick-to: 6.8
Change-Id: I3fda6a56d6de0d7378d2339bb8ca3930f06dd6ae
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The example server doesn't really need to use Qt. Remove the
dependency on Qt Core.
Pick-to: 6.8
Change-Id: I8b64e9765f529baa1bcf041a801723ceaed85334
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
These modules are not relevant anymore. After porting Qt::Grpc
relied on native gRPC implementation. But since we migrated to the
fully functional Qt HTTP/2 the need of reference gRPC and protobuf
gone.
Remove the WrapgRPC and WrapProtobuf modules, use the protobuf
gRPC modules directly in tests examples and tools. Since non of
those never add the build-time depdendcy on reference libraries,
we don't need to add the respective dependencies in Qt packages.
The only thing we still wrap is protoc. We either look for executable
but we never propagate it as the reference target, but utilize the
path from there.
Fixes: QTBUG-128809
Change-Id: Id5008f8dd935288cbaa8a9abb88d485824099d46
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Currently we're doing something manually, which, since Qt6 is a
dedicated feature. Use that instead for less error-prone disconnections
for our single-shot signals.
Lets not re-invent the wheel for something that has been (potentially
faster rather then slower) invented for this exact usecase.
We will promote the usage of Qt::SingleShotConnection, so as good
teachers we should be using it as well.
Pick-to: 6.8
Change-Id: I3b2b9f176f06d91b4d0946a38c53a4c2614c8a01
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This was forgotten when we switched to unique_ptr's.
Pick-to: 6.8.0 6.8
Change-Id: I684639bbafc65ea5eea34074a77367b82c9d9054
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
All new enums should be scoped.
Drive-by change: Remove the redundant suffixes of the enum elements.
It's obvious from the scope that those are errors.
Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: Ided4ab4a1ddb2d14713f876ffe4fe339af39ae6b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
We obviously store the lambda and its context forever. Add the explicit
disconnect to cleanup the memory on failure.
Pick-to: 6.8
Change-Id: I1afda515f8c8dc96fec9edb847ee26efd8802c6b
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The use of shared pointers has potential risk of storing the
QGrpcOperation children forever and leaking in user code. The problem
is clearly in the lambda connections that we encourage to use in the
docs and examples:
auto stream = testStream(...);
QObject::connect(stream.get(), &QGrpcOperation::finished,
ctx, [ctx, stream]{...});
The above code will hold the 'stream' forever, unless user will make
the explicit disconnect in the lambda.
By using std::unique_ptr we partially solve this, or at least convince
user to solve this. When user creates lambda he knows the 'stream'
lifetime and most probably should consider that after the move, lambda
is owning the QGrpcOperation, so the need of disconnect is more clear
in this case:
auto stream = testStream(...);
auto *streamPtr = stream.get();
QObject::connect(streamPtr, &QGrpcOperation::finished,
ctx, [ctx, stream = std::move(stream)]{...});
The code becomes a bit more complicated, but it points explicitly to
the potential risk. Also it disallows to make this trick to multiple
lambdas at the same time.
Of course using the lambda context to control the QGrpcOperation
lifetime in this case is not necessary. But even if users will decide
to manage the QGrpcOperation lifetime differently, the use of
std::unique_ptr will clearly point to the ownership.
[ChangeLog][Grpc] All generated RPC methods now return std::unique_ptr
instead of std::shared_ptr. This change explicitly defines that caller
takes the ownership of the returned pointers.
Pick-to: 6.8
Change-Id: I271b91454f0c1b12b77127a7e025fa493367e279
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This will unlock the use of enum fields duplicates in the same scope
if the respective feature will be supported by the reference protobuf.
Pick-to: 6.8
Task-number: QTBUG-126992
Change-Id: Ib38e313b62885042e2f75376836d1cb0ad2574db
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Rename the deserializationError(String) interfaces to
lastError(String). The new interface encourages to write the errors
not only during deserialization but also serialization.
TODO: Add serialization error handling to the existing
QAbstractProtobufSerializer implementations. See QTBUG-128331.
[ChangeLog][Protobuf] QAbstractProtobufSerializer::DeserializationError
is renamed to QAbstractProtobufSerializer::Error and now contains list
of both possible serialization and deserialization errors.
[ChangeLog][Protobuf][QAbstractProtobufSerializer] deserializationError
and deserializationErrorString renamed to lastError and lastErrorString
respecively. Interfaces return the error from the last operation,
either serialization or deserialization.
Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: I705eb69e07393aa6601cc79712845200873235a0
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
gRPC in examples using the reference grpc++, which depends on abseil.
There is known upstream issue that abseil passes the MSVC only linker
flag that blocks the example compilation with MinGW compiler. The
problem meanwhile is bigger than that, since abseil simply don't have
a proper MinGW support, so we should warn users, that we do not
officially support MinGW in the examples that use the reference gRPC
server implementation.
Pick-to: 6.8 6.7
Fixes: QTBUG-128174
Change-Id: I319c54b5df02dac0be1dee441ec324f54f05ad93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Make sure to look for the ProtobufTools and GrpcTools packages
explicitly, for the grpc 'chat' example, to ensure the public
CMake API is available when the example is built as an external
project.
The Tools packages are not looked up automatically because the target
sysroot is missing protobuf tools dependencies, and thus we never
record a dependency from the target library packages to the tools
packages.
Augments 68b2e1db08
Adapts to 63b9cc81df
Pick-to: 6.8
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Task-number: QTBUG-110849
Change-Id: I036a37e0fb9c81de325a33ab6ae7322d14ae0cbc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
The header includes were not up-to-date.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: Id2a3d21925a0bf2ec6c8dfcb44617db3a8d5059c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
All examples now depend on ProtobufQuick module. Guard them properly.
Fixes: QTBUG-126126
Pick-to: 6.8
Change-Id: I49d631558da70b0d531c3b0c1e56b1d2d7890b8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
There is likely already an instantiation available for it. Prefer the
usage of QHash to stay within the (Qt) lib boundary.
Remove qgrpcdefs.h as it's now obsolete. Update all occurrences of
QGrpcMetadata.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: Ida7bcd851c2d4b247c1b7a8dccddc3d518e0b5ae
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This will make it easier to re-use it. This enum has a high chance of
being reused in the future.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: I587a2ae41e85b03539bc6213f53851ac37a415df
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Otherwise the example fails to configure when building as as an
external project in CI, with the errors:
CMake Error at Qt6ProtobufTools/Qt6ProtobufToolsMacros.cmake:605
(target_link_libraries):
Target "magic8ball_plugin" links to: Qt6::ProtobufQuick but the target
was not found.
Pick-to: 6.8
Change-Id: Iab3a8c6162f885efd149374a73f8599c1f375aed
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
- GrpcChannelOptions doesn't have host property anymore.
- There is a hostUri property in GrpcHttp2Channel {},
that should be used.
- The documentation part for magic8ball is updated accordingly.
Amends 2625537aee
Pick-to: 6.8
Change-Id: I23c35835838e468cf057beddccf2a32590e00e69
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
The signal is the redundant attempt to make Qt-style primitives. It
increases the usage complexity without any visible advantages. The
finished signal should instead accept the QGrpcStatus code and allow
users to make the descisions about the success of the operation in a
single call stack.
[ChangeLog][GRPC] The QGrpcOperation::errorOccurred and
QGrpcChannelOperation::errorOccurred signals are removed.
[ChangeLog][GRPC] The QGrpcOperation::finished and
QGrpcChannelOperation::finished signals now have QGrpcStatus argument
that indicates the status received from the server-side for the
operation.
Task-number: QTBUG-123625
Change-Id: I87669e0921c41cef0ff9d408bed1b057ba5198f2
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The host URI is not an optional property of the QGrpcHttp2Channel and
has not relations to QGrpcChannelOptions. We should move it to the
QGrpcHttp2Channel and use it there directly instead of making the
assumption that any channel should be created using the host URI. This
also removes the requirement of having the options as mandatory
argument to construct the gRPC channels.
Task-number: QTBUG-123625
Change-Id: I6cd64bad6c379f8875dcd6794a95bf68b46da605
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
It was concluded that we will use the 'set~()' syntax in our options but
still return a reference to allow chaining.
Task-number: QTBUG-123625
Change-Id: I00838465b485d096b4b7bd3d691d24385543d662
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>