Commit graph

48 commits

Author SHA1 Message Date
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
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
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
Aleix Pol
5921ab6f2a Drop Qt5-only code branches 2024-04-27 17:46:39 +02:00
Alexander Lohnau
dc8f3e209e Reformat project with clang-format 2023-12-02 14:56:20 +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
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
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
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
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
46dd0c59da Remove unused priority() method 2023-06-22 23:46:44 +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
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
Nicolas Fella
a918ffc0cb Add and make use of ECM's clang-format integration 2022-09-11 23:21:58 +00: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
Nicolas Fella
87db95b22f Convert license headers to SPDX expressions 2020-08-17 09:48:10 +00:00
Nicolas Fella
6025f7cc48 Remove usused includes 2020-01-20 22:35:37 +01:00
Yuri Chornoivan
ba8ee54558 Fix minor typos 2019-12-22 10:15:58 +02:00
Yuri Chornoivan
01c4d0411b Fix minor EBN issues 2019-12-22 09:49:55 +02:00
Matthijs Tijink
0b6224fc0e Bluetooth multiplexer integration and assorted fixes 2019-07-20 12:29:33 +02:00
Matthijs Tijink
cda1280456 Add connection multiplexer 2019-07-20 12:29:33 +02:00
Nicolas Fella
e601755644 Force usage of QStringLiteral and port remaining offenders 2019-06-10 14:40:28 +00:00
Nicolas Fella
67efdc4fef s/Q_DECL_OVERRIDE/override 2019-05-09 01:03:20 +02:00
Nicolas Fella
3b8fedea1a Replace http GNU urls with https 2019-03-23 17:29:26 +01:00
Nicolas Fella
1f23fa27b2 Don't use QString::null 2019-02-03 02:00:36 +01:00
Nicolas Fella
8548ebd032 Clean up includes 2019-02-03 01:44:22 +01:00
Matthijs Tijink
e77c1c87ac Add description of bluetooth multiplexing protocol
Summary:
As mentioned on telegram, there are some fundamental issues with bluetooth. The only approach I could get working was multiplexing: manually sending multiple streams of data over a single connection.

This is the description of that multiplexing protocol. I have an implementation of this protocol, but I'd first like some feedback to see if this is what we're going to use before finishing up those patches.

See the document itself for more details. I make the protocol forward-compatible, although I don't expect we will need ever that.

Test Plan: None, this is just a description.

Reviewers: #kde_connect, andyholmes, albertvaka

Reviewed By: #kde_connect, albertvaka

Subscribers: albertvaka, kdeconnect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D17987
2019-01-19 14:03:37 +01:00
Matthijs Tijink
97551d09ff Add handling for the identity packet to be split across two messages.
Summary: If the identity packet is split across two packets, then save it until we get a notification that more data is available for reading over the bluetooth link.

Test Plan: Connect a phone and laptop over Bluetooth, and verify that both the phone and laptop are able to see each other, and that either side can start and successfully go through the pairing process.

Reviewers: #kde_connect, mtijink

Reviewed By: #kde_connect, mtijink

Subscribers: mtijink, kdeconnect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D17789
2018-12-31 13:25:59 +01:00
Matthijs Tijink
7cab490cc5 Fix receiving payloads using a bluetooth connection
Summary:
This fixes receiving payloads using the bluetooth backend.

This looks like some bug in Qt, but I couldn't figure out what happens exactly (will report a bug though).

Test Plan: Receiving files now works!

Reviewers: #kde_connect, apol

Reviewed By: #kde_connect, apol

Subscribers: kdeconnect, nicolasfella, apol, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D12153
2018-10-04 19:05:34 +02:00
Matthijs Tijink
1b570d4719 Make bluetooth payload upload work & asynchronous
Summary: Sharing files to the Android bluetooth backend now works. The code is asynchronous now too.

Test Plan: I tested several files, and they all get transferred correctly. The socket gets destroyed correctly too.

Reviewers: #kde_connect, apol

Reviewed By: #kde_connect, apol

Subscribers: apol, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D12264
2018-04-24 20:33:55 +02:00
Albert Vaca
f47f517827 Rename NetworkPackage -> NetworkPacket
Summary: KDE Connect, now with correct naming!

Test Plan: It still builds.

Reviewers: #kde_connect, apol, nicolasfella

Reviewed By: #kde_connect, apol, nicolasfella

Subscribers: nicolasfella

Differential Revision: https://phabricator.kde.org/D11036
2018-03-05 20:03:23 +01:00
Jean Vincent
72535ecf48 Make member variable names, & placement and * placement more coherent
Summary:
Change all member variables to the form m_fooBar because it is the preferred form in Qt (it was half and half between this and mFooBar, and a minority didn't have anything).
Place all references and pointers on the side of the type since it is the majority.

Basically:
 - mFoo -> m_foo
 - foo -> m_foo (if it is a member variable)
 - Type &ref -> Type& ref
 - Type *ptr -> Type* ptr

Reviewers: #kde_connect, nicolasfella, albertvaka

Reviewed By: #kde_connect, nicolasfella, albertvaka

Subscribers: albertvaka, #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D7312
2017-09-03 21:45:08 +02:00
Jean Vincent
c864267f04 Replace Q_FOREACH with C++11 range-for
Summary:
The use of Q_FOREACH is advised against (https://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH) since Qt 5.7 and will eventually be removed from Qt.

I replaced all occurrences with the range-for loop introduced in C++11 (except for the one in daemon.cpp in deviceIdByName which might have a bug / typo in it).

I added const to the container or casted it with qAsConst when appropriate to avoid unnecessary copies.

(This is my first submission. I did all the unit tests, and they all passed but I don't know how to show it here.)

Reviewers: #kde_connect, nicolasfella, apol

Reviewed By: #kde_connect, nicolasfella, apol

Subscribers: albertvaka, apol, nicolasfella

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D6724
2017-07-21 09:57:19 +02:00
Àlex Fiestas
abfa8c8183
Port to newer api
This is a blind port, I have not tested it but allows this code to
compile.
2017-05-24 23:54:59 +02:00
Àlex Fiestas
54ef8862eb
(Bluetooth) Remove compatibility with Qt < 5.4.0 2017-05-24 23:54:59 +02:00
Àlex Fiestas
11a01d2f4e
Set unique include guard
Otherwise the code will not compile if both, lan and bluetooth are
enabled.
2017-05-24 23:54:59 +02:00
Albert Vaca
6792b45fae
Adapt to new API in master 2017-05-24 23:54:58 +02:00
Saikrishna Arcot
d711547ab5
Add initial Bluetooth backend implementation.
KDE Connect runs, and the bluetooth service gets published in the SDP
(service discovery protocol), which other devices use to determine what
services are available.

The getPairedDevices() method in the link provider class uses D-Bus to get
the list of paired devices, since Qt doesn't have a method giving that
information. As a result, that part of the code only works on Linux.

REVIEW: 122174
2017-05-24 23:54:58 +02:00