Commit Graph

20 Commits

Author SHA1 Message Date
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 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
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 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
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
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
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
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
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
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