summaryrefslogtreecommitdiff
path: root/examples/network
Commit message (Collapse)AuthorAgeFilesLines
* Torrent example: update usage of integer typesMårten Nordheim2023-04-116-63/+64
| | | | | | | | | | | | Some of the 'int's are purposefully 32-bit because that's what the protocol is, but others aren't. So, be more explicit. Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: I338abca1f13b0c95f49a6f52933712f43f147590 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Doc: Use the \examplecategory macro to tag examplesTopi Reinio2023-04-117-7/+7
| | | | | | | | | | | | | | | | The '\meta category' command was used for tagging examples with a specific category, used in Qt Creators Welcome mode. As we want to also generate lists of examples belonging to a category elsewhere in the documentation, replace the command with a macro that expands to the original \meta command and also adds the example to a group using the \ingroup command. This way, the category names can be used as arguments to the \generatelist or \annotatedlist commands. Pick-to: 6.5 Task-number: QTBUG-112731 Change-Id: I46762dabc5f718fecc09a3533235eaa911dda5a0 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Remove loopback network exampleMårten Nordheim2023-03-239-283/+0
| | | | | | | | | | It doesn't showcase anything interesting that other examples don't already show off. Pick-to: 6.5 Change-Id: Ie95c3ddb3ff52b3beab54bd6fa75fb75ae5c7ba5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
* Clean up multicast examplesMårten Nordheim2023-03-237-6/+10
| | | | | | | | | They're small, not much to polish. Pick-to: 6.5 Change-Id: Iada573504de557ab18381370bb9760b1f60cc2e4 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* HTTP example: update screenshotMårten Nordheim2023-03-023-1/+1
| | | | | | | | Fixes: QTBUG-108874 Pick-to: 6.5 Change-Id: Ib87895c6512abb967734ce4c1ed0be76c698feb4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* DNS Lookup: Use ideomatic cstdio includeMårten Nordheim2023-03-021-19/+21
| | | | | | | | | Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: I646f0c985adc45a17103b5f98394f3def4b6ada2 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* DNS Lookup: Change local function to return struct instead of enumMårten Nordheim2023-03-021-36/+38
| | | | | | | | | | This let's us get rid of an out-parameter. Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: Ifc08d3905932f28ecdfdf3a7de1499700cc7e606 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* DNS Lookup: Use standard functions to print version/helpMårten Nordheim2023-03-021-4/+3
| | | | | | | | | | showHelp was already in use, but not showVersion. Return 0 in both cases, even if it's unreachable. Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: Iba820e89d7de066130163e7829f75bbfcfa3f7dd Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* DNS Lookup: reflow some code to avoid exceeding column limitMårten Nordheim2023-03-021-15/+31
| | | | | | | Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: Ic17ded256152f7d89bd200ea0e163f2b8f1ea70a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* DNS Lookup: Use std::optional instead of casting enum to intMårten Nordheim2023-03-021-5/+5
| | | | | | | Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: I0bd5dc004154c1c4026be2feb6187c53e5e77801 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* DNS Lookup: Avoid unneeded allocations in parsing functionMårten Nordheim2023-03-021-11/+11
| | | | | | | | | | | By using .compare(~~~, Qt::CaseInsensitive) instead of .toLower() Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: I60e1fdc0a54450e7385e90f84fd509e62b82d2c9 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Delete the Network Download (Manager)? examplesMårten Nordheim2023-03-0214-622/+0
| | | | | | | | | | | | | | | | | | | | Their use of QtNetwork is already covered by the HTTP example. While showcasing that QNAM easily deals with multiple simultaneous requests, waiting until finished() is emitted to write anything is not exactly idiomatic. And managing your own queue to only have one request running at a time is a weird example for an asynchronous framework. In this regard, having an example for a complete download manager (with a GUI) would be interesting, but may ultimately be very time-consuming to make for limited gain. Task-number: QTBUG-110643 Pick-to: 6.5 Change-Id: I6b2c1546b85fa89ab7ce1ff5565b0293b5710b74 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
* Doc: fix links to renamed network examplesVolker Hilsheimer2023-03-014-7/+6
| | | | | | Pick-to: 6.5 Change-Id: I8790bb660070a092e268294b5640c6d5af41deb0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fortune* Example: update screenshotsMårten Nordheim2023-02-284-0/+0
| | | | | | | Fixes: QTBUG-108875 Pick-to: 6.5 Change-Id: Ib57482959973815681b0b178acea3634a4f63220 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Torrent example: Fix use-after-free crashMårten Nordheim2023-02-211-0/+4
| | | | | | | | | | | | The crash would sometimes happen shortly after removing a torrent since the RateController would still try to use it even though it had been deallocated. Pick-to: 6.5 Task-number: QTBUG-110622 Change-Id: Icad1531ea58560a3a3157a3ed8c0e6b283573196 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
* Torrent example: Fix some stack overflow issuesMårten Nordheim2023-02-211-2/+2
| | | | | | | | | | | | | | Because of the .size() used as part of the expression it ends up copying sizeof(qsizetype) bytes to the array, instead of the (rationally) expected 4 bytes. Amends 69c31f6f68a1399c1fc1e545e318eaa40966fe85 Pick-to: 6.5 Task-number: QTBUG-110622 Change-Id: I732e3f4bb5934ff3860087baa91f9bebbf044a7f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
* Torrent: simplify QBitArray usageMårten Nordheim2023-02-211-7/+1
| | | | | | | | | | There is specific API for counting number of 0-bits Pick-to: 6.5 Task-number: QTBUG-110622 Change-Id: Ifa33862ff7b98a59f362bc52c492e8a037799835 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* examples: Connect Quit action to QCoreApplication::quit, not QWidget::closeTor Arne Vestbø2023-02-204-4/+5
| | | | | | Pick-to: 6.5 Change-Id: I44ca7b61a4a261a7d3aad0dfeb870eb927ee768d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Torrent example: delete unimplemented functionsMårten Nordheim2023-02-141-3/+0
| | | | | | | | | | That's not fit for an example... Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: Ib196d61867f95f3ff2e45841509d49df9360ad25 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Torrent example: Convert some timeouts from int to chronoMårten Nordheim2023-02-144-9/+11
| | | | | | | | | | | | Using seconds because then they all have the same type, even if all-but-one could use minutes. Delete one unused interval value. Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: I66b456de8a4b867859e9e2b13ce72e8ec691c79a Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Torrent example: Remove manual little-big endian conversionMårten Nordheim2023-02-141-43/+24
| | | | | | | | | | | | ... and use QtEndian instead. The conversion would be done even on a big-endian system, so the example would not work correctly on such machines. Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: I6a660ff68fa5a8d9b4c1faf9e264d937c605c47e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Delete googlesuggestMårten Nordheim2023-02-1411-500/+0
| | | | | | | | | | | As a networking example it doesn't contribute much. But it has some interesting uses of widget/events Pick-to: 6.5 Change-Id: I194d32e6a304ae41819c20751e9f1ee1d9b5abdb Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* HTTP example: Reflow QMessageBox usage in if-statementMårten Nordheim2023-02-021-3/+4
| | | | | | | | | | It gets hard to read like that. And update mentions of 'SSL' to 'TLS' in the message while we're there. Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: Ia7b27bfb3d99391b14ed396ca9a6400621022bf6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Examples: Fix CMake Unity (Jumbo) buildsFriedemann Kleint2023-02-011-2/+2
| | | | | | | | | | Disambiguate variables and add some exclusions. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Ie72b3caab9fd571c3fb6f7d8606584885bc09e66 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* Torrent example: Use QByteArray toPercentEncodingMårten Nordheim2023-01-301-6/+2
| | | | | | | | | | | | | | | | The hand-rolled loop produced incorrect output and was subsequently rejected by trackers. The torrent example doesn't support modern features though, so it's still a bit hit-or-miss whether a torrent will work. E.g. downloading an Arch iso does not work since it relies on DHT, PeX and HTTP seeds. Fixes: QTBUG-109798 Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: Ica40fb9205f09d135407a160a28a45d06a418176 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Torrent example: don't try to announce to an empty URLMårten Nordheim2023-01-301-0/+2
| | | | | | | | Task-number: QTBUG-109798 Task-number: QTBUG-110622 Pick-to: 6.5 Change-Id: I3603232eb094387388da6421bf5525a3ba54fe03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* HTTP Example: Add proxy handlingMårten Nordheim2023-01-242-0/+32
| | | | | | | | | | | If a proxy is configured on the system then we will request credentials if needed. Task-number: QTBUG-108874 Fixes: QTBUG-106245 Pick-to: 6.5 Change-Id: Icbea491492cde4634421b1a1e722a3768d56dec8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* HTTP example: remove needlessly unset-ing window flagMårten Nordheim2023-01-241-2/+0
| | | | | | | | | | In Qt 6 it is unset by default. Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: I35af9d7c1517fd393710b7b1b978d3f39c61acf0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* HTTP example: Fix missing translation and improve othersMårten Nordheim2023-01-241-13/+12
| | | | | | | | | As a drive-by: print the path with native separators Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: I73164acb159d1a45960e16d5f57996e8c27257f7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* HTTP example: rename to HTTP ClientMårten Nordheim2023-01-242-2/+4
| | | | | | | | | | | It can do more than HTTP but let's keep the naming simple. Most people likely aren't looking to do file: or data: or qrc: in this example. Task-number: QTBUG-108874 Pick-to: 6.5 Change-Id: I8a822640f4a8015ebf6c56cb6a614d6426e8a912 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fortune* Example: Rename and add category/tagsMårten Nordheim2023-01-244-4/+12
| | | | | | | Task-number: QTBUG-108875 Pick-to: 6.5 Change-Id: I8eeff88187be4f85514d9871eb5009c51ad6de64 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Fortune* Example: remove needless unset-ing of window flagMårten Nordheim2023-01-172-2/+0
| | | | | | | | | It's unset by default in Qt6. Task-number: QTBUG-108875 Pick-to: 6.5 Change-Id: I3f1c6e4e6de54e9ca0ed8892f9da1d346d16d4c7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fortune* Example: Bump QDataStream format versionMårten Nordheim2023-01-174-4/+4
| | | | | | | | | | | | | | One of the examples were using a different version than the others. Though QString's formatting probably didn't change since then so it was no problem. Anyway, pretend like we're releasing it now for the first time and set 6.5 on all of them Task-number: QTBUG-108875 Pick-to: 6.5 Change-Id: I28b496ab3d8ff54c503a032ba15882cdf3d5eccf Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fortune* Example: convert simple for-loop to ranged-forMårten Nordheim2023-01-174-22/+20
| | | | | | | | | Ends up shortening the loop, making it easier to read at a glance. Pick-to: 6.5 Task-number: QTBUG-108875 Change-Id: Ia12a994259b00e9b57f2de48124be9cb38553bf5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Threaded Fortune Example: update example to use qintptr for descriptorsMårten Nordheim2023-01-172-3/+3
| | | | | | | | Pick-to: 6.5 Task-number: QTBUG-108875 Change-Id: Ie635a3d2c4c61a59547e8fed0ec84da8538968a3 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Examples: Do not wrap custom types in Qt namespaceKai Köhne2023-01-0210-41/+1
| | | | | | | | | | The Qt namespace should be used for types defined in the Qt library, not for user types. Pick-to: 6.5 Change-Id: I6df0ca054888f4a65b19a9cb44324321d1dcfad8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* examples: port network examples to new connection styleSamuel Gaist2022-12-216-6/+6
| | | | | | Task-number: QTBUG-106893 Change-Id: Id0f558362108fedececb9eede36becc04ff4e307 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove showMaximized() workaround for Android in examplesTor Arne Vestbø2022-12-021-4/+0
| | | | | | | Android implements QPlatformIntegration::ShowIsMaximized nowadays. Change-Id: I451a9a8edc8ec407946d44f3e6921c78ac1d11aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Examples: Use PRIVATE CMake linkageKai Köhne2022-11-3021-21/+21
| | | | | | | We (almost) only build apps, for which PRIVATE linkage makes more sense. Change-Id: I09a509c3fb33a00cdfdede687b3f95d638f42091 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Doc: Fix typo and mismatch between code and descriptionAndreas Eliasson2022-11-302-2/+2
| | | | | | | Fixes: QTBUG-107675 Pick-to: 6.4 6.2 Change-Id: I38140617a2b0525db417137aa41a52a389b3bea3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Examples: Use qt_standard_project_setup()Kai Köhne2022-11-1721-48/+42
| | | | | Change-Id: I0ceab08108b7e58e4e2ed25db9e3c289f5c0ddac Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Examples: Use Qt6:: to qualify Qt CMake packagesKai Köhne2022-11-1722-84/+84
| | | | | | | This is what we promote also in the documentation. Change-Id: If91aebafe861b0c934acbb2c69afd182abc3345d Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-118-26/+26
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Replace qExchange with std::exchangeMarc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | None of these users require C++20 constexpr or C++23 noexcept, the only remaining difference between std::exchange and qExchange. This leaves a single qExchange() user, in QScopedValueRollback, that requires the constexpr version, only available from C++20, and thus remains unported. Task-number: QTBUG-99313 Change-Id: Iea46f6ed61d6bd8a5b2fd9d9ec4d70c980b443a2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2322-22/+22
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0322-0/+66
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-16141-6497/+284
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* secure UDP server: do not use deprecated protocol (DTLS 1.0)Timur Pocheptsov2022-03-101-6/+0
| | | | | | | | | | | | And also remove check for DtlsV1_2OrGreater for negotiated session protocol, since it must have been resolved to a specific protocol by this point. Fixes: QTBUG-100154 Pick-to: 6.3 6.2 Change-Id: I3aec31faed8b9cb22be0062da057c62864eba34f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Examples: Remove unneeded CMake optionsKai Köhne2022-01-2421-78/+0
| | | | | | | | | | | | | | | CMAKE_INCLUDE_CURRENT_DIR is not necessary anymore for moc since CMake 3.8: https://cmake.org/cmake/help/latest/release/3.8.html#other-changes CMAKE_AUTORCC should not be used anymore. Instead, we now use qt_add_resources() or similar Enable CMAKE_AUTOUIC only if .ui files are present. Pick-to: 6.3 Task-number: QTBUG-87643 Change-Id: I835e2994cd5dba9918136999499b9077961b616c Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>