Commit Graph

1597 Commits

Author SHA1 Message Date
Konrad Kujawa eeb96d7a7b Rename QGrpcAsyncOperation to QGrpcOperation
QGrpcOperation name is more matching the implementation,
because is no longer thread safe and does not implement any of
async methods.

Task-number: QTBUG-108833
Pick-to: 6.5
Change-Id: I926dc651b2c3daa58429bcb358a827bd398cee46
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-20 15:25:19 +01:00
Alexey Edelev 7b565c1d13 grpc: Minor test updates
Minimize incrementing and check of the iterator variables. Replaces
hardcoded test values with constants.

Change-Id: I5ae4c5e1ab8db62b5744e62f62a5124536686342
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-19 11:03:39 +01:00
Alexey Edelev 6ad57034be grpc: Make the latency between messages adjustable in tests
Reduce the base latency to 300ms since this should be good enough for
tests on localhost. Also replace all 'QT_TRY_<>' test calls with the
'QT_TRY_<>_WITH_TIMEOUT' calls to reduce the execution time.
Add signal spies for the 'finished' signal, to make sure that client
completed the communication with server, before checking messages
that were received from server and ensure that 'errorOccured' signal
is not called where it shouldn't.

Fixes: QTBUG-108212
Change-Id: I45338ad0495d77e461d96d2dd4193f1337dfbb3c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-19 11:03:26 +01:00
Qt Submodule Update Bot 24386c66ae Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I608c50f255829c0f52cfcc12ce8643f673d49bb5
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-17 11:52:19 +00:00
Jani Heikkinen d3ac699fb6 Bump version to 6.6.0
Change-Id: I3b2d3ddfaec45504cf6f00ea039dba0f713d0aef
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2022-12-15 06:55:23 +02:00
Qt Submodule Update Bot 2f397561b6 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I0ed01a829e3dc820e56a4fd6324077bdfa73b5e1
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-15 04:55:22 +00:00
Konrad Kujawa cb1bf672a1 Check required dependencies for gRPC before adding WrapgRPC library
Check required dependencies for gRPC, which are linked as
INTERFACE_LINK_LIBRARIES which results in error when trying to use
gRPC library.

Fixes: QTBUG-109372
Pick-to: 6.5
Change-Id: Ib1adb7f9aff3041c50fabaa47bf269081342a639
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-14 15:24:23 +01:00
Alexey Edelev b5662a170f grpc: Add the missing call of the finished() signal
Add the missing call of the finished() signal to the native-based
implementation of gRPC stream. Emit both errorOccured and finished
when the stream is finished with error. This behavior is aligned
with the behavior of QNetworkReply.

Task-number: QTBUG-108212
Change-Id: I3f45e33c89aca1cd258066a9f7b3df846ceeccc2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-11 21:21:24 +01:00
Qt Submodule Update Bot e02a320d98 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I01f1274186e788963bad179572162f8bfa19673e
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-11 16:37:40 +00:00
Qt Submodule Update Bot 8ebfb11795 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: If915e74da5843d447dad22d03b0cec1b75a570f4
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-10 13:55:37 +00:00
Qt Submodule Update Bot ddcf9523a6 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I5822b2a48a1905c0941b92bc7dabffa74d5605bc
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-10 07:17:43 +00:00
Alexey Edelev b27a709a18 Use pkg-config to find gRPC libraries if CMake package is not found
Look for the gRPC libraries using PkgConfig module. This helps to
find gRPC on systems that don't have CMake packages installed.

Task-number: QTBUG-108833
Change-Id: Iaaa9d38facd6490c3d96d9eb30b0cdddde46edde
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-12-09 18:31:53 +01:00
Konrad Kujawa 0d56724387 Introduce QtGrpc
QtGrpc provides support for serializing and deserializing
gRPC services using Qt.

The tool was originally written by Alexey Edelev, along with various
contributors, on GitHub. Originally under MIT license, but major
contributors have agreed to relicense the code under GPL/commercial for
inclusion in tools for Qt. Their copyright notice is retained and
the original source code, still licensed as MIT, can be found in its
original repository[0].

[0]: https://github.com/semlanik/qtprotobuf

Change-Id: Id29e70df1249e9369fbfaa2c543f3ff29efbdbea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-09 15:00:04 +01:00
Qt Submodule Update Bot d8e62f9f82 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I1ad00835ae79d01c96f8aa5e677ef4d4a4e1bac6
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-09 10:12:19 +00:00
Alexey Edelev df0cb8776f Add test that serializes an uninitialized message
Task-number: QTBUG-109291
Change-Id: Idff8e8977cc0c51ce1e3f9b9ac63775f2f6d4340
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-08 13:10:07 +01:00
Alexey Edelev 90c34b291a Avoid mixing const and non-const iterator
Fix the HandlersRegistry::findHandler function, avoid mixing const and
non-const iterator.

Change-Id: I81d6c1495850ad230db26c5f7af606ceca90a0d5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-08 13:09:48 +01:00
Qt Submodule Update Bot b652dbc814 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I82775dabf9ffe611f3d4371cfae2372718311225
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-07 19:55:03 +00:00
Alexey Edelev d0047b2846 Rename qtprotobufgen options
Rename:
  FOLDER option to GENERATE_PACKAGE_SUBFOLDERS
  COMMENTS option to COPY_COMMENTS
  OUT_GENERATED_HEADERS option to OUTPUT_HEADERS
  OUT_GENERATED_TARGETS option to OUTPUT_TARGETS

Adjust and cleanup the corresponding documentation.

Change-Id: I2fdeaaba89257c8bbca4389a08119abf3158702f
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-07 12:29:45 +01:00
Alexey Edelev 270b37f462 Remove FIELD_ENUM option
Oneof fields depend on the enum that contains field numbers. Enable
the option by default.

Change-Id: I4d5dd63f328d26bdce15d6310489c4146fbf5c0d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-12-07 12:29:45 +01:00
Alexey Edelev e040265d42 Avoid polluting the source directory if qtprotobufgen test failed
Use a directory where the test binary is located to generate
the protobuf source files. This avoids polluting the source
directory if test exits with the critical error.

Change-Id: I288b5b3b84b243c28e9dd967e4411a7d4805d1bf
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-07 12:29:45 +01:00
Mårten Nordheim 81d3e8eb8c Protobuf: store and re-emit unknown fields
Use the unknownEntries variable we so cleverly added in
QProtobufMessagePrivate to store the data for the unknown fields.

By using a bytes-to-count mapping we can easily store multiple repeated
entries of a message, which could happen in a repeated list with
multiple identical entries. Since we don't know if a field is actually
marked as _repeated_ or not (since it's an unknown field) we just have
to assume it is.

Fixes: QTBUG-101966
Change-Id: I1ebde5fdaebe2987a68de1632f136bb6606e718a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-12-07 12:29:45 +01:00
Alexey Edelev 660608d6b0 Add protobuf message registry and raw QProtobufMessage serialization
This allows to create messages using the full protobuf message
name, if the message was registered.

Using this mapping between QMetaType and QProtobufOrdering it's
now possible to serialize and deserialize pointers to QProtobufMessage
without casting QProtobufMessage to the protobuf message type.

This is partially required for conformance testing and Any type
handling.

Change-Id: I58fd2d821b76ce3f59f121b65ad28c2b28a189e7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-07 11:48:30 +01:00
Mårten Nordheim e1a98f4b16 Slim down test includes
The <QtTest/QtTest> include is a module-include and includes
_all_ of QtTest + its dependencies (QtCore)

Change-Id: I2a3d04798c259924b462f6e2eaec9d863c6c9edb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-12-07 11:07:26 +01:00
Marc Mutz ac917dea04 Mark the module free of qAsConst()
Change-Id: If18b75ad3fe3efee22e8f35c87977aba8e89d50e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-05 10:45:01 +01:00
Qt Submodule Update Bot eed393f073 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I66300c3ac5ed04a9ef4d729e9acf65297bd9823f
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-12-05 05:57:27 +00:00
Tatiana Borisova edb15aa9c2 QtProtobuf: Output tests for the generator
- test qt_add_protobuf and COMMENTS:FOLDER:FIELD_ENUM:EXTRA_NAMESPACE options
- call qtprotobufgen via command line with/without options

Task-number: QTBUG-103980
Change-Id: I658a6bebaee2e9135dd30b84108f24d4596bd7c7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-02 13:45:10 +01:00
Mårten Nordheim dd83ec0772 Fix all translate strings
It was supposed to be 'translate', not 'tr'.

Change-Id: I315285ccc9df1772fdaba8bcd1db658171796140
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-12-02 12:05:35 +01:00
Alexey Edelev 85f67bb7e9 Update the 'since' tag in protobuf documentation
Update version to 6.5, since protobuf was not released at 6.4 times.

Change-Id: I1714ca467fb897e9f079cc06cdd94d26b66fe6cb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-29 15:00:13 +01:00
Mårten Nordheim 78b649ea46 Protobuf: introduce base class QProtobufMessage
And inherit from it instead of QObject in messages.
Messages are inherently value-types. They don't have any logic
associated with them, they simply store some value(s).

Value-types should be copyable and movable but QObject _is not_ because
this would break connections and parenting.

By making the objects Q_GADGETs we can still retain Q_PROPERTY, and by
having a pointer to the object's staticMetaObject we can implement
property/setProperty functionality in QProtobufMessage with minimal
effort.

As a side-effect of this we no longer emit, or even have, signals
when values on a message changes. But, as mentioned previously, messages
don't have any logic associated to them so they would never update
without users either calling an associated setter function or by
deserializing a new message into an already-existing object.

As another side-effect: propertyCount has decreased because we no longer
have QObject's 'name' property.

Fixes: QTBUG-100986
Change-Id: I0366a180bf5aadd4afb075527b80cc0a3e923ab6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-11-29 13:38:49 +01:00
Qt Submodule Update Bot cd33c3cd52 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I8a0d01edcfec261d8efbc3a7a49aadbc0bd67b16
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-11-26 12:52:12 +00:00
Qt Submodule Update Bot bea95b4e2b Update dependencies on 'dev' in qt/qtgrpc
Change-Id: If0d1f1ee35a928fe25be68c71a91469a477d8e80
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-11-25 16:02:40 +00:00
Qt Submodule Update Bot 113b514bf4 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ie8e1d9c68f6322230a128824c1056f96f6d0a350
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-11-24 12:11:20 +00:00
Alexey Edelev cb689995e8 Enable qtprotobufgen feature when cross-compiling
Unlock testing on targeting platforms if they do force building tools.
Since the tool package requires the 'protoc' executable we also
need to make sure that 'protoc' could be found using host package
prefix path. This adds QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH to
seach prefixes of the 'protoc' executable.

TODO: We need to add protobuf to the b2qt CI image to build
qtprotobufgen unconditionally.

Change-Id: I29a711fe3c0986d7845d1a0622bc18badfdbd934
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-24 10:20:31 +01:00
Mårten Nordheim 122625ed30 Protobuf: Store the full message name in char_data
And store the size of the message name in the Data section.
Adding more meta data can be done in a similar way, adding extra fields
to char_data, bumping the version field and updating char_data() to deal
with new data.

Change-Id: Id7d3d867d74bcc80a05e597a4d0af7056982accb
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-23 17:23:19 +01:00
Alexey Edelev 41e980af0d Combine type trait checks to something readable
There are type checks that are repeated in the QProtobufSerializer
code. It makes sense to generalize them into appropriate structures
for code readability.

Change-Id: Ifb94e4bf1306aacbd2973cf6d88495ed182cf277
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-23 07:55:54 +01:00
Alexey Edelev e1a4a1c531 Add the packed attribute support for the message fields
Protobuf allows non-packed way of serialization of the repeated
fields. This is controlled on the protobuf schema level by adding the
'packed' attribute to a message field descriptor. If the attribute is
not set the default value is 'true', so all repeated messages should
use the 'packed' approach when serializing.

Fixes: QTBUG-103979
Change-Id: I078a18734785865a4b7b34190a642b82b7829755
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-22 12:36:48 +01:00
Alexey Edelev 11fe1e2e40 Add support for field flags
Add the additional field to the property ordering structure to
indicate the special attributes that the message fields may have,
e.g. the 'packed' attribute.

Task-number: QTBUG-103979
Change-Id: I62c974cc924011956feb7692d6cb4fcd072dc1e6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-22 12:36:47 +01:00
Alexey Edelev 99bb364a7b Change the container type of the internal type serializers
The list of integrated type serializers is predefined and can be
initialized statically. Using std::array allows us to avoid extra
allocations and gives us clean and simple static initialization.

Change-Id: I04290d3b343487d6967341502c893f76a5044139
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-22 12:36:46 +01:00
Qt Submodule Update Bot 72ecabc23e Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ia16cdf72761041dd223b0d943d511a928132e6ad
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-11-18 06:48:12 +00:00
Alexey Edelev 12d35dcdc0 Tune namespace related functions to make them pure string
Tune namespace related functions to make them pure string to stop
using std::vector to collect strings up, for later joining.

Change-Id: Ibc2dc3250a62dfd0f4db6135fea5f72146b8c552
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-17 17:13:09 +01:00
Alexey Edelev 3a3c1413f5 Forcibly disable the generating of the QML code in generator
Disable the generating of QML code in qtprotobufgen until the QML
part is ported to Qt6 using the modern QML API.

Change-Id: I24bec2ef65fbc6ca9ee28a4cd4253c924c19991c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-16 18:07:49 +01:00
Mårten Nordheim 8eef978222 Protobuf: Drop indentation from initializer templates
and move it into the code instead.

Change-Id: Ia15606452cd9fc9afad4ff8d8709a4fde961354b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-11-16 12:35:36 +01:00
Alexey Edelev 7b5769e64d Update dependencies.yaml manually to unlock CI
Change-Id: Id244c99aeaa22f0ff6c0bd128be8a5813a562b8d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-16 12:11:38 +01:00
Alexey Edelev 964249aaa4 Add protoc-native way of option handling
The protoc tool has the generic mechanisms for plugin option handling.
The plugin-specific options can be specified using the
--<plugin_name>_opt argument or by prepending options to the
--<plugin_name>_out argument with colon separator. In both cases
options need to be separated by semicolon. Add the processing of this
argument to generator and use --<plugin_name>_opt as the default one
in CMake API. Also adjust format of the QT_PROTOBUF_OPTIONS environment
variable to make them consistent.

Change-Id: I269ca7b9b2a952d0d30b18cb57c1465ae261c83a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-08 12:03:14 +01:00
Mårten Nordheim 5dceb77dff Long Live QProtobuf
The code handles serialization and deserialization by itself with no
extra dependencies. It also contains a system for registering converters
specific to Protobuf serialization as well as having the ability to
extend it to handle JSON encoding[0] in the future, using QJson.

This patch is a companion to the patch introducing the qtprotobufgen
tool.

The code was originally written by Alexey Edelev, along with various
contributors, on GitHub. Originally under MIT license, but major
contributors have agreed to relicense the code under LGPL/GPL/commercial
for inclusion in Qt. Their copyright notice is retained and the
original source code, still licensed as MIT, can be found in its
original repository[1].

[0]: https://developers.google.com/protocol-buffers/docs/proto3#json
[1]: https://github.com/semlanik/qtprotobuf

Done-with: Alexey Edelev <alexey.edelev@qt.io>
Change-Id: I8b2e7074a19f39bd52ab263e215d2e99ffaf1162
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2022-11-08 10:33:41 +01:00
Mårten Nordheim fffdeaea77 Long live qtprotobufgen
The generator generates Qt-based classes to be used in conjunction with
'QProtobuf' (separate patch).

qtprotobufgen works as an extension to the protoc tool from Google, and
thus also depends on its libraries for building.

The tool was originally written by Alexey Edelev, along with various
contributors, on GitHub. Originally under MIT license, but major
contributors have agreed to relicense the code under GPL/commercial for
inclusion in tools for Qt. Their copyright notice is retained and
the original source code, still licensed as MIT, can be found in its
original repository[0].

[0]: https://github.com/semlanik/qtprotobuf

Done-with: Alexey Edelev <alexey.edelev@qt.io>
Change-Id: I0d5f3d722cb98bca70fc0d4544ed840edb27430c
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2022-11-08 10:33:39 +01:00
Jukka Jokiniva 17ce4be291 Initial empty repository 2022-10-10 10:00:30 +00:00