summaryrefslogtreecommitdiffstats
path: root/src/plugins/networkinformation/networkmanager
Commit message (Collapse)AuthorAgeFilesLines
* Replace some QString::fromUtf16() with QStringView::toString()Thiago Macieira2024-03-041-2/+2
| | | | | | | | | | | | | | The QStringView counterpart is somewhat faster because it doesn't go through the UTF-16 codec in QUtf16::convertToUnicode(), which tries to detect the BOM. I've included QString::fromWCharArray in this because: a) it's used extensively in Windows code b) wide chars in memory probably don't have BOMs anyway Change-Id: I01ec3c774d9943adb903fffd17b815be4d2ab8ba Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Network: includemocsMårten Nordheim2024-02-231-0/+1
| | | | | Change-Id: I81defa535dcbe81ddcf9be6ff2258cde909861a3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix qWarnings Could not connect "org.freedesktop.NetworkManager" [...]David Faure2024-01-094-37/+51
| | | | | | | | | | | | | | | | | | | | | | Could not connect "org.freedesktop.NetworkManager" to "stateChanged" : Type not registered with QtDBus in parameter list: QNetworkManagerInterface::NMState Could not connect "org.freedesktop.NetworkManager" to "connectivityChanged" : Type not registered with QtDBus in parameter list: QNetworkManagerInterface::NMConnectivityState Could not connect "org.freedesktop.NetworkManager" to "deviceTypeChanged" : Type not registered with QtDBus in parameter list: QNetworkManagerInterface::NMDeviceType Could not connect "org.freedesktop.NetworkManager" to "meteredChanged" : Type not registered with QtDBus in parameter list: QNetworkManagerInterface::NMMetered These came from the fact that QDBus reimplements connectNotify() to detect connections to a dbus interface's signals. It was triggered also when connecting to "normal" signals from the dbus interface subclass QNetworkManagerInterface, leading to those (new) warnings. The fix in this commit replaces signals with direct method calls, given that the two classes are internal and that QNetworkManagerInterface is only used by QNetworkManagerNetworkInformationBackend (and now vice-versa too). Pick-to: 6.7 Change-Id: Ifef3f65ab8e4e21a2f7fdba7fa5f0fc566153649 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Move QNetworkManagerNetworkInformationBackend to its own header fileDavid Faure2024-01-093-31/+60
| | | | | | | | | (in preparation for the next commit) Pick-to: 6.7 Change-Id: I1a6771dc953540dfa63cb80306a48122e97eb600 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
* QNetworkInfo[NetworkManager]: Fix double-lookupMårten Nordheim2023-10-171-6/+6
| | | | | | | Change-Id: Ia44993fa229b223cfa40ed6cf922c4d5cfd3042b Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNetworkInfo[NetworkManager]: Avoid creating temporary QStringsMårten Nordheim2023-10-161-10/+31
| | | | | | | | | | | | | | | Previously we had some inline c-string literals. But since the parameter for those is const-ref QString it has to actually allocate the storage and convert the string to UTF-16. By putting it as a function that returns a QString constructed with u""_s, we instead create a cheap non-owning QString that just refers to the string somewhere in memory. As a drive-by: move other string-literals into functions as well. Change-Id: I2f2ca5b979cfa772665fa83689837f991b0c656d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QNetworkInfo[NetworkManager]: Mark invalid if unconnectedMårten Nordheim2023-10-133-6/+13
| | | | | | | | | | | | | | On some configs (e.g. using Snap) the NetworkManager service is not available without some manifest or similar. In this case, the _interface_ we have is still valid but we can't connect to the service. So we need to mark the interface as invalid in this case, so that we can avoid trying to use this plugin. Pick-to: 6.6 6.5 Fixes: QTBUG-117490 Change-Id: I3c5ebb492f9ca4dfdf4353d77705ba993279eb69 Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNetworkInfo[NetworkManager]: Make ctors explicitMårten Nordheim2023-10-051-2/+2
| | | | | | Change-Id: I65a37bd108bd52b9ab754127e9f6c4929bf3eca1 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QNetworkInfo[NetworkManager]: Clean up some string macro usageMårten Nordheim2023-09-271-13/+13
| | | | | Change-Id: I7ee967b09aeafb8bfbedd509032dd1f45fd4956e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Normalize signal/slot signatures [1/2]: non-QPairMarc Mutz2023-07-121-2/+2
| | | | | | | | | | | | | | | | This is the result of running util/normalize, dropped some false positives: - it removed the space after "d, " in Q_PRIVATE_SLOT(d, foo()) - it removed spaces in moc text streaming of "SLOT(" << ... << ")" In addition, the tool replaces QPair with std::pair. This is surprising and therefore performed in a separate commit. Pick-to: 6.6 Change-Id: If4e3815d7c0840defc1b82bcbf41a8265acda0d8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* plugins: use nullptr instead of 0 and NULLJohannes Kauffmann2022-10-021-1/+1
| | | | | Change-Id: I7f3e56db1d0db178d8a7d9eb91c09e03cae89f6b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | 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-031-0/+3
| | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-05-163-114/+6
| | | | | | | | | | | | | 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>
* QNetworkManagerNetworkInformationPlugin: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 Task-number: QTBUG-102886 Change-Id: I625ac4cd59bee6a0a21d6a09c1fc72f726c3c41f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix potential crash in QNetworkInformation if no network is availableSimeon Kuran2022-04-261-11/+16
| | | | | | | | | | In some circumstances, an empty QDBusInterface was created. However, this can lead to a crash on some systems (observed in Ubuntu 20.04). The crash happens, when no network is available. Pick-to: 6.3 Change-Id: I37316db547f33f082b8aaa73494db1bdf5aded1d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtNetwork: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-211-14/+12
| | | | | | Task-number: QTBUG-98434 Change-Id: Ic235b92377203f7a1429ae7fd784c4a1fa893e9f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace uses of _qs with _s in sources and examplesSona Kurazyan2022-04-191-1/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: I48360ba3b23965cd3d90ac243c100a0656a4cde8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Misc: Do not depend on transitive includesFabian Kosmale2022-03-171-3/+5
| | | | | | | | As a drive-by, remove superfluous includes from qnetworkmanagerservice.h and obey the coding conventions for includes in a few more places. Change-Id: I65b68c0cef7598d06a125e97637040392d4be9ff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNI NetworkManager: Extract Method primaryConnectionDevicePath()Marc Mutz2021-11-042-5/+15
| | | | | | | Avoids duplication of complex code (RB tree lookup). Change-Id: I70ac7095b05ee56cdf7c86dd1d1a7c9c3232c9d4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNI NetworkManager: Small refactorings and correctness fixMårten Nordheim2021-11-043-25/+20
| | | | | | | | | | Extract and reuse a lambda for initialization and slot object. Pass a QDBusObjectPath parameter by const-ref. Avoid implicit ascii-to-utf16 string conversion. Change-Id: I591ae6e58e010ccabcf9012db866949492e0191d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QNI: networkmanager support for the isMetered APIMårten Nordheim2021-11-043-15/+79
| | | | | | | Task-number: QTBUG-91024 Change-Id: I25ac05adbcbfa92a98fe1e9db9ac931e5c340fcd Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNI: Add a convenience method for loading the default pluginMårten Nordheim2021-10-221-3/+7
| | | | | | | | | We have some official plugins, we may as well treat them as default and give a convenient function which loads those. Change-Id: I6251c77ac042b795bcf24b86e510e960ee4bab54 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QNI:NetworkManager: Update dbus interface usageMårten Nordheim2021-10-072-6/+12
| | | | | | | | | | | | | | | | We were using the non-standard interface for PropertiesChanged, and support for this was dropped in a Network Manager update earlier this year[0]. Switch to using the standard interface. [0] https://networkmanager.dev/blog/networkmanager-1-32/ Pick-to: 6.2 Change-Id: Ibdf2b635ae13a3150c4d2faa028c15c70c8af5ca Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* QNetworkInformation: support transportMedium with NetworkManagerMårten Nordheim2021-10-073-6/+135
| | | | | | | Task-number: QTBUG-91023 Change-Id: Ie50e29ec321768ec6d0358d96a8c36b9b7cb10ba Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNetworkInformation: refactor NetworkManager backend a littleMårten Nordheim2021-10-051-12/+10
| | | | | | | | | Using individual booleans to track that the value had changed was not necessary. Change-Id: Ieb4712776339aa78bdc75d7608fd74f96d19bbae Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* TLS plugins: Prefix with 'q'Mårten Nordheim2021-08-301-1/+1
| | | | | | | | For consistency with other plugins. Pick-to: 6.2 Change-Id: I45507389a42e645c94f1ca3f32262a2181f282f7 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* CMake: Rename qt6_add_plugin TYPE option to PLUGIN_TYPEAlexandru Croitor2021-08-061-1/+1
| | | | | | | | | | | | | The intention is to remove TYPE as a keyword completely before 6.2.0 release, but in case if that's not possible due to the large amount of repositories and examples, just print a deprecation warning for now and handle both TYPE and PLUGIN_TYPE. Task-number: QTBUG-95170 Pick-to: 6.2 Change-Id: If0c18345483b9254b0fc21120229fcc2a2fbfbf5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't give plugins PUBLIC usage requirementsJoerg Bornemann2021-07-071-1/+1
| | | | | | | | | | | | | | | | | | | | The pro2cmake.py conversion script faithfully reproduced the .pro files for the plugins, which specified the libraries as public. But in CMake, the implications of this are that public usage requirements should then be propagated to consumers. We don't expect any consumers, since a plugin is created as a MODULE library in CMake, so for Windows we don't even have an import library to link with. The only exception to this is for static builds where plugins are created as STATIC libraries instead, but only in certain controlled situations do we then link to plugins. Even then, usage requirements are not expected to propagate to the consumers, so these relationships should always be specified as private. Pick-to: 6.2 Task-number: QTBUG-90819 Change-Id: Ibc7c2bcd3b6a9dc77df40c4c0c22ff254a80f33d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QNetworkInformation: Rename the plugins and typeMårten Nordheim2021-06-114-0/+470
To better match other plugins in Qt Pick-to: 6.2 Change-Id: I6ab19603f13c80a8afe4fe69f64669559a0eea15 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Yuhang Zhao <2546789017@qq.com>