Commit Graph

29 Commits

Author SHA1 Message Date
Alexey Edelev 252c5467de Add the hint to find the host grpc_cpp_plugin when crosscompiling
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>
2025-03-18 18:08:13 +01:00
Alexey Edelev 30d983f27b Encourage to use vcpkg when building magic8ball example
Pick-to: 6.9
Task-number: QTBUG-132738
Change-Id: Ib13a5cfc82b64570a76ec9494d9bdb1a3b773695
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-07 11:10:58 +01:00
Alexey Edelev 9c03a6b0a7 Add vcpkg.json for the QtGRPC Magic 8 Ball example
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>
2025-03-07 11:10:47 +01:00
Dennis Oberst cb35d20adb Rewrite the qtgrpc chat example
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>
2025-02-24 10:41:22 +01:00
Dennis Oberst 6ab4321ccc Docs: create and distribute the \gRPC macro for adding trademarks
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>
2024-12-17 11:08:01 +01:00
Alexey Edelev b6f0fdc89a Use the upper-case Protobuf module name when looking it
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>
2024-12-03 16:18:57 +01:00
Jaime Resano c761459e59 Rework magic8ball example
Improve QML layout, GRPC communications, animation logic and
documentation. Simplify the GRPC server implementation removing Qt
parts.

Task-number: QTBUG-129571
Pick-to: 6.8
Change-Id: I8913ca3b52950d950dd5862bd986b222f0e6405e
Reviewed-by: Jaime Resano <Jaime.RESANO-AISA@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-11-15 14:40:21 +01:00
Jaime Resano 4e6fa8f643 Docs: move magic8ball grpc example documentation to suitable folder
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>
2024-11-13 14:35:07 +02:00
Alexey Edelev fa7c4410e8 Remove WrapgRPC and WrapProtobuf modules
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>
2024-10-15 18:12:58 +02:00
Alexey Edelev a5d79af204 Warn if users attempt building gRPC servers using MinGW
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>
2024-08-23 12:34:14 +02:00
Alexandru Croitor 5edd77f14b CMake: Add explicit lookup of ProtobufQuick package for magic8ball
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>
2024-07-15 13:11:12 +02:00
Tatiana Borisova fe51e73865 Fix magic8ball QML example
- 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>
2024-06-12 16:01:33 +02:00
Alexey Edelev fb9158fb9d Add the missing linking of protobuf backing QML library to magic8ball
Fixes the missing QML import in macOS.

Fixes: QTBUG-124917
Pick-to: 6.7
Change-Id: I8cdafa4d8e49e5a674555a95f1924f3d0415e915
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-03 15:09:20 +02:00
Lucie Gérard 4b21c9ef0d Correct license for example files
According to QUIP-18 [1], all example files should be
LicenseRef-Qt-Commercial OR BSD-3-Clause

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: If6b8c8eb88c8880e6e277f472dfdd5b380a5c83d
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-03-15 14:28:25 +01:00
Alexandru Croitor 68b2e1db08 CMake: Make examples build as external projects
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>
2024-03-06 17:14:45 +01:00
Tatiana Borisova 28323b583b Fix magic8ball example
- qtgrpcgen uses different naming rules for Grpc Clients now

Pick-to: 6.7
Change-Id: I54974e8143331c71b490a1c6df2d07aefc52d0a9
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-01-25 20:02:32 +01:00
Tatiana Borisova 34bd21d7d5 Add minimum_required version into MagicServerRunner CMake-project file
- also add Copyright into magic8ball example

Pick-to: 6.6 6.7
Change-Id: I0a2c9aa10b197fe225fbeccf27ddc650b805c518
Reviewed-by: 🌴 Alexey Edelev 🌴 <alexey.edelev@qt.io>
2023-12-14 16:32:19 +01:00
Alexey Edelev ef916940f7 Rename QML URI of the QtGrpcQuick module
Shorten the URI to follow the naming rule common for Qt QML Modules.

[ChangeLog][GRPC][QML] The QML URI of the QtGrpcQuick module is changed
to QtGrpc. All occurrences of module imports should be changed to
'import QtGrpc'.

Change-Id: I6039fc81e2c47838937729b1524f6112a165ca3a
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-11-14 16:14:49 +01:00
Alexey Edelev 36a64710a9 Format the .proto files according to the clang-format rules
Pick-to: 6.6 6.5
Change-Id: Iedc563ab8689779960dc6a2cc0b5817a874374e0
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-08-23 10:02:50 +02:00
Alexandru Croitor 98c145e001 CMake: Look for GrpcQuick package for the magic8ball example
Needed when building examples as ExternalProjects, otherwise CMake
complains about not finding the GrpcQuick target.

Amends 3b74fdff66

Change-Id: Ia071884ca3909cf0e76828c490ae923eb7568cb8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-08-03 18:24:42 +02:00
Tatiana Borisova 3b74fdff66 magic8ball example: extend QML support
Update magic8ball example using enabled QtGrpc API in QMl.

Task-number: QTBUG-114893
Change-Id: I055d20354d8260480af1b8b0d741077734117e75
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-07-28 17:50:03 +02:00
Konrad Kujawa 3b8b24c7e5 Introduce QGrpcCallOptions and QGrpcChannelOptions
Use the new classes to store call and channel options used to
create gRPC channels and perform gRPC calls.
Add QGrpcCallOptions parameter to call() and startStream() methods.
Change constructor parameter of QGrpcHttp2Channel and QGrpcChannel
to QGrpcChannelOptions that stores previous parameters used to
construct channel. Add additional deadline option to be able to
configure call timeout.

[ChangeLog] Add QGrpcCallOptions to store and process additional
call options.
[ChangeLog] Add QGrpcChannelOptions to store and process channel
options and default call options.

Task-number: QTBUG-111037
Change-Id: Icd92e95c036fb5b4c268907ab912fcf59ef9a69a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-23 13:34:34 +02:00
Alexey Edelev 30104d3c72 Fix warning related to the deprecated AUTORESOURCE_PREFIX argument
Replace the AUTORESOURCE_PREFIX argument with the explicit
RESOURCE_PREFIX.

Pick-to: 6.5
Change-Id: Iac73ba194ed1af07456dde7df9cd95fa55e5e024
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-05-15 13:01:56 +02:00
Alexey Edelev 1e07202376 Revert "Disable -fPIE for the qtgrpc/qtprotobuf executables"
This reverts commit 272957831e.

Reason for revert: This can be re-enabled since we enabled PIC/PIE in provisioning.

Change-Id: I181ab2b258c0751f8379877584dac03772601240
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-03-09 08:32:38 +00:00
Alexey Edelev 3b10bf74b2 Add the missing copyright and license headers to the .proto files
Pick-to: 6.5 6.5.0
Change-Id: Id3d75385f251e77aebe0b56a82549e19fd0fbf84
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-03-06 11:20:05 +01:00
Tatiana Borisova fb47ac8040 Window Material theme should be always light for magic8ball app
Plus, make clientserver code more readable

Pick-to: 6.5
Task-number: QTBUG-109598
Change-Id: If8f5c6779a8114308fcc02cf517ce602050a4f68
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-03-02 21:36:17 +01:00
Alexey Edelev 272957831e Disable -fPIE for the qtgrpc/qtprotobuf executables
If libprotobuf is not built with -fPIE enabled we cannot link it
to qtprotobufgen. Disable the flag until provisioning got the proper
update.

Do the same trick for all executables and libraries that are linked
to the libgrpc* or libproto* libraries.

TODO: Re-enable PIE once QTBUG-111485 is fixed.

Task-number: QTBUG-111485
Pick-to: 6.5
Change-Id: I8735069c0c0ab61ec5b118ee5c261f77627e3f8c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-24 13:47:33 +01:00
Alexey Edelev aed766a6e6 Remove redundant records from magic8ball example
libprotobuf is linked implicitly by libgrpc++. WrapgRPC_INCLUDE_PATH
doesn't have any effect, but pollutes the compiler include paths.

This fixes the standalone build of the example.

Pick-to: 6.5
Change-Id: Idaba45eb3232d379c61477d1cb62605692f49414
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 11:27:10 +00:00
Tatiana Borisova 681d104f0d The example of Qt gRPC-Client part with qml based UI
Pick-to: 6.5
Task-number: QTBUG-109598
Change-Id: I670f779fb9a85d02ad69a54dc6adaa50f52a7a71
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-02-21 21:30:32 +01:00