Commit graph

333 commits

Author SHA1 Message Date
Albert Vaca Cintora
89f950ca88
Backport mdns.h updates from upstream 2024-10-10 15:07:24 +02:00
Rob Emery
fd304d9edb Working around cast from 'struct sockaddr *' to 'struct sockaddr_in6 *' increases required alignment from 1 to 4
for BSD
2024-10-10 08:51:57 +01:00
Rob Emery
65cb10ffe2 mdns 0 to nullptr 2024-10-10 08:51:57 +01:00
Rob Emery
251ea971c5 Make bluetooth work if enabled after kdeconnectd is started
Previously, if kdeconnectd was started with bluetooth disabled/unplugged
it would continue to not work until kdeconnectd is restarted.
2024-10-04 04:25:51 +00:00
Rob Emery
8b9235b64e Fixing bluetooth under QT6/OpenSUSE Tumbleweed
It looks like this has never worked under QT6, the implementation was inconsistent with the QT5 behaviour. Given that the QT5 behaviour works with the shipped Android app, I've tweaked the QT6 to be functionally equivalent to the QT5 implementations.

https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/600#note_1018493

@diamnew if you are able to build and test this; that would be a great help.
2024-09-23 21:07:52 +00:00
Albert Vaca Cintora
942aa2a170
Fix warning 2024-09-09 13:29:16 +02:00
Albert Vaca Cintora
2295f6968b Remove custom keepalive intervals 2024-08-12 11:02:13 +00:00
Simon Redman
a6fd9f9e9e Correct reference to NetworkPacket in isValidIdentityPacket calls
## Summary

Fix Bluetooth branch build errors for changes in !678

## Test Plan

### Before:
Build errors in bluetoothlinkprovider.cpp due to undefined variable and due to incorrect argument type.

```
/home/simon/src/kdeconnect-kde/core/backends/bluetooth/bluetoothlinkprovider.cpp:301:56: error: cann
ot convert ‘NetworkPacket’ to ‘NetworkPacket*’
  301 |     if (!success || !DeviceInfo::isValidIdentityPacket(receivedPacket)) {
      |                                                        ^~~~~~~~~~~~~~
      |                                                        |
      |                                                        NetworkPacket
<snip>
```

### After:
Clean build.
2024-06-10 20:59:03 +00:00
Albert Vaca Cintora
17c97a4768 Add a parent to KCompositeJob
So they are stopped if the device is destroyed
2024-06-04 14:15:23 +00:00
Albert Vaca Cintora
b672d80249
Validate and filter device names 2024-05-19 16:24:54 +02:00
Albert Vaca Cintora
983788e5c9
Dedupe Q_EMIT 2024-05-19 16:15:56 +02:00
Albert Vaca Cintora
9a39eaa237 Use EC keys instead of RSA
Use smaller and safer EC keys, replacing 2048 bit RSA.

NID_X9_62_prime256v1 is roughly as secure as a 3072 bit RSA key, but way shorter. 
Since we have to embed the key in the identity packet that is sent over UDP and
some stacks aren't happy with large UDP messages (notably: macos), I switched to
EC instead of to a longer RSA key.

This seems to be compatible with other clients even on older systems like Android 5.0.

I did stick with NID_X9_62_prime256v1 because stronger EC like NID_secp384r1 failed
the handshake (I didn't investigate why).

We now store the kind of key in the config, so we can know which kind of key we are loading.
2024-05-19 10:04:43 +00:00
Albert Vaca Cintora
59fd3d7dd4
Update commented code 2024-05-12 19:54:21 +02:00
Aleix Pol
a0d93fa537 Make sure we are not using deprecated APIs
Bumps the deprecation values in line with the APIs we depend on.
2024-04-27 17:47:29 +02:00
Aleix Pol
5921ab6f2a Drop Qt5-only code branches 2024-04-27 17:46:39 +02:00
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
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
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
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
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
5cc2043c35 Update old-style connect/disconnect where possible 2023-08-08 22:51:30 +02: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
Alexander Lohnau
6300e9d0c6 Enable Qt6 CI 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
Alexander Lohnau
a3fc5eaf9f Make optional bluetooth and MDNS build against KF6 too 2023-07-25 18:29:38 +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
Albert Vaca Cintora
6c1b81a384 Use nullptr instead of 0 2023-07-20 18:26:24 +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
042adebd0a Port to updeprecated KJob::processedAmountChanged signal 2023-07-20 11:16:04 +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
Albert Vaca Cintora
bb8e67efc9 Add CMake flag to enable MDNS (off by default) 2023-07-17 20:41:15 +00:00
Albert Vaca Cintora
17dcf80f2d Send UDP identity packets without capabilities only if needed
Instead of always doing so on MacOS, do it only when we get a
DatagramTooLargeError. On MacOS, the size is limited only for
broadcast but not for unicast.
2023-07-17 20:41:15 +00:00