Commit graph

311 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Nicolas Fella
a918ffc0cb Add and make use of ECM's clang-format integration 2022-09-11 23:21:58 +00:00