Commit graph

633 commits

Author SHA1 Message Date
Albert Vaca Cintora
132ae2ca7c Remove unused stuff 2023-08-28 18:48:04 +02:00
Albert Vaca Cintora
5cc2043c35 Update old-style connect/disconnect where possible 2023-08-08 22:51:30 +02:00
Albert Vaca Cintora
f5b4a174e4 Use nullptr instead of NULL 2023-08-08 20:24:22 +02:00
Weixuan Xiao
621ae3e007 Fix potential race condition 2023-08-06 19:48:23 +00:00
Alexander Lohnau
49a51e2d27 Handle qDDebug/qCWarning categories more consistently
We can always provide a function rather than a value.
This is what we do in most places already and is consistent with the
rest of KDE.
This gets compiled to the same code.

```cpp
explicit QLoggingCategoryMacroHolder(const QLoggingCategory &cat)
{
    if (IsOutputEnabled)
        init(cat);
}
explicit QLoggingCategoryMacroHolder(QMessageLogger::CategoryFunction catfunc)
{
    if (IsOutputEnabled)
        init(catfunc());
}
```
2023-08-05 20:22:18 +00:00
Alexander Lohnau
ee2e782748 CompositeUploadJob: Use lambda connect, log errors 2023-08-05 20:22:18 +00:00
Alexander Lohnau
405f61bf85 Discard unused params more elegantly
By commenting out the parameter name, we get compile-time checks
Also, we can omit them for slots and Qt will not forward the parameters.

In case we had TODOs next to the code, I kept the Q_UNUSED statements
for now.
2023-08-05 20:22:18 +00:00
Alexander Lohnau
46feeda0cb Remove unused default destructors
Overriding and defaulting them in the header doesn't make sense

For the dbus interfaces, we don't have any reasources to clean up or memory to be released. Meaning we can drop those lines too
2023-08-05 20:22:18 +00:00
Alexander Lohnau
83888412a9 Simplify and optimize some string usages
- Using QLatin1String when concatinating strings is faster, because they
  are more lightweight. For the resulting string, we need to allocate
  new memory anyway
- Use QLatin1String overloads where they are provided by Qt APIs
- Just use const char* for log messages, the quoting of QStrings is not
  needed
- Make sure to reuse string results when possible
2023-08-05 20:22:18 +00:00
Albert Vaca Cintora
21b245cd71 Avoid starting more than 1 connection to the same device
Since we close old connections when a new connection is received, due to
race conditions we could end up without a valid connection in this case.

Equivalent to https://invent.kde.org/network/kdeconnect-android/-/merge_requests/382
2023-08-04 08:25:45 +00:00
Albert Vaca Cintora
abb6dfcc6e plugins: Add context-aware logging in case of errors
Also clean up some unneeded statements
2023-08-03 20:54:38 +02:00
Alexander Lohnau
1631ada5b3 Simplify KDEConnectPlugin::recievePacket
- We do not need the return type. If a plugin declares it can handle the
  packet it should do so. We don't have any fallback logic in place and
  the packet types are namespaced with the plugin IDs anyway.

- Provide a default implementation with a warning, not all plugins need
  to overwrite this
2023-08-03 20:49:44 +02:00
Alexander Lohnau
6300e9d0c6 Enable Qt6 CI 2023-07-31 06:39:08 +00:00
Alexander Lohnau
6fbecf28da Remove trailing / for KPluginMetaData::findPlugins
This is not needed and pretty much all usages of this method don't do it too
2023-07-31 06:39:08 +00:00
Alexander Lohnau
399d279e83 KDEConnectPluginConfig: Remove unneeded check for delete
Deleting a nullptr is a noop
2023-07-31 06:39:08 +00:00
Alexander Lohnau
b54f0e2467 Modernize plugin loading code
Use the new utility-methods and improve the logging.
2023-07-31 06:39:08 +00:00
Albert Vaca Cintora
b454a6f880 Fix memory leak due to m_receivedIdentityPackets growing
We didn't always remove entries from m_receivedIdentityPackets indexed
by sockets that got deleted.
2023-07-30 07:29:52 +00:00
Alexander Lohnau
2e67f95017 Add explicit moc includes to cpp files
The rationale is explained in https://planet.kde.org/friedrich-kossebau-2023-06-28-include-also-moc-files-of-headers/

In case of KDEConnect, it impressively speeds up compilation. Before it
took 390 seconds on a clean build and with this change it took 330 seconds.
This is due to the mocs_compilation having to include the header files
and thus all their headers. Due to the lots of small plugins we have,
this means that the same headers must be compiled plenty of times.
When we include the moc files directly in the C++ file, they are already
available.
2023-07-30 07:27:45 +00:00
Albert Vaca Cintora
70f6ebf6d5 Check for errors in KdeConnectConfig 2023-07-29 10:36:12 +02:00
Albert Vaca Cintora
675d1c1262 Make it compile and don't use .data() on temporary QByteArray 2023-07-29 10:36:12 +02:00
Edward Kigwana
20e7790773 core: sslhelper: Check return of openssl functions
Use unique_ptr to manage object lifetime and also avoid use of deprecated
MACROS and functions.
2023-07-29 10:36:09 +02:00
Edward Kigwana
1bbd9ff6e3 core: sslhelper: Extern openssl headers and add getSslError helper
openssl headers include C headers prior to #ifdef __cplusplus.

Signed-off-by: Edward Kigwana <ekigwana@gmail.com>
2023-07-29 10:35:37 +02:00
Albert Vaca Cintora
d0786d1b62 Simplify using QSslKey 2023-07-29 10:35:37 +02:00
Albert Vaca Cintora
d948d882aa Replace QCA with a simple OpenSSL wrapper 2023-07-29 08:19:17 +00:00
Albert Vaca Cintora
74e9cdbf12 Do not get deviceId by reference 2023-07-26 21:40:52 +02:00
Alexander Lohnau
a3fc5eaf9f Make optional bluetooth and MDNS build against KF6 too 2023-07-25 18:29:38 +02:00
Alexander Lohnau
e00ffbb4f6 Use versionless cmake variable for KF requirements
Also, adjust find_package calls that are hidden behind a feature flag
2023-07-25 18:29:38 +02:00
Alexander Lohnau
a1195a72a3 Use versionless Qt targets where possible
We depend on 5.15 which allows us to use those
2023-07-25 18:29:38 +02:00
Alexander Lohnau
98040c3ffe GIT_SILENT Re-run clang-format 2023-07-22 20:51:19 +00:00
Alexander Lohnau
f740a8bda8 Use target-centric CMake approach for declaring debug category
This makes it easier to read, because we do not have to handle a list of
files that get added to the targets. In other KDE projects, we also
prefer the target centric approach.

In case one wants to reuse the same category in multiple places, it
would be best to create a small static lib. But for now, this is not
needed.
2023-07-22 20:51:19 +00:00
Albert Vaca Cintora
dd4831f823 Add missing NOTIFY to properties 2023-07-22 20:09:46 +02:00
Alexander Lohnau
ac3d439a2a Clean up unneeded version checks
With the min. version bumped, those can be safely removed
2023-07-22 16:17:24 +02:00
Alexander Lohnau
1ee75463e0 Get rid of QOverload/static_cast for overloaded signals
By exclusing deprecated API in the KF5 build, the deprecated signal no
longer cause an ambiguity
2023-07-22 16:17:24 +02:00
Alexander Lohnau
e97af9dc15 Provide default implementation for KdeConnectPlugin::connected
In most plugins, we just provided a dummy implementation
2023-07-22 16:06:21 +02:00
Albert Vaca Cintora
32abeb8ed0 Fix typo causing us to intersect with the wrong set 2023-07-22 15:21:26 +02:00
Albert Vaca Cintora
6c1b81a384 Use nullptr instead of 0 2023-07-20 18:26:24 +02:00
Albert Vaca Cintora
382ace9c69 Remove check for Qt > 5.14 when minimum is 5.15 2023-07-20 18:23:45 +02:00
Albert Vaca Cintora
8c97e56f23 Remove duplicated target_link_libraries 2023-07-20 18:23:14 +02:00
Alexander Lohnau
e9063d168d LanLinkProvider: Restore previous network change behavior 2023-07-20 13:32:17 +03:00
Alexander Lohnau
1dadbd47b2 lanlinkprovider: Load backend explicitly to avoid nullptr warning
This is needed to make it work properly with Qt6 at runtime
2023-07-20 13:32:16 +03:00
Alexander Lohnau
5b5265f7a8 Port away from deprecated QtNetwork classes 2023-07-20 11:16:04 +03:00
Alexander Lohnau
b3163d8725 dbushelper: Use QRegularExpression instead of QRegExp
The pattern does not contain any wildcard specific text
2023-07-20 11:16:04 +03:00
Alexander Lohnau
042adebd0a Port to updeprecated KJob::processedAmountChanged signal 2023-07-20 11:16:04 +03:00
Alexander Lohnau
77f44ce943 Port away from deprecated QList::toSet and QSet::toList 2023-07-20 11:15:50 +03:00
Alexander Lohnau
52b6d57942 Qt6 build fixes in plugins and KCM 2023-07-20 11:15:46 +03:00
Alexander Lohnau
a9292f651f Port deprecated KPluginLoader usage 2023-07-20 11:15:46 +03:00
Alexander Lohnau
c5bfc4a5b0 Allow building against Qt6/KF6 2023-07-20 11:15:41 +03:00
Albert Vaca Cintora
495e3019e4 Reduce number of optional dependencies
Change some optional dependencies from being optional to being mandatory
or being mandatory but behind on-by-default cmake flags. Eg: instead of
only compiling Wayland support if we find the appropriate libraries, we
always require the libraries unless the user specifies WITH_WAYLAND=OFF.

Optional libraries are hard to discover by packagers (since they don't
see an error once we add them) and create lots of possible build flavors
with a different features that can confuse users.
2023-07-19 17:08:03 +00:00
Albert Vaca Cintora
22be63ae9e Remove compatibility with Qt < 5.15
In theory we support Qt 5.6 (because of SailfishOS) but in practice we are not checking that in the CI so probably we broke the compatibility long ago. Also, I don't think anyone is using this code in SailfishOS, so we can greatly simplify the code by requiring Qt 5.15 or later.
2023-07-18 20:13:27 +00:00
Albert Vaca Cintora
20750b7d99 Fixes from code review 2023-07-17 20:41:15 +00:00