├── src ├── qt_cmdline.cmake ├── protobuf │ ├── qt_cmdline.cmake │ ├── doc │ │ ├── images │ │ │ ├── msvc-kit.webp │ │ │ ├── qt-creator.webp │ │ │ └── path-env-variable.webp │ │ ├── QtProtobufDoc │ │ └── src │ │ │ ├── qtprotobuf-toc.qdoc │ │ │ └── cmake-commands.qdoc │ ├── qtprotobufglobal.h │ ├── qtprotobuflogging.cpp │ ├── qprotobufobject.qdoc │ ├── qtprotobufdefs_p.h │ ├── qprotobufobject.h │ ├── qtprotobuflogging_p.h │ ├── qprotobufjsonserializer.h │ ├── qprotobufserializer.h │ └── qabstractprotobufserializer.h ├── grpc │ ├── doc │ │ └── src │ │ │ ├── qtgrpcgen.qdocinc │ │ │ ├── snippets │ │ │ └── qt-add-grpc-example.cmake │ │ │ ├── qtgrpc-toc.qdoc │ │ │ ├── qtgrpc-module.qdoc │ │ │ ├── qt-add-grpc-example.qdocinc │ │ │ └── cmake-commands.qdoc │ ├── qtgrpclogging.cpp │ ├── qtgrpcglobal.h │ ├── qtgrpclogging_p.h │ ├── qgrpccallreply.h │ └── configure.cmake ├── grpcquick │ ├── qtgrpcquicklogging.cpp │ ├── qqmlabstractgrpcchannel.cpp │ ├── qqmlabstractgrpcchannel_p.h │ ├── qqmlgrpcnamespace_p.h │ ├── qtgrpcquicklogging_p.h │ ├── qqmlgrpcmetadata.cpp │ ├── qqmlabstractgrpcchannel.h │ └── CMakeLists.txt ├── protobufqttypes │ ├── CMakeLists.txt │ ├── protobufqtguitypes │ │ ├── qtprotobufqtguitypesglobal.h │ │ ├── qtprotobufqtguitypes.h │ │ ├── CMakeLists.txt │ │ └── QtGui │ │ │ └── QtGui.proto │ └── protobufqtcoretypes │ │ ├── qtprotobufqtcoretypesglobal.h │ │ ├── CMakeLists.txt │ │ └── qtprotobufqtcoretypes.h ├── wellknown │ ├── qtprotobufwellknowntypesglobal.h │ ├── CMakeLists.txt │ └── qprotobufwellknowntypesjsonserializers_p.h ├── protobufquick │ └── CMakeLists.txt ├── tools │ ├── qtprotoccommon │ │ ├── qtprotocdefs.h │ │ ├── CMakeLists.txt │ │ └── descriptorprinterbase.h │ ├── qtprotobufgen │ │ ├── QtProtocCommandWrapper.cmake │ │ ├── enumdefinitionprinter.h │ │ ├── enumdeclarationprinter.h │ │ └── main.cpp │ └── qtgrpcgen │ │ ├── main.cpp │ │ ├── qmlclientdefinitionprinter.h │ │ ├── clientdefinitionprinter.h │ │ ├── qmlclientdeclarationprinter.h │ │ └── clientdeclarationprinter.h └── CMakeLists.txt ├── .tag ├── tests ├── auto │ ├── grpc │ │ ├── client │ │ │ ├── unarycall │ │ │ │ ├── BLACKLIST │ │ │ │ └── CMakeLists.txt │ │ │ ├── serverstream │ │ │ │ ├── BLACKLIST │ │ │ │ └── CMakeLists.txt │ │ │ ├── shared │ │ │ │ ├── test_server │ │ │ │ │ ├── assets │ │ │ │ │ │ └── generate.sh │ │ │ │ │ ├── testserverrunner.h │ │ │ │ │ └── testserver.cpp │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── client_service │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── mockserver │ │ │ │ │ └── CMakeLists.txt │ │ │ │ └── client_test_common │ │ │ │ │ └── grpcclienttestbase.h │ │ │ ├── interceptors │ │ │ │ ├── interceptor1.proto │ │ │ │ └── interceptor2.proto │ │ │ ├── end2end │ │ │ │ ├── event.proto │ │ │ │ └── eventhub.proto │ │ │ ├── CMakeLists.txt │ │ │ ├── deadline │ │ │ │ └── CMakeLists.txt │ │ │ ├── ssl │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── tst_grpc_client_ssl.cpp │ │ │ ├── bidistream │ │ │ │ └── CMakeLists.txt │ │ │ └── clientstream │ │ │ │ └── CMakeLists.txt │ │ ├── server │ │ │ ├── tst_grpc_server.cpp │ │ │ └── CMakeLists.txt │ │ ├── qgrpcstatus │ │ │ └── CMakeLists.txt │ │ ├── qgrpcserializationformat │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ ├── qgrpccalloptions │ │ │ ├── CMakeLists.txt │ │ │ └── tst_qgrpccalloptions.cpp │ │ ├── qgrpcchanneloptions │ │ │ └── CMakeLists.txt │ │ ├── qgrpchttp2channel │ │ │ └── CMakeLists.txt │ │ └── shared │ │ │ └── message_latency_defs.h │ ├── grpcquick │ │ ├── metadata │ │ │ ├── tst_metadata_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── calloptions │ │ │ ├── tst_calloptions_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── channeloptions │ │ │ ├── tst_channeloptions_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── http2channel │ │ │ ├── tst_grpchttp2channel_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── client │ │ │ ├── CMakeLists.txt │ │ │ ├── unarycall │ │ │ │ └── tst_grpc_client_unarycall_qml.cpp │ │ │ ├── bidistream │ │ │ │ └── tst_grpc_client_bidistream_qml.cpp │ │ │ └── serverstream │ │ │ │ └── tst_grpc_client_serverstream_qml.cpp │ │ └── CMakeLists.txt │ ├── protobufgen │ │ └── data │ │ │ ├── qtprotobufgenminimal.proto │ │ │ ├── qtprotobufgen_mutable_getter_clashing.proto │ │ │ ├── cmd_line_generated │ │ │ ├── header_guard_pragma │ │ │ │ └── qtprotobufgenminimal_qtprotoreg.cpp │ │ │ ├── header_guard_filename │ │ │ │ └── qtprotobufgenminimal_qtprotoreg.cpp │ │ │ ├── export_macro_custom_file_name_force_generate │ │ │ │ └── custom_file_name.hpp │ │ │ └── copy_comments │ │ │ │ └── annotation_qtprotoreg.cpp │ │ │ └── cmake_generated │ │ │ ├── qml │ │ │ └── tst_qtprotobufgen_qml_exports.qpb.h │ │ │ ├── export_macro │ │ │ └── tst_qtprotobufgen_export_macro_exports.qpb.h │ │ │ ├── qml_uri │ │ │ └── tst_qtprotobufgen_qml_uri_exports.qpb.h │ │ │ ├── no_options │ │ │ └── tst_qtprotobufgen_no_options_exports.qpb.h │ │ │ ├── copy_comments │ │ │ ├── tst_qtprotobufgen_copy_comments_exports.qpb.h │ │ │ └── annotation_qtprotoreg.cpp │ │ │ ├── extra_namespace │ │ │ └── tst_qtprotobufgen_extra_namespace_exports.qpb.h │ │ │ └── generate_package_subfolders │ │ │ └── tst_qtprotobufgen_generate_package_subfolders_exports.qpb.h │ ├── protobufqml │ │ ├── nested │ │ │ └── tst_protobuf_nested_qml.cpp │ │ ├── oneof │ │ │ ├── tst_protobuf_oneof_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── syntax │ │ │ ├── tst_protobuf_syntax_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── basic │ │ │ ├── tst_protobuf_basictypes_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── enums │ │ │ └── tst_protobuf_enumtypes_qml.cpp │ │ ├── messagelists │ │ │ ├── tst_protobuf_repeated_qml.cpp │ │ │ └── CMakeLists.txt │ │ ├── nopackage │ │ │ └── tst_protobuf_nopackage_qml.cpp │ │ └── CMakeLists.txt │ ├── shared │ │ └── data │ │ │ └── proto │ │ │ ├── nopackageexternal.proto │ │ │ ├── timestampmessages.proto │ │ │ ├── testserivcenomessages.proto │ │ │ ├── fieldindexrange.proto │ │ │ ├── extranamespace.proto │ │ │ ├── nopackage.proto │ │ │ ├── optional.proto │ │ │ ├── testservice.proto │ │ │ ├── anymessages.proto │ │ │ ├── oneofmessages.proto │ │ │ ├── qtguitypes.proto │ │ │ ├── additionalenums.proto │ │ │ └── qtcoretypes.proto │ ├── grpcgen │ │ └── data │ │ │ ├── 666-invalid-identifier.proto │ │ │ ├── cmake_generated │ │ │ ├── invalid-identifier │ │ │ │ ├── 666-invalid-identifier_qtprotoreg.cpp │ │ │ │ ├── tst_qtgrpcgen_invalid-identifier_exports.qpb.h │ │ │ │ ├── tst_qtgrpcgen_protobuf_invalid-identifier_exports.qpb.h │ │ │ │ ├── 666-invalid-identifier_client.grpc.qpb.cpp │ │ │ │ └── 666-invalid-identifier_client.grpc.qpb.h │ │ │ ├── qml │ │ │ │ ├── qtgrpcgen_qtprotoreg.cpp │ │ │ │ └── tst_qtgrpcgen_qml_exports.qpb.h │ │ │ ├── protobuf_common │ │ │ │ ├── qtgrpc │ │ │ │ │ └── tests │ │ │ │ │ │ └── qtgrpcgen_qtprotoreg.cpp │ │ │ │ └── tst_qtgrpcgen_protobuf_common_exports.qpb.h │ │ │ ├── no_options │ │ │ │ └── tst_qtgrpcgen_no_options_exports.qpb.h │ │ │ └── generate_package_subfolders │ │ │ │ └── tst_qtgrpcgen_generate_package_subfolders_exports.qpb.h │ │ │ ├── cmd_line_generated │ │ │ └── export_macro_custom_file_name_force_generate │ │ │ │ └── custom_file_name.hpp │ │ │ └── qtgrpcgen.proto │ ├── protobuf │ │ ├── recursive │ │ │ ├── recursive.proto │ │ │ └── CMakeLists.txt │ │ ├── wellknown │ │ │ └── proto │ │ │ │ └── durationtest.proto │ │ ├── nested │ │ │ ├── proto │ │ │ │ └── externalpackage.proto │ │ │ └── CMakeLists.txt │ │ ├── converters │ │ │ └── CMakeLists.txt │ │ ├── basic │ │ │ └── proto │ │ │ │ ├── fieldindexrange.proto │ │ │ │ └── unknownfield.proto │ │ ├── transparentwrapper │ │ │ ├── CMakeLists.txt │ │ │ └── tst_protobuf_transparentwrapper.cpp │ │ ├── extranamespace │ │ │ ├── proto │ │ │ │ └── extranamespace.proto │ │ │ └── CMakeLists.txt │ │ ├── qprotobuflazymessagepointer │ │ │ └── CMakeLists.txt │ │ ├── duplicated_metatypes │ │ │ ├── proto │ │ │ │ ├── duplicated_metatypes_external.proto │ │ │ │ └── duplicated_metatypes.proto │ │ │ └── CMakeLists.txt │ │ ├── conformance │ │ │ └── data │ │ │ │ └── qt_attribution.json │ │ ├── qprotobufpropertyorderingbuilder │ │ │ └── CMakeLists.txt │ │ ├── qprotobufoneof │ │ │ └── CMakeLists.txt │ │ ├── externalpackage │ │ │ ├── proto │ │ │ │ ├── externalpackageconsumer.proto │ │ │ │ └── externalpackage.proto │ │ │ └── CMakeLists.txt │ │ ├── sequence │ │ │ ├── CMakeLists.txt │ │ │ └── proto │ │ │ │ └── sequence.proto │ │ ├── nopackage │ │ │ └── CMakeLists.txt │ │ ├── syntax │ │ │ └── CMakeLists.txt │ │ ├── CMakeLists.txt │ │ └── enums │ │ │ └── CMakeLists.txt │ ├── protobufqttypes │ │ ├── qtcoretypesnested.proto │ │ └── qtguitypesnested.proto │ ├── protocplugintestcommon │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── manual │ ├── CMakeLists.txt │ └── grpc │ │ ├── CMakeLists.txt │ │ └── benchmarks │ │ ├── CMakeLists.txt │ │ └── bench_qtgrpcclient │ │ └── CMakeLists.txt ├── benchmarks │ ├── protobuf │ │ ├── CMakeLists.txt │ │ └── deserialize │ │ │ ├── tst_bench_deserialize_protobuf_base.h │ │ │ ├── tst_bench_deserialize_protobuf.cpp │ │ │ └── data │ │ │ └── bench.proto │ └── CMakeLists.txt └── CMakeLists.txt ├── .gitreview ├── examples ├── grpc │ ├── chat │ │ ├── doc │ │ │ └── images │ │ │ │ ├── chat_room.webp │ │ │ │ ├── chat_login.webp │ │ │ │ └── chat_settings.webp │ │ ├── client │ │ │ ├── android │ │ │ │ └── res │ │ │ │ │ ├── drawable-hdpi │ │ │ │ │ └── icon.png │ │ │ │ │ ├── drawable-ldpi │ │ │ │ │ └── icon.png │ │ │ │ │ ├── drawable-mdpi │ │ │ │ │ └── icon.png │ │ │ │ │ ├── drawable-xhdpi │ │ │ │ │ └── icon.png │ │ │ │ │ ├── drawable-xxhdpi │ │ │ │ │ └── icon.png │ │ │ │ │ └── drawable-xxxhdpi │ │ │ │ │ └── icon.png │ │ │ ├── ChatMessages │ │ │ │ ├── TextDelegate.qml │ │ │ │ ├── ImageDelegate.qml │ │ │ │ ├── UserStatusDelegate.qml │ │ │ │ └── FileContinuationDelegate.qml │ │ │ ├── chatmessagemodel.h │ │ │ ├── userstatusmodel.h │ │ │ ├── main.cpp │ │ │ └── StatusDisplay.qml │ │ ├── CMakeLists.txt │ │ ├── proto │ │ │ ├── qtgrpcchat.proto │ │ │ └── chatmessages.proto │ │ ├── vcpkg.json │ │ └── server │ │ │ └── credentials │ │ │ └── createCerts.sh │ ├── vehicle │ │ ├── doc │ │ │ └── images │ │ │ │ └── vehicle.webp │ │ ├── resources │ │ │ ├── direction_straight.svg │ │ │ ├── direction_left.svg │ │ │ ├── direction_right.svg │ │ │ └── fuel_icon.svg │ │ ├── StyledText.qml │ │ ├── main.cpp │ │ ├── proto │ │ │ ├── navigationservice.proto │ │ │ └── vehicleservice.proto │ │ ├── vcpkg.json │ │ ├── vehiclethread.h │ │ └── navigationthread.h │ ├── magic8ball │ │ ├── doc │ │ │ └── images │ │ │ │ └── magic8ballScreenshot.webp │ │ ├── ScaleAnimation.qml │ │ ├── proto │ │ │ └── exampleservice.proto │ │ ├── MagicText.qml │ │ ├── main.cpp │ │ └── vcpkg.json │ ├── clientguide │ │ ├── proto │ │ │ └── clientguide.proto │ │ ├── CMakeLists.txt │ │ └── client │ │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── protobuf │ ├── sensors │ │ ├── doc │ │ │ └── images │ │ │ │ ├── client.webp │ │ │ │ └── emulator.webp │ │ ├── tlv.proto │ │ ├── sensors.proto │ │ ├── vcpkg.json │ │ ├── client │ │ │ ├── CMakeLists.txt │ │ │ ├── main.cpp │ │ │ ├── sensorclient.h │ │ │ └── clientconsole.h │ │ ├── emulator │ │ │ ├── CMakeLists.txt │ │ │ ├── main.cpp │ │ │ ├── emulatorconsole.h │ │ │ └── sensoremulator.h │ │ └── CMakeLists.txt │ └── CMakeLists.txt └── CMakeLists.txt ├── qt_cmdline.cmake ├── dependencies.yaml ├── .cmake.conf ├── configure.cmake ├── LICENSES ├── LicenseRef-Qt-Commercial.txt ├── Qt-GPL-exception-1.0.txt └── BSD-3-Clause.txt └── coin ├── axivion └── ci_config_linux.json └── module_config.yaml /src/qt_cmdline.cmake: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/protobuf/qt_cmdline.cmake: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.tag: -------------------------------------------------------------------------------- 1 | 0611b5be2401a813402bd547135dc99c77de84ac 2 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/unarycall/BLACKLIST: -------------------------------------------------------------------------------- 1 | [Deadline] 2 | macos 64bit arm 3 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/serverstream/BLACKLIST: -------------------------------------------------------------------------------- 1 | [Deadline] 2 | macos 64bit arm 3 | -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=codereview.qt-project.org 3 | project=qt/qtgrpc 4 | defaultbranch=dev 5 | -------------------------------------------------------------------------------- /src/protobuf/doc/images/msvc-kit.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/src/protobuf/doc/images/msvc-kit.webp -------------------------------------------------------------------------------- /src/protobuf/doc/images/qt-creator.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/src/protobuf/doc/images/qt-creator.webp -------------------------------------------------------------------------------- /examples/grpc/chat/doc/images/chat_room.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/doc/images/chat_room.webp -------------------------------------------------------------------------------- /examples/grpc/chat/doc/images/chat_login.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/doc/images/chat_login.webp -------------------------------------------------------------------------------- /examples/grpc/vehicle/doc/images/vehicle.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/vehicle/doc/images/vehicle.webp -------------------------------------------------------------------------------- /src/protobuf/doc/images/path-env-variable.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/src/protobuf/doc/images/path-env-variable.webp -------------------------------------------------------------------------------- /examples/grpc/chat/doc/images/chat_settings.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/doc/images/chat_settings.webp -------------------------------------------------------------------------------- /examples/protobuf/sensors/doc/images/client.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/protobuf/sensors/doc/images/client.webp -------------------------------------------------------------------------------- /examples/protobuf/sensors/doc/images/emulator.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/protobuf/sensors/doc/images/emulator.webp -------------------------------------------------------------------------------- /tests/manual/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_subdirectory(grpc) 5 | -------------------------------------------------------------------------------- /qt_cmdline.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_commandline_subconfig(src/protobuf) 5 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/android/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/client/android/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /examples/grpc/chat/client/android/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/client/android/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /examples/grpc/chat/client/android/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/client/android/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /examples/grpc/chat/client/android/res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/client/android/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /examples/grpc/chat/client/android/res/drawable-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/client/android/res/drawable-xxhdpi/icon.png -------------------------------------------------------------------------------- /examples/grpc/magic8ball/doc/images/magic8ballScreenshot.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/magic8ball/doc/images/magic8ballScreenshot.webp -------------------------------------------------------------------------------- /tests/benchmarks/protobuf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_subdirectory(deserialize) 5 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/android/res/drawable-xxxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qt/qtgrpc/dev/examples/grpc/chat/client/android/res/drawable-xxxhdpi/icon.png -------------------------------------------------------------------------------- /tests/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(QT_FEATURE_qtprotobufgen) 5 | add_subdirectory(protobuf) 6 | endif() 7 | -------------------------------------------------------------------------------- /dependencies.yaml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | ../qtbase: 3 | ref: df1292e2b96aab02ad6df778d8336e7958ad5d1c 4 | required: true 5 | ../qtdeclarative: 6 | ref: 7ef1d06ce70fa360613dca0b5ff03365ebbc9883 7 | required: false 8 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/metadata/tst_metadata_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QUICK_TEST_MAIN(tst_metadata_qml) 7 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/calloptions/tst_calloptions_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QUICK_TEST_MAIN(tst_calloptions_qml) 7 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/qtprotobufgenminimal.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | package qt.protobuf; 6 | 7 | message Empty {} 8 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/nested/tst_protobuf_nested_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | QUICK_TEST_MAIN(tst_protobuf_nested_qml) 6 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/oneof/tst_protobuf_oneof_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | QUICK_TEST_MAIN(tst_protobuf_oneof_qml) 6 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/syntax/tst_protobuf_syntax_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QUICK_TEST_MAIN(tst_protobuf_syntax_qml) 7 | -------------------------------------------------------------------------------- /tests/manual/grpc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(TARGET Qt6::qtprotobufgen AND CMAKE_CXX_STANDARD_LATEST GREATER_EQUAL 20) 5 | add_subdirectory(benchmarks) 6 | endif() 7 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/resources/direction_straight.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/basic/tst_protobuf_basictypes_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | QUICK_TEST_MAIN(tst_protobuf_basictypes_qml) 6 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/enums/tst_protobuf_enumtypes_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | QUICK_TEST_MAIN(tst_protobuf_enumtypes_qml) 6 | 7 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/messagelists/tst_protobuf_repeated_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | QUICK_TEST_MAIN(tst_protobuf_repeated_qml) 6 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/nopackage/tst_protobuf_nopackage_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | QUICK_TEST_MAIN(tst_protobuf_nopackage_qml) 6 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/channeloptions/tst_channeloptions_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QUICK_TEST_MAIN(tst_grpc_channeloptions_qml) 7 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/http2channel/tst_grpchttp2channel_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QUICK_TEST_MAIN(tst_grpchttp2channel_qml) 7 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_subdirectory(unarycall) 5 | add_subdirectory(serverstream) 6 | add_subdirectory(clientstream) 7 | add_subdirectory(bidistream) 8 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/nopackageexternal.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | message SimpleIntMessageExt { 6 | int32 testFieldInt = 1; 7 | } 8 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/shared/test_server/assets/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | openssl req -x509 -newkey rsa:4096 -days 365 -nodes -keyout key.pem -out cert.pem -subj "/C=DE/ST=Berlin/L=Berlin/O=The Qt Company GmbH/OU=RnD/CN=localhost/emailAddress=alexey.edelev@qt.io" 4 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/resources/direction_left.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/protobuf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | if(QT_FEATURE_qtprotobufgen AND TARGET Qt6::Network AND TARGET Qt6::Widgets) 5 | qt_internal_add_example(sensors) 6 | endif() 7 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/resources/direction_right.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/StyledText.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | import QtQuick 5 | 6 | Text { 7 | font.family: "Helvetica" 8 | color: "white" 9 | font.pointSize: 18 10 | } 11 | -------------------------------------------------------------------------------- /src/grpc/doc/src/qtgrpcgen.qdocinc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | //! [qml-li] 5 | \li \c {QML} 6 | enables the generation of a QML client for the \gRPC service. 7 | //! [qml-li] 8 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/666-invalid-identifier.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | message Empty {} 6 | 7 | service InvalidService { 8 | rpc Get(Empty) returns (Empty) {} 9 | } 10 | -------------------------------------------------------------------------------- /src/grpc/qtgrpclogging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | Q_LOGGING_CATEGORY(Grpc, "qt.grpc", QtWarningMsg) 9 | 10 | QT_END_NAMESPACE 11 | -------------------------------------------------------------------------------- /.cmake.conf: -------------------------------------------------------------------------------- 1 | set(QT_REPO_MODULE_VERSION "6.12.0") 2 | set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1") 3 | 4 | set(QT_EXTRA_INTERNAL_TARGET_DEFINES 5 | "QT_LEAN_HEADERS=1" 6 | "QT_NO_CONTEXTLESS_CONNECT=1" 7 | "QT_NO_FOREACH=1" 8 | "QT_NO_QASCONST=1" 9 | "QT_NO_URL_CAST_FROM_STRING=1" 10 | ) 11 | -------------------------------------------------------------------------------- /src/grpcquick/qtgrpcquicklogging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | Q_LOGGING_CATEGORY(GrpcQuick, "qt.grpc.quick", QtWarningMsg) 9 | 10 | QT_END_NAMESPACE 11 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | add_subdirectory(basic) 5 | add_subdirectory(enums) 6 | add_subdirectory(nopackage) 7 | add_subdirectory(syntax) 8 | add_subdirectory(nested) 9 | add_subdirectory(messagelists) 10 | add_subdirectory(oneof) 11 | -------------------------------------------------------------------------------- /src/protobufqttypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(QT_FEATURE_protobuf_qtcoretypes) 5 | add_subdirectory(protobufqtcoretypes) 6 | endif() 7 | 8 | if(TARGET Qt6::Gui AND QT_FEATURE_protobuf_qtguitypes) 9 | add_subdirectory(protobufqtguitypes) 10 | endif() 11 | -------------------------------------------------------------------------------- /src/protobuf/qtprotobufglobal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | #ifndef QTPROTOBUFGLOBAL_H 5 | #define QTPROTOBUFGLOBAL_H 6 | 7 | #include 8 | #include 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /tests/auto/protobuf/recursive/recursive.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.tests; 6 | 7 | message RecursiveMessage { 8 | int32 testFieldInt = 1; 9 | RecursiveMessage testFieldRecursive = 2; 10 | } 11 | -------------------------------------------------------------------------------- /tests/auto/protobuf/wellknown/proto/durationtest.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | import "google/protobuf/duration.proto"; 6 | 7 | package qtproto.tests; 8 | 9 | message DurationMessage { 10 | google.protobuf.Duration field = 1; 11 | } 12 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/timestampmessages.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | import "google/protobuf/timestamp.proto"; 6 | 7 | package qtproto.tests; 8 | 9 | message TimestampMessage { 10 | google.protobuf.Timestamp field = 1; 11 | } 12 | -------------------------------------------------------------------------------- /examples/grpc/chat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.16) 5 | project(QtGrpcChat LANGUAGES CXX) 6 | 7 | find_package(Qt6 REQUIRED COMPONENTS Qml) # Needed for deployment 8 | 9 | add_subdirectory(server) 10 | add_subdirectory(client) 11 | -------------------------------------------------------------------------------- /src/protobuf/qtprotobuflogging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Alexey Edelev 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | Q_LOGGING_CATEGORY(Protobuf, "qt.protobuf", QtWarningMsg) 9 | 10 | QT_END_NAMESPACE 11 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/shared/test_server/testserverrunner.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef TEST_SERVER_H 5 | #define TEST_SERVER_H 6 | 7 | #include 8 | 9 | class TestServer 10 | { 11 | public: 12 | void run(qint64 latency); 13 | }; 14 | 15 | #endif // TEST_SERVER_H 16 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/qtprotobufgen_mutable_getter_clashing.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | package qt.protobuf; 6 | 7 | message MessageType { 8 | } 9 | 10 | message MessageHoder { 11 | MessageType mutField = 1; 12 | MessageType field = 2; 13 | } 14 | -------------------------------------------------------------------------------- /configure.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_extra_definition("QT_VERSION_STR" "\"${PROJECT_VERSION}\"" PUBLIC) 5 | qt_extra_definition("QT_VERSION_MAJOR" ${PROJECT_VERSION_MAJOR} PUBLIC) 6 | qt_extra_definition("QT_VERSION_MINOR" ${PROJECT_VERSION_MINOR} PUBLIC) 7 | qt_extra_definition("QT_VERSION_PATCH" ${PROJECT_VERSION_PATCH} PUBLIC) 8 | -------------------------------------------------------------------------------- /tests/auto/protobuf/nested/proto/externalpackage.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace1.tests.nested; 6 | 7 | message NestedFieldMessage { 8 | message NestedMessage { 9 | sint32 field = 1; 10 | } 11 | NestedMessage nested = 1; 12 | } 13 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/interceptors/interceptor1.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | 6 | package tst.i1; 7 | 8 | message CallMessage { 9 | string text = 1; 10 | int64 number = 2; 11 | } 12 | 13 | service Interceptor { 14 | rpc Unary(CallMessage) returns (CallMessage); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/invalid-identifier/666-invalid-identifier_qtprotoreg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "666-invalid-identifier.qpb.h" 3 | 4 | #include 5 | 6 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarEmpty(qRegisterProtobufType); 7 | static bool Register_666_invalid_identifierProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }(); 8 | 9 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/qml/qtgrpcgen_qtprotoreg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "qtgrpcgen.qpb.h" 3 | 4 | #include 5 | 6 | namespace qtgrpc::tests { 7 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarIntMessage(qRegisterProtobufType); 8 | static bool RegisterQtgrpcgenProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }(); 9 | } // namespace qtgrpc::tests 10 | 11 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/testserivcenomessages.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | import "basicmessages.proto"; 6 | 7 | package qtgrpc.tests.nomessages; 8 | 9 | service TestService { 10 | rpc testMethod(qtprotobufnamespace.tests.SimpleStringMessage) returns (qtprotobufnamespace.tests.SimpleStringMessage) {} 11 | } 12 | -------------------------------------------------------------------------------- /examples/grpc/magic8ball/ScaleAnimation.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | import QtQuick 5 | 6 | NumberAnimation { 7 | property string mode: "ZoomIn" 8 | property: "scale" 9 | duration: 1000 10 | easing.amplitude: 6.0 11 | easing.period: 2.5 12 | from: mode == "ZoomIn" ? 0.3 : 1.0 13 | to: mode == "ZoomIn" ? 1.0 : 0.3 14 | } 15 | -------------------------------------------------------------------------------- /src/protobuf/doc/QtProtobufDoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | // Include all module headers for the documentation build 5 | #include 6 | #include 7 | #include 8 | #include 9 | -------------------------------------------------------------------------------- /tests/auto/protobufqttypes/qtcoretypesnested.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.qttypes.tests; 6 | import "QtCore/QtCore.proto"; 7 | 8 | message NestedQUrlMessage { 9 | message QUrlMessage { 10 | QtCore.QUrl testField = 1; 11 | } 12 | NestedQUrlMessage.QUrlMessage testField = 1; 13 | } 14 | -------------------------------------------------------------------------------- /tests/auto/protobufqttypes/qtguitypesnested.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.qttypes.tests; 6 | import "QtGui/QtGui.proto"; 7 | 8 | message NestedQColorMessage { 9 | message QColorMessage { 10 | QtGui.QColor testField = 1; 11 | } 12 | NestedQColorMessage.QColorMessage testField = 1; 13 | } 14 | -------------------------------------------------------------------------------- /src/protobuf/qprotobufobject.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \inmodule QtProtobuf 6 | \relates QAbstractProtobufSerializer 7 | \macro Q_PROTOBUF_OBJECT 8 | 9 | Declares the propertyOrdering member in a class inheriting \l QProtobufMessage. 10 | This is used as part of the code generated by the qtprotobufgen tool. 11 | */ 12 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/qml/tst_qtgrpcgen_qml_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTGRPCGEN_QML_LIB) 5 | # define QPB_TST_QTGRPCGEN_QML_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTGRPCGEN_QML_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTGRPCGEN_QML_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/end2end/event.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | 6 | message Event { 7 | enum Type { 8 | UNKNOWN = 0; 9 | SERVER = 1; 10 | CLIENT = 2; 11 | } 12 | Type type = 1; 13 | string name = 2; 14 | uint64 number = 3; 15 | } 16 | 17 | message EventList { 18 | repeated Event events = 1; 19 | } 20 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/protobuf_common/qtgrpc/tests/qtgrpcgen_qtprotoreg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "qtgrpc/tests/qtgrpcgen.qpb.h" 3 | 4 | #include 5 | 6 | namespace qtgrpc::tests { 7 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarIntMessage(qRegisterProtobufType); 8 | static bool RegisterQtgrpcgenProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }(); 9 | } // namespace qtgrpc::tests 10 | 11 | -------------------------------------------------------------------------------- /examples/grpc/magic8ball/proto/exampleservice.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | syntax = "proto3"; 4 | 5 | package qtgrpc.examples; 6 | 7 | message AnswerRequest { 8 | string question = 1; 9 | } 10 | 11 | message AnswerResponse { 12 | string message = 1; 13 | } 14 | 15 | service ExampleService { 16 | rpc answerMethod(AnswerRequest) returns (AnswerResponse) {} 17 | } 18 | -------------------------------------------------------------------------------- /src/wellknown/qtprotobufwellknowntypesglobal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | #ifndef QT_PROTOBUF_WELLKNOWN_TYPES_GLOBAL_H 5 | #define QT_PROTOBUF_WELLKNOWN_TYPES_GLOBAL_H 6 | 7 | #include 8 | #include 9 | 10 | #endif // QT_PROTOBUF_WELLKNOWN_TYPES_GLOBAL_H 11 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Set the default message latency for the gRPC tests in milliseconds. 5 | add_compile_definitions(QT_GRPC_TEST_MESSAGE_LATENCY=${QT_INTERNAL_GRPC_TEST_MESSAGE_LATENCY_MSEC}) 6 | 7 | add_subdirectory(client) 8 | add_subdirectory(metadata) 9 | add_subdirectory(channeloptions) 10 | add_subdirectory(http2channel) 11 | add_subdirectory(calloptions) 12 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmd_line_generated/header_guard_pragma/qtprotobufgenminimal_qtprotoreg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "qtprotobufgenminimal.qpb.h" 3 | 4 | #include 5 | 6 | namespace qt::protobuf { 7 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarEmpty(qRegisterProtobufType); 8 | static bool RegisterQtprotobufgenminimalProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }(); 9 | } // namespace qt::protobuf 10 | 11 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmd_line_generated/header_guard_filename/qtprotobufgenminimal_qtprotoreg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "qtprotobufgenminimal.qpb.h" 3 | 4 | #include 5 | 6 | namespace qt::protobuf { 7 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarEmpty(qRegisterProtobufType); 8 | static bool RegisterQtprotobufgenminimalProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }(); 9 | } // namespace qt::protobuf 10 | 11 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/interceptors/interceptor2.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | 6 | package tst.i2; 7 | 8 | message StreamMessage { 9 | bytes data = 1; 10 | uint64 tag = 2; 11 | } 12 | 13 | service Interceptor { 14 | rpc BidiStream(stream StreamMessage) returns (stream StreamMessage); 15 | rpc ClientStream(stream StreamMessage) returns (StreamMessage); 16 | } 17 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/qml/tst_qtprotobufgen_qml_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTPROTOBUFGEN_QML_LIB) 5 | # define QPB_TST_QTPROTOBUFGEN_QML_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTPROTOBUFGEN_QML_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTPROTOBUFGEN_QML_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /examples/grpc/magic8ball/MagicText.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | import QtQuick 5 | import QtQuick.Layouts 6 | 7 | Text { 8 | Layout.alignment: Qt.AlignCenter 9 | Layout.fillWidth: true 10 | wrapMode: Text.WordWrap 11 | horizontalAlignment: Text.AlignHCenter 12 | font.family: "Helvetica" 13 | font.pointSize: 16 14 | color: "#264BAF" 15 | style: Text.Sunken 16 | } 17 | -------------------------------------------------------------------------------- /tests/auto/grpc/server/tst_grpc_server.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | #include 6 | 7 | class QtGrpcServerTest : public QObject 8 | { 9 | Q_OBJECT 10 | private Q_SLOTS: 11 | void trueTest(); 12 | }; 13 | 14 | void QtGrpcServerTest::trueTest() 15 | { 16 | QVERIFY(true); 17 | } 18 | 19 | QTEST_MAIN(QtGrpcServerTest) 20 | #include "tst_grpc_server.moc" 21 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/export_macro/tst_qtprotobufgen_export_macro_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_CUSTOM_EXPORT_NAME_LIB) 5 | # define QPB_CUSTOM_EXPORT_NAME_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_CUSTOM_EXPORT_NAME_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_CUSTOM_EXPORT_NAME_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/tlv.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | syntax = "proto3"; 4 | 5 | //! [0] 6 | package qt.examples.sensors.tlv; 7 | 8 | enum MessageType { 9 | Coordinates = 0; 10 | Temperature = 1; 11 | WarningNotification = 2; 12 | } 13 | 14 | // Protobuf messages imply inline data size. 15 | message TlvMessage { 16 | MessageType type = 1; 17 | bytes value = 2; 18 | } 19 | //! [0] 20 | -------------------------------------------------------------------------------- /src/protobufquick/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_internal_add_qml_module(ProtobufQuick 5 | URI QtProtobuf 6 | VERSION ${CMAKE_PROJECT_VERSION} 7 | PLUGIN_TARGET protobufquickplugin 8 | CLASS_NAME ProtobufQuickPlugin 9 | SOURCES 10 | qqmlprotobuftypes_p.h 11 | LIBRARIES 12 | Qt::Core 13 | Qt::Protobuf 14 | Qt::Qml 15 | PUBLIC_LIBRARIES 16 | Qt::Quick 17 | ) 18 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/shared/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | find_program(go NAMES go go.exe) 5 | 6 | if(go AND QT_ALLOW_DOWNLOAD AND NOT CMAKE_CROSSCOMPILING) 7 | add_subdirectory(test_server_go) 8 | set(qt_internal_grpc_use_golang_test_server TRUE) 9 | else() 10 | add_subdirectory(test_server) 11 | endif() 12 | add_subdirectory(client_service) 13 | add_subdirectory(client_test_common) 14 | add_subdirectory(mockserver) 15 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/no_options/tst_qtgrpcgen_no_options_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTGRPCGEN_NO_OPTIONS_LIB) 5 | # define QPB_TST_QTGRPCGEN_NO_OPTIONS_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTGRPCGEN_NO_OPTIONS_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTGRPCGEN_NO_OPTIONS_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /LICENSES/LicenseRef-Qt-Commercial.txt: -------------------------------------------------------------------------------- 1 | Licensees holding valid commercial Qt licenses may use this software in 2 | accordance with the the terms contained in a written agreement between 3 | you and The Qt Company. Alternatively, the terms and conditions that were 4 | accepted by the licensee when buying and/or downloading the 5 | software do apply. 6 | 7 | For the latest licensing terms and conditions, see https://www.qt.io/terms-conditions. 8 | For further information use the contact form at https://www.qt.io/contact-us. 9 | -------------------------------------------------------------------------------- /src/protobufqttypes/protobufqtguitypes/qtprotobufqtguitypesglobal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QTPROTOBUFQTGUITYPESGLOBAL_H 6 | #define QTPROTOBUFQTGUITYPESGLOBAL_H 7 | 8 | #include 9 | #include 10 | 11 | #endif // QTPROTOBUFQTGUITYPESGLOBAL_H 12 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/qml_uri/tst_qtprotobufgen_qml_uri_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTPROTOBUFGEN_QML_URI_LIB) 5 | # define QPB_TST_QTPROTOBUFGEN_QML_URI_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTPROTOBUFGEN_QML_URI_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTPROTOBUFGEN_QML_URI_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /src/protobufqttypes/protobufqtcoretypes/qtprotobufqtcoretypesglobal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QTPROTOBUFQTCORETYPESGLOBAL_H 6 | #define QTPROTOBUFQTCORETYPESGLOBAL_H 7 | 8 | #include 9 | #include 10 | 11 | #endif // QTPROTOBUFQTCORETYPESGLOBAL_H 12 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmd_line_generated/export_macro_custom_file_name_force_generate/custom_file_name.hpp: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_EXPORT_MACRO_WITH_FILE_LIB) 5 | # define QPB_EXPORT_MACRO_WITH_FILE_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_EXPORT_MACRO_WITH_FILE_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_EXPORT_MACRO_WITH_FILE_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QGuiApplication app(argc, argv); 10 | QQmlApplicationEngine engine; 11 | engine.loadFromModule("qtgrpc.examples.vehicle", "Main"); 12 | if (engine.rootObjects().isEmpty()) 13 | return -1; 14 | return app.exec(); 15 | } 16 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | add_subdirectory(shared) 4 | 5 | add_subdirectory(deadline) 6 | add_subdirectory(unarycall) 7 | add_subdirectory(serverstream) 8 | add_subdirectory(clientstream) 9 | add_subdirectory(bidistream) 10 | if(QT_FEATURE_ssl AND NOT WIN32) 11 | add_subdirectory(ssl) 12 | endif() 13 | if(TARGET grpc_mock_server) 14 | add_subdirectory(end2end) 15 | add_subdirectory(interceptors) 16 | endif() 17 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmd_line_generated/export_macro_custom_file_name_force_generate/custom_file_name.hpp: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_EXPORT_MACRO_WITH_FILE_LIB) 5 | # define QPB_EXPORT_MACRO_WITH_FILE_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_EXPORT_MACRO_WITH_FILE_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_EXPORT_MACRO_WITH_FILE_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /tests/auto/protocplugintestcommon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | set(CMAKE_AUTOMOC TRUE) 5 | qt_add_library(protocplugintestcommon STATIC protocplugintestcommon.h protocplugintestcommon.cpp) 6 | qt_autogen_tools_initial_setup(protocplugintestcommon) 7 | 8 | target_include_directories(protocplugintestcommon PUBLIC 9 | "$") 10 | target_link_libraries(protocplugintestcommon PUBLIC Qt6::Core Qt6::Test) 11 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/no_options/tst_qtprotobufgen_no_options_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTPROTOBUFGEN_NO_OPTIONS_LIB) 5 | # define QPB_TST_QTPROTOBUFGEN_NO_OPTIONS_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTPROTOBUFGEN_NO_OPTIONS_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTPROTOBUFGEN_NO_OPTIONS_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/ChatMessages/TextDelegate.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | import QtQuick 5 | import QtGrpcChat.Proto 6 | 7 | //! [client-qml-5] 8 | TextEdit { 9 | id: root 10 | 11 | required property textMessage message 12 | 13 | text: message.content 14 | color: "#f3f3f3" 15 | font.pointSize: 14 16 | wrapMode: TextEdit.Wrap 17 | readOnly: true 18 | selectByMouse: true 19 | } 20 | //! [client-qml-5] 21 | -------------------------------------------------------------------------------- /src/grpc/doc/src/snippets/qt-add-grpc-example.cmake: -------------------------------------------------------------------------------- 1 | #! [0] 2 | cmake_minimum_required(VERSION 3.16...3.22) 3 | project(MyProject) 4 | 5 | find_package(Qt6 REQUIRED COMPONENTS Protobuf Grpc) 6 | qt_standard_project_setup() 7 | 8 | qt_add_executable(MyApp main.cpp) 9 | 10 | qt_add_protobuf(MyApp 11 | PROTO_FILES 12 | path/to/messages.proto 13 | ) 14 | 15 | qt_add_grpc(MyApp CLIENT 16 | PROTO_FILES 17 | path/to/service.proto 18 | ) 19 | 20 | target_link_libraries(MyApp PRIVATE Qt6::Protobuf Qt6::Grpc) 21 | #! [0] 22 | -------------------------------------------------------------------------------- /src/grpc/qtgrpcglobal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 4 | 5 | #ifndef QTGRPCGLOBAL_H 6 | #define QTGRPCGLOBAL_H 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #endif // QTGRPCGLOBAL_H 18 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/protobuf_common/tst_qtgrpcgen_protobuf_common_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTGRPCGEN_PROTOBUF_COMMON_LIB) 5 | # define QPB_TST_QTGRPCGEN_PROTOBUF_COMMON_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTGRPCGEN_PROTOBUF_COMMON_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTGRPCGEN_PROTOBUF_COMMON_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/copy_comments/tst_qtprotobufgen_copy_comments_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTPROTOBUFGEN_COPY_COMMENTS_LIB) 5 | # define QPB_TST_QTPROTOBUFGEN_COPY_COMMENTS_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTPROTOBUFGEN_COPY_COMMENTS_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTPROTOBUFGEN_COPY_COMMENTS_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/end2end/eventhub.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | 6 | import "event.proto"; 7 | 8 | message None {} 9 | 10 | service EventHub { 11 | rpc Push(Event) returns (None) {} 12 | rpc Subscribe(None) returns (stream Event) {} 13 | rpc SubscribeList(None) returns (stream EventList) {} 14 | rpc Notify(stream Event) returns (None) {} 15 | rpc Exchange(stream Event) returns (stream Event) {} 16 | } 17 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/invalid-identifier/tst_qtgrpcgen_invalid-identifier_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTGRPCGEN_INVALID_IDENTIFIER_LIB) 5 | # define QPB_TST_QTGRPCGEN_INVALID_IDENTIFIER_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTGRPCGEN_INVALID_IDENTIFIER_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTGRPCGEN_INVALID_IDENTIFIER_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /examples/grpc/chat/proto/qtgrpcchat.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | //! [proto-1] 5 | syntax = "proto3"; 6 | 7 | package chat; 8 | 9 | import "chatmessages.proto"; 10 | 11 | service QtGrpcChat { 12 | // Register a user with \a Credentials. 13 | rpc Register(Credentials) returns (None); 14 | // Join as a registered user and exchange \a ChatMessage(s) 15 | rpc ChatRoom(stream ChatMessage) returns (stream ChatMessage) {} 16 | } 17 | //! [proto-1] 18 | -------------------------------------------------------------------------------- /tests/auto/grpc/qgrpcstatus/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qgrpcstatus LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_qgrpcstatus 11 | SOURCES 12 | tst_qgrpcstatus.cpp 13 | LIBRARIES 14 | Qt::Test 15 | Qt::Core 16 | Qt::Grpc 17 | ) 18 | -------------------------------------------------------------------------------- /tests/auto/protobuf/converters/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_converters LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_protobuf_converter 11 | SOURCES 12 | tst_protobuf_converter.cpp 13 | LIBRARIES 14 | Qt::Test 15 | Qt::Protobuf 16 | ) 17 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/extra_namespace/tst_qtprotobufgen_extra_namespace_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTPROTOBUFGEN_EXTRA_NAMESPACE_LIB) 5 | # define QPB_TST_QTPROTOBUFGEN_EXTRA_NAMESPACE_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTPROTOBUFGEN_EXTRA_NAMESPACE_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTPROTOBUFGEN_EXTRA_NAMESPACE_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/fieldindexrange.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.tests; 6 | 7 | message FieldIndexTest1Message { 8 | sint32 testField = 31; 9 | } 10 | 11 | message FieldIndexTest2Message { 12 | sint32 testField = 8191; 13 | } 14 | 15 | message FieldIndexTest3Message { 16 | sint32 testField = 2097151; 17 | } 18 | 19 | message FieldIndexTest4Message { 20 | sint32 testField = 536870911; 21 | } 22 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/client/unarycall/tst_grpc_client_unarycall_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | #include 7 | 8 | class GrpcClientUnarycallQml : public QObject 9 | { 10 | Q_OBJECT 11 | private: 12 | ServerProcRunner m_serverProccess{ TEST_GRPC_SERVER_PATH }; 13 | }; 14 | 15 | QUICK_TEST_MAIN_WITH_SETUP(tst_grpc_client_unarycall_qml, GrpcClientUnarycallQml) 16 | 17 | #include "tst_grpc_client_unarycall_qml.moc" 18 | -------------------------------------------------------------------------------- /tests/auto/protobuf/basic/proto/fieldindexrange.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.tests; 6 | 7 | message FieldIndexTest1Message { 8 | sint32 testField = 31; 9 | } 10 | 11 | message FieldIndexTest2Message { 12 | sint32 testField = 8191; 13 | } 14 | 15 | message FieldIndexTest3Message { 16 | sint32 testField = 2097151; 17 | } 18 | 19 | message FieldIndexTest4Message { 20 | sint32 testField = 536870911; 21 | } 22 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/extranamespace.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.tests; // Generated namespaces will be prepended with 6 | // the extra namespace 7 | message EmptyMessage {} 8 | 9 | message SimpleStringMessage { 10 | string testFieldString = 6; 11 | } 12 | 13 | message ComplexMessage { 14 | int32 testFieldInt = 1; 15 | SimpleStringMessage testComplexField = 2; 16 | } 17 | -------------------------------------------------------------------------------- /src/grpc/doc/src/qtgrpc-toc.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \page qtgrpc-toc.html 6 | \title Qt GRPC module topics 7 | 8 | The following list has links to all the individual topics (HTML files) 9 | in the Qt GRPC module. 10 | 11 | \list 12 | \li \l {The qtgrpcgen Tool} 13 | \li \l {CMake Commands in Qt6 GRPC}{CMake Commands} 14 | \list 15 | \li \l{qt_add_grpc} 16 | \endlist 17 | \endlist 18 | 19 | */ 20 | -------------------------------------------------------------------------------- /tests/auto/protobuf/transparentwrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_transparentwrapper LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_protobuf_transparentwrapper 11 | SOURCES 12 | tst_protobuf_transparentwrapper.cpp 13 | LIBRARIES 14 | Qt::Protobuf 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /src/protobufqttypes/protobufqtcoretypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_internal_add_protobuf_module(ProtobufQtCoreTypes 5 | SOURCES 6 | qtprotobufqtcoretypes.cpp 7 | qtprotobufqtcoretypes.h 8 | qtprotobufqtcoretypesglobal.h 9 | qtprotobufqttypescommon_p.h 10 | LIBRARIES 11 | Qt::Core 12 | Qt::Protobuf 13 | Qt::ProtobufPrivate 14 | PROTO_FILES 15 | QtCore/QtCore.proto 16 | PRIVATE_HEADER_FILTERS 17 | ".*\\.qpb\\.h" 18 | ) 19 | -------------------------------------------------------------------------------- /tests/auto/protobuf/extranamespace/proto/extranamespace.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.tests; // Generated namespaces will be prepended with 6 | // the extra namespace 7 | message EmptyMessage {} 8 | 9 | message SimpleStringMessage { 10 | string testFieldString = 6; 11 | } 12 | 13 | message ComplexMessage { 14 | int32 testFieldInt = 1; 15 | SimpleStringMessage testComplexField = 2; 16 | } 17 | -------------------------------------------------------------------------------- /tests/auto/protobuf/qprotobuflazymessagepointer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qprotobuflazymessagepointer LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_qprotobuflazymessagepointer 11 | SOURCES 12 | tst_qprotobuflazymessagepointer.cpp 13 | LIBRARIES 14 | Qt::Protobuf 15 | ) 16 | -------------------------------------------------------------------------------- /tests/auto/protobuf/duplicated_metatypes/proto/duplicated_metatypes_external.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.duplicated_metatypes_external; 6 | 7 | enum TestEnum { 8 | TEST_ENUM_VALUE0 = 0; 9 | TEST_ENUM_VALUE1 = 1; 10 | } 11 | 12 | message Message1 { 13 | string opts = 1; 14 | } 15 | 16 | message Message2 { 17 | map opts = 1; 18 | } 19 | 20 | message Message3 { 21 | map opts = 1; 22 | } 23 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/invalid-identifier/tst_qtgrpcgen_protobuf_invalid-identifier_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTGRPCGEN_PROTOBUF_INVALID_IDENTIFIER_LIB) 5 | # define QPB_TST_QTGRPCGEN_PROTOBUF_INVALID_IDENTIFIER_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTGRPCGEN_PROTOBUF_INVALID_IDENTIFIER_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTGRPCGEN_PROTOBUF_INVALID_IDENTIFIER_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /tests/auto/protobuf/conformance/data/qt_attribution.json: -------------------------------------------------------------------------------- 1 | { 2 | "Id": "protobuf-tests", 3 | "Name": "protobuf-tests", 4 | "QDocModule": "qtprotobuf", 5 | "QtUsage": "Used in the qtprotobufgen conformance tests.", 6 | "QtParts": [ "tests" ], 7 | "Files": ["conformance.proto", "test_messages_proto3.proto"], 8 | 9 | "SecurityCritical": false, 10 | "Homepage": "https://protobuf.dev", 11 | "License": "BSD 3-clause \"New\" or \"Revised\" License", 12 | "LicenseId": "BSD-3-Clause", 13 | "Copyright": "Copyright 2008 Google Inc.", 14 | "Version": "21.9" 15 | } 16 | -------------------------------------------------------------------------------- /tests/auto/protobuf/qprotobufpropertyorderingbuilder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qprotobufoneof LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_qprotobufpropertyorderingbuilder 11 | SOURCES 12 | tst_qprotobufpropertyorderingbuilder.cpp 13 | LIBRARIES 14 | Qt::ProtobufPrivate 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /tests/auto/grpc/qgrpcserializationformat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qgrpcserializationformat LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_qgrpcserializationformat 11 | SOURCES 12 | tst_qgrpcserializationformat.cpp 13 | LIBRARIES 14 | Qt::Test 15 | Qt::Core 16 | Qt::Grpc 17 | ) 18 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/generate_package_subfolders/tst_qtgrpcgen_generate_package_subfolders_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTGRPCGEN_GENERATE_PACKAGE_SUBFOLDERS_LIB) 5 | # define QPB_TST_QTGRPCGEN_GENERATE_PACKAGE_SUBFOLDERS_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTGRPCGEN_GENERATE_PACKAGE_SUBFOLDERS_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTGRPCGEN_GENERATE_PACKAGE_SUBFOLDERS_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/qtgrpcgen.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtgrpc.tests; 6 | 7 | message IntMessage { 8 | sint32 field = 1; 9 | } 10 | 11 | service TestService { 12 | rpc testMethod(IntMessage) returns (IntMessage) {} 13 | rpc testMethodServerStream(IntMessage) returns (stream IntMessage) {} 14 | rpc testMethodClientStream(stream IntMessage) returns (IntMessage) {} 15 | rpc testMethodBiStream(stream IntMessage) returns (stream IntMessage) {} 16 | } 17 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/sensors.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | syntax = "proto3"; 4 | 5 | //! [0] 6 | package qt.examples.sensors; 7 | 8 | message Coordinates { 9 | double longitude = 1; 10 | double latitude = 2; 11 | double altitude = 3; 12 | } 13 | 14 | message Temperature { 15 | enum Unit { 16 | Farenheit = 0; 17 | Celsius = 1; 18 | } 19 | sint32 value = 1; 20 | Unit units = 2; 21 | } 22 | 23 | message WarningNotification { 24 | string text = 1; 25 | } 26 | //! [0] 27 | -------------------------------------------------------------------------------- /src/protobufqttypes/protobufqtguitypes/qtprotobufqtguitypes.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QTPROTOBUFQTGUITYPES_H 6 | #define QTPROTOBUFQTGUITYPES_H 7 | 8 | #include 9 | 10 | QT_BEGIN_NAMESPACE 11 | 12 | namespace QtProtobuf { 13 | 14 | Q_PROTOBUFQTGUITYPES_EXPORT void registerProtobufQtGuiTypes(); 15 | 16 | } 17 | 18 | QT_END_NAMESPACE 19 | 20 | #endif // QTPROTOBUFQTGUITYPES_H 21 | -------------------------------------------------------------------------------- /tests/auto/grpc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Set the default message latency for the gRPC tests in milliseconds. 5 | add_compile_definitions(QT_GRPC_TEST_MESSAGE_LATENCY=${QT_INTERNAL_GRPC_TEST_MESSAGE_LATENCY_MSEC}) 6 | 7 | if(TARGET gRPC::grpc++) 8 | add_subdirectory(client) 9 | add_subdirectory(server) 10 | add_subdirectory(qgrpchttp2channel) 11 | add_subdirectory(qgrpcserializationformat) 12 | add_subdirectory(qgrpcstatus) 13 | add_subdirectory(qgrpccalloptions) 14 | add_subdirectory(qgrpcchanneloptions) 15 | endif() 16 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/generate_package_subfolders/tst_qtprotobufgen_generate_package_subfolders_exports.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #if defined(QT_SHARED) || !defined(QT_STATIC) 4 | # if defined(QT_BUILD_TST_QTPROTOBUFGEN_GENERATE_PACKAGE_SUBFOLDERS_LIB) 5 | # define QPB_TST_QTPROTOBUFGEN_GENERATE_PACKAGE_SUBFOLDERS_EXPORT Q_DECL_EXPORT 6 | # else 7 | # define QPB_TST_QTPROTOBUFGEN_GENERATE_PACKAGE_SUBFOLDERS_EXPORT Q_DECL_IMPORT 8 | # endif 9 | #else 10 | # define QPB_TST_QTPROTOBUFGEN_GENERATE_PACKAGE_SUBFOLDERS_EXPORT 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /examples/grpc/magic8ball/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QGuiApplication app(argc, argv); 10 | QQmlApplicationEngine engine; 11 | QObject::connect( 12 | &engine, &QQmlApplicationEngine::objectCreationFailed, &app, 13 | []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection); 14 | 15 | engine.loadFromModule("qtgrpc.examples.magic8ball", "Main"); 16 | return app.exec(); 17 | } 18 | -------------------------------------------------------------------------------- /src/protobufqttypes/protobufqtcoretypes/qtprotobufqtcoretypes.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QTPROTOBUFQTCORETYPES_H 6 | #define QTPROTOBUFQTCORETYPES_H 7 | 8 | #include 9 | 10 | QT_BEGIN_NAMESPACE 11 | 12 | namespace QtProtobuf { 13 | 14 | Q_PROTOBUFQTCORETYPES_EXPORT void registerProtobufQtCoreTypes(); 15 | 16 | } 17 | 18 | QT_END_NAMESPACE 19 | 20 | #endif // QTPROTOBUFQTCORETYPES_H 21 | -------------------------------------------------------------------------------- /tests/auto/protobuf/qprotobufoneof/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qprotobufoneof LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_qprotobufoneof 11 | SOURCES 12 | tst_qprotobufoneof.cpp 13 | LIBRARIES 14 | Qt::Protobuf 15 | ) 16 | 17 | set_property(TARGET tst_qprotobufoneof APPEND PROPERTY AUTOMOC_MACRO_NAMES "Q_PROTOBUF_OBJECT") 18 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/resources/fuel_icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", 3 | "description": "The Sensors example shows how two applications can communicate by sending protobuf messages using UDP sockets", 4 | "dependencies": [ 5 | "protobuf" 6 | ], 7 | "features": { 8 | "vcpkg-qt": { 9 | "description": "Use Qt libraries from vcpkg", 10 | "dependencies": [ 11 | { 12 | "name": "qtgrpc", 13 | "version>=": "6.9" 14 | } 15 | ] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/tools/qtprotoccommon/qtprotocdefs.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 3 | 4 | #ifndef QTPROTOCDEFS_H 5 | #define QTPROTOCDEFS_H 6 | 7 | #include 8 | #if GOOGLE_PROTOBUF_VERSION >= 3012000 9 | // Idicates the major libprotoc API update that happened in version 3.12 10 | # define HAVE_PROTOBUF_SYNC_PIPER 11 | #endif 12 | 13 | #if GOOGLE_PROTOBUF_VERSION >= 4023000 14 | // Idicates that libprotoc has Descriptor::real_oneof_decl method 15 | # define HAVE_REAL_ONEOF_DECL 16 | #endif 17 | 18 | #endif // QTPROTOCDEFS_H 19 | -------------------------------------------------------------------------------- /src/protobuf/doc/src/qtprotobuf-toc.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \page qtprotobuf-toc.html 6 | \title Qt Protobuf module topics 7 | 8 | List of topics (HTML files) in the Qt Protobuf module. 9 | 10 | \list 11 | \li \l {Example of installation for Windows using vcpkg}{Installation for Windows using vcpkg} 12 | \li \l {The qtprotobufgen Tool} 13 | \li \l {CMake Commands in Qt6 Protobuf}{CMake Commands} 14 | \list 15 | \li \l{qt_add_protobuf} 16 | \endlist 17 | \endlist 18 | 19 | */ 20 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/nopackage.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | import "nopackageexternal.proto"; 6 | 7 | message EmptyMessage {} 8 | 9 | enum TestEnum { 10 | LOCAL_ENUM_VALUE0 = 0; 11 | LOCAL_ENUM_VALUE1 = 1; 12 | LOCAL_ENUM_VALUE2 = 2; 13 | LOCAL_ENUM_VALUE3 = 5; 14 | } 15 | 16 | message SimpleIntMessage { 17 | int32 testFieldInt = 1; 18 | } 19 | 20 | message NoPackageExternalMessage { 21 | SimpleIntMessageExt testField = 1; 22 | } 23 | 24 | message NoPackageMessage { 25 | SimpleIntMessage testField = 1; 26 | } 27 | -------------------------------------------------------------------------------- /src/grpcquick/qqmlabstractgrpcchannel.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | 9 | QQmlAbstractGrpcChannel::QQmlAbstractGrpcChannel(QQmlAbstractGrpcChannelPrivate &dd, 10 | QObject *parent) 11 | : QObject(dd, parent) 12 | { 13 | } 14 | 15 | QQmlAbstractGrpcChannel::~QQmlAbstractGrpcChannel() 16 | = default; 17 | 18 | 19 | QT_END_NAMESPACE 20 | 21 | #include "moc_qqmlabstractgrpcchannel.cpp" 22 | -------------------------------------------------------------------------------- /tests/auto/grpc/qgrpccalloptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qgrpccalloptions LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_qgrpccalloptions 11 | SOURCES 12 | tst_qgrpccalloptions.cpp 13 | INCLUDE_DIRECTORIES 14 | "${CMAKE_CURRENT_LIST_DIR}/../shared" 15 | LIBRARIES 16 | Qt::Core 17 | Qt::Test 18 | Qt::TestPrivate 19 | Qt::Grpc 20 | ) 21 | -------------------------------------------------------------------------------- /src/protobufqttypes/protobufqtguitypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_internal_add_protobuf_module(ProtobufQtGuiTypes 5 | SOURCES 6 | qtprotobufqtguitypes.cpp 7 | qtprotobufqtguitypes.h 8 | qtprotobufqtguitypesglobal.h 9 | LIBRARIES 10 | Qt::Core 11 | Qt::Gui 12 | Qt::Protobuf 13 | Qt::ProtobufPrivate 14 | Qt::ProtobufQtCoreTypesPrivate 15 | PUBLIC_LIBRARIES 16 | Qt::ProtobufQtCoreTypes # TODO: QTBUG-86533 workaround 17 | PROTO_FILES 18 | QtGui/QtGui.proto 19 | PRIVATE_HEADER_FILTERS 20 | ".*\\.qpb\\.h" 21 | ) 22 | -------------------------------------------------------------------------------- /tests/auto/grpc/qgrpcchanneloptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qgrpcchanneloptions LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_qgrpcchanneloptions 11 | SOURCES 12 | tst_qgrpcchanneloptions.cpp 13 | INCLUDE_DIRECTORIES 14 | "${CMAKE_CURRENT_LIST_DIR}/../shared" 15 | LIBRARIES 16 | Qt::Core 17 | Qt::Test 18 | Qt::TestPrivate 19 | Qt::Grpc 20 | ) 21 | -------------------------------------------------------------------------------- /src/grpc/doc/src/qtgrpc-module.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | /*! 4 | \module QtGrpc 5 | \title Qt GRPC C++ Classes 6 | \ingroup frameworks-technologies 7 | \qtcmakepackage Grpc 8 | \since 6.5 9 | 10 | \brief The Qt GRPC module provides support for communicating with \gRPC services. 11 | */ 12 | 13 | /*! 14 | \group qtgrpc-examples 15 | \title Qt GRPC Examples 16 | \brief A collection of examples for \l {Qt GRPC C++ Classes} 17 | 18 | These examples demonstrate how to generate code using the protobuf and \gRPC schemas, 19 | and use it in your projects. 20 | */ 21 | -------------------------------------------------------------------------------- /src/tools/qtprotoccommon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_add_library(QtProtocCommon STATIC 5 | qtprotocdefs.h 6 | baseprinter.cpp baseprinter.h 7 | descriptorprinterbase.h 8 | generatorbase.cpp generatorbase.h 9 | generatorcommon.cpp generatorcommon.h 10 | options.cpp options.h 11 | commontemplates.cpp commontemplates.h 12 | utils.cpp utils.h 13 | ) 14 | 15 | target_link_libraries(QtProtocCommon 16 | PUBLIC 17 | protobuf::libprotobuf 18 | protobuf::libprotoc 19 | ) 20 | 21 | target_include_directories(QtProtocCommon PUBLIC 22 | $ 23 | ) 24 | -------------------------------------------------------------------------------- /tests/auto/protobuf/externalpackage/proto/externalpackageconsumer.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | import "externalpackage.proto"; 6 | 7 | package qtprotobufnamespace.tests; 8 | 9 | message SimpleExternalEnumMessage { 10 | qtprotobufnamespace1.externaltests.ExternalTestEnum externalEnum = 1; 11 | } 12 | 13 | message RepeatedExternalComplexMessage { 14 | repeated qtprotobufnamespace1.externaltests.ExternalComplexMessage testExternalComplex = 1; 15 | } 16 | 17 | message NestedExternal { 18 | qtprotobufnamespace1.externaltests.NestedFieldMessage.NestedMessage externalNested = 1; 19 | } 20 | -------------------------------------------------------------------------------- /coin/axivion/ci_config_linux.json: -------------------------------------------------------------------------------- 1 | { 2 | "Project": { 3 | "BuildSystemIntegration": { 4 | "child_order": [ 5 | "LinkLibraries" 6 | ] 7 | }, 8 | "LinkLibraries": { 9 | "_active": true, 10 | "_copy_from": "AxivionLinker", 11 | "input_files": [ 12 | "$(splitpath:TARGET_NAME)" 13 | ], 14 | "ir": "$(env:IRNAME)", 15 | "plugin_files": [ 16 | "$(splitpath:PLUGINS)" 17 | ] 18 | } 19 | }, 20 | "_Format": "1.0", 21 | "_Version": "7.6.2", 22 | "_VersionNum": [ 23 | 7, 24 | 6, 25 | 2, 26 | 12725 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /examples/grpc/clientguide/proto/clientguide.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | //! [0] 5 | syntax = "proto3"; 6 | package client.guide; // enclosing namespace 7 | 8 | message Request { 9 | int64 time = 1; 10 | sint32 num = 2; 11 | } 12 | 13 | message Response { 14 | int64 time = 1; 15 | sint32 num = 2; 16 | } 17 | 18 | service ClientGuideService { 19 | rpc UnaryCall (Request) returns (Response); 20 | rpc ServerStreaming (Request) returns (stream Response); 21 | rpc ClientStreaming (stream Request) returns (Response); 22 | rpc BidirectionalStreaming (stream Request) returns (stream Response); 23 | } 24 | //! [0] 25 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/proto/navigationservice.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | syntax = "proto3"; 4 | 5 | package qtgrpc.examples; 6 | import "google/protobuf/empty.proto"; 7 | 8 | //! [Proto types] 9 | enum DirectionEnum { 10 | RIGHT = 0; 11 | LEFT = 1; 12 | STRAIGHT = 2; 13 | BACKWARD = 3; 14 | } 15 | 16 | message NavigationMsg { 17 | int32 totalDistance = 1; 18 | int32 traveledDistance = 2; 19 | DirectionEnum direction = 3; 20 | string street = 4; 21 | } 22 | 23 | service NavigationService { 24 | rpc getNavigationStream(google.protobuf.Empty) returns (stream NavigationMsg) {} 25 | } 26 | //! [Proto types] 27 | -------------------------------------------------------------------------------- /src/protobuf/doc/src/cmake-commands.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \group cmake-commands-qtprotobuf 6 | \title CMake Commands in Qt6 Protobuf 7 | 8 | You should call the following CMake commands to use the Qt6::Protobuf 9 | module in your project: 10 | \badcode 11 | find_package(Qt6 REQUIRED COMPONENTS Protobuf) 12 | 13 | target_link_libraries(mytarget PRIVATE Qt6::Protobuf) 14 | \endcode 15 | 16 | You can use the \l {qt_add_protobuf} CMake command 17 | to implicitly call Qt Protobuf code generation for your project. 18 | 19 | \include qt-add-protobuf-example.qdocinc 0 20 | 21 | \sa{CMake Command Reference} 22 | */ 23 | -------------------------------------------------------------------------------- /coin/module_config.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | accept_configuration: 3 | condition: property 4 | property: features 5 | not_contains_value: Disable 6 | 7 | instructions: 8 | Build: 9 | - type: EnvironmentVariable 10 | variableName: VERIFY_SOURCE_SBOM 11 | variableValue: "ON" 12 | - type: EnvironmentVariable 13 | variableName: USE_VCPKG 14 | variableValue: "ON" 15 | enable_if: 16 | condition: property 17 | property: target.osVersion 18 | not_in_values: [Android_ANY] 19 | - !include "{{qt/qtbase}}/coin_module_build_template_v2.yaml" 20 | 21 | Test: 22 | - !include "{{qt/qtbase}}/coin_module_test_template_v3.yaml" 23 | - !include "{{qt/qtbase}}/coin_module_test_docs.yaml" 24 | -------------------------------------------------------------------------------- /examples/grpc/chat/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", 3 | "description": "Simple chat based on the Qt GRPC client API.", 4 | "dependencies": [ 5 | "protobuf", 6 | "grpc" 7 | ], 8 | "features": { 9 | "vcpkg-qt": { 10 | "description": "Use Qt libraries from vcpkg", 11 | "dependencies": [ 12 | { 13 | "name": "qtgrpc", 14 | "version>=": "6.9" 15 | }, 16 | { 17 | "name": "qtdeclarative", 18 | "version>=": "6.9" 19 | } 20 | ] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/grpc/doc/src/qt-add-grpc-example.qdocinc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | //! [0] 5 | \snippet qt-add-grpc-example.cmake 0 6 | 7 | The example above calls the \c{qt_add_grpc()} CMake function to start Qt GRPC 8 | code generation for \c service sections within the provided protobuf schema. 9 | 10 | \note If the protobuf schema also contains \c message definitions, the 11 | \c{qt_add_protobuf()} CMake function should also be called to start Qt Protobuf 12 | code generation. 13 | 14 | Since we reuse the executable target, all generated files will be appended to 15 | the target, and the include directories will be updated accordingly. 16 | //! [0] 17 | -------------------------------------------------------------------------------- /examples/grpc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | if(TARGET Qt6::qtprotobufgen AND TARGET Qt6::qtgrpcgen) 5 | qt_internal_add_example(clientguide) 6 | if(TARGET Qt6::ProtobufQuick AND TARGET Qt6::QuickControls2) 7 | qt_internal_add_example(magic8ball) 8 | 9 | if(TARGET Qt6::ProtobufWellKnownTypes) 10 | qt_internal_add_example(vehicle) 11 | endif() 12 | 13 | if(QT_FEATURE_clipboard AND QT_FEATURE_quickcontrols2_material 14 | AND TARGET Qt6::ProtobufQtCoreTypes AND TARGET Qt6::GrpcQuick) 15 | qt_internal_add_example(chat) 16 | endif() 17 | endif() 18 | endif() 19 | 20 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/proto/vehicleservice.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | syntax = "proto3"; 4 | 5 | package qtgrpc.examples; 6 | import "google/protobuf/empty.proto"; 7 | 8 | 9 | //! [Proto types] 10 | message SpeedMsg { 11 | int32 speed = 1; 12 | } 13 | 14 | message RpmMsg { 15 | int32 rpm = 1; 16 | } 17 | 18 | message AutonomyMsg { 19 | int32 autonomy = 1; 20 | } 21 | 22 | service VehicleService { 23 | rpc getSpeedStream(google.protobuf.Empty) returns (stream SpeedMsg) {} 24 | rpc getRpmStream(google.protobuf.Empty) returns (stream RpmMsg) {} 25 | rpc getAutonomy(google.protobuf.Empty) returns (AutonomyMsg) {} 26 | } 27 | //! [Proto types] 28 | -------------------------------------------------------------------------------- /tests/auto/grpc/qgrpchttp2channel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_qgrpchttp2channel LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | include("../shared/client_service/CMakeLists.txt") 9 | endif() 10 | 11 | qt_internal_add_test(tst_qgrpchttp2channel 12 | SOURCES 13 | tst_qgrpchttp2channel.cpp 14 | INCLUDE_DIRECTORIES 15 | ${CMAKE_CURRENT_SOURCE_DIR}/../../shared 16 | LIBRARIES 17 | Qt::Test 18 | Qt::Core 19 | Qt::Grpc 20 | tst_grpc_client_qtgrpc_gen 21 | ) 22 | 23 | -------------------------------------------------------------------------------- /examples/grpc/clientguide/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | cmake_minimum_required(VERSION 3.16) 4 | project(ClientGuide LANGUAGES CXX) 5 | 6 | if(NOT DEFINED INSTALL_EXAMPLESDIR) 7 | set(INSTALL_EXAMPLESDIR "examples") 8 | endif() 9 | 10 | set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/grpc/clientguide") 11 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 12 | 13 | add_subdirectory(server) 14 | if (NOT TARGET clientguide_server) 15 | message(WARNING "The Qt GRPC Client Guide requires the 'clientguide_server' target") 16 | return() 17 | endif() 18 | 19 | add_subdirectory(client) 20 | add_dependencies(clientguide_client clientguide_server) 21 | 22 | -------------------------------------------------------------------------------- /src/grpcquick/qqmlabstractgrpcchannel_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef QQMLABSTRACTGRPCCHANNEL_P_H 5 | #define QQMLABSTRACTGRPCCHANNEL_P_H 6 | 7 | // 8 | // W A R N I N G 9 | // ------------- 10 | // 11 | // This file is not part of the Qt API. It exists purely as an 12 | // implementation detail. This header file may change from version to 13 | // version without notice, or even be removed. 14 | // 15 | // We mean it. 16 | // 17 | 18 | #include 19 | 20 | QT_BEGIN_NAMESPACE 21 | 22 | class QQmlAbstractGrpcChannelPrivate : public QObjectPrivate 23 | { 24 | }; 25 | 26 | QT_END_NAMESPACE 27 | 28 | #endif // QQMLABSTRACTGRPCCHANNEL_P_H 29 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/optional.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.optional.tests; 6 | 7 | message TestStringMessage { 8 | string stringField = 2; 9 | } 10 | 11 | message OptionalMessage { 12 | sint32 testField = 1; 13 | optional sint32 testFieldOpt = 2; 14 | bool testFieldBool = 3; 15 | optional bool testFieldBoolOpt = 4; 16 | bytes testFieldBytes = 5; 17 | optional bytes testFieldBytesOpt = 6; 18 | string testFieldString = 7; 19 | optional string testFieldStringOpt = 8; 20 | TestStringMessage testFieldMessage = 9; 21 | optional TestStringMessage testFieldMessageOpt = 10; 22 | } 23 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.16) 5 | 6 | qt_add_executable(protobuf_sensors_client 7 | main.cpp 8 | clientconsole.cpp clientconsole.h 9 | sensorclient.cpp sensorclient.h 10 | clientconsole.ui 11 | ) 12 | 13 | target_link_libraries(protobuf_sensors_client PRIVATE 14 | Qt6::Core 15 | Qt6::Protobuf 16 | Qt6::Widgets 17 | Qt6::Network 18 | protobuf_sensors 19 | ) 20 | 21 | install(TARGETS protobuf_sensors_client 22 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" 23 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" 24 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" 25 | ) 26 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/shared/client_service/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(WIN32) 5 | add_library(tst_grpc_client_qtgrpc_gen STATIC) 6 | endif() 7 | 8 | qt6_add_protobuf(tst_grpc_client_qtgrpc_gen 9 | OUTPUT_DIRECTORY 10 | "${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated" 11 | PROTO_FILES 12 | ${CMAKE_CURRENT_LIST_DIR}/../../../shared/proto/testservice.proto 13 | ) 14 | 15 | qt6_add_grpc(tst_grpc_client_qtgrpc_gen CLIENT 16 | PROTO_FILES 17 | ${CMAKE_CURRENT_LIST_DIR}/../../../shared/proto/testservice.proto 18 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated" 19 | ) 20 | 21 | qt_autogen_tools_initial_setup(tst_grpc_client_qtgrpc_gen) 22 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", 3 | "description": "The example simulates a vehicle dashboard that displays data sent by a gRPC server.", 4 | "dependencies": [ 5 | "protobuf", 6 | "grpc" 7 | ], 8 | "features": { 9 | "vcpkg-qt": { 10 | "description": "Use Qt libraries from vcpkg", 11 | "dependencies": [ 12 | { 13 | "name": "qtgrpc", 14 | "version>=": "6.9" 15 | }, 16 | { 17 | "name": "qtdeclarative", 18 | "version>=": "6.9" 19 | } 20 | ] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/emulator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.16) 5 | 6 | qt_add_executable(protobuf_sensor_emulator 7 | main.cpp 8 | sensoremulator.h sensoremulator.cpp 9 | emulatorconsole.h emulatorconsole.cpp 10 | emulatorconsole.ui 11 | ) 12 | 13 | target_link_libraries(protobuf_sensor_emulator PRIVATE 14 | Qt6::Core 15 | Qt6::Protobuf 16 | Qt6::Widgets 17 | Qt6::Network 18 | protobuf_sensors 19 | ) 20 | 21 | install(TARGETS protobuf_sensor_emulator 22 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" 23 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" 24 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" 25 | ) 26 | -------------------------------------------------------------------------------- /examples/grpc/magic8ball/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", 3 | "description": "Magic 8 Ball application that receives answers from gRPC server using Qt GRPC client API.", 4 | "dependencies": [ 5 | "protobuf", 6 | "grpc" 7 | ], 8 | "features": { 9 | "vcpkg-qt": { 10 | "description": "Use Qt libraries from vcpkg", 11 | "dependencies": [ 12 | { 13 | "name": "qtgrpc", 14 | "version>=": "6.9" 15 | }, 16 | { 17 | "name": "qtdeclarative", 18 | "version>=": "6.9" 19 | } 20 | ] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/tools/qtprotobufgen/QtProtocCommandWrapper.cmake: -------------------------------------------------------------------------------- 1 | #!${CMAKE_COMMAND} -P 2 | # Copyright (C) 2022 The Qt Company Ltd. 3 | # SPDX-License-Identifier: BSD-3-Clause 4 | 5 | if(GENERATOR_NAME EQUAL "qtgrpc") 6 | set(ENV{QT_GRPC_OPTIONS} "${QT_GRPC_OPTIONS}") 7 | elseif(GENERATOR_NAME EQUAL "qtprotobuf") 8 | set(ENV{QT_PROTOBUF_OPTIONS} "${QT_PROTOBUF_OPTIONS}") 9 | endif() 10 | 11 | 12 | execute_process(COMMAND 13 | ${PROTOC_EXECUTABLE} 14 | ${PROTOC_ARGS} 15 | WORKING_DIRECTORY "${WORKING_DIRECTORY}" 16 | OUTPUT_VARIABLE output 17 | ERROR_VARIABLE output 18 | RESULT_VARIABLE result 19 | ) 20 | 21 | if(NOT result EQUAL 0) 22 | message(FATAL_ERROR "Unable to execute ${PROTOC_EXECUTABLE}:(${result}) ${output}") 23 | elseif(output) 24 | message("${output}") 25 | endif() 26 | -------------------------------------------------------------------------------- /src/grpc/doc/src/cmake-commands.qdoc: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only 3 | 4 | /*! 5 | \group cmake-commands-qtgrpc 6 | \title CMake Commands in Qt6 GRPC 7 | 8 | You should call the following CMake commands to use the Qt6::Grpc 9 | module in your project: 10 | \badcode 11 | find_package(Qt6 REQUIRED COMPONENTS Grpc) 12 | 13 | target_link_libraries(mytarget PRIVATE Qt6::Grpc) 14 | \endcode 15 | 16 | You can use the \l {qt_add_grpc} CMake command 17 | to implicitly call Qt GRPC code generation for your project. 18 | 19 | To generate \gRPC services using Qt GRPC and link them with your program 20 | consider the following example: 21 | \include qt-add-grpc-example.qdocinc 0 22 | 23 | \sa{CMake Command Reference} 24 | */ 25 | -------------------------------------------------------------------------------- /src/protobuf/qtprotobufdefs_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | #ifndef QTPROTOBUFDEFS_P_H 5 | #define QTPROTOBUFDEFS_P_H 6 | 7 | // 8 | // W A R N I N G 9 | // ------------- 10 | // 11 | // This file is not part of the Qt API. It exists purely as an 12 | // implementation detail. This header file may change from version to 13 | // version without notice, or even be removed. 14 | // 15 | // We mean it. 16 | // 17 | 18 | QT_BEGIN_NAMESPACE 19 | 20 | constexpr int ProtobufFieldNumMin = 1; 21 | constexpr int ProtobufFieldNumMax = 536870911; 22 | constexpr int ProtobufFieldMaxCount = ProtobufFieldNumMax - ProtobufFieldNumMin + 1; 23 | 24 | QT_END_NAMESPACE 25 | 26 | #endif // QTPROTOBUFDEFS_P_H 27 | -------------------------------------------------------------------------------- /tests/auto/protobuf/externalpackage/proto/externalpackage.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace1.externaltests; 6 | 7 | message ExternalInt32Message { 8 | repeated int32 localList = 1; 9 | } 10 | 11 | message ExternalComplexMessage { 12 | ExternalInt32Message testFieldInt = 1; 13 | } 14 | 15 | enum ExternalTestEnum { 16 | EXTERNAL_TEST_ENUM_VALUE0 = 0; 17 | EXTERNAL_TEST_ENUM_VALUE1 = 1; 18 | EXTERNAL_TEST_ENUM_VALUE2 = 2; 19 | EXTERNAL_TEST_ENUM_VALUE3 = 3; 20 | EXTERNAL_TEST_ENUM_VALUE4 = 4; 21 | } 22 | 23 | message NestedFieldMessage { 24 | message NestedMessage { 25 | sint32 field = 1; 26 | } 27 | NestedMessage nested = 1; 28 | } 29 | -------------------------------------------------------------------------------- /examples/grpc/chat/server/credentials/createCerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2025 The Qt Company Ltd. 3 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 4 | 5 | DAYS_VALID=36500 6 | SUBJECT="/C=DE/ST=Berlin/L=Berlin/O=The Qt Company GmbH/OU=R&D/CN=localhost/emailAddress=dennis.oberst@qt.io" 7 | 8 | # Generate Root CA 9 | openssl genrsa -out root.key 2048 10 | openssl req -x509 -new -nodes -key root.key -sha256 -days $DAYS_VALID -out root.crt -subj "$SUBJECT" 11 | 12 | # Generate Server Certificate 13 | openssl genrsa -out localhost.key 2048 14 | openssl req -new -key localhost.key -out localhost.csr -subj "$SUBJECT" 15 | openssl x509 -req -in localhost.csr -CA root.crt -CAkey root.key -CAcreateserial -out localhost.crt -days $DAYS_VALID -sha256 16 | 17 | # Cleanup 18 | rm localhost.csr root.srl root.key 19 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/client/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #include 5 | 6 | #include "clientconsole.h" 7 | #include "sensorclient.h" 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | QApplication app(argc, argv); 12 | SensorClient client; 13 | ClientConsole console; 14 | QObject::connect(&client, &SensorClient::coordinatesUpdated, &console, 15 | &ClientConsole::onCoordinatesUpdated); 16 | QObject::connect(&client, &SensorClient::temperatureUpdated, &console, 17 | &ClientConsole::onTemperatureUpdated); 18 | QObject::connect(&client, &SensorClient::warning, &console, &ClientConsole::onWarning); 19 | console.show(); 20 | return app.exec(); 21 | } 22 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/testservice.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtgrpc.tests; 6 | 7 | message SimpleStringMessage { 8 | string testFieldString = 6; 9 | } 10 | 11 | message SimpleIntMessage { 12 | sint32 testField = 1; 13 | } 14 | 15 | message BlobMessage { 16 | bytes testBytes = 1; 17 | } 18 | 19 | service TestService { 20 | rpc testMethod(SimpleStringMessage) returns (SimpleStringMessage) {} 21 | rpc testMethodServerStream(SimpleStringMessage) returns (stream SimpleStringMessage) {} 22 | rpc testMethodClientStream(stream SimpleStringMessage) returns (SimpleStringMessage) {} 23 | rpc testMethodBiStream(stream SimpleStringMessage) returns (stream SimpleStringMessage) {} 24 | } 25 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/emulator/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #include "emulatorconsole.h" 5 | 6 | #include 7 | #include "sensoremulator.h" 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | QApplication app(argc, argv); 12 | SensorEmulator emul; 13 | EmulatorConsole console; 14 | QObject::connect(&console, &EmulatorConsole::coordinatesUpdated, &emul, 15 | &SensorEmulator::sendCoordinates); 16 | QObject::connect(&console, &EmulatorConsole::temperatureUpdated, &emul, 17 | &SensorEmulator::sendTemperature); 18 | QObject::connect(&console, &EmulatorConsole::warning, &emul, &SensorEmulator::sendWarning); 19 | console.show(); 20 | return app.exec(); 21 | } 22 | -------------------------------------------------------------------------------- /tests/auto/protobuf/sequence/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_sequence LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_protobuf_sequence 11 | SOURCES 12 | tst_protobuf_sequence.cpp 13 | INCLUDE_DIRECTORIES 14 | ../shared 15 | LIBRARIES 16 | Qt::Test 17 | Qt::Protobuf 18 | ) 19 | 20 | qt6_add_protobuf(tst_protobuf_sequence 21 | PROTO_FILES 22 | proto/sequence.proto 23 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 24 | ) 25 | qt_autogen_tools_initial_setup(tst_protobuf_sequence) 26 | -------------------------------------------------------------------------------- /src/protobuf/qprotobufobject.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QPROTOBUFOBJECT_H 6 | #define QPROTOBUFOBJECT_H 7 | 8 | #if 0 9 | # pragma qt_sync_skip_header_check 10 | # pragma qt_sync_stop_processing 11 | #endif 12 | 13 | 14 | #include 15 | 16 | #include 17 | 18 | #define Q_PROTOBUF_OBJECT Q_PROTOBUF_OBJECT_EXPORT(/* not exported */) 19 | #define Q_PROTOBUF_OBJECT_EXPORT(...)\ 20 | Q_GADGET_EXPORT(__VA_ARGS__)\ 21 | public:\ 22 | __VA_ARGS__ static const QtProtobufPrivate::QProtobufPropertyOrdering staticPropertyOrdering;\ 23 | private: 24 | 25 | #endif // QPROTOBUFOBJECT_H 26 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/calloptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_calloptions_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_calloptions_qml 11 | QMLTEST 12 | SOURCES 13 | tst_calloptions_qml.cpp 14 | LIBRARIES 15 | Qt::Qml 16 | Qt::GrpcQuick 17 | ) 18 | 19 | qt_policy(SET QTP0001 NEW) 20 | qt_policy(SET QTP0004 NEW) 21 | 22 | qt_add_qml_module(tst_calloptions_qml 23 | URI QmlTestUri 24 | VERSION 1.0 25 | QML_FILES 26 | qml/tst_calloptions.qml 27 | ) 28 | 29 | qt_autogen_tools_initial_setup(tst_calloptions_qml) 30 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/metadata/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_metadata_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_grpc_metadata_qml 11 | QMLTEST 12 | SOURCES 13 | tst_metadata_qml.cpp 14 | LIBRARIES 15 | Qt::Qml 16 | Qt::GrpcQuick 17 | ) 18 | 19 | qt_policy(SET QTP0001 NEW) 20 | qt_policy(SET QTP0004 NEW) 21 | 22 | qt_add_qml_module(tst_grpc_metadata_qml 23 | URI QmlTestUri 24 | VERSION 1.0 25 | QML_FILES 26 | qml/tst_metadata.qml 27 | ) 28 | 29 | qt_autogen_tools_initial_setup(tst_grpc_metadata_qml) 30 | -------------------------------------------------------------------------------- /src/grpcquick/qqmlgrpcnamespace_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef QQMLGRPCNAMESPACE_P_H 5 | #define QQMLGRPCNAMESPACE_P_H 6 | 7 | // 8 | // W A R N I N G 9 | // ------------- 10 | // 11 | // This file is not part of the Qt API. It exists purely as an 12 | // implementation detail. This header file may change from version to 13 | // version without notice, or even be removed. 14 | // 15 | // We mean it. 16 | // 17 | 18 | #include 19 | 20 | #include 21 | 22 | QT_BEGIN_NAMESPACE 23 | 24 | namespace QtGrpcForeign { 25 | Q_NAMESPACE 26 | QML_FOREIGN_NAMESPACE(QtGrpc) 27 | QML_NAMED_ELEMENT(QtGrpc) 28 | QML_ADDED_IN_VERSION(6, 8) 29 | } 30 | 31 | QT_END_NAMESPACE 32 | 33 | #endif // QQMLGRPCNAMESPACE_P_H 34 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/anymessages.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | import "google/protobuf/any.proto"; 6 | 7 | package qtproto.tests; 8 | 9 | message AnyMessage { 10 | google.protobuf.Any field = 1; 11 | } 12 | 13 | message RepeatedAnyMessage { 14 | repeated google.protobuf.Any anys = 1; 15 | } 16 | 17 | message TwoAnyMessage { 18 | google.protobuf.Any one = 1; 19 | google.protobuf.Any two = 2; 20 | } 21 | 22 | message Example { 23 | string str = 1; 24 | sint32 i = 2; 25 | sint32 j = 3; 26 | sint32 h = 4; 27 | string str2 = 5; 28 | } 29 | 30 | message SimpleMessage { 31 | int32 i = 500000; 32 | } 33 | 34 | message AnyOneOf { 35 | oneof data { 36 | google.protobuf.Any any = 1; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | # Evaluate features before including repository subparts. 4 | 5 | qt_feature_evaluate_features("${CMAKE_CURRENT_SOURCE_DIR}/protobuf/configure.cmake") 6 | add_subdirectory(protobuf) 7 | 8 | if(QT_FEATURE_protobufquick) 9 | add_subdirectory(protobufquick) 10 | endif() 11 | 12 | qt_feature_evaluate_features("${CMAKE_CURRENT_SOURCE_DIR}/grpc/configure.cmake") 13 | if(QT_FEATURE_grpc) 14 | add_subdirectory(grpc) 15 | if(TARGET Qt6::Quick AND QT_FEATURE_grpcquick) 16 | add_subdirectory(grpcquick) 17 | endif() 18 | endif() 19 | 20 | add_subdirectory(tools) 21 | 22 | if(TARGET Qt6::qtprotobufgen) 23 | if(QT_FEATURE_protobuf_wellknowntypes) 24 | add_subdirectory(wellknown) 25 | endif() 26 | add_subdirectory(protobufqttypes) 27 | endif() 28 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/ChatMessages/ImageDelegate.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | import QtQuick 5 | import QtGrpcChat.Proto 6 | 7 | Image { 8 | id: root 9 | 10 | required property fileMessage message 11 | // Images with PreserveAspectFit have a different height 12 | // then their actual paintedHeight. Limit the actual height 13 | // of the delegate to the height ratio. 14 | readonly property real heightRatio: paintedHeight / paintedWidth 15 | 16 | source: new URL(message.content) 17 | width: implicitWidth 18 | height: implicitHeight 19 | fillMode: Image.PreserveAspectFit 20 | 21 | clip: true 22 | smooth: true 23 | antialiasing: true 24 | asynchronous: true 25 | TapHandler { onTapped: ChatEngine.openUrl(root.message.content) } 26 | } 27 | -------------------------------------------------------------------------------- /tests/auto/grpc/shared/message_latency_defs.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | #ifndef MESSAGE_LATENCY_DEFS_H 4 | #define MESSAGE_LATENCY_DEFS_H 5 | 6 | #ifndef QT_GRPC_TEST_MESSAGE_LATENCY 7 | #ifdef Q_OS_WINDOWS 8 | # define QT_GRPC_TEST_MESSAGE_LATENCY 1000 9 | #else 10 | # define QT_GRPC_TEST_MESSAGE_LATENCY 300 11 | #endif 12 | #endif 13 | 14 | constexpr int MessageLatency = QT_GRPC_TEST_MESSAGE_LATENCY; 15 | #ifdef Q_OS_WINDOWS 16 | constexpr int MessageLatencyThreshold = MessageLatency / 3; // we also need ~300 for WIN 17 | #else 18 | constexpr int MessageLatencyThreshold = MessageLatency / 5; 19 | #endif 20 | constexpr int MessageLatencyWithThreshold = MessageLatency + MessageLatencyThreshold; 21 | constexpr int FailTimeout = QT_GRPC_TEST_MESSAGE_LATENCY * 5; 22 | 23 | #endif // MESSAGE_LATENCY_DEFS_H 24 | -------------------------------------------------------------------------------- /tests/auto/protobuf/recursive/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_recursive LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt6_add_protobuf(tst_protobuf_recursive_gen 11 | PROTO_FILES 12 | recursive.proto 13 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 14 | ) 15 | qt_autogen_tools_initial_setup(tst_protobuf_recursive_gen) 16 | 17 | qt_internal_add_test(tst_protobuf_recursive 18 | SOURCES 19 | tst_protobuf_recursive.cpp 20 | INCLUDE_DIRECTORIES 21 | ../shared 22 | LIBRARIES 23 | Qt::Test 24 | Qt::Protobuf 25 | tst_protobuf_recursive_gen 26 | ) 27 | -------------------------------------------------------------------------------- /src/grpc/qtgrpclogging_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef QTGRPCLOGGING_P_H 5 | #define QTGRPCLOGGING_P_H 6 | 7 | // 8 | // W A R N I N G 9 | // ------------- 10 | // 11 | // This file is not part of the Qt API. It exists purely as an 12 | // implementation detail. This header file may change from version to 13 | // version without notice, or even be removed. 14 | // 15 | // We mean it. 16 | // 17 | 18 | #include 19 | 20 | QT_BEGIN_NAMESPACE 21 | Q_DECLARE_LOGGING_CATEGORY(Grpc) 22 | QT_END_NAMESPACE 23 | 24 | #define qGrpcDebug(...) qCDebug(Grpc, __VA_ARGS__) 25 | #define qGrpcInfo(...) qCInfo(Grpc, __VA_ARGS__) 26 | #define qGrpcWarning(...) qCWarning(Grpc, __VA_ARGS__) 27 | #define qGrpcCritical(...) qCCritical(Grpc, __VA_ARGS__) 28 | 29 | #endif // QTGRPCLOGGING_P_H 30 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(QT_BUILD_STANDALONE_TESTS) 5 | # Gui is need to build and run tests on Android Platforms. 6 | find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Protobuf Grpc) 7 | find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Quick QuickTest) 8 | endif() 9 | 10 | # Find OpenSSL first since it's a transitive dependency that may not be available in CONFIG mode 11 | find_package(OpenSSL QUIET) 12 | 13 | set(_qt_grpc_backup_prefer_config ${CMAKE_FIND_PACKAGE_PREFER_CONFIG}) 14 | set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) 15 | 16 | find_package(Protobuf QUIET) 17 | find_package(gRPC QUIET) 18 | 19 | set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${_qt_grpc_backup_prefer_config}) 20 | unset(_qt_grpc_backup_prefer_config) 21 | 22 | set(QT_BUILD_TESTS_BATCHED FALSE) 23 | qt_build_tests() 24 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/channeloptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_channel_options_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_grpc_channel_options_qml 11 | QMLTEST 12 | SOURCES 13 | tst_channeloptions_qml.cpp 14 | LIBRARIES 15 | Qt::Qml 16 | Qt::GrpcQuick 17 | Qt::QmlNetwork 18 | ) 19 | 20 | qt_policy(SET QTP0001 NEW) 21 | qt_policy(SET QTP0004 NEW) 22 | 23 | qt_add_qml_module(tst_grpc_channel_options_qml 24 | URI QmlTestUri 25 | VERSION 1.0 26 | QML_FILES 27 | qml/tst_channeloptions.qml 28 | ) 29 | 30 | qt_autogen_tools_initial_setup(tst_grpc_channel_options_qml) 31 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/oneofmessages.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | import "basicmessages.proto"; 6 | 7 | package qtprotobufnamespace.tests; 8 | 9 | message OneofSimpleMessage { 10 | oneof testOneof { 11 | int32 testOneofFieldInt = 1; 12 | int32 testOneofFieldSecondInt = 2; 13 | } 14 | } 15 | 16 | message OneofComplexMessage { 17 | int32 testFieldInt = 1; 18 | oneof testOneof { 19 | int32 testOneofFieldInt = 42; 20 | ComplexMessage testOneofComplexField = 3; 21 | ComplexMessage testOneofSecondComplexField = 4; 22 | } 23 | oneof secondOneof { 24 | int32 secondFieldInt = 43; 25 | ComplexMessage secondComplexField = 5; 26 | ComplexMessage secondSecondComplexField = 6; 27 | int32 test_snake_case_field = 7; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | cmake_minimum_required(VERSION 3.16) 5 | project(protobuf_sensors LANGUAGES CXX) 6 | 7 | if(NOT DEFINED INSTALL_EXAMPLESDIR) 8 | set(INSTALL_EXAMPLESDIR "examples") 9 | endif() 10 | 11 | set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/protobuf/sensors") 12 | 13 | find_package(Qt6 REQUIRED COMPONENTS Core Protobuf Widgets Network) 14 | 15 | qt_standard_project_setup() 16 | 17 | add_subdirectory(emulator) 18 | add_subdirectory(client) 19 | 20 | #! [0] 21 | qt_add_protobuf(protobuf_sensors 22 | PROTO_FILES 23 | sensors.proto 24 | tlv.proto 25 | ) 26 | #! [0] 27 | 28 | install(TARGETS protobuf_sensors 29 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" 30 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" 31 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" 32 | ) 33 | -------------------------------------------------------------------------------- /tests/auto/protobuf/externalpackage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_externalpackage LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_protobuf_externalpackage 11 | SOURCES 12 | tst_protobuf_externalpackage.cpp 13 | INCLUDE_DIRECTORIES 14 | ../shared 15 | LIBRARIES 16 | Qt::Test 17 | Qt::Protobuf 18 | ) 19 | 20 | qt6_add_protobuf(tst_protobuf_externalpackage 21 | PROTO_FILES 22 | proto/externalpackage.proto 23 | proto/externalpackageconsumer.proto 24 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 25 | ) 26 | qt_autogen_tools_initial_setup(tst_protobuf_externalpackage) 27 | -------------------------------------------------------------------------------- /src/grpcquick/qtgrpcquicklogging_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef QTGRPCQUICKLOGGING_P_H 5 | #define QTGRPCQUICKLOGGING_P_H 6 | 7 | // 8 | // W A R N I N G 9 | // ------------- 10 | // 11 | // This file is not part of the Qt API. It exists purely as an 12 | // implementation detail. This header file may change from version to 13 | // version without notice, or even be removed. 14 | // 15 | // We mean it. 16 | // 17 | 18 | #include 19 | 20 | QT_BEGIN_NAMESPACE 21 | Q_DECLARE_LOGGING_CATEGORY(GrpcQuick) 22 | QT_END_NAMESPACE 23 | 24 | #define qGrpcQuickDebug(...) qCDebug(GrpcQuick, __VA_ARGS__) 25 | #define qGrpcQuickInfo(...) qCInfo(GrpcQuick, __VA_ARGS__) 26 | #define qGrpcQuickWarning(...) qCWarning(GrpcQuick, __VA_ARGS__) 27 | #define qGrpcQuickCritical(...) qCCritical(GrpcQuick, __VA_ARGS__) 28 | 29 | #endif // QTGRPCQUICKLOGGING_P_H 30 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/invalid-identifier/666-invalid-identifier_client.grpc.qpb.cpp: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #include "666-invalid-identifier_client.grpc.qpb.h" 4 | 5 | namespace InvalidService { 6 | using namespace Qt::StringLiterals; 7 | 8 | Client::Client(QObject *parent) 9 | : QGrpcClientBase("InvalidService"_L1, parent) 10 | { 11 | } 12 | 13 | Client::~Client() = default; 14 | 15 | std::unique_ptr Client::Get(const Empty &arg) 16 | { 17 | return Get(arg, {}); 18 | } 19 | 20 | 21 | std::unique_ptr Client::Get(const Empty &arg, const QGrpcCallOptions &options) 22 | { 23 | auto reply = call("Get"_L1, arg, options); 24 | if (auto *replyPtr = reply.get(); replyPtr != nullptr) { 25 | setOperationResponseMetaType(replyPtr, QMetaType::fromType()); 26 | } 27 | return reply; 28 | } 29 | 30 | } // namespace InvalidService 31 | 32 | -------------------------------------------------------------------------------- /tests/auto/protobuf/duplicated_metatypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_duplicated_metatypes LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_protobuf_duplicatedmetatypes 11 | SOURCES 12 | tst_protobuf_duplicatedmetatypes.cpp 13 | INCLUDE_DIRECTORIES 14 | ../shared 15 | LIBRARIES 16 | Qt::Test 17 | Qt::Protobuf 18 | ) 19 | 20 | qt6_add_protobuf(tst_protobuf_duplicatedmetatypes 21 | PROTO_FILES 22 | proto/duplicated_metatypes.proto 23 | proto/duplicated_metatypes_external.proto 24 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 25 | ) 26 | qt_autogen_tools_initial_setup(tst_protobuf_duplicatedmetatypes) 27 | -------------------------------------------------------------------------------- /tests/manual/grpc/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(grpc_benchmarks LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | set(CMAKE_CXX_STANDARD 20) 11 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 12 | set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) 13 | 14 | find_package(Qt6 REQUIRED COMPONENTS Core) 15 | 16 | if(APPLE) 17 | add_compile_options(-fexperimental-library) # Due to std::format support 18 | endif() 19 | 20 | set(proto_path "${CMAKE_CURRENT_LIST_DIR}/proto/bench.proto") 21 | set(proto_include "${CMAKE_CURRENT_LIST_DIR}/proto") 22 | set(qrpcbench_common_include "${CMAKE_CURRENT_LIST_DIR}") 23 | 24 | add_subdirectory(asyncbenchserver) 25 | add_subdirectory(bench_qtgrpcclient) 26 | add_subdirectory(bench_async_ref_client) 27 | -------------------------------------------------------------------------------- /src/wellknown/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_internal_add_protobuf_module(ProtobufWellKnownTypes 5 | SOURCES 6 | qtprotobufwellknowntypesglobal.h 7 | qprotobufanysupport.cpp qprotobufanysupport.h 8 | qprotobufwellknowntypesjsonserializers_p.h qprotobufwellknowntypesjsonserializers.cpp 9 | PUBLIC_LIBRARIES 10 | Qt::Protobuf 11 | EXTRA_CMAKE_INCLUDES 12 | # Generated inside the qt_internal_add_protobuf_wellknown_types call 13 | "${QT_CMAKE_EXPORT_NAMESPACE}ProtobufWellKnownTypesExtras.cmake" 14 | LIBRARIES 15 | Qt::ProtobufPrivate 16 | ) 17 | 18 | qt_internal_add_protobuf_wellknown_types(ProtobufWellKnownTypes 19 | TYPES 20 | any 21 | api 22 | duration 23 | empty 24 | field_mask 25 | source_context 26 | struct 27 | timestamp 28 | type 29 | wrappers 30 | ) 31 | -------------------------------------------------------------------------------- /tests/auto/protobuf/nested/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_nested LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt6_add_protobuf(tst_protobuf_nestedtypes_qtprotobuf_gen 11 | PROTO_FILES 12 | proto/nestedmessages.proto 13 | proto/externalpackage.proto 14 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 15 | ) 16 | qt_autogen_tools_initial_setup(tst_protobuf_nestedtypes_qtprotobuf_gen) 17 | 18 | qt_internal_add_test(tst_protobuf_nestedtypes 19 | SOURCES 20 | tst_protobuf_nestedtypes.cpp 21 | INCLUDE_DIRECTORIES 22 | ../shared 23 | LIBRARIES 24 | Qt::Test 25 | Qt::Protobuf 26 | tst_protobuf_nestedtypes_qtprotobuf_gen 27 | ) 28 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/http2channel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_http2channel_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_internal_add_test(tst_grpc_http2channel_qml 11 | QMLTEST 12 | SOURCES 13 | tst_grpchttp2channel_qml.cpp 14 | LIBRARIES 15 | Qt::Qml 16 | Qt::GrpcQuick 17 | ) 18 | 19 | qt_policy(SET QTP0001 NEW) 20 | qt_policy(SET QTP0004 NEW) 21 | 22 | qt_add_qml_module(tst_grpc_http2channel_qml 23 | URI QmlTestUri 24 | VERSION 1.0 25 | QML_FILES 26 | qml/tst_grpchttp2channel.qml 27 | ) 28 | 29 | qt_autogen_tools_initial_setup(tst_grpc_http2channel_qml) 30 | 31 | if(QT_BUILD_STANDALONE_TESTS) 32 | qt_import_qml_plugins(tst_grpc_http2channel_qml) 33 | endif() 34 | 35 | -------------------------------------------------------------------------------- /tests/auto/protobuf/extranamespace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_extranamespace LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt6_add_protobuf(tst_protobuf_extranamespace_qtprotobuf_gen 11 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 12 | PROTO_FILES proto/extranamespace.proto 13 | EXTRA_NAMESPACE "MyTestNamespace" 14 | ) 15 | qt_autogen_tools_initial_setup(tst_protobuf_extranamespace_qtprotobuf_gen) 16 | 17 | qt_internal_add_test(tst_protobuf_extranamespace 18 | SOURCES 19 | tst_protobuf_extranamespace.cpp 20 | INCLUDE_DIRECTORIES 21 | ../shared 22 | LIBRARIES 23 | Qt::Test 24 | Qt::Protobuf 25 | tst_protobuf_extranamespace_qtprotobuf_gen 26 | ) 27 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/qtguitypes.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.qttypes.tests; 6 | import "QtGui/QtGui.proto"; 7 | 8 | message QRgba64Message { 9 | QtGui.QRgba64 testField = 1; 10 | } 11 | 12 | message QColorMessage { 13 | QtGui.QColor testField = 1; 14 | } 15 | 16 | message QMatrix4x4Message { 17 | QtGui.QMatrix4x4 testField = 1; 18 | } 19 | 20 | message QVector2DMessage { 21 | QtGui.QVector2D testField = 1; 22 | } 23 | 24 | message QVector3DMessage { 25 | QtGui.QVector3D testField = 1; 26 | } 27 | 28 | message QVector4DMessage { 29 | QtGui.QVector4D testField = 1; 30 | } 31 | 32 | message QTransformMessage { 33 | QtGui.QTransform testField = 1; 34 | } 35 | 36 | message QQuaternionMessage { 37 | QtGui.QQuaternion testField = 1; 38 | } 39 | 40 | message QImageMessage { 41 | QtGui.QImage testField = 1; 42 | } 43 | -------------------------------------------------------------------------------- /src/grpcquick/qqmlgrpcmetadata.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | 9 | QQmlGrpcMetadata::QQmlGrpcMetadata(QObject *parent) 10 | : QObject(parent) 11 | { 12 | } 13 | 14 | QQmlGrpcMetadata::~QQmlGrpcMetadata() = default; 15 | 16 | void QQmlGrpcMetadata::setData(const QVariantMap &data) 17 | { 18 | if (m_variantdata == data) 19 | return; 20 | 21 | m_metadata.clear(); 22 | m_variantdata = data; 23 | for (const auto&[key, val]: m_variantdata.asKeyValueRange()) { 24 | // Transform the variant map into a QHash 25 | for (const auto &it : QStringTokenizer(get(val), u',')) 26 | m_metadata.insert(key.toUtf8(), it.toUtf8()); 27 | } 28 | emit dataChanged(); 29 | } 30 | 31 | QT_END_NAMESPACE 32 | 33 | #include "moc_qqmlgrpcmetadata_p.cpp" 34 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/ChatMessages/UserStatusDelegate.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | import QtQuick 5 | 6 | import QtGrpcChat.Proto 7 | 8 | Text { 9 | id: innerText 10 | 11 | required property var base 12 | 13 | color: base.lightColor 14 | font.pointSize: 14 15 | text: { 16 | switch (base.display.userStatus.type) { 17 | case UserStatus.Type.LOGIN: 18 | return "" + base.messageOwner + " " + qsTr("joined the chat") 19 | case UserStatus.Type.LOGOUT: 20 | return "" + base.messageOwner + " " + qsTr("left the chat") 21 | case UserStatus.Type.ACTIVE: 22 | return "" + base.messageOwner + " " + qsTr("went active") 23 | case UserStatus.Type.INACTIVE: 24 | return "" + base.messageOwner + " " + qsTr("went inactive") 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/vehiclethread.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #ifndef VEHICLETHREAD_H 5 | #define VEHICLETHREAD_H 6 | 7 | #include "vehicleservice_client.grpc.qpb.h" 8 | #include 9 | #include 10 | 11 | namespace qtgrpc::examples { 12 | 13 | class VehicleThread : public QThread 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit VehicleThread(QObject *parent = nullptr); 19 | ~VehicleThread() override; 20 | 21 | void run() override; 22 | 23 | signals: 24 | void speedChanged(int speed); 25 | void rpmChanged(int rpm); 26 | void autonomyChanged(int level); 27 | 28 | void connectionError(QString error); 29 | 30 | private: 31 | std::unique_ptr m_client; 32 | std::unique_ptr m_streamSpeed; 33 | std::unique_ptr m_streamRpm; 34 | }; 35 | 36 | } 37 | 38 | #endif // VEHICLETHREAD_H 39 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/client/sensorclient.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #ifndef SENSORCLIENT_H 5 | #define SENSORCLIENT_H 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace qt::examples::sensors { 13 | class Coordinates; 14 | class Temperature; 15 | class WarningNotification; 16 | } // namespace qt::examples::sensors 17 | 18 | class SensorClient : public QObject 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit SensorClient(QObject *parent = nullptr); 23 | void receive(); 24 | 25 | signals: 26 | void coordinatesUpdated(const qt::examples::sensors::Coordinates &); 27 | void temperatureUpdated(const qt::examples::sensors::Temperature &); 28 | void warning(const qt::examples::sensors::WarningNotification &); 29 | 30 | private: 31 | QUdpSocket m_client; 32 | QProtobufSerializer m_serializer; 33 | }; 34 | 35 | #endif // SENSORCLIENT_H 36 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/client/clientconsole.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #ifndef CLIENTCONSOLE_H 5 | #define CLIENTCONSOLE_H 6 | 7 | #include 8 | 9 | namespace qt::examples::sensors { 10 | class Coordinates; 11 | class Temperature; 12 | class WarningNotification; 13 | } // namespace qt::examples::sensors 14 | 15 | QT_BEGIN_NAMESPACE 16 | namespace Ui { 17 | class ClientConsole; 18 | } 19 | QT_END_NAMESPACE 20 | 21 | class ClientConsole : public QWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | ClientConsole(QWidget *parent = nullptr); 27 | ~ClientConsole(); 28 | 29 | void onCoordinatesUpdated(const qt::examples::sensors::Coordinates &coord); 30 | void onTemperatureUpdated(const qt::examples::sensors::Temperature &temp); 31 | void onWarning(const qt::examples::sensors::WarningNotification &warn); 32 | 33 | private: 34 | Ui::ClientConsole *ui; 35 | }; 36 | 37 | #endif // CLIENTCONSOLE_H 38 | -------------------------------------------------------------------------------- /src/tools/qtprotobufgen/enumdefinitionprinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2020 Alexey Edelev , Tatyana Borisova 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 4 | 5 | #ifndef ENUMDEFINITIONPRINTER_H 6 | #define ENUMDEFINITIONPRINTER_H 7 | 8 | #include "descriptorprinterbase.h" 9 | 10 | namespace QtProtobuf { 11 | class EnumDefinitionPrinter final 12 | : public qtprotoccommon::DescriptorPrinterBase 13 | { 14 | public: 15 | explicit EnumDefinitionPrinter(const google::protobuf::EnumDescriptor *descriptor, 16 | std::shared_ptr<::google::protobuf::io::Printer> printer); 17 | ~EnumDefinitionPrinter(); 18 | 19 | void run() { printRegisterBody(); } 20 | 21 | void printRegisterBody(); 22 | void printQmlPluginRegisterBody(); 23 | }; 24 | 25 | } // namespace QtProtobuf 26 | 27 | #endif // ENUMDEFINITIONPRINTER_H 28 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/emulator/emulatorconsole.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #ifndef EMULATORCONSOLE_H 5 | #define EMULATORCONSOLE_H 6 | 7 | #include 8 | 9 | namespace qt::examples::sensors { 10 | class Coordinates; 11 | class Temperature; 12 | class WarningNotification; 13 | } // namespace qt::examples::sensors 14 | 15 | QT_BEGIN_NAMESPACE 16 | namespace Ui { 17 | class EmulatorConsole; 18 | } 19 | QT_END_NAMESPACE 20 | 21 | class EmulatorConsole : public QWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | explicit EmulatorConsole(QWidget *parent = nullptr); 27 | ~EmulatorConsole(); 28 | 29 | signals: 30 | void coordinatesUpdated(const qt::examples::sensors::Coordinates &); 31 | void temperatureUpdated(const qt::examples::sensors::Temperature &); 32 | void warning(const qt::examples::sensors::WarningNotification &); 33 | 34 | private: 35 | Ui::EmulatorConsole *ui; 36 | }; 37 | #endif // EMULATORCONSOLE_H 38 | -------------------------------------------------------------------------------- /examples/protobuf/sensors/emulator/sensoremulator.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #ifndef SENSOREMULATOR_H 5 | #define SENSOREMULATOR_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace qt::examples::sensors { 12 | class Coordinates; 13 | class Temperature; 14 | class WarningNotification; 15 | } // namespace qt::examples::sensors 16 | class SensorEmulator : public QObject 17 | { 18 | Q_OBJECT 19 | public: 20 | explicit SensorEmulator(QObject *parent = nullptr); 21 | 22 | void sendCoordinates(const qt::examples::sensors::Coordinates &coords); 23 | void sendTemperature(const qt::examples::sensors::Temperature &temp); 24 | void sendWarning(const qt::examples::sensors::WarningNotification &warn); 25 | 26 | private: 27 | void send(const QByteArray &data); 28 | 29 | QUdpSocket m_socket; 30 | QProtobufSerializer m_serializer; 31 | }; 32 | 33 | #endif // SENSOREMULATOR_H 34 | -------------------------------------------------------------------------------- /src/tools/qtgrpcgen/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 3 | 4 | #include 5 | 6 | #include "qgrpcgenerator.h" 7 | #include "options.h" 8 | #include "utils.h" 9 | 10 | #include 11 | #include 12 | 13 | using namespace QtGrpc; 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | char *optionsPtr = getenv("QT_GRPC_OPTIONS"); 18 | if (optionsPtr != nullptr) { 19 | QT_PROTOBUF_DEBUG("QT_GRPC_OPTIONS: " << optionsPtr); 20 | std::string error; 21 | qtprotoccommon::Options::setFromString(optionsPtr, qtprotoccommon::Options::QtGrpcGen, 22 | &error); 23 | if (!error.empty()) { 24 | std::cerr << error << std::endl; 25 | return EXIT_FAILURE; 26 | } 27 | } 28 | QGrpcGenerator generator; 29 | return ::google::protobuf::compiler::PluginMain(argc, argv, &generator); 30 | } 31 | -------------------------------------------------------------------------------- /src/tools/qtgrpcgen/qmlclientdefinitionprinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 3 | 4 | #pragma once 5 | 6 | #include "descriptorprinterbase.h" 7 | 8 | namespace QtGrpc { 9 | 10 | class QmlClientDefinitionPrinter : 11 | public qtprotoccommon::DescriptorPrinterBase 12 | { 13 | public: 14 | QmlClientDefinitionPrinter(const google::protobuf::ServiceDescriptor *service, 15 | const std::shared_ptr<::google::protobuf::io::Printer> &printer); 16 | void run() 17 | { 18 | printOpenNamespace(); 19 | printConstructor(); 20 | printMethods(); 21 | printCloseNamespace(); 22 | } 23 | void printOpenNamespace(); 24 | void printConstructor(); 25 | void printMethods(); 26 | void printCloseNamespace(); 27 | private: 28 | void printMethod(const ::google::protobuf::MethodDescriptor *method); 29 | }; 30 | 31 | } // namespace QtGrpc 32 | -------------------------------------------------------------------------------- /tests/auto/protobuf/nopackage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_nopackage LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt6_add_protobuf(tst_protobuf_nopackagetypes_qtprotobuf_gen 11 | PROTO_FILES 12 | ../../shared/data/proto/nopackage.proto 13 | ../../shared/data/proto/nopackageexternal.proto 14 | GENERATE_PACKAGE_SUBFOLDERS 15 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 16 | ) 17 | qt_autogen_tools_initial_setup(tst_protobuf_nopackagetypes_qtprotobuf_gen) 18 | 19 | qt_internal_add_test(tst_protobuf_nopackagetypes 20 | SOURCES 21 | tst_protobuf_nopackagetypes.cpp 22 | INCLUDE_DIRECTORIES 23 | ../shared 24 | LIBRARIES 25 | Qt::Test 26 | Qt::Protobuf 27 | tst_protobuf_nopackagetypes_qtprotobuf_gen 28 | ) 29 | -------------------------------------------------------------------------------- /LICENSES/Qt-GPL-exception-1.0.txt: -------------------------------------------------------------------------------- 1 | The Qt Company GPL Exception 1.0 2 | 3 | Exception 1: 4 | 5 | As a special exception you may create a larger work which contains the 6 | output of this application and distribute that work under terms of your 7 | choice, so long as the work is not otherwise derived from or based on 8 | this application and so long as the work does not in itself generate 9 | output that contains the output from this application in its original 10 | or modified form. 11 | 12 | Exception 2: 13 | 14 | As a special exception, you have permission to combine this application 15 | with Plugins licensed under the terms of your choice, to produce an 16 | executable, and to copy and distribute the resulting executable under 17 | the terms of your choice. However, the executable must be accompanied 18 | by a prominent notice offering all users of the executable the entire 19 | source code to this application, excluding the source code of the 20 | independent modules, but including any changes you have made to this 21 | application, under the terms of this license. 22 | 23 | -------------------------------------------------------------------------------- /src/grpcquick/qqmlabstractgrpcchannel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef QQMLABSTRACTGRPCCHANNEL_H 5 | #define QQMLABSTRACTGRPCCHANNEL_H 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | QT_BEGIN_NAMESPACE 16 | 17 | class QQmlAbstractGrpcChannelPrivate; 18 | class Q_GRPCQUICK_EXPORT QQmlAbstractGrpcChannel : public QObject 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit QQmlAbstractGrpcChannel(QObject *parent = nullptr) : QObject(parent) { } 23 | ~QQmlAbstractGrpcChannel() override; 24 | 25 | virtual std::shared_ptr channel() const = 0; 26 | 27 | protected: 28 | explicit QQmlAbstractGrpcChannel(QQmlAbstractGrpcChannelPrivate &dd, QObject *parent = nullptr); 29 | 30 | private: 31 | Q_DECLARE_PRIVATE(QQmlAbstractGrpcChannel) 32 | }; 33 | 34 | QT_END_NAMESPACE 35 | 36 | #endif // QQMLABSTRACTGRPCCHANNEL_H 37 | -------------------------------------------------------------------------------- /tests/auto/protobuf/syntax/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_syntax LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt6_add_protobuf(tst_protobuf_syntax_qtprotobuf_gen 11 | PROTO_FILES 12 | ../../shared/data/proto/syntax.proto 13 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 14 | ALLOW_MUTABLE_GETTER_CONFLICTS 15 | ) 16 | qt_autogen_tools_initial_setup(tst_protobuf_syntax_qtprotobuf_gen) 17 | 18 | qt_internal_add_test(tst_protobuf_syntax 19 | SOURCES 20 | tst_protobuf_syntax.cpp 21 | INCLUDE_DIRECTORIES 22 | ../shared 23 | LIBRARIES 24 | Qt::Test 25 | Qt::Protobuf 26 | tst_protobuf_syntax_qtprotobuf_gen 27 | ) 28 | 29 | set_target_properties(tst_protobuf_syntax_qtprotobuf_gen PROPERTIES 30 | QT_USE_PROTOBUF_LIST_ALIASES FALSE 31 | ) 32 | -------------------------------------------------------------------------------- /tests/auto/protobuf/sequence/proto/sequence.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.tests.sequence; 6 | 7 | message TestMessageSequence { 8 | TestMessageSequence2 testField = 1; 9 | } 10 | 11 | message TestMessageSequence2 { 12 | bool testField = 1; 13 | } 14 | 15 | message CyclingSecondDependency { 16 | CyclingFirstDependency testField = 1; 17 | } 18 | 19 | message CyclingFirstDependency { 20 | CyclingSecondDependency testField = 1; 21 | } 22 | 23 | message RepeatedFieldSequence { 24 | repeated RepeatedFieldSequence2 testField = 1; 25 | } 26 | 27 | message RepeatedFieldSequence2 { 28 | bool testField = 1; 29 | } 30 | 31 | message MapFieldSequence { 32 | map testField = 1; 33 | } 34 | 35 | message MapFieldSequence2 { 36 | bool testField = 1; 37 | } 38 | 39 | message lowerCaseSequence { 40 | lowerCaseSequence2 testField = 1; 41 | } 42 | 43 | message lowerCaseSequence2 { 44 | bool testField = 1; 45 | } 46 | -------------------------------------------------------------------------------- /tests/auto/grpcgen/data/cmake_generated/invalid-identifier/666-invalid-identifier_client.grpc.qpb.h: -------------------------------------------------------------------------------- 1 | /* This file is autogenerated. DO NOT CHANGE. All changes will be lost */ 2 | 3 | #ifndef _666_INVALID_IDENTIFIER_CLIENT_GRPC_QPB_H 4 | #define _666_INVALID_IDENTIFIER_CLIENT_GRPC_QPB_H 5 | 6 | #include "666-invalid-identifier.qpb.h" 7 | #include "tst_qtgrpcgen_invalid-identifier_exports.qpb.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace InvalidService { 16 | 17 | class QPB_TST_QTGRPCGEN_INVALID_IDENTIFIER_EXPORT Client : public QGrpcClientBase 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | explicit Client(QObject *parent = nullptr); 23 | ~Client() override; 24 | 25 | [[nodiscard]] 26 | std::unique_ptr Get(const Empty &arg); 27 | [[nodiscard]] 28 | std::unique_ptr Get(const Empty &arg, const QGrpcCallOptions &options); 29 | 30 | 31 | }; 32 | } // namespace InvalidService 33 | 34 | #endif // _666_INVALID_IDENTIFIER_CLIENT_GRPC_QPB_H 35 | -------------------------------------------------------------------------------- /examples/grpc/clientguide/client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | cmake_minimum_required(VERSION 3.16) 4 | 5 | #! [0] 6 | set(proto_files "${CMAKE_CURRENT_LIST_DIR}/../proto/clientguide.proto") 7 | 8 | find_package(Qt6 COMPONENTS Protobuf Grpc) 9 | qt_standard_project_setup(REQUIRES 6.9) 10 | 11 | qt_add_executable(clientguide_client main.cpp) 12 | 13 | # Using the executable as input target will append the generated files to it. 14 | qt_add_protobuf(clientguide_client 15 | PROTO_FILES ${proto_files} 16 | ) 17 | qt_add_grpc(clientguide_client CLIENT 18 | PROTO_FILES ${proto_files} 19 | ) 20 | 21 | target_link_libraries(clientguide_client PRIVATE Qt6::Protobuf Qt6::Grpc) 22 | #! [0] 23 | 24 | target_compile_definitions(clientguide_client PRIVATE 25 | SERVER_PATH="$") 26 | 27 | install(TARGETS clientguide_client 28 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" 29 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" 30 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" 31 | ) 32 | -------------------------------------------------------------------------------- /src/tools/qtprotobufgen/enumdeclarationprinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2020 Alexey Edelev , Tatyana Borisova 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 4 | 5 | #ifndef ENUMDECLARATIONPRINTER_H 6 | #define ENUMDECLARATIONPRINTER_H 7 | 8 | #include "descriptorprinterbase.h" 9 | 10 | namespace QtProtobuf { 11 | class EnumDeclarationPrinter final 12 | : public qtprotoccommon::DescriptorPrinterBase 13 | { 14 | public: 15 | explicit EnumDeclarationPrinter( 16 | const google::protobuf::EnumDescriptor *descriptor, 17 | std::shared_ptr<::google::protobuf::io::Printer> printer); 18 | ~EnumDeclarationPrinter(); 19 | 20 | void run() 21 | { 22 | startEnum(); 23 | printEnum(); 24 | encloseEnum(); 25 | } 26 | 27 | private: 28 | void startEnum(); 29 | void printEnum(); 30 | void encloseEnum(); 31 | }; 32 | 33 | } // namespace QtProtobuf 34 | 35 | #endif // ENUMDECLARATIONPRINTER_H 36 | -------------------------------------------------------------------------------- /src/tools/qtgrpcgen/clientdefinitionprinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 4 | 5 | #pragma once 6 | 7 | #include "descriptorprinterbase.h" 8 | 9 | namespace QtGrpc { 10 | 11 | class ClientDefinitionPrinter : 12 | public qtprotoccommon::DescriptorPrinterBase 13 | { 14 | public: 15 | ClientDefinitionPrinter(const google::protobuf::ServiceDescriptor *service, 16 | const std::shared_ptr<::google::protobuf::io::Printer> &printer); 17 | void run() 18 | { 19 | printOpenNamespace(); 20 | printConstructorDestructor(); 21 | printMethods(); 22 | printCloseNamespace(); 23 | } 24 | void printOpenNamespace(); 25 | void printConstructorDestructor(); 26 | void printMethods(); 27 | void printCloseNamespace(); 28 | private: 29 | void printMethod(const ::google::protobuf::MethodDescriptor *method); 30 | }; 31 | 32 | } // namespace QtGrpc 33 | -------------------------------------------------------------------------------- /tests/auto/protobuf/transparentwrapper/tst_protobuf_transparentwrapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | #include 7 | 8 | using namespace QtProtobuf; 9 | 10 | class ProtobufTransparentWrapperTest : public QObject 11 | { 12 | Q_OBJECT 13 | private Q_SLOTS: 14 | void specialFunctions() const; 15 | void hashValueDoesNotDependOnTag() const; 16 | }; 17 | 18 | void ProtobufTransparentWrapperTest::specialFunctions() const 19 | { 20 | TransparentWrapper v(42); 21 | 22 | QCOMPARE_EQ(qHash(v), qHash(v.t)); 23 | 24 | QCOMPARE_EQ(qbswap(v), qbswap(v.t)); 25 | } 26 | 27 | void ProtobufTransparentWrapperTest::hashValueDoesNotDependOnTag() const 28 | { 29 | TransparentWrapper v1(42); 30 | TransparentWrapper v2(42); 31 | 32 | QCOMPARE_EQ(qHash(v1), qHash(v2)); 33 | } 34 | 35 | QTEST_MAIN(ProtobufTransparentWrapperTest) 36 | #include "tst_protobuf_transparentwrapper.moc" 37 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/ChatMessages/FileContinuationDelegate.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | import QtQuick 5 | import QtQuick.Controls 6 | import QtQuick.Layouts 7 | 8 | import QtGrpcChat.Proto 9 | 10 | ColumnLayout { 11 | id: root 12 | 13 | required property fileMessage message 14 | property color textColor 15 | 16 | ProgressBar { 17 | id: fileProgress 18 | to: root.message.continuation.count 19 | value: root.message.continuation.index + 1 20 | } 21 | RowLayout { 22 | Text { 23 | Layout.fillWidth: true 24 | horizontalAlignment: Text.AlignLeft 25 | text: root.message.name 26 | color: root.textColor 27 | font.pointSize: 14 28 | } 29 | Text { 30 | Layout.fillWidth: true 31 | horizontalAlignment: Text.AlignRight 32 | text: fileProgress.value + "/" + fileProgress.to 33 | color: root.textColor 34 | font.pointSize: 14 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/tools/qtprotobufgen/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 4 | 5 | #include 6 | 7 | #include "qprotobufgenerator.h" 8 | #include "options.h" 9 | #include "utils.h" 10 | 11 | #include 12 | #include 13 | 14 | using namespace ::QtProtobuf; 15 | int main(int argc, char *argv[]) 16 | { 17 | char *optionsPtr = getenv("QT_PROTOBUF_OPTIONS"); 18 | if (optionsPtr != nullptr) { 19 | QT_PROTOBUF_DEBUG("QT_PROTOBUF_OPTIONS: " << optionsPtr); 20 | std::string error; 21 | qtprotoccommon::Options::setFromString(optionsPtr, qtprotoccommon::Options::QtProtobufGen, 22 | &error); 23 | if (!error.empty()) { 24 | std::cerr << error << std::endl; 25 | return EXIT_FAILURE; 26 | } 27 | } 28 | QProtobufGenerator generator; 29 | return ::google::protobuf::compiler::PluginMain(argc, argv, &generator); 30 | } 31 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/chatmessagemodel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 4 | 5 | #ifndef CHATMESSAGEMODEL_H 6 | #define CHATMESSAGEMODEL_H 7 | 8 | #include "chatmessages.qpb.h" 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | class ChatMessageModel : public QAbstractListModel 17 | { 18 | Q_OBJECT 19 | QML_INTERFACE 20 | 21 | public: 22 | explicit ChatMessageModel(QObject *parent = nullptr); 23 | ~ChatMessageModel() override; 24 | 25 | Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override; 26 | 27 | Q_INVOKABLE QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 28 | 29 | void appendMessage(const chat::ChatMessage &message); 30 | 31 | private: 32 | QList m_chatMessages; 33 | Q_DISABLE_COPY_MOVE(ChatMessageModel) 34 | }; 35 | 36 | #endif // CHATMESSAGEMODEL_H 37 | -------------------------------------------------------------------------------- /examples/grpc/vehicle/navigationthread.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #ifndef NAVIGATIONTHREAD_H 5 | #define NAVIGATIONTHREAD_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace qtgrpc::examples { 13 | 14 | class NavigationThread : public QThread 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit NavigationThread(QObject *parent = nullptr); 20 | ~NavigationThread() override; 21 | 22 | void run() override; 23 | 24 | signals: 25 | void totalDistanceChanged(int distance); 26 | void traveledDistanceChanged(int distance); 27 | void directionChanged(qtgrpc::examples::DirectionEnumGadget::DirectionEnum direction); 28 | void streetChanged(QString street); 29 | 30 | void connectionError(QString error); 31 | 32 | private: 33 | std::unique_ptr m_stream; 34 | std::shared_ptr m_client; 35 | }; 36 | 37 | } 38 | 39 | #endif // NAVIGATIONTHREAD_H 40 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/deadline/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_client_deadline LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | 9 | include("../shared/test_server/CMakeLists.txt") 10 | include("../shared/client_service/CMakeLists.txt") 11 | include("../shared/client_test_common/CMakeLists.txt") 12 | endif() 13 | 14 | if(NOT TARGET grpc_testserver) 15 | return() 16 | endif() 17 | 18 | qt_internal_add_test(tst_grpc_client_deadline 19 | SOURCES 20 | tst_grpc_client_deadline.cpp 21 | INCLUDE_DIRECTORIES 22 | ${CMAKE_CURRENT_SOURCE_DIR}/../../shared 23 | DEFINES 24 | TEST_GRPC_SERVER_PATH="$" 25 | LIBRARIES 26 | Qt::Test 27 | Qt::Core 28 | Qt::Grpc 29 | tst_grpc_client_qtgrpc_gen 30 | tst_grpc_client_test_common 31 | ) 32 | 33 | add_dependencies(tst_grpc_client_deadline grpc_testserver) 34 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/ssl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_client_ssl LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | 9 | include("../shared/test_server/CMakeLists.txt") 10 | include("../shared/client_service/CMakeLists.txt") 11 | include("../shared/client_test_common/CMakeLists.txt") 12 | endif() 13 | 14 | if(NOT TARGET grpc_testserver) 15 | return() 16 | endif() 17 | 18 | qt_internal_add_test(tst_grpc_client_ssl 19 | SOURCES 20 | tst_grpc_client_ssl.cpp 21 | INCLUDE_DIRECTORIES 22 | ${CMAKE_CURRENT_SOURCE_DIR}/../../shared 23 | DEFINES 24 | TEST_GRPC_SERVER_PATH="$" 25 | LIBRARIES 26 | Qt::Test 27 | Qt::Core 28 | Qt::Grpc 29 | Qt::Network 30 | tst_grpc_client_qtgrpc_gen 31 | tst_grpc_client_test_common 32 | ) 33 | 34 | add_dependencies(tst_grpc_client_ssl grpc_testserver) 35 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/unarycall/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_client_unarycall LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | 9 | include("../shared/test_server/CMakeLists.txt") 10 | include("../shared/client_service/CMakeLists.txt") 11 | include("../shared/client_test_common/CMakeLists.txt") 12 | endif() 13 | 14 | if(NOT TARGET grpc_testserver) 15 | return() 16 | endif() 17 | 18 | qt_internal_add_test(tst_grpc_client_unarycall 19 | SOURCES 20 | tst_grpc_client_unarycall.cpp 21 | INCLUDE_DIRECTORIES 22 | ${CMAKE_CURRENT_SOURCE_DIR}/../../shared 23 | DEFINES 24 | TEST_GRPC_SERVER_PATH="$" 25 | LIBRARIES 26 | Qt::Test 27 | Qt::Core 28 | Qt::Grpc 29 | tst_grpc_client_qtgrpc_gen 30 | tst_grpc_client_test_common 31 | ) 32 | 33 | add_dependencies(tst_grpc_client_unarycall grpc_testserver) 34 | -------------------------------------------------------------------------------- /tests/benchmarks/protobuf/deserialize/tst_bench_deserialize_protobuf_base.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef TST_BENCH_DESERIALIZE_PROTOBUF_BASE_H 5 | #define TST_BENCH_DESERIALIZE_PROTOBUF_BASE_H 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include "bench.qpb.h" 12 | 13 | using ProtobufData = std::array, 3>; 14 | using ProtobufDataPtr = ProtobufData *; 15 | 16 | class ProtobufDeserializeBenchmarkBase : public QObject 17 | { 18 | Q_OBJECT 19 | 20 | protected: 21 | ProtobufDeserializeBenchmarkBase(ProtobufDataPtr data, 22 | std::unique_ptr serializer); 23 | 24 | private Q_SLOTS: 25 | void initTestCase(); 26 | void deserialize_data(); 27 | void deserialize(); 28 | 29 | private: 30 | ProtobufDataPtr m_data = nullptr; 31 | std::unique_ptr m_serializer; 32 | qtbench::MapTypes m_benchMsg; 33 | }; 34 | 35 | #endif // TST_BENCH_DESERIALIZE_PROTOBUF_BASE_H 36 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/bidistream/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_client_bidistream LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | 9 | include("../shared/test_server/CMakeLists.txt") 10 | include("../shared/client_service/CMakeLists.txt") 11 | include("../shared/client_test_common/CMakeLists.txt") 12 | endif() 13 | 14 | if(NOT TARGET grpc_testserver) 15 | return() 16 | endif() 17 | 18 | qt_internal_add_test(tst_grpc_client_bidistream 19 | SOURCES 20 | tst_grpc_client_bidistream.cpp 21 | INCLUDE_DIRECTORIES 22 | ${CMAKE_CURRENT_SOURCE_DIR}/../../shared 23 | DEFINES 24 | TEST_GRPC_SERVER_PATH="$" 25 | LIBRARIES 26 | Qt::Test 27 | Qt::Core 28 | Qt::Grpc 29 | tst_grpc_client_qtgrpc_gen 30 | tst_grpc_client_test_common 31 | ) 32 | 33 | add_dependencies(tst_grpc_client_bidistream grpc_testserver) 34 | -------------------------------------------------------------------------------- /src/protobuf/qtprotobuflogging_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QTPROTOBUFLOGGING_P_H 6 | #define QTPROTOBUFLOGGING_P_H 7 | 8 | // 9 | // W A R N I N G 10 | // ------------- 11 | // 12 | // This file is not part of the Qt API. It exists purely as an 13 | // implementation detail. This header file may change from version to 14 | // version without notice, or even be removed. 15 | // 16 | // We mean it. 17 | // 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | QT_BEGIN_NAMESPACE 25 | QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(Protobuf, Q_PROTOBUF_EXPORT) 26 | QT_END_NAMESPACE 27 | 28 | #define qProtoDebug(...) qCDebug(Protobuf, __VA_ARGS__) 29 | #define qProtoInfo(...) qCInfo(Protobuf, __VA_ARGS__) 30 | #define qProtoWarning(...) qCWarning(Protobuf, __VA_ARGS__) 31 | #define qProtoCritical(...) qCCritical(Protobuf, __VA_ARGS__) 32 | 33 | #endif // QTPROTOBUFLOGGING_P_H 34 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/clientstream/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_client_clientstream LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | 9 | include("../shared/test_server/CMakeLists.txt") 10 | include("../shared/client_service/CMakeLists.txt") 11 | include("../shared/client_test_common/CMakeLists.txt") 12 | endif() 13 | 14 | if(NOT TARGET grpc_testserver) 15 | return() 16 | endif() 17 | 18 | qt_internal_add_test(tst_grpc_client_clientstream 19 | SOURCES 20 | tst_grpc_client_clientstream.cpp 21 | INCLUDE_DIRECTORIES 22 | ${CMAKE_CURRENT_SOURCE_DIR}/../../shared 23 | DEFINES 24 | TEST_GRPC_SERVER_PATH="$" 25 | LIBRARIES 26 | Qt::Test 27 | Qt::Core 28 | Qt::Grpc 29 | tst_grpc_client_qtgrpc_gen 30 | tst_grpc_client_test_common 31 | ) 32 | 33 | add_dependencies(tst_grpc_client_clientstream grpc_testserver) 34 | -------------------------------------------------------------------------------- /tests/auto/protobuf/duplicated_metatypes/proto/duplicated_metatypes.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.duplicated_metatypes; 6 | 7 | import "duplicated_metatypes_external.proto"; 8 | 9 | enum TestEnum { 10 | TEST_ENUM_VALUE0 = 0; 11 | TEST_ENUM_VALUE1 = 1; 12 | } 13 | 14 | message Message0 { 15 | string opts = 1; 16 | } 17 | 18 | message Message1 { 19 | map opts = 1; 20 | } 21 | 22 | message Message2 { 23 | map opts = 1; 24 | } 25 | 26 | message Message3 { 27 | map opts = 1; 28 | } 29 | 30 | message Message4 { 31 | map opts = 1; 32 | } 33 | 34 | message Message5 { 35 | map opts = 1; 36 | } 37 | 38 | message Message6 { 39 | map opts = 1; 40 | } 41 | 42 | message Message7 { 43 | map opts = 1; 44 | } 45 | 46 | message Message8 { 47 | map opts = 1; 48 | } 49 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/additionalenums.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.tests.enums; 6 | 7 | message SimpleEnumMessage { 8 | enum LocalEnum { 9 | LOCAL_ENUM_VALUE0 = 0; 10 | LOCAL_ENUM_VALUE1 = 1; 11 | LOCAL_ENUM_VALUE2 = 2; 12 | LOCAL_ENUM_VALUE3 = 3; 13 | } 14 | 15 | LocalEnum localEnum = 1; 16 | } 17 | 18 | message MixedEnumUsageMessage { 19 | enum LocalEnum { 20 | LOCAL_ENUM_VALUE0 = 0; 21 | LOCAL_ENUM_VALUE1 = 1; 22 | LOCAL_ENUM_VALUE2 = 2; 23 | LOCAL_ENUM_VALUE3 = 3; 24 | } 25 | 26 | LocalEnum localEnum = 1; 27 | repeated LocalEnum localEnumList = 2; 28 | map localEnumMap = 3; 29 | } 30 | 31 | enum TestEnum { 32 | TEST_ENUM_VALUE0 = 0; 33 | TEST_ENUM_VALUE1 = 1; 34 | TEST_ENUM_VALUE2 = 2; 35 | TEST_ENUM_VALUE3 = 4; 36 | TEST_ENUM_VALUE4 = 3; 37 | } 38 | 39 | enum TestEnumSecondInFile { 40 | TEST_ENUM_SIF_VALUE0 = 0; 41 | TEST_ENUM_SIF_VALUE1 = 1; 42 | TEST_ENUM_SIF_VALUE2 = 2; 43 | } 44 | -------------------------------------------------------------------------------- /src/protobuf/qprotobufjsonserializer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | #ifndef QPROTOBUFJSONSERIALIZER_H 5 | #define QPROTOBUFJSONSERIALIZER_H 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | 13 | QT_BEGIN_NAMESPACE 14 | 15 | class QProtobufJsonSerializerPrivate; 16 | class Q_PROTOBUF_EXPORT QProtobufJsonSerializer final : public QAbstractProtobufSerializer 17 | { 18 | Q_DISABLE_COPY_MOVE(QProtobufJsonSerializer) 19 | 20 | public: 21 | QProtobufJsonSerializer(); 22 | ~QProtobufJsonSerializer() override; 23 | 24 | Error lastError() const override; 25 | QString lastErrorString() const override; 26 | 27 | private: 28 | QByteArray serializeMessage(const QProtobufMessage *message) const override; 29 | bool deserializeMessage(QProtobufMessage *message, QByteArrayView data) const override; 30 | 31 | private: 32 | std::unique_ptr d_ptr; 33 | }; 34 | 35 | QT_END_NAMESPACE 36 | 37 | #endif // QPROTOBUFJSONSERIALIZER_H 38 | 39 | -------------------------------------------------------------------------------- /src/grpcquick/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | qt_internal_add_qml_module(GrpcQuick 5 | URI QtGrpc 6 | VERSION ${CMAKE_PROJECT_VERSION} 7 | PLUGIN_TARGET grpcquickplugin 8 | CLASS_NAME GrpcQuickPlugin 9 | SOURCES 10 | qqmlabstractgrpcchannel.h qqmlabstractgrpcchannel_p.h qqmlabstractgrpcchannel.cpp 11 | qqmlgrpcnamespace_p.h 12 | qqmlgrpchttp2channel_p.h qqmlgrpchttp2channel.cpp 13 | qqmlgrpcchanneloptions_p.h qqmlgrpcchanneloptions.cpp 14 | qqmlgrpccalloptions.h qqmlgrpccalloptions.cpp 15 | qqmlgrpcmetadata_p.h qqmlgrpcmetadata.cpp 16 | qqmlgrpcfunctionalhandlers.h qqmlgrpcfunctionalhandlers.cpp 17 | qtgrpcquicklogging_p.h qtgrpcquicklogging.cpp 18 | qtqmlgrpcstreamsender.h qtqmlgrpcstreamsender.cpp 19 | LIBRARIES 20 | Qt::Core 21 | Qt::CorePrivate 22 | Qt::Grpc 23 | PUBLIC_LIBRARIES 24 | Qt::Quick 25 | QT_LICENSE_ID QT_COMMERCIAL_OR_GPL3 26 | ) 27 | 28 | qt_internal_extend_target(GrpcQuick CONDITION QT_FEATURE_qml_ssl 29 | LIBRARIES 30 | Qt::QmlNetwork 31 | Qt::QmlNetworkPrivate 32 | ) 33 | -------------------------------------------------------------------------------- /src/protobufqttypes/protobufqtguitypes/QtGui/QtGui.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | 6 | package QtGui; 7 | 8 | message QRgba64 { 9 | uint64 rgba64 = 1; 10 | } 11 | 12 | message QColor { 13 | oneof color { 14 | QRgba64 rgba64 = 1; 15 | uint32 rgba = 2; 16 | } 17 | } 18 | 19 | message QMatrix4x4 { 20 | // 16 floats in row-major order 21 | repeated float m = 1; 22 | } 23 | 24 | message QVector2D { 25 | float x_pos = 1; 26 | float y_pos = 2; 27 | } 28 | 29 | message QVector3D { 30 | float x_pos = 1; 31 | float y_pos = 2; 32 | float z_pos = 3; 33 | } 34 | 35 | message QVector4D { 36 | float x_pos = 1; 37 | float y_pos = 2; 38 | float z_pos = 3; 39 | float w_pos = 4; 40 | } 41 | 42 | message QTransform { 43 | repeated double m = 1; 44 | } 45 | 46 | message QQuaternion { 47 | float scalar = 1; 48 | float x = 2; 49 | float y = 3; 50 | float z = 4; 51 | } 52 | 53 | message QImage { 54 | bytes data = 1; 55 | string format = 2; // see QImageWriter::supportedImageFormats() 56 | } 57 | -------------------------------------------------------------------------------- /tests/benchmarks/protobuf/deserialize/tst_bench_deserialize_protobuf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "tst_bench_deserialize_protobuf_base.h" 9 | 10 | using namespace Qt::StringLiterals; 11 | 12 | class ProtobufDeserializeBenchmark : public ProtobufDeserializeBenchmarkBase 13 | { 14 | Q_OBJECT 15 | public: 16 | ProtobufDeserializeBenchmark(); 17 | }; 18 | 19 | std::array, 3> data = { 20 | std::make_pair("qtbench.SimpleBoolMessage", QByteArray::fromHex("0801")), 21 | std::make_pair("qtbench.SimpleBytesMessage", 22 | QByteArray::fromHex("0a0c48656c6c6f20776f726c6421")), 23 | std::make_pair("qtbench.RecursiveMessage", 24 | QByteArray::fromHex("080112120802120e0803120a08041206080512020806")), 25 | }; 26 | 27 | ProtobufDeserializeBenchmark::ProtobufDeserializeBenchmark() 28 | : ProtobufDeserializeBenchmarkBase(&data, std::make_unique()) 29 | { 30 | } 31 | 32 | QTEST_MAIN(ProtobufDeserializeBenchmark) 33 | 34 | #include "tst_bench_deserialize_protobuf.moc" 35 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/shared/test_server/testserver.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include "testserverrunner.h" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | QStringList argumentList; 14 | for (int i = 0; i < argc; ++i) 15 | argumentList.append(argv[i]); 16 | 17 | QCommandLineParser parser; 18 | parser.addOption({ "latency", "Expected latency of test server communication in ms.", "ms" }); 19 | 20 | if (!parser.parse(argumentList)) { 21 | qCritical() << parser.errorText(); 22 | return 1; 23 | } 24 | 25 | QString latencyString = parser.value("latency"); 26 | if (latencyString.isEmpty()) { 27 | qCritical("Message latency is missing"); 28 | return 2; 29 | } 30 | bool ok = false; 31 | auto latency = latencyString.toLongLong(&ok); 32 | if (!ok) { 33 | qCritical() << "Unable to parse message latency argument" << parser.value("latency"); 34 | return 3; 35 | } 36 | 37 | auto server = std::make_unique(); 38 | server->run(latency); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /src/grpc/qgrpccallreply.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 4 | 5 | #ifndef QGRPCCALLREPLY_H 6 | #define QGRPCCALLREPLY_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | QT_BEGIN_NAMESPACE 18 | 19 | class QAbstractGrpcChannel; 20 | 21 | class Q_GRPC_EXPORT QGrpcCallReply final : public QGrpcOperation 22 | { 23 | Q_OBJECT 24 | QT_DEFINE_TAG_STRUCT(PrivateConstructor); 25 | 26 | public: 27 | explicit QGrpcCallReply(const QLatin1StringView service, const QLatin1StringView method, 28 | const QGrpcCallOptions &options, 29 | const std::weak_ptr &channel, PrivateConstructor); 30 | ~QGrpcCallReply() override; 31 | 32 | private: 33 | Q_DISABLE_COPY_MOVE(QGrpcCallReply) 34 | friend class QGrpcClientBasePrivate; 35 | 36 | public: 37 | bool event(QEvent *event) override; 38 | }; 39 | 40 | QT_END_NAMESPACE 41 | 42 | #endif // QGRPCCALLREPLY_H 43 | -------------------------------------------------------------------------------- /tests/auto/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(QT_FEATURE_qtprotobufgen OR QT_FEATURE_qtgrpcgen) 5 | add_subdirectory(protocplugintestcommon) 6 | endif() 7 | 8 | if(QT_FEATURE_qtprotobufgen) 9 | add_subdirectory(protobufgen) 10 | endif() 11 | if(QT_FEATURE_qtgrpcgen) 12 | add_subdirectory(grpcgen) 13 | endif() 14 | 15 | if(NOT QT_INTERNAL_GRPC_TEST_MESSAGE_LATENCY_MSEC) 16 | if (WIN32) 17 | set(QT_INTERNAL_GRPC_TEST_MESSAGE_LATENCY_MSEC 2000) 18 | else() 19 | set(QT_INTERNAL_GRPC_TEST_MESSAGE_LATENCY_MSEC 300) 20 | endif() 21 | endif() 22 | 23 | add_subdirectory(protobuf) 24 | if(QT_FEATURE_grpc AND TARGET Qt6::qtprotobufgen AND TARGET Qt6::qtgrpcgen) 25 | add_subdirectory(grpc) 26 | endif() 27 | 28 | if(TARGET Qt6::qtprotobufgen AND QT_FEATURE_protobufquick AND TARGET Qt6::QuickTest) 29 | add_subdirectory(protobufqml) 30 | endif() 31 | 32 | if(TARGET Qt6::qtgrpcgen AND TARGET Qt6::GrpcQuick AND TARGET Qt6::QuickTest) 33 | add_subdirectory(grpcquick) 34 | endif() 35 | 36 | if(TARGET Qt6::ProtobufQtCoreTypes 37 | AND TARGET Qt6::ProtobufQtGuiTypes 38 | AND TARGET Qt6::qtprotobufgen) 39 | add_subdirectory(protobufqttypes) 40 | endif() 41 | -------------------------------------------------------------------------------- /tests/auto/protobuf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Basic functionality 5 | if(TARGET Qt6::qtprotobufgen) 6 | get_target_property(protoc_version WrapProtoc::WrapProtoc _qt_internal_protobuf_version) 7 | 8 | add_subdirectory(basic) 9 | add_subdirectory(json) 10 | add_subdirectory(syntax) 11 | add_subdirectory(nopackage) 12 | add_subdirectory(enums) 13 | add_subdirectory(externalpackage) 14 | add_subdirectory(sequence) 15 | add_subdirectory(extranamespace) 16 | add_subdirectory(nested) 17 | add_subdirectory(converters) 18 | add_subdirectory(duplicated_metatypes) 19 | add_subdirectory(recursive) 20 | if(protoc_version VERSION_GREATER_EQUAL "3.12") 21 | add_subdirectory(optional) 22 | endif() 23 | 24 | if(TARGET Qt6::ProtobufWellKnownTypes) 25 | add_subdirectory(wellknown) 26 | endif() 27 | 28 | if(NOT CMAKE_CROSSCOMPILING AND TARGET Qt6::ProtobufWellKnownTypes) 29 | add_subdirectory(conformance) 30 | endif() 31 | endif() 32 | add_subdirectory(qprotobuflazymessagepointer) 33 | add_subdirectory(qprotobufoneof) 34 | add_subdirectory(qprotobufpropertyorderingbuilder) 35 | add_subdirectory(transparentwrapper) 36 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/userstatusmodel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | #ifndef USERSTATUSMODEL_H 5 | #define USERSTATUSMODEL_H 6 | 7 | #include "chatmessages.qpb.h" 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | class UserStatusModel : public QAbstractListModel 15 | { 16 | Q_OBJECT 17 | QML_INTERFACE 18 | 19 | public: 20 | enum UserRole { 21 | Username = Qt::UserRole, 22 | Status, 23 | }; 24 | 25 | explicit UserStatusModel(QObject *parent = nullptr); 26 | ~UserStatusModel() override; 27 | 28 | Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override; 29 | 30 | Q_INVOKABLE QVariant data(const QModelIndex &index, int role = Qt::UserRole) const override; 31 | 32 | QHash roleNames() const override; 33 | 34 | bool updateUserStatus(const chat::ChatMessage &message); 35 | 36 | signals: 37 | void rowCountChanged(); 38 | 39 | private: 40 | QList> mActiveUsers; 41 | Q_DISABLE_COPY_MOVE(UserStatusModel) 42 | }; 43 | 44 | #endif // USERSTATUSMODEL_H 45 | -------------------------------------------------------------------------------- /src/tools/qtprotoccommon/descriptorprinterbase.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev , Tatyana Borisova 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 4 | 5 | #ifndef DESCRIPTORPRINTERBASE_H 6 | #define DESCRIPTORPRINTERBASE_H 7 | 8 | #include "baseprinter.h" 9 | 10 | #include "commontemplates.h" 11 | #include "generatorcommon.h" 12 | 13 | namespace qtprotoccommon { 14 | 15 | template 16 | class DescriptorPrinterBase : public BasePrinter 17 | { 18 | public: 19 | explicit DescriptorPrinterBase(const T *descriptor, 20 | std::shared_ptr<::google::protobuf::io::Printer> printer, 21 | TypeMap &&typeMap) 22 | : BasePrinter(printer), m_descriptor(descriptor), m_typeMap(std::move(typeMap)) 23 | { 24 | } 25 | ~DescriptorPrinterBase() = default; 26 | 27 | void encloseClass() 28 | { 29 | m_printer->Print(CommonTemplates::SemicolonBlockEnclosureTemplate()); 30 | } 31 | 32 | protected: 33 | const T *m_descriptor; 34 | TypeMap m_typeMap; 35 | }; 36 | } // namespace qtprotoccommon 37 | 38 | #endif // DESCRIPTORPRINTERBASE_H 39 | -------------------------------------------------------------------------------- /src/grpc/configure.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | qt_feature("grpc" PUBLIC 4 | SECTION "Utilities" 5 | LABEL "gRPC support" 6 | PURPOSE "Provides support for serializing and deserializing gRPC services using Qt." 7 | CONDITION TARGET Qt6::Network AND QT_FEATURE_http 8 | ) 9 | 10 | qt_feature("qtgrpcgen" PRIVATE 11 | SECTION "Utilities" 12 | LABEL "Qt GRPC generator" 13 | PURPOSE "Provides support for generating Qt-based gRPC services." 14 | DISABLE NOT QT_FEATURE_grpc 15 | CONDITION TARGET protobuf::libprotoc AND TARGET protobuf::libprotobuf AND 16 | TARGET WrapProtoc::WrapProtoc AND TEST_libprotobuf AND TEST_libprotoc 17 | ) 18 | 19 | qt_feature("grpcquick" PUBLIC 20 | SECTION "Utilities" 21 | LABEL "QML gRPC support" 22 | PURPOSE "Allows using the gRPC API from QML" 23 | CONDITION QT_FEATURE_grpc AND TARGET Qt6::Qml 24 | ) 25 | 26 | qt_configure_add_summary_section(NAME "Qt GRPC") 27 | qt_configure_add_summary_entry(ARGS "grpc") 28 | qt_configure_add_summary_entry(ARGS "grpcquick") 29 | qt_configure_end_summary_section() 30 | qt_configure_add_summary_section(NAME "Qt GRPC tools") 31 | qt_configure_add_summary_entry(ARGS "qtgrpcgen") 32 | qt_configure_end_summary_section() 33 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_basic_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | set(CMAKE_AUTOMOC TRUE) 11 | qt_policy(SET QTP0001 NEW) 12 | qt_policy(SET QTP0004 NEW) 13 | 14 | qt_internal_add_test(tst_protobuf_basictypes_qml 15 | QMLTEST 16 | SOURCES 17 | tst_protobuf_basictypes_qml.cpp 18 | LIBRARIES 19 | Qt::Qml 20 | Qt::Protobuf 21 | ) 22 | 23 | qt_add_qml_module(tst_protobuf_basictypes_qml 24 | URI QmlTestUri 25 | VERSION 1.0 26 | QML_FILES 27 | qml/tst_basic.qml 28 | ) 29 | 30 | qt_add_protobuf(tst_protobuf_basictypes_qml 31 | PROTO_FILES 32 | ../../shared/data/proto/basicmessages.proto 33 | QML 34 | GENERATE_PACKAGE_SUBFOLDERS 35 | FIELD_ENUM 36 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 37 | ) 38 | 39 | qt_autogen_tools_initial_setup(tst_protobuf_basictypes_qml) 40 | if(QT_BUILD_STANDALONE_TESTS) 41 | qt_import_qml_plugins(tst_protobuf_basictypes_qml) 42 | endif() 43 | 44 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/oneof/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_basic_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | set(CMAKE_AUTOMOC TRUE) 11 | qt_policy(SET QTP0001 NEW) 12 | qt_policy(SET QTP0004 NEW) 13 | 14 | qt_internal_add_test(tst_protobuf_oneof_qml 15 | QMLTEST 16 | SOURCES 17 | tst_protobuf_oneof_qml.cpp 18 | LIBRARIES 19 | Qt::Qml 20 | Qt::Protobuf 21 | ) 22 | 23 | qt_add_qml_module(tst_protobuf_oneof_qml 24 | URI QmlTestUri 25 | VERSION 1.0 26 | QML_FILES 27 | qml/tst_oneof.qml 28 | ) 29 | 30 | qt_add_protobuf(tst_protobuf_oneof_qml 31 | PROTO_FILES 32 | ../../shared/data/proto/basicmessages.proto 33 | ../../shared/data/proto/oneofmessages.proto 34 | QML 35 | GENERATE_PACKAGE_SUBFOLDERS 36 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 37 | ) 38 | 39 | qt_autogen_tools_initial_setup(tst_protobuf_oneof_qml) 40 | if(QT_BUILD_STANDALONE_TESTS) 41 | qt_import_qml_plugins(tst_protobuf_oneof_qml) 42 | endif() 43 | -------------------------------------------------------------------------------- /tests/auto/protobuf/basic/proto/unknownfield.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtproto.tests; 6 | 7 | // Generate the message using one of the messages with all three fields defined 8 | // in e.g. Python and then deserialize it with PartialMessage. 9 | 10 | message StringMessage { 11 | int32 aaa = 1; 12 | int64 timestamp = 2; 13 | string extraField = 3; 14 | } 15 | 16 | message LargeIndexStringMessage { 17 | int32 aaa = 1; 18 | int64 timestamp = 2; 19 | string extraField = 536870900; 20 | } 21 | 22 | message IntMessage { 23 | int32 aaa = 1; 24 | int64 timestamp = 2; 25 | int32 extraField = 3; 26 | } 27 | 28 | message MapMessage { 29 | int32 aaa = 1; 30 | int64 timestamp = 2; 31 | map extraField = 3; 32 | } 33 | 34 | message RepeatedMessage { 35 | int32 aaa = 1; 36 | int64 timestamp = 2; 37 | repeated int32 extraField = 3; 38 | } 39 | 40 | message RepeatedMessageNonPacked { 41 | int32 aaa = 1; 42 | int64 timestamp = 2; 43 | repeated int32 extraField = 3 [packed = false]; 44 | } 45 | 46 | message PartialMessage { 47 | int32 aaa = 1; 48 | int64 timestamp = 2; 49 | // No third field 50 | } 51 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | # Pass 3rd party dependency locations to examples as external projects. 5 | if(NOT Protobuf_ROOT AND "$ENV{Protobuf_ROOT}") 6 | set(Protobuf_ROOT "$ENV{Protobuf_ROOT}") 7 | endif() 8 | 9 | if(NOT gRPC_ROOT AND "$ENV{gRPC_ROOT}") 10 | set(gRPC_ROOT "$ENV{gRPC_ROOT}") 11 | endif() 12 | 13 | if(NOT absl_ROOT AND "$ENV{absl_ROOT}") 14 | set(absl_ROOT "$ENV{absl_ROOT}") 15 | endif() 16 | 17 | if(NOT OPENSSL_ROOT_DIR AND "$ENV{OPENSSL_ROOT_DIR}") 18 | set(OPENSSL_ROOT_DIR "$ENV{OPENSSL_ROOT_DIR}") 19 | endif() 20 | 21 | set(QT_EXAMPLE_CMAKE_VARS_TO_PASS Protobuf_ROOT:STRING gRPC_ROOT:STRING OPENSSL_ROOT_DIR:STRING) 22 | 23 | # In the CI, we assume the absl dependency is next to the gRPC one. 24 | if(gRPC_ROOT AND NOT absl_ROOT) 25 | get_filename_component(absl_ROOT "${gRPC_ROOT}" DIRECTORY) 26 | string(APPEND absl_ROOT "/absl") 27 | if(EXISTS "${absl_ROOT}") 28 | list(APPEND QT_EXAMPLE_CMAKE_VARS_TO_PASS absl_ROOT:STRING) 29 | endif() 30 | endif() 31 | 32 | qt_examples_build_begin(EXTERNAL_BUILD) 33 | 34 | add_subdirectory(protobuf) 35 | 36 | if(TARGET Qt6::Grpc) 37 | add_subdirectory(grpc) 38 | endif() 39 | qt_examples_build_end() 40 | -------------------------------------------------------------------------------- /src/wellknown/qprotobufwellknowntypesjsonserializers_p.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 3 | 4 | #ifndef QPROTOBUFWELLKNOWNTYPESJSONSERIALIZERS_P_H 5 | #define QPROTOBUFWELLKNOWNTYPESJSONSERIALIZERS_P_H 6 | 7 | // 8 | // W A R N I N G 9 | // ------------- 10 | // 11 | // This file is not part of the Qt API. It exists purely as an 12 | // implementation detail. This header file may change from version to 13 | // version without notice, or even be removed. 14 | // 15 | // We mean it. 16 | // 17 | 18 | #include 19 | 20 | QT_BEGIN_NAMESPACE 21 | 22 | namespace QtProtobufWellKnownTypesPrivate { 23 | void registerTimestampCustomJsonHandler(); 24 | void registerDurationCustomJsonHandler(); 25 | void registerBoolValueCustomJsonHandler(); 26 | void registerInt32ValueCustomJsonHandler(); 27 | void registerInt64ValueCustomJsonHandler(); 28 | void registerUInt32ValueCustomJsonHandler(); 29 | void registerUInt64ValueCustomJsonHandler(); 30 | void registerFloatValueCustomJsonHandler(); 31 | void registerDoubleValueCustomJsonHandler(); 32 | void registerStringValueCustomJsonHandler(); 33 | void registerBytesValueCustomJsonHandler(); 34 | } 35 | 36 | QT_END_NAMESPACE 37 | 38 | #endif // QPROTOBUFWELLKNOWNTYPESJSONSERIALIZERS_P_H 39 | -------------------------------------------------------------------------------- /tests/auto/grpc/qgrpccalloptions/tst_qgrpccalloptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | class QGrpcCallOptionsTest : public QObject 11 | { 12 | Q_OBJECT 13 | 14 | private Q_SLOTS: 15 | void hasSpecialMemberFunctions() const { common.hasSpecialMemberFunctions(); } 16 | void hasImplicitQVariant() const { common.hasImplicitQVariant(); } 17 | void hasMemberSwap() const { common.hasMemberSwap(); } 18 | #if QT_DEPRECATED_SINCE(6, 13) 19 | void deprecatedPropertyMetadata() const { common.deprecatedPropertyMetadata(); } 20 | void propertyMetadataCompat() const { common.propertyMetadataCompat(); } 21 | #endif 22 | void propertyMetadata() const { common.propertyMetadata(); } 23 | void propertyDeadline() const { common.propertyDeadline(); } 24 | void propertyFilterServerMetadata() const { common.propertyFilterServerMetadata(); } 25 | void streamsToDebug() const { common.streamsToDebug(); } 26 | void comparesEqual() const { common.comparesEqual(); } 27 | 28 | private: 29 | GrpcCommonOptionsTest common; 30 | }; 31 | 32 | QTEST_MAIN(QGrpcCallOptionsTest) 33 | 34 | #include "tst_qgrpccalloptions.moc" 35 | -------------------------------------------------------------------------------- /src/protobuf/qprotobufserializer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QPROTOBUFSERIALIZER_H 6 | #define QPROTOBUFSERIALIZER_H 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | QT_BEGIN_NAMESPACE 17 | 18 | class QProtobufMessage; 19 | class QProtobufSerializerPrivate; 20 | class Q_PROTOBUF_EXPORT QProtobufSerializer final : public QAbstractProtobufSerializer 21 | { 22 | Q_DISABLE_COPY_MOVE(QProtobufSerializer) 23 | public: 24 | QProtobufSerializer(); 25 | ~QProtobufSerializer() override; 26 | 27 | Error lastError() const override; 28 | QString lastErrorString() const override; 29 | 30 | void shouldPreserveUnknownFields(bool preserveUnknownFields); 31 | 32 | private: 33 | QByteArray serializeMessage(const QProtobufMessage *message) const override; 34 | bool deserializeMessage(QProtobufMessage *message, QByteArrayView data) const override; 35 | 36 | std::unique_ptr d_ptr; 37 | }; 38 | 39 | QT_END_NAMESPACE 40 | #endif // QPROTOBUFSERIALIZER_H 41 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 4 | 5 | #include "chatengine.h" 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | QtProtobuf::registerProtobufQtCoreTypes(); 18 | 19 | QGuiApplication app(argc, argv); 20 | QGuiApplication::setWindowIcon(QIcon(":/res/qtchat_logo.png")); 21 | QGuiApplication::setApplicationName("QtGrpcChat"); 22 | QGuiApplication::setOrganizationName("The Qt Company"); 23 | QGuiApplication::setOrganizationDomain("qt.io"); 24 | #ifdef USE_EMOJI_FONT 25 | QFontDatabase::addApplicationFont(":/NotoColorEmoji.ttf"); 26 | #endif 27 | 28 | QQmlApplicationEngine engine; 29 | engine.loadFromModule("QtGrpcChat", "Main"); 30 | if (engine.rootObjects().isEmpty()) 31 | return -1; 32 | 33 | // Install the engine as event filter. We use it to detect inactivity 34 | auto *chatEngine = engine.singletonInstance("QtGrpcChat", "ChatEngine"); 35 | app.installEventFilter(chatEngine); 36 | 37 | return QGuiApplication::exec(); 38 | } 39 | -------------------------------------------------------------------------------- /tests/auto/shared/data/proto/qtcoretypes.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | syntax = "proto3"; 4 | 5 | package qtprotobufnamespace.qttypes.tests; 6 | import "QtCore/QtCore.proto"; 7 | 8 | message QUrlMessage { 9 | QtCore.QUrl testField = 1; 10 | } 11 | 12 | message QUuidMessage { 13 | QtCore.QUuid testField = 1; 14 | } 15 | 16 | message QCharMessage { 17 | QtCore.QChar testField = 1; 18 | } 19 | 20 | message QTimeZoneMessage { 21 | QtCore.QTimeZone testField = 1; 22 | } 23 | 24 | message QTimeMessage { 25 | QtCore.QTime testField = 1; 26 | } 27 | 28 | message QDateMessage { 29 | QtCore.QDate testField = 1; 30 | } 31 | 32 | message QDateTimeMessage { 33 | QtCore.QDateTime testField = 1; 34 | } 35 | 36 | message QSizeMessage { 37 | QtCore.QSize testField = 1; 38 | } 39 | 40 | message QSizeFMessage { 41 | QtCore.QSizeF testField = 1; 42 | } 43 | 44 | message QPointMessage { 45 | QtCore.QPoint testField = 1; 46 | } 47 | 48 | message QPointFMessage { 49 | QtCore.QPointF testField = 1; 50 | } 51 | 52 | message QRectMessage { 53 | QtCore.QRect testField = 1; 54 | } 55 | 56 | message QRectFMessage { 57 | QtCore.QRectF testField = 1; 58 | } 59 | 60 | message QVersionNumberFMessage { 61 | QtCore.QVersionNumber testField = 1; 62 | } 63 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/serverstream/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_client_serverstream LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | 9 | include("../shared/test_server/CMakeLists.txt") 10 | include("../shared/client_service/CMakeLists.txt") 11 | include("../shared/client_test_common/CMakeLists.txt") 12 | endif() 13 | 14 | if(NOT TARGET grpc_testserver) 15 | return() 16 | endif() 17 | 18 | qt_internal_add_test(tst_grpc_client_serverstream 19 | SOURCES 20 | tst_grpc_client_serverstream.cpp 21 | INCLUDE_DIRECTORIES 22 | ${CMAKE_CURRENT_SOURCE_DIR}/../../shared 23 | DEFINES 24 | TEST_GRPC_SERVER_PATH="$" 25 | LIBRARIES 26 | Qt::Test 27 | Qt::Core 28 | Qt::Grpc 29 | tst_grpc_client_qtgrpc_gen 30 | tst_grpc_client_test_common 31 | ) 32 | 33 | qt_add_resources(tst_grpc_client_serverstream 34 | "assets" 35 | PREFIX 36 | "/" 37 | BASE 38 | "../../shared/" 39 | FILES 40 | "../../shared/assets/testfile" 41 | ) 42 | 43 | add_dependencies(tst_grpc_client_serverstream grpc_testserver) 44 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/client/bidistream/tst_grpc_client_bidistream_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | class GrpcClientBidiStreamQml : public QObject 12 | { 13 | Q_OBJECT 14 | 15 | public slots: 16 | void qmlEngineAvailable(QQmlEngine *engine) 17 | { 18 | // Initialization requiring the QQmlEngine to be constructed 19 | engine->rootContext()->setContextProperty("testMessageLatencyWithThreshold", 20 | QVariant::fromValue(MessageLatencyWithThreshold)); 21 | if (m_serverProccess.state() != QProcess::ProcessState::Running) { 22 | qInfo() << "Restarting server"; 23 | m_serverProccess.restart(); 24 | QVERIFY2(m_serverProccess.state() == QProcess::ProcessState::Running, 25 | "Precondition failed - Server cannot be started."); 26 | } 27 | } 28 | 29 | private: 30 | ServerProcRunner m_serverProccess{ TEST_GRPC_SERVER_PATH }; 31 | }; 32 | 33 | QUICK_TEST_MAIN_WITH_SETUP(tst_grpc_client_bidistream_qml, GrpcClientBidiStreamQml) 34 | 35 | #include "tst_grpc_client_bidistream_qml.moc" 36 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/shared/mockserver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2025 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | # Find OpenSSL first since it's a transitive dependency that may not be available in CONFIG mode 5 | find_package(OpenSSL) 6 | 7 | set(_qt_grpc_backup_prefer_config ${CMAKE_FIND_PACKAGE_PREFER_CONFIG}) 8 | set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) 9 | 10 | find_package(Protobuf) 11 | find_package(gRPC) 12 | 13 | set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${_qt_grpc_backup_prefer_config}) 14 | unset(_qt_grpc_backup_prefer_config) 15 | 16 | if(CMAKE_CROSSCOMPILING) 17 | find_program(grpc_cpp_plugin grpc_cpp_plugin NO_CACHE) 18 | elseif(TARGET gRPC::grpc_cpp_plugin) 19 | set(grpc_cpp_plugin $) 20 | else() 21 | set(grpc_cpp_plugin "") 22 | endif() 23 | 24 | if(NOT grpc_cpp_plugin OR NOT TARGET WrapProtoc::WrapProtoc 25 | OR NOT TARGET gRPC::grpc++) 26 | message(WARNING "Dependencies of 'grpc_mock_server' not found. Skipping.") 27 | return() 28 | endif() 29 | 30 | add_library(grpc_mock_server STATIC mockserver.h mockserver.cpp) 31 | target_include_directories(grpc_mock_server 32 | PUBLIC 33 | "${CMAKE_CURRENT_LIST_DIR}" 34 | ) 35 | 36 | target_link_libraries(grpc_mock_server 37 | PUBLIC 38 | protobuf::libprotobuf 39 | gRPC::grpc++ 40 | Qt::Test 41 | ) 42 | 43 | -------------------------------------------------------------------------------- /tests/auto/grpcquick/client/serverstream/tst_grpc_client_serverstream_qml.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | class GrpcClientServerStreamQml : public QObject 12 | { 13 | Q_OBJECT 14 | 15 | public slots: 16 | void qmlEngineAvailable(QQmlEngine *engine) 17 | { 18 | // Initialization requiring the QQmlEngine to be constructed 19 | engine->rootContext()->setContextProperty("testMessageLatencyWithThreshold", 20 | QVariant::fromValue(MessageLatencyWithThreshold)); 21 | if (m_serverProccess.state() != QProcess::ProcessState::Running) { 22 | qInfo() << "Restarting server"; 23 | m_serverProccess.restart(); 24 | QVERIFY2(m_serverProccess.state() == QProcess::ProcessState::Running, 25 | "Precondition failed - Server cannot be started."); 26 | } 27 | } 28 | 29 | private: 30 | ServerProcRunner m_serverProccess{ TEST_GRPC_SERVER_PATH }; 31 | }; 32 | 33 | QUICK_TEST_MAIN_WITH_SETUP(tst_grpc_client_serverstream_qml, GrpcClientServerStreamQml) 34 | 35 | #include "tst_grpc_client_serverstream_qml.moc" 36 | -------------------------------------------------------------------------------- /tests/auto/protobuf/enums/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_enums LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt6_add_protobuf(tst_protobuf_enumtypes_gen 11 | PROTO_FILES 12 | enummessages.proto 13 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 14 | ) 15 | qt_autogen_tools_initial_setup(tst_protobuf_enumtypes_gen) 16 | 17 | qt_internal_add_test(tst_protobuf_enumtypes 18 | SOURCES 19 | tst_protobuf_enumtypes.cpp 20 | INCLUDE_DIRECTORIES 21 | ../shared 22 | LIBRARIES 23 | Qt::Test 24 | Qt::Protobuf 25 | tst_protobuf_enumtypes_gen 26 | ) 27 | 28 | qt_internal_add_test(tst_protobuf_serialization_enumtypes 29 | SOURCES 30 | tst_protobuf_serialization_enumtypes.cpp 31 | LIBRARIES 32 | Qt::Test 33 | Qt::Protobuf 34 | tst_protobuf_enumtypes_gen 35 | ) 36 | 37 | qt_internal_add_test(tst_protobuf_deserialization_enumtypes 38 | SOURCES 39 | tst_protobuf_deserialization_enumtypes.cpp 40 | LIBRARIES 41 | Qt::Test 42 | Qt::Protobuf 43 | tst_protobuf_enumtypes_gen 44 | ) 45 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/shared/client_test_common/grpcclienttestbase.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | #ifndef GRPCCLIENTTESTBASE_H 5 | #define GRPCCLIENTTESTBASE_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | class GrpcClientTestBase : public QObject 18 | { 19 | Q_OBJECT 20 | protected: 21 | enum Channel { 22 | NoChannels = 0x0, 23 | Qt = 0x1, 24 | Ssl = 0x2, 25 | Json = 0x4, 26 | SslNoCredentials = 0x8, 27 | WithChannelDeadline = 0x10, 28 | }; 29 | Q_DECLARE_FLAGS(Channels, Channel) 30 | 31 | GrpcClientTestBase(Channels channels) : m_channels(channels) { } 32 | 33 | std::shared_ptr client(); 34 | GrpcClientTestBase::Channels channelType(); 35 | 36 | public Q_SLOTS: 37 | void initTestCase_data(); 38 | void init(); 39 | 40 | private: 41 | ServerProcRunner m_serverProccess{ QFINDTESTDATA(TEST_GRPC_SERVER_PATH) }; 42 | Channels m_channelType; 43 | Channels m_channels; 44 | std::shared_ptr m_client; 45 | }; 46 | 47 | #endif // GRPCCLIENTTESTBASE_H 48 | -------------------------------------------------------------------------------- /tests/auto/grpc/client/ssl/tst_grpc_client_ssl.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include "testservice_client.grpc.qpb.h" 15 | 16 | using namespace qtgrpc::tests; 17 | 18 | class QtGrpcSslClientTest : public GrpcClientTestBase 19 | { 20 | Q_OBJECT 21 | public: 22 | QtGrpcSslClientTest() 23 | : GrpcClientTestBase(Channels(GrpcClientTestBase::Channel::SslNoCredentials)) 24 | { 25 | } 26 | private Q_SLOTS: 27 | void incorrectSecureCredentialsTest(); 28 | }; 29 | 30 | void QtGrpcSslClientTest::incorrectSecureCredentialsTest() 31 | { 32 | SimpleStringMessage req; 33 | req.setTestFieldString("Hello Qt!"); 34 | 35 | auto reply = client()->testMethod(req); 36 | QSignalSpy finishedSpy(reply.get(), &QGrpcCallReply::finished); 37 | QTRY_COMPARE_EQ_WITH_TIMEOUT(finishedSpy.count(), 1, MessageLatencyWithThreshold); 38 | auto status = finishedSpy.first().first().value(); 39 | QVERIFY(!status.isOk()); 40 | } 41 | 42 | QTEST_MAIN(QtGrpcSslClientTest) 43 | #include "tst_grpc_client_ssl.moc" 44 | -------------------------------------------------------------------------------- /tests/auto/grpc/server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_grpc_server LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt6_add_protobuf(tst_grpc_server_qtgrpc_gen 11 | PROTO_FILES 12 | ${CMAKE_CURRENT_SOURCE_DIR}/../shared/proto/testservice.proto 13 | OUTPUT_DIRECTORY 14 | "${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated" 15 | ) 16 | 17 | qt6_add_grpc(tst_grpc_server_qtgrpc_gen CLIENT 18 | PROTO_FILES 19 | ${CMAKE_CURRENT_SOURCE_DIR}/../shared/proto/testservice.proto 20 | OUTPUT_DIRECTORY 21 | "${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated" 22 | ) 23 | 24 | qt_autogen_tools_initial_setup(tst_grpc_server_qtgrpc_gen) 25 | 26 | qt_internal_add_test(tst_grpc_server 27 | SOURCES 28 | tst_grpc_server.cpp 29 | INCLUDE_DIRECTORIES 30 | ${CMAKE_CURRENT_SOURCE_DIR}/../shared 31 | LIBRARIES 32 | Qt::Test 33 | Qt::Core 34 | Qt::Grpc 35 | tst_grpc_server_qtgrpc_gen 36 | ) 37 | 38 | set(assets_resource_files "../shared/assets/testfile") 39 | qt_add_resources(tst_grpc_server 40 | "assets" 41 | PREFIX 42 | "/" 43 | FILES 44 | ${assets_resource_files} 45 | ) 46 | -------------------------------------------------------------------------------- /examples/grpc/chat/client/StatusDisplay.qml: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | pragma ComponentBehavior: Bound 5 | 6 | import QtQuick 7 | 8 | Rectangle { 9 | id: root 10 | 11 | property alias text: label.text 12 | readonly property int animTime: 3000 13 | 14 | function restart() : void { anim.restart() } 15 | 16 | z: 2 17 | height: label.contentHeight + 10 18 | radius: 5 19 | color: "transparent" 20 | visible: anim.running 21 | 22 | ColorAnimation { 23 | id: anim 24 | to: "transparent" 25 | duration: root.animTime 26 | easing.type: Easing.InQuint 27 | target: root 28 | properties: "color" 29 | onStarted: { 30 | label.color = "black" 31 | textAnim.restart() 32 | } 33 | } 34 | 35 | ColorAnimation { 36 | id: textAnim 37 | to: "transparent" 38 | duration: root.animTime 39 | easing.type: Easing.InQuint 40 | target: label 41 | properties: "color" 42 | } 43 | 44 | Text { 45 | id: label 46 | anchors.fill: parent 47 | horizontalAlignment: Text.AlignHCenter 48 | verticalAlignment: Text.AlignVCenter 49 | text: "OK" 50 | font.pixelSize: 24 51 | clip: true 52 | wrapMode: Text.WordWrap 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/tools/qtgrpcgen/qmlclientdeclarationprinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2023 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 3 | 4 | #pragma once 5 | 6 | #include "descriptorprinterbase.h" 7 | #include 8 | 9 | namespace google::protobuf { 10 | class ServiceDescriptor; 11 | class Message; 12 | } 13 | namespace io { 14 | class Printer; 15 | } 16 | 17 | namespace QtGrpc { 18 | 19 | class QmlClientDeclarationPrinter : 20 | public qtprotoccommon::DescriptorPrinterBase<::google::protobuf::ServiceDescriptor> 21 | { 22 | public: 23 | QmlClientDeclarationPrinter(const ::google::protobuf::ServiceDescriptor *service, 24 | const std::shared_ptr<::google::protobuf::io::Printer> &printer); 25 | ~QmlClientDeclarationPrinter() = default; 26 | 27 | void run() 28 | { 29 | printOpenNamespace(); 30 | printStreamSenders(); 31 | printClientClass(); 32 | printPublicBlock(); 33 | printConstructor(); 34 | printClientMethodsDeclaration(); 35 | encloseClass(); 36 | printCloseNamespace(); 37 | } 38 | 39 | private: 40 | void printOpenNamespace(); 41 | void printStreamSenders(); 42 | void printClientClass(); 43 | void printConstructor(); 44 | void printClientMethodsDeclaration(); 45 | void printCloseNamespace(); 46 | }; 47 | 48 | } // namespace QtGrpc 49 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmake_generated/copy_comments/annotation_qtprotoreg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "annotation.qpb.h" 3 | 4 | #include 5 | 6 | namespace qtprotobufnamespace::tests { 7 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage1(qRegisterProtobufType); 8 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage2(qRegisterProtobufType); 9 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage3(qRegisterProtobufType); 10 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage4(qRegisterProtobufType); 11 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage5(qRegisterProtobufType); 12 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage6(qRegisterProtobufType); 13 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage7(qRegisterProtobufType); 14 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage8(qRegisterProtobufType); 15 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage9(qRegisterProtobufType); 16 | static bool RegisterAnnotationProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }(); 17 | } // namespace qtprotobufnamespace::tests 18 | 19 | -------------------------------------------------------------------------------- /tests/benchmarks/protobuf/deserialize/data/bench.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only 3 | 4 | syntax = "proto3"; 5 | 6 | package qtbench; 7 | 8 | message ScalarTypes { 9 | enum EnumType { 10 | Value1 = 0; 11 | Value2 = 1; 12 | Value3 = 2; 13 | } 14 | int32 field1 = 1; 15 | uint32 field2 = 2; 16 | sint32 field3 = 3; 17 | fixed32 field4 = 4; 18 | sfixed32 field5 = 5; 19 | int64 field6 = 6; 20 | uint64 field7 = 7; 21 | sint64 field8 = 8; 22 | fixed64 field9 = 9; 23 | sfixed64 field10 = 10; 24 | float field11 = 11; 25 | double field12 = 12; 26 | string field13 = 13; 27 | bytes field14 = 14; 28 | EnumType field15 = 15; 29 | } 30 | 31 | message ScalarTypesRepeated { 32 | repeated ScalarTypes field1 = 1; 33 | repeated ScalarTypes.EnumType field2 = 2; 34 | } 35 | 36 | message MapTypes { 37 | map field1 = 1; 38 | map field2 = 2; 39 | } 40 | 41 | message BenchmarkMessage { 42 | repeated MapTypes field1 = 1; 43 | } 44 | 45 | message SimpleBoolMessage { 46 | bool testFieldBool = 1; 47 | } 48 | 49 | message SimpleBytesMessage { 50 | bytes testFieldBytes = 1; 51 | } 52 | 53 | message RecursiveMessage { 54 | int32 testFieldInt = 1; 55 | RecursiveMessage testFieldRecursive = 2; 56 | } 57 | -------------------------------------------------------------------------------- /src/tools/qtgrpcgen/clientdeclarationprinter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 4 | 5 | #pragma once 6 | 7 | #include "descriptorprinterbase.h" 8 | 9 | #include 10 | 11 | namespace google::protobuf { 12 | class ServiceDescriptor; 13 | class Message; 14 | } 15 | namespace io { 16 | class Printer; 17 | } 18 | 19 | namespace QtGrpc { 20 | 21 | class ClientDeclarationPrinter : 22 | public qtprotoccommon::DescriptorPrinterBase<::google::protobuf::ServiceDescriptor> 23 | { 24 | public: 25 | ClientDeclarationPrinter(const ::google::protobuf::ServiceDescriptor *service, 26 | const std::shared_ptr<::google::protobuf::io::Printer> &printer); 27 | ~ClientDeclarationPrinter() = default; 28 | 29 | void run() 30 | { 31 | printOpenNamespace(); 32 | printClientClass(); 33 | printPublicBlock(); 34 | printConstructorDestructor(); 35 | printClientMethodsDeclaration(); 36 | encloseClass(); 37 | printCloseNamespace(); 38 | } 39 | 40 | private: 41 | void printOpenNamespace(); 42 | void printClientClass(); 43 | void printConstructorDestructor(); 44 | void printClientMethodsDeclaration(); 45 | void printCloseNamespace(); 46 | }; 47 | 48 | } // namespace QtGrpc 49 | -------------------------------------------------------------------------------- /tests/auto/protobufgen/data/cmd_line_generated/copy_comments/annotation_qtprotoreg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "annotation.qpb.h" 3 | 4 | #include 5 | 6 | namespace qtprotobufnamespace::tests { 7 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage1(qRegisterProtobufType); 8 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage2(qRegisterProtobufType); 9 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage3(qRegisterProtobufType); 10 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage4(qRegisterProtobufType); 11 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage5(qRegisterProtobufType); 12 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage6(qRegisterProtobufType); 13 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage7(qRegisterProtobufType); 14 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage8(qRegisterProtobufType); 15 | static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarAnnotatedMessage9(qRegisterProtobufType); 16 | static bool RegisterAnnotationProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }(); 17 | } // namespace qtprotobufnamespace::tests 18 | 19 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/messagelists/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_messagelists_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_policy(SET QTP0001 NEW) 11 | qt_policy(SET QTP0004 NEW) 12 | 13 | qt_internal_add_test(tst_protobuf_repeated_qml 14 | QMLTEST 15 | SOURCES 16 | tst_protobuf_repeated_qml.cpp 17 | LIBRARIES 18 | Qt::Qml 19 | Qt::Protobuf 20 | ) 21 | 22 | qt_add_protobuf(tst_protobuf_repeated_qml_gen 23 | PROTO_FILES 24 | ../../shared/data/proto/basicmessages.proto 25 | ../../shared/data/proto/repeatedmessages.proto 26 | QML 27 | FIELD_ENUM 28 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 29 | ) 30 | 31 | qt_add_qml_module(tst_protobuf_repeated_qml 32 | URI QmlTestUri 33 | VERSION 1.0 34 | QML_FILES 35 | qml/tst_repeated.qml 36 | ) 37 | 38 | qt_autogen_tools_initial_setup(tst_protobuf_repeated_qml) 39 | qt_autogen_tools_initial_setup(tst_protobuf_repeated_qml_gen) 40 | qt_autogen_tools_initial_setup(tst_protobuf_repeated_qml_genplugin) 41 | 42 | if(QT_BUILD_STANDALONE_TESTS) 43 | qt_import_qml_plugins(tst_protobuf_repeated_qml) 44 | endif() 45 | 46 | -------------------------------------------------------------------------------- /tests/auto/protobufqml/syntax/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2023 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) 5 | cmake_minimum_required(VERSION 3.16) 6 | project(tst_protobuf_syntax_qml LANGUAGES CXX) 7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) 8 | endif() 9 | 10 | qt_policy(SET QTP0001 NEW) 11 | qt_policy(SET QTP0004 NEW) 12 | 13 | qt_internal_add_test(tst_protobuf_syntax_qml 14 | QMLTEST 15 | SOURCES 16 | tst_protobuf_syntax_qml.cpp 17 | LIBRARIES 18 | Qt::Qml 19 | ) 20 | 21 | qt_add_protobuf(tst_protobuf_syntax_qml_gen 22 | PROTO_FILES 23 | ../../shared/data/proto/syntax.proto 24 | QML 25 | OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" 26 | ALLOW_MUTABLE_GETTER_CONFLICTS 27 | ) 28 | 29 | qt_add_qml_module(tst_protobuf_syntax_qml 30 | URI QmlTestUri 31 | VERSION 1.0 32 | QML_FILES 33 | qml/tst_syntax.qml 34 | ) 35 | 36 | set_target_properties(tst_protobuf_syntax_qml_gen PROPERTIES 37 | QT_USE_PROTOBUF_LIST_ALIASES FALSE 38 | ) 39 | 40 | qt_autogen_tools_initial_setup(tst_protobuf_syntax_qml) 41 | qt_autogen_tools_initial_setup(tst_protobuf_syntax_qml_gen) 42 | qt_autogen_tools_initial_setup(tst_protobuf_syntax_qml_genplugin) 43 | 44 | if(QT_BUILD_STANDALONE_TESTS) 45 | qt_import_qml_plugins(tst_protobuf_syntax_qml) 46 | endif() 47 | -------------------------------------------------------------------------------- /src/protobuf/qabstractprotobufserializer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 The Qt Company Ltd. 2 | // Copyright (C) 2019 Alexey Edelev 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only 4 | 5 | #ifndef QABSTRACTPROTOBUFSERIALIZER_H 6 | #define QABSTRACTPROTOBUFSERIALIZER_H 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | QT_BEGIN_NAMESPACE 16 | 17 | class QProtobufMessage; 18 | 19 | class Q_PROTOBUF_EXPORT QAbstractProtobufSerializer 20 | { 21 | public: 22 | enum class Error : uint8_t { 23 | None, 24 | InvalidHeader, 25 | UnknownType, 26 | UnexpectedEndOfStream, 27 | InvalidFormat, 28 | }; 29 | 30 | QByteArray serialize(const QProtobufMessage *message) const; 31 | bool deserialize(QProtobufMessage *message, QByteArrayView data) const; 32 | 33 | virtual ~QAbstractProtobufSerializer(); 34 | 35 | virtual Error lastError() const = 0; 36 | virtual QString lastErrorString() const = 0; 37 | 38 | private: 39 | virtual QByteArray serializeMessage(const QProtobufMessage *message) const = 0; 40 | virtual bool deserializeMessage(QProtobufMessage *message, QByteArrayView data) const = 0; 41 | }; 42 | 43 | QT_END_NAMESPACE 44 | #endif // QABSTRACTPROTOBUFSERIALIZER_H 45 | -------------------------------------------------------------------------------- /examples/grpc/chat/proto/chatmessages.proto: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 The Qt Company Ltd. 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause 3 | 4 | //! [proto-2] 5 | syntax = "proto3"; 6 | 7 | package chat; 8 | 9 | import "QtCore/QtCore.proto"; 10 | 11 | message ChatMessage { 12 | string username = 1; 13 | int64 timestamp = 2; 14 | oneof content { 15 | TextMessage text = 3; 16 | FileMessage file = 4; 17 | UserStatus user_status = 5; 18 | } 19 | } 20 | //! [proto-2] 21 | 22 | message TextMessage { 23 | string content = 1; 24 | } 25 | 26 | //! [proto-3] 27 | message FileMessage { 28 | enum Type { 29 | UNKNOWN = 0; 30 | IMAGE = 1; 31 | AUDIO = 2; 32 | VIDEO = 3; 33 | TEXT = 4; 34 | } 35 | Type type = 1; 36 | string name = 2; 37 | bytes content = 3; 38 | uint64 size = 4; 39 | 40 | message Continuation { 41 | uint64 index = 1; 42 | uint64 count = 2; 43 | QtCore.QUuid uuid = 3; 44 | } 45 | optional Continuation continuation = 5; 46 | } 47 | //! [proto-3] 48 | 49 | message UserStatus { 50 | enum Type { 51 | NONE = 0; 52 | LOGIN = 1; 53 | ACTIVE = 2; 54 | INACTIVE = 3; 55 | LOGOUT = 4; 56 | } 57 | Type type = 1; 58 | bool fetched = 2; 59 | } 60 | 61 | message Credentials { 62 | string name = 1; 63 | string password = 2; 64 | } 65 | 66 | message None {} 67 | -------------------------------------------------------------------------------- /LICENSES/BSD-3-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) . 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 7 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /tests/manual/grpc/benchmarks/bench_qtgrpcclient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2024 The Qt Company Ltd. 2 | # SPDX-License-Identifier: BSD-3-Clause 3 | 4 | set(proto_out_dir "${CMAKE_CURRENT_BINARY_DIR}/include/proto/") 5 | set(proto_out_include "${CMAKE_CURRENT_BINARY_DIR}/include/") 6 | 7 | if (NOT TARGET Qt6::Grpc) 8 | message(WARNING "Dependencies of QtGrpc bench_qtgrpcclient not found. Skipping.") 9 | return() 10 | endif() 11 | 12 | qt_internal_add_executable( 13 | bench_qtgrpcclient 14 | SOURCES 15 | bench_qtgrpcclient.cpp 16 | LIBRARIES 17 | Qt::Grpc 18 | Qt::ProtobufWellKnownTypes 19 | INCLUDE_DIRECTORIES 20 | "${proto_out_include}" 21 | "${qrpcbench_common_include}" 22 | OUTPUT_DIRECTORY 23 | "${CMAKE_CURRENT_BINARY_DIR}" 24 | ) 25 | 26 | qt_add_protobuf(bench_qtgrpcclient 27 | PROTO_FILES 28 | "${proto_path}" 29 | OUTPUT_DIRECTORY 30 | "${proto_out_dir}" 31 | PROTO_INCLUDES 32 | $ 33 | ) 34 | 35 | qt_add_grpc(bench_qtgrpcclient CLIENT 36 | PROTO_FILES 37 | "${proto_path}" 38 | OUTPUT_DIRECTORY 39 | "${proto_out_dir}" 40 | PROTO_INCLUDES 41 | $ 42 | ) 43 | 44 | target_compile_definitions(bench_qtgrpcclient PRIVATE QTGRPCCLIENT) 45 | 46 | if(TARGET asyncbenchserver) 47 | add_dependencies(bench_qtgrpcclient asyncbenchserver) 48 | endif() 49 | --------------------------------------------------------------------------------