Commit graph

644 commits

Author SHA1 Message Date
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
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
Albert Vaca Cintora
a04d9480a4 Add a way to disable UDP broadcasts for testing 2023-07-17 20:41:15 +00:00
Albert Vaca Cintora
34e0128fe9 Add MDNS discovery 2023-07-17 20:41:15 +00:00
Albert Vaca Cintora
f218c5f4e5 Fix windows build 2023-07-16 18:01:13 +02:00
Albert Vaca Cintora
9c87393b28 clang-format pass 2023-07-16 16:20:34 +02:00
Albert Vaca Cintora
af907cea83 Check for null devices in compositeuploadjob 2023-07-16 15:01:04 +02:00
Albert Vaca Cintora
12a1f33665 Fix crash when sending files 2023-07-16 14:44:31 +02:00
Albert Vaca Cintora
05f38b064d Fix Windows build when linking against current KF5
We need to link against WinSock2 because we use WSAIoctl to set keepalive
2023-07-12 23:10:24 +02:00
Albert Vaca Cintora
5796b561bf Simplify the code that reads from the socket line by line
Since sockets are buffered `QIODevices` we can use `canReadLine()` to check
if we have a full line, instead of using a custom `SocketLineReader` class
(and the copy-pasted `DeviceLineReader` in the Bluetooth backend). 

We can also loop through all the lines instead of queuing calls to `dataReceived`.

And we don't need transactions.
2023-07-10 15:58:56 +00:00
Albert Vaca Cintora
9fa07a2361 Call connected only once in the lifetime of a plugin 2023-06-29 09:01:31 +00:00
Albert Vaca Cintora
beb7e94cbb Cleanup 2023-06-27 13:15:11 +02:00
Albert Vaca Cintora
db546e7608 Add DeviceInfo class
Equivalent to this Android MR (see description there): https://invent.kde.org/network/kdeconnect-android/-/merge_requests/374
2023-06-27 11:10:59 +00:00
Albert Vaca Cintora
3018b3bf3d Connect to QUdpSocket's errorOcurred to make errors visible 2023-06-25 21:58:50 +02:00
Albert Vaca Cintora
3c36384078 Fix loopback link pairing timing out when already paired 2023-06-24 17:40:46 +02:00
Albert Vaca Cintora
46dd0c59da Remove unused priority() method 2023-06-22 23:46:44 +02:00
Albert Vaca Cintora
7ca8b7bf95 Fix infinite loop when already paired devices ask to pair 2023-06-16 19:49:50 +02:00
Albert Vaca Cintora
a56ff23770 Let Qt delete this when the parent is destroyed 2023-06-02 16:38:52 +00:00
Albert Vaca Cintora
fbaf5ade71 Remove unused name method 2023-06-02 16:38:52 +00:00
Albert Vaca Cintora
064ddfa3fe Refactor PairingHandler
We now have a single PairingHandler for all types of links.

The implementation now is more aligned with the one for Android.
2023-06-02 16:38:52 +00:00
Albert Vaca Cintora
571575df28 When receiving files, delay de-duplicating filenames
When receiving two files with the same name, the first file might not be
saved to disk already when we have to decide the name for the second if
we do it too early.

BUG: 470078
2023-05-25 22:54:17 +00:00
Ali Abdel-Qader
bbac0aa085 Use explicit constructor for QSslCertificate with value initialized
argument

Previously the BluetoothDeviceLink::certificate() method was returning a
value initialized object which I believe default initializes the object.
However, Clang throws a build error at this because QSslCertificate has
explicit constructors. This change uses one of those constructors and
uses value intialization to default construct/initialize the argument
for it. It fixes the build and hopefully doesn't break anything since
this is a TODO anyways!

BUG: 469428

Signed-off-by: Ali Abdel-Qader <abdelqaderali@protonmail.com>
2023-05-06 15:51:53 -04:00
Albert Vaca Cintora
81d6a12dfa Do not load the BigScreen plugin unless on a TV 2023-04-11 22:05:24 +00:00
Albert Vaca Cintora
6e2f218b55 Follow-up to my previous commit (fixes build) 2023-04-10 10:52:29 +02:00
Albert Vaca Cintora
74caaface0 Further KIO::AccessManager cleanup 2023-04-10 08:29:48 +00:00
Nicolas Fella
2c2e883288 Don't use KIO::AccessManager
The main thing it provides over QNetworkAccessManager is integration
with the CookieJar and using kio-http, but since we jsut exchange bytes
from another local device that's not interesting for us
2023-04-10 08:29:48 +00:00
Albert Vaca Cintora
87a608136f Remove check for a legacy field
Introduced in ee5bf89071
2023-03-23 17:03:58 +00:00
Albert Vaca Cintora
107dfb9e3d Remove specific list of ciphers
We can let the system use the full list when negotiating since we no longer
support Android < 5.0
2023-03-05 14:25:05 +00:00
Albert Vaca Cintora
20ede97ec4 Fix format 2023-03-04 23:44:39 +01:00
ValdikSS ValdikSS
bd796836c5 Enable socket Keep-Alive on Windows
Windows does not use setsockopt for keep-alive configuration,
requiring WSAIoctl call.

https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals

BUG: 442790
BUG: 451597
2023-03-04 13:06:55 +00:00
Aleix Pol
804d17b67c Ensure openconfig.h is only included once
Addresses a warning by the compiler
2023-02-17 07:48:45 +00:00
Willyanto Willyanto
29f56dcc29 Perform initialization in initialization list
Fixes variable is assigned in constructor body. Consider performing
initialization in initialization list. (CWE-398)
2022-12-22 23:24:31 +07:00
Volker Krause
002848efa8 Adapt build system to also support Qt 6
This is complicated by the Qt 5.6 requirement of SailfishOS, hopefully
that didn't get broken by this.
2022-10-29 16:51:41 +02:00
ValdikSS ValdikSS
390a44a901 Really set source IP for broadcast discovery packets on Windows/FreeBSD
This whole code was no-op: it enumerates network interfaces, enumerates
its IP addresses, but does not change the address of broadcast UDP
packet, sending it only via default route/interface.

Bind the socket to IP addresses of the interfaces to fix the issue.

BUG: 459171
2022-10-17 22:21:46 +00:00
Simon Redman
8cfa308140 Fix some Qt and KF5 deprecation warnings
## Summary

Fixes a few warnings about deprecated fields and methods.

## Test Plan

Things still seem to be basically working 🤷
2022-10-17 21:17:49 +00:00
Nicolas Fella
a918ffc0cb Add and make use of ECM's clang-format integration 2022-09-11 23:21:58 +00:00
Kai Uwe Broulik
9c78fa0fff compositeuploadjob: Set total and processed files
This is the proper way to communicate progress.
It has Plasma show the file name in case of single files
and "n of m files" as before for multiple files.
2022-08-09 12:53:10 +02:00
Weixuan Xiao
e468759df4 Send broadcast on each LAN interfaces on FreeBSD
On FreeBSD 12 or later, a new routing strategy is introduced, which
prevents broadcast using 255.255.255.255.
Thus, we need to explicitly send the broadcast to each network 
interfaces.
Here the commit can simply reuse the code for Windows.

Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252596
2022-07-19 10:14:35 +00:00
Weixuan Xiao
fd8b8078de Detect MTU on macOS and FreeBSD to adaptively reduce discovery packet
Detect the MTU on macOS and FreeBSD (which share the network parts of FreeBSD) and adaptively remove the outgoing and incoming capabilities.
The incoming capabilities are usually shorter, fit the size and help initialize the plugin list on the peer. This should fix an empty plugin list when the identity packet is sent by the macOS app.

If the MTU is still too short, both the capabilities need to be removed, which is not likely to happen.
2022-07-11 20:51:18 +00:00
Nicolas Fella
ad01ef1695 Fix activating existing settings window on Wayland
Add the necessary bits for XDG activation to work

Move the code for launching the settings from the daemon to the respective processes so that we don't need to pass activation tokens over another process boundary
2022-07-06 12:55:39 +00:00
Nicolas Fella
f7f3c01ec8 Use undeprecated install dirs
Using kde-dev-scripts/kf5/cmakelists_install_vars.pl
2022-04-21 00:50:14 +02:00
Weixuan Xiao
f1843cb492 Improve D-Bus implementation on macOS
Better patch to replace !218.

- Auto and quick detection of previous D-Bus instance;
- Remove private D-Bus compile definition, only use it on macOS without an existing D-Bus instance;
- Safe reboot after crashes because the indicator is not relating on the kdeconnectd to run a D-Bus session;
- Safe exit after clicking on `Quit` in the systray.


More details in commit logs:

Only enable private D-Bus on macOS because the other platforms do not
need them.
The app should be able to easily detect the session bus from the env
DBUS_LAUNCHD_SESSION_BUS_SOCKET from launchd through launchctl.
Because https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/dbus/dbus-sysdeps-unix.c#L4392
shows that it is the only probing method on macOS with launchd.

The D-Bus session bus can be easily found from launchd/launchctl
with DBUS_LAUNCHD_SESSION_BUS_SOCKET env. It can be an external one
(installed from HomeBrew) or an internal one (launched by a previous
instance followed by a crash).

The indicator helper on macOS can now automatically detect whether we can use a potentially
(with launchd/launchctl env set, or KDE Connect macOS
private_bus_address set) existed and usable session bus.
If previous bus is usable, just try to launch the kdeconnectd with us.
Otherwise, launch a private D-Bus daemon, export the launchd/launchctl
env, and run a kdeconnectd instance.

Everything works better and quicker now :)
2022-04-12 05:40:03 +00:00
Méven Car
4e424b1bd5 Fix build error: invalid user-defined conversion from ‘QByteArray’ to ‘const char*’
NO_CHANGELOG
2021-11-24 10:22:42 +00:00
Laurent Montel
6957b6aa39 GIT_SILENT: add missing override 2021-10-27 06:53:06 +02:00
Vladimir Panteleev
b706750af8
Use device ID from client SSL certificate, not UDP packet
Consider the following scenario:

1. We send a UDP broadcast
2. We receive a reply from 192.168.0.1 with device ID "foo"
3. We connect to 192.168.0.1, and find that the device's certificate
   is actually for a different ID "bar". This could be because the
   packet did not actually originate from 192.168.0.1, or this host is
   malicious / malfunctioning.
4. We remember that device ID "foo" has certificate with common name "bar".
5. When we finally attempt to connect to the real device ID "foo", we
   reject their certificate (common name "foo"). We can now never
   successfully connect to "foo".

On some network (mis-)configurations, this completely prevents
kdeconnectd from connecting to any peers, because a reply which is
seen as originating from the local interface address will cause
kdeconnectd to immediately connect to itself and remember its own
certificate.

Address this by using the certificate display name of the peer, which
will match the real device ID.
2021-09-25 12:51:59 +00:00
Weixuan XIAO
664da445ee Empty capabilities in identity packet for UDP
To avoid incomplete UDP transmission on macOS
2021-07-04 19:13:21 +00:00
Aleix Pol
042fdd368a Fix warnings 2021-03-03 15:20:24 +01:00
Kai Uwe Broulik
8dae6772e0 Fix CompositeFileTransferJob speed calculation
The `QElapsedTimer` was never started. Clean it up somewhat and use a dedicated
250ms timer for reporting transferred bytes periodically (like KIO does it) and
1000ms for calculating speed so it's not as erratic.

Furthermore, report final numbers in `slotResult` rather than complicating
`slotProcessedAmount` for that.

Also, fix typo "send" -> "sent"
2021-01-31 23:50:14 +01:00
Kai Uwe Broulik
daa6f7fc14 Clean up FileTransferJob description
* Set magic `destUrl` property to let it know the job destination in case of
  multiple files being transferred
* Set a normal "Receiving File(s)" title like we do with "Copying" title
* Set device name and destination path as details
2021-01-31 22:22:36 +01:00
Nicolas Fella
9082ed4699 Fix build with bluetooth enabled
We need to implement this pure virtual method.

This is just a placeholder and lacks a proper implementation.
2020-11-30 20:11:47 +01:00
Albert Vaca Cintora
e7518493df Add a verification key that's displayed when pairing
The key is a sha256 of both devices' certificates. Both should generate the
same key, so hey user can check they are pairing against the right device.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-11-26 11:28:49 +01:00
Nicolas Fella
1060c1a81a Add API for opening the KCM to daemon
We have a few places that open the KCM, with different arguments.

Centralize the implementation in one place.

This makes it easier to switch to invoking systemsettings5 in the future (once https://invent.kde.org/plasma/systemsettings/-/merge_requests/11 is in).

It also makes sure the relevant device is selected when clicking on a pairing notification.

The function is exposed to DBus for the Plasmoid and potential third-party users.

CCBUG: 425660
2020-10-18 18:40:48 +00:00
Albert Vaca Cintora
e05769e6de Fix initial set of devices not being emitted in dbus 2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
bd27aec9d2 Do not replace connections for a given deviceId if the certs have changed
Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
ce0f00fc2d Limit the ports we try to connect to to the port range of KDE Connect
So we can't trigger connections to other services.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
613899be24 Do not remember more than a few identity packets at a time
To prevent the kdeconnect process from using too much memory.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
542d94a70c Limit number of connected sockets from unpaired devices
Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
8112729eb0 Don't brute-force reading the socket
The package will arrive eventually, and dataReceived will be emitted.
Otherwise we just end up calling dataReceived to no end.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
024e5f23db Do not let lanlink connections stay open for long without authenticating
If there's no information received, close the socket to try again.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
4fbd01a3d4 Limit identity packets to 8KiB
Healthy identity packages shouldn't be that big and we don't want to
allow systems around us to send us ever humongous packages that will
just leave us without any memory.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Matthias Gerstner
7e47d04053 Fix use after free in LanLinkProvider::connectError()
If QSslSocket::connectToHost() hasn't finished running.

Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
aa84aa5dcb Do not leak the local user in the device name.
Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Albert Vaca Cintora
7b904f47b3 Do not ignore SSL errors, except for self-signed cert errors.
Thanks Matthias Gerstner <mgerstner@suse.de> for reporting this.
2020-10-02 12:52:08 +02:00
Aleix Pol
bf089f3461 Remove unused variable 2020-09-24 18:31:11 +02:00
Aleix Pol
d4cf48901c SocketLineReader: don't call packets bytes 2020-09-16 02:16:06 +02:00
Nicolas Fella
400c800deb [app] Add plugin settings page
Include a page that allows (de)selecting and configuring plugins

This is one of the last missing pieces for feature parity with the KCM.
2020-09-08 20:33:20 +02:00
Richard Liebscher
8d16d05c8a Custom devices 2020-08-18 21:55:24 +02:00
Nicolas Fella
87db95b22f Convert license headers to SPDX expressions 2020-08-17 09:48:10 +00:00
Piyush Aggarwal
771c9dcd22 fix code indentation in lanlinkprovider 2020-08-07 21:22:28 +00:00
Piyush Aggarwal
e3225a1430 fix QSslKey::ca-certificate deprecated warning 2020-08-07 21:22:28 +00:00
Richard Liebscher
f1b3c0e0ca Better device name in Sailfish OS 2020-08-02 19:19:27 +00:00
Richard Liebscher
f3656d962c Save changed device name and type 2020-08-02 18:34:02 +02:00
Nicolas Fella
79164ca8ba Replace manual include dir handling with interface target
We use kdeconnect-version.h in several places and therefore it needs to be in the include path. We currently do this by setting target_include_path in a few places. Replace this with an interface library that we can link against that sets up the correct include path. IMO it is cleaner this way.
2020-07-30 10:53:48 +02:00
Antonio Larrosa
1d36164230 Use ecm_qt_declare_logging_category to declare the logging categories
This automatizes the generation of logging categories so a
kdeconnect-kde.categories is generated and installed to
/usr/share/qlogging-categories5/ so kdebugsettings can use it.

Also, sets the default logging level to Warning. So now the logs
of users won't be filled with debug messages but they can
modify the configuration easily with kdebugsettings.
2020-05-26 18:55:47 +02:00
Nicolas Fella
93e68756bc Port away from deprecated error signal 2020-05-09 17:21:14 +00:00
Nicolas Fella
4254b23d5d trim some whitespace 2020-05-09 16:46:52 +02:00
Nicolas Fella
9277cc537a Implement basic device type detection 2020-04-24 12:24:56 +00:00
Abdel-Rahman Abdel-Rahman
2728f8d864 Close all sockets before suspension 2020-04-16 22:32:57 +00:00
Nicolas Fella
1a9c2dbc4c Fix coding style 2020-04-10 23:43:06 +02:00
Nicolas Fella
28e7e99100 Merge branch 'release/20.04' 2020-03-21 21:21:02 +01:00
Nicolas Fella
eac1e07e29 Revert "Make default name and device type customizable"
This causes a crash described in https://invent.kde.org/kde/kdeconnect-kde/-/merge_requests/206#note_37534

This reverts commit a39a2d562d.
2020-03-21 21:13:41 +01:00
Nicolas Fella
2c8cf96a6c Read payload size as qint64 2020-03-20 19:54:47 +00:00
Richard Liebscher
e066ef9236 Vergotten include in !190 2020-03-10 19:49:41 +00:00
Richard Liebscher
a39a2d562d Make default name and device type customizable 2020-03-01 20:55:40 +00:00
Richard Liebscher
bb5539c8c3 Make plugins work in SailfishConnect 2020-03-01 20:00:40 +00:00
Nicolas Fella
6025f7cc48 Remove usused includes 2020-01-20 22:35:37 +01:00
Richard Liebscher
456d4830fe Made code more explicit and additional tests. 2020-01-04 14:13:36 +01:00
Richard Liebscher
5c0ad3fb85 Remove payload keys when no payload exists 2020-01-03 15:48:48 +01:00
Yuri Chornoivan
ba8ee54558 Fix minor typos 2019-12-22 10:15:58 +02:00