Commit Graph

39 Commits

Author SHA1 Message Date
Samuli Piippo 1c985e5bfe CMake: install vehiclelib example library
Amend 84f941cec0 and install vehiclelib
as well.

Change-Id: Ia301101601a0e7f52f94c3fde2ae329080e0c6ae
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 10:59:55 +02: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 84f941cec0 Multi-thread clients usage example
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>
2024-03-04 08:47:44 +01:00
Alexey Edelev b9519412ae Move all registration functionality to a separate unit
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>
2024-01-26 20:51:01 +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 e17d28e0d0 qRegisterProtobufTypes() should be called for applications implicitly
- Delete manual qRegisterProtobufTypes() call in QML auto-tests
- Add auto-generation line into qtprotobufgen
*_protobuftyperegistrations.cpp file. Now registration is happening via
static variable.

Pick-to: 6.7 6.6
Task-number: QTBUG-117643
Change-Id: Ic9c7e299fd2cd157ff4f2705d34bc4606a83ddbe
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-01-24 11:40:14 +01:00
Alexey Edelev 11bd27f1a6 Adjust the licensing across the repo
Pick-to: 6.7 6.6
Fixes: QTBUG-117783
Change-Id: I85d73a876f911383b31821ba6f7de2a07dcc9f3c
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2024-01-12 09:54:57 +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 5dfa8a431f Add the network error handling to the chat example
Make the error from the gRPC channel visible to user.

Pick-to: 6.6
Change-Id: I0c41228612beb5c1c665f79f60d14c607f5739f8
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-11-17 13:44:07 +00: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 1cfd2d8e16 Add upper level project definition for gRPC chat example
Fixes the warning when building server and client at once.

Task-number: QTBUG-118180
Pick-to: 6.6 6.5
Change-Id: Idb52857d9d858edbecc029f3199f20fce86f40a9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-11-01 09:59:28 +01:00
Tatiana Borisova cff4e95f6a GRPC Chat example fails to build for QNX
- Platforms with QT_NO_CLIPBOARD should skip GRPC Chat example

Fixes: QTBUG-118321
Change-Id: Ia5f4c67867633460a73a3cdeb935f2e4ab4d9877
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-10-26 14:57:40 +02:00
Alexey Edelev f3aa84d05b Rename QGrpcStream to QGrpcServerStream
Rename QGrpcStream and all related functionality to QGrpcServerStream
and corresponding names. The stream only implements server-side
streaming, and should be named accordingly.

Task-number: QTBUG-105494
Change-Id: I6b94452a447609186b1aa68ff8795293eef9dc28
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-08-28 13:36:38 +02:00
Tatiana Borisova 06ea668e0b Provide QtGrpcQuick plugin documentation
- Update qt grpc tool with QML key description
- Document QGrpcMetadata typealias
- Update Chat example links to QGrpcMetadata

Task-number: QTBUG-115923
Change-Id: Id71cba0add3f36d1cbb6fd2c202fc9b1d3c888cc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-26 16:22:36 +02:00
Tatiana Borisova a8e8078f91 Fix source code references in grpc examples
Fixes: QTBUG-116258
Change-Id: I80c90ac0d8b3047fd8df5dc82af3cd391dc5c654
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-23 16:12:24 +00: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
Alexey Edelev b089a773e9 Move enums to the nested namespace out of class
Protobuf allows the following construction:
  message A {
      enum AEnum {
        AVal0 = 0;
      }
      B.BEnum val = 1;
  }
  message B {
      enum BEnum {
          BVal0 = 0;
      }
      A.AEnum val = 1;
  }

This requires forward declaration of nested enums, that is not possible
in C++. To solve this problem we may do the same trick that we do
for nested messages already.
This patch moves the nested enum type out of class to the
_QtProtobufNested namespace. The solution require the enum name
specification when using enums from this moment, since the owning
messages only contain type aliases now. So from example above to access
the AVal0 you need to use the full qualifier:
  A::AEnum::AVal0

The new generated code structure registrates Qml types using the built-in
macros, that unlocks direct linking of backing library without the need
of Qml plugin usage.

[ChangeLog][Protobuf] Nested enums moved out of message classes to the
nested namespace, same as the nested messages.

[ChangeLog][Protobuf][Qml] The geneated protobuf Qml modules do not
require the use of Qml plugins.

Fixes: QTBUG-115800
Change-Id: Ia67fcbecf492c3fd41350eada4d62fc9e5ea4dab
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-18 19:01:25 +02:00
Alexey Edelev 653180829e Fix the client 'bind' call eaten by Q_ASSERT_X
Q_ASSERT_X is empty in release-like configs, so the actual functionality
is eaten by macro. Fix issue in sensor example.

Pick-to: 6.5 6.6
Change-Id: Ib162a09a6552b9f1a522daadc998b8e597780e8a
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-08-16 10:57:19 +02:00
Dennis Oberst 5f75a40f92 chat example: fix unused string usage in server
We try to print this string but it is never assigned. Lets show
the users who registered.

Pick-to: 6.6 6.5
Change-Id: I0e384a2591aae0e39c567b1ccab694bdeddee920
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-09 15:58:01 +00: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
Alexey Edelev f08446cd8b Migrate to implictily shared lists
It doesn't make sense to store messages in repeated fields using
shared_ptr, especially because all protobuf messages implemented
using implicit sharing. This also allow using repeated fields from
QML without the need for extra registrations and conversion.

Task-number: QTBUG-113688
Change-Id: I0a2bf2bb79a26a1e8017cccb5d3a06b867c15c79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-01 15:51:55 +02:00
Konrad Kujawa d5803c0918 Update QtGRPC chat example to new options and QGrpcMetadata changes
Use QGrpcChannelOptions and QGrpcMetadata to set up user-password
authentication for SimpleChatEngine.

Task-number: QTBUG-111037
Change-Id: I2e7dea87d542b4f7585b0724a45c1398fa2047b5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-23 13:34:34 +02:00
Konrad Kujawa 4235684288 Introduce QGrpcMetadata
Introduce alias to std::multimap names QGrpcMetadata, to represent
additional HTTP headers, that can be added to channel and call options.
Then channel implementations can use QGrpcMetadata and append all
metadata do each call (TODO).

Task-number: QTBUG-111037
Change-Id: Ie16e658407a57a5f44bc1a0ff54dcb3ca8b06fe1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-23 13:34:34 +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
Topi Reinio b519fe95fd Doc: Use the \examplecategory macro to tag examples
The '\meta category' command was used for tagging examples with a
specific category, used in Qt Creators Welcome mode.

As we want to also generate lists of examples belonging to a category
elsewhere in the documentation, replace the command with a macro that
expands to the original \meta command and also adds the example to
a group using the \ingroup command. This way, the category names can
be used as arguments to the \generatelist or \annotatedlist commands.

Pick-to: 6.5
Task-number: QTBUG-112731
Change-Id: I38b38c524b35ad4c0049f2978f5fc65d03c6a1cd
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-04-11 13:34:44 +00:00
Tatiana Borisova 24a3216dfb Update Qt GRPC documentation
* Split descriptions into Overview and Usage parts
* Add qt_add_grpc procedure page
* Add qtgrpcgen page
* Move qgrpc example into qdoc include header file
* Enable examples

Task-number: QTBUG-103235
Pick-to: 6.5 6.5.0
Change-Id: Ia2810e93ec2cf673c249f33ded101018259f06f2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-03-15 19:51:12 +01:00
Konrad Kujawa 147d8a606d Fix links to CMake commands in magic 8 ball documentation
Pick-to: 6.5 6.5.0
Change-Id: I7071cfaabdd0983ff584d8b043cbf3f409fd8784
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-03-15 12:08:35 +01: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 4502bb0e76 Require c++17 for grpcchat server
The example server uses the c++17 standard but doesn't require it in
CMake. Add the missing requirement.

Amends fdd1d0339f

Pick-to: 6.5
Change-Id: I84f10ec22198cb50a8f393036382021ad5bf39e0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-03-07 11:52:58 +01: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 4c52dcca60 Fix qml warnings in the chat example
Amends fdd1d0339f

Task-number: QTBUG-109598
Pick-to: 6.5
Change-Id: Ied1bb64f5b70e087c8028a6c88d3bd29fc310aee
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-01 17:29:11 +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 fdd1d0339f Backport the simple chat example
Backport the simple chat example. The application implements a simple
messenger using Qt GRPC. It shows how to utilize the server-side
streaming and use the call-based user/password credentials.

Task-number: QTBUG-109598
Pick-to: 6.5
Change-Id: I4ca3695780a9cc9991c92c4423e3af9d8e0eaf35
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 18:29:39 +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
Alexey Edelev 76d94d29ea Add example of communication using protobuf messages
Add the protobuf example that emulates the work of dummy sensors that
send data to the sensor client. The example uses UDP sockets to send
datagrams that contain protobuf messages. Messages consist of two
layers:
 - The Type-Length-Value wrapping message that specifies the the
   message type and allows to verify the message size.
 - Sensor message that contains a sensor data.

The example intends to show how to generate the code from the protobuf
schema and use it in simple UDP signalling protocol on both sender and
receiver sides.

Both client and emulator have simple UI implemented using QtWidgets.

Task-number: QTBUG-109598
Pick-to: 6.5
Change-Id: I13e2c5bcd995b8aa6d873c495a7bd83f6651a061
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-13 15:10:52 +01:00