Commit graph

65 commits

Author SHA1 Message Date
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
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
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
70f6ebf6d5 Check for errors in KdeConnectConfig 2023-07-29 10:36:12 +02:00
Albert Vaca Cintora
d0786d1b62 Simplify using QSslKey 2023-07-29 10:35:37 +02:00
Albert Vaca Cintora
d948d882aa Replace QCA with a simple OpenSSL wrapper 2023-07-29 08:19:17 +00:00
Alexander Lohnau
77f44ce943 Port away from deprecated QList::toSet and QSet::toList 2023-07-20 11:15:50 +03: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
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
Nicolas Fella
a918ffc0cb Add and make use of ECM's clang-format integration 2022-09-11 23:21:58 +00: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
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
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
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
9277cc537a Implement basic device type detection 2020-04-24 12:24:56 +00: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
Richard Liebscher
a39a2d562d Make default name and device type customizable 2020-03-01 20:55:40 +00:00
Nicolas Fella
39fe270cd1 Port Kdeconnectconfig to reference based singleton
It's more expressive in the sense that it makes clear that the user should not delete the object
2019-09-08 17:09:52 +02:00
Nicolas Fella
0d7c504cf0 Rename DbusHelper => DBusHelper 2019-08-14 17:36:19 +02:00
Piyush Aggarwal
ccc8bb8a0e Split config issue fix for Win32 build 2019-08-01 14:01:50 +00:00
Weixuan Xiao
4f4b6c309f Allow to use private DBus 2019-06-18 01:21:31 +00:00
Nicolas Fella
e601755644 Force usage of QStringLiteral and port remaining offenders 2019-06-10 14:40:28 +00:00
Nicolas Fella
2b7026fc10 Fix daemon's error handling 2019-05-13 22:35:25 +00:00
Albert Vaca Cintora
5ddaadd471 More logging and remove redundant check as per CR 2019-05-09 00:03:59 +02:00
Albert Vaca
3fc7df550b Better error handling when loading cert and key
BUG: 405207
2019-05-09 00:03:59 +02:00
Nicolas Fella
3b8fedea1a Replace http GNU urls with https 2019-03-23 17:29:26 +01:00
Nicolas Fella
23703423fb Coding style 2018-12-25 01:52:16 +01:00
Nicolas Fella
a45921685b Extract code to methods 2018-12-25 01:42:42 +01:00
Nicolas Fella
8f16c3fd9a Remove unneeded methods
Remove unneeded declaration
2018-12-25 00:58:03 +01:00
Albert Vaca
b9932769c9 Fix env variable on Windows 2018-11-20 21:49:46 +01:00
Yuri Chornoivan
5fe74ce041 Fix minor EBN issues and typos 2018-10-07 21:23:20 +03: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
Albert Vaca
83c250e9f1 Trust the name stored in the certificate
Having a separate copy of it in the config leads to them not being in sync

BUG: 381542
2017-07-14 00:19:26 +02:00
Albert Vaca
b7bb8d94c5 Fixed QStrings not being passed by ref 2016-11-26 16:36:34 +01:00
Albert Vaca
60331ccbf1 Clazy says all this QStringLiteral and QLatin1String were missing/wrong 2016-11-26 16:21:29 +01:00
Albert Vaca
7638683c85 Print a qCritical in addition to showing a notification 2016-11-24 15:11:30 +01:00
Albert Vaca
f61dde5bbb Use different files instead of different groups 2016-09-19 13:35:03 +02:00
Albert Vaca
54801aac3b Use a new config group so we don't conflict with older versions' config 2016-08-25 18:06:01 +02:00
Aleix Pol
86b086e392 Make warnings actual warnings 2016-06-22 16:31:01 +02:00
Aleix Pol
bfd698af36 Fix issues detected by clazy
Don't use for(:) on Qt containers. It detaches without need.
2016-06-20 19:22:29 +02:00
Albert Vaca
78d4ba2106 Cleanup 2016-03-08 07:29:34 -08:00
Albert Vaca
b1ef3f9fc9 Use a different key for settings, so we don't clash with older versions. 2016-03-02 15:36:45 -08:00
Albert Vaca
16f9af908a WIP 2015-11-30 10:36:01 -08:00
Albert Vaca
30d2dd991b Merge branch 'master' into sslmaster 2015-11-30 03:40:07 -08:00
Aleix Pol
4730022810 Pass arguments as const-reference 2015-09-12 09:45:59 +02:00
Vineet Garg
78e9c08732 Merge branch 'master' into ssl
Conflicts:
	core/backends/lan/socketlinereader.h
	core/backends/lan/uploadjob.h
	core/networkpackage.h
2015-08-25 03:43:41 +05:30
Boris Egorov
1924173df2 Fix various krazy2 warnings
Fix following krazy2 warning types:
[explicit], [endswithnewline], [doublequote_chars], [includes], [normalize],
[postfixop], [spelling]

See http://ebn.kde.org/krazy/reports/playground/base/kdeconnect-kde/index.html
for details.

SLOT/SIGNAL normalization done with Qt normalize utility:
https://github.com/qtproject/qtrepotools/tree/master/util/normalize

REVIEW: 124857
2015-08-21 22:38:54 +06:00