Commit graph

694 commits

Author SHA1 Message Date
Rob Emery
e2e36e698c
Refactoring 2024-11-03 22:26:09 +01:00
Rob Emery
27f5882dc1
By ref 2024-11-03 22:26:09 +01:00
Rob Emery
b5bf26c919
Refactoring 2024-11-03 22:26:09 +01:00
Rob Emery
fd07c7bea6
Injecting disabled status from the very start 2024-11-03 22:26:08 +01:00
Rob Emery
9800664360
These all need to be near-idempotent 2024-11-03 22:26:08 +01:00
Rob Emery
97841c8634
Rough enable/disable for lanlink 2024-11-03 22:26:08 +01:00
Rob Emery
bc48c5e9f8
Hacking in a very rough enable/disable (untested) implementation 2024-11-03 22:26:08 +01:00
Rob Emery
21b081ad14
Wiring up config and forcing implementation of enable/disable per
provider
2024-11-03 22:26:07 +01:00
Rob Emery
355c2e1ff8
Wiring this up to send through, looks like the array is empty for some
reason that I'm not seeing at a glance at current
2024-11-03 22:26:07 +01:00
Rob Emery
e97461937c
Using string serialisation to workaround the weird build failure if
I make the return type anything more complex
2024-11-03 22:26:07 +01:00
Rob Emery
cc2dc39f92
OK this only works with QString and QStringList for some reason;
so I'll hack some substringing stuff together for now
2024-11-03 22:26:07 +01:00
Rob Emery
5b5fac2d5d
So this doesn't seem to work, if the return type is anything other than
QString or QStringList then it blows up with:
/home/rob/kde/src/kdeconnect-kde/kcm/kcm.cpp: In constructor ‘KdeConnectKcm::KdeConnectKcm(QObject*, const KPluginMetaData&, const QVariantList&)’:
/home/rob/kde/src/kdeconnect-kde/kcm/kcm.cpp:82:17: error: ‘class DaemonDbusInterface’ has no member named ‘linkProviders’
   82 |         daemon->linkProviders(),

even though the signatures are correct etc. No idea, I'll have
to fix this ultimately but I'll workaround it for now
2024-11-03 22:26:07 +01:00
Rob Emery
0bb9c8e294
OK, so this builds; but doesn't return the right type now. Untested if
the UI does what we want
2024-11-03 22:26:06 +01:00
Rob Emery
e1ce928d01
This at least compiles 2024-11-03 22:26:06 +01:00
Rob Emery
0856afe216
New tact, lets create a new endpoint entirely based on "devices" 2024-11-03 22:26:06 +01:00
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
bbcbec7709 Refactor macOS startup code
Moves all the stuff that is needed to start DBus on macOS (which for some reason it needs several steps, involving the use of `launchctl`) into a single `startDBusDaemon()` function. Before, it was spread into `kdeconnectconfig.cpp`, `indicatorhelper_mac.cpp` and `dbushelper.cpp`.

It also removes checking for an existing DBus daemon and always starts our own, since in most cases we couldn't connect to it anyway. This, together with removing the sleep in the retries when polling for the DBus daemon from 3s to 100ms, makes the startup much faster, so I removed the loading splash screen.
2024-09-21 09:27:24 +00:00
Alexander Lohnau
0b4d0757dc NetworkPacket: Optimize serialization/deserialization
We don't need to convert the data to an intermediate QVariantMap just to
make JSON out of it. This siginificantly improves performance.
The measurements were done with 3000000 iterations each:

Before serialization: 0.0045009 msecs
Before deserialization: 0.002293 msecs

After serialization: 0.0034216 msecs (32% faster)
After deserialization: 0.001776 msecs (29% faster)
2024-09-17 08:45:39 +00:00
Albert Vaca Cintora
942aa2a170
Fix warning 2024-09-09 13:29:16 +02:00
Adam Liscak
a4e6e11dd6 certificate handling after 10years
Auto reconfiguration of own certificate:

currently:
if kdeconncectd loads its certificate and its expired or not effective yet
it generates a new certificate

previously:
if kdeconncectd loads its certificate and its expired or not effective yet
it continues having the same certificate
This brings forth an issue: Other devices would refuse to connect to a device with 
an expired or non-effective certificate.


Auto-delete of orphan certificates:

currently:
Devices in kdeconnectd's devicelist that have illegal ssl certificates
(expired, not effective yet, empty) get automatically deleted from the
devicelist


previously:
they would just exist forever until the user deletes them


A year does not have 356 days: 

currently: int a_year_in_seconds = 365 * 24 * 60 * 60;

previously: int a_year_in_seconds = 356 * 24 * 60 * 60;
2024-08-26 17:42:08 +00:00
Albert Vaca Cintora
2295f6968b Remove custom keepalive intervals 2024-08-12 11:02:13 +00:00
Rob Emery
a3f6816954 Re-enabling bluetooth by default now https://bugs.kde.org/show_bug.cgi?id=482192 is fixed
As discussed, re-enabling this for the next release
2024-07-31 21:18:07 +00:00
Rob Emery
bb146a76d0 Bluetooth provider workaround for BlueZ/DBus timeouts
Context: https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/600#note_884500

When bluetooth doesn't exist on the machine at all, QTConnectivity
tries to communicate with Bluez via dbus and introduces a 30 odd second
pause. That's not necessarily a problem in concept, however this blocks
the main thread of KDEConnect, which also then blocks the main thread
of Plasma on logon and causes tremendous delays and very broken
behaviour.

For the life of me, I cannot find a way to do "is bluetooth ok" without
QTConnect kicking off the dbus call so I think the only option is to
thread off the startup of the providers so that pauses don't block
the whole process.

I've just tested this here and my logon with bluetooth missing went
from approx 35 seconds down to about 2.

Ready for input/feedback whenever people have time; in my testing at the moment it seems to completely break the behaviour of KDEConnect (i.e. things can't connect), I'm guessing this is something to do with the effect of wrapping everything in the QThread. I'll dig into that next and see if I can figure it out.

BUG: 481870
2024-07-22 21:29:03 +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
af4ce1c33c Show pairing keys everywhere and always shorten to 8 chars
The previous key was 64 freakin characters long which made it more prone
to being ignored, and thus less secure.
2024-05-18 20:26:48 +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
Nicolas Fella
8c62a108d6 [filetransferjob] Simplify error handling
QNetworkReply::finished is also emitted in the error case, so by also connecting to errorOccured we emitResult twice
2024-04-17 10:15:03 +00:00
Daozhong Ma
8b6a585014 Fix incorrect filename for duplicate copies on notification displays
The filename is just changed after notification is displayed.

BUG: 484727
2024-03-31 01:51:03 +00:00
Simon Redman
7f3287a71b Disable Bluetooth backend due to https://bugs.kde.org/show_bug.cgi?id=482192 2024-03-02 14:46:29 +00: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
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