Commit Graph

7 Commits

Author SHA1 Message Date
Alexey Edelev 97a99986c0 Scope QAbstractProtobufSerializer::Error enum
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>
2024-09-05 10:41:03 +02:00
Alexey Edelev e04f23a76a Generate protobuf enum as enum class
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>
2024-08-28 14:47:48 +02:00
Alexey Edelev 119add5fde Make error handling in QAbstractProtobufSerializer generic
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>
2024-08-28 14:47:48 +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
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
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