Commit graph

655 commits

Author SHA1 Message Date
Andreas Sturmlechner
6e99c00d76
Drop obsolete QT_VERSION_CHECK ifdefs from code
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2023-12-28 19:18:02 +01:00
Andreas Sturmlechner
79bc9a85e4 Cleanup all occurences of QT_MAJOR_VERSION in cmake
Follow-up to 7f03aa548c

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2023-12-28 17:49:07 +01:00
Alexander Lohnau
dc8f3e209e Reformat project with clang-format 2023-12-02 14:56:20 +01:00
Alexander Lohnau
a8adedd100 Disable clang-format for mdns header
This is imported and thus doesn't make sense to be formatted
2023-12-02 14:24:08 +01:00
Rob Emery
4dba3394a7 Bluetooth support improvements #1 (!600)
Android counterpart: https://invent.kde.org/network/kdeconnect-android/-/merge_requests/399

Bluetooth support is now enabled by default.
2023-11-20 18:09:13 +00:00
Laurent Montel
b61f32262e GIT_SILENT: Adapt to KConfigGroup name officially being a QString type 2023-11-06 20:05:39 +01:00
Rob Emery
ad75b438cb Implementing link priorities
Now that devices can potentially be connected via both network and bluetooth simultaneously we should prioritise connections over the highest performing link (probably wifi/network). To this end the
m_deviceLinks are now sorted based on priority with the fastest links first; this means that when Device::sendPacket is scheduling to send a packet, it should always use the fastest link first.
2023-10-01 10:39:59 +00:00
Andy Holmes
0640279ae0 Sanitize certificate subject name before comparing to deviceId
The device ID is sanitized to make it safe for D-Bus, so the device ID
stored in the certificate as the subject name also needs to be
sanitized before comparison.
2023-09-06 21:09:02 +00:00
Albert Vaca Cintora
49fa11dfc1 UDP port can be a constant 2023-08-30 13:11:03 +00:00
Alexander Lohnau
88d89e7211 Use std::unique_ptr for pimpl classes
This is consistent with what we do in frameworks
2023-08-28 17:20:46 +00:00
Alexander Lohnau
a1a7e57011 Daemon: Do not return value by const ref
We operate on a QSharedData object and thus can trivially make a copy. We generally don't use use const refs as return values in KDE APIs unless there is a compelling reason to do so
2023-08-28 17:20:46 +00:00
Alexander Lohnau
890299943d KDEConnectPlugin: Remove Q_SLOTS for virtual methods
We call this as a normal method and don't need them exposed
2023-08-28 17:20:46 +00:00
Alexander Lohnau
16adb6a298 PluginLoader: Improve const corretness, remove unneeded qAsConst
Because they are member variables, we do not need qAsConst in a method that is declared as const
2023-08-28 17:20:46 +00:00
Alexander Lohnau
b70de1eb21 kcmplugin: Do not use d-ptr for trivial members that are fully qualified
Also, make this for the most part header only, because it is just a utility class.
We could make this entirely header only, but it is not worth it.
2023-08-28 17:20:46 +00:00
Alexander Lohnau
473589cd32 Networkpacket: Let Qt generate property setters
We don't need to call this explicitly, it is only called by assigning properties
2023-08-28 17:20:46 +00:00
Albert Vaca Cintora
5e270fea2e Error checking 2023-08-28 17:08:18 +00:00
Aleix Pol Gonzalez
1b3e8db72f Fixes from code review 2023-08-28 17:08:18 +00:00
Albert Vaca Cintora
5e225a23cb Add MDNS e2e test 2023-08-28 17:08:18 +00:00
Albert Vaca Cintora
80c34b28ac Enable MDNS by default 2023-08-28 17:08:18 +00:00
Albert Vaca Cintora
bbfbd53123 Implement IP match function 2023-08-28 17:08:18 +00:00
Albert Vaca Cintora
b3ac0df630 Better handling of network changes for MDNS 2023-08-28 17:08:18 +00:00
Albert Vaca Cintora
3485e3aa44 Replace KDNSSD with mdns.h
KDNSSD only works with Avahi (so, only on Linux) while mdns.h is a
header-only library [1] that implements mdns from scratch and should
work on all platforms.

[1] https://github.com/mjansson/mdns
2023-08-28 17:08:18 +00:00
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