How kde/kdeconnect-kde works
Main system type and purpose
• Type: A modular desktop application built on top of a “core” C++ library exposing DBus interfaces, with multiple UI front‑ends and plugins.
• Purpose: Allow devices (e.g. phone↔computer) to communicate over TLS, sharing clipboard, notifications, files, multimedia controls, SMS, etc.
Break down the top‑level components
• Core Library (“core/”):
– LinkProviders (bluetooth, lan, loopback)
– Device abstraction & NetworkPacket handling
– Plugin loader & SSL helper
– Exposes DBus interfaces (core/dbushelper.cpp)
• Daemon (“daemon/”):
– desktop_daemon (kdeconnectd) that runs headless, registers with system DBus
• UI & Integration Layers:
– app/ (QtQuick QML desktop UI)
– cli/ (kdeconnect‑cli tool)
– settings/ (Settings QML + desktop KCM)
– indicator/ (system tray indicator for Plasma, Windows, macOS)
– kcmplugin/ (KDE System Settings module)
– nautilus‑extension/, kio/ (File‑manager integration)
– plasmoid/ (Plasma widget)
– smsapp/ (standalone SMS QML app)
– urlhandler/ (URL share handler)
– declarativeplugin/ (common QML/DBus glue for various front‑ends)
• Plugins (“plugins/*”):
– Individual feature plugins (battery, clipboard, ping, sftp, …)
– Defined by JSON metadata + C++/QML code
– Loaded at runtime by core PluginLoader
• Tests (“tests/”):
– Unit and integration tests against core and plugins
Relationships and data flows
• DBus Bus (system and session) sits in the middle:
– UI front‑ends ⟷ Core Library (DBus method calls & signals)
• Core Library ⟷ PluginLoader (dynamic load at startup)
• Core Library ⟷ LinkProviders: discovers & maintains Device links
• Core Library ⟷ Remote Device (over TLS via LinkProvider) using NetworkPackets
• Plugins register handlers with Core Library; they exchange JSON packets + optional binary payload over the Device link
• Daemon registers core on system DBus so multiple front‑ends can connect
Architectural patterns & principles
• Modular plugin architecture: plugins loaded dynamically, communicate only through well‑defined Packet types
• Microkernel‑style core: UI‑agnostic, exposes services (device discovery, packet routing) via DBus
• Separation of concerns:
– LinkProviders handle connectivity
– Core handles device and packet management
– Plugins implement features
– UIs consume DBus APIs
• Cross‑platform abstraction: OS‑specific code isolated in small helper classes (indicatorhelper_mac.cpp, win, Linux X11/Wayland, QML, etc.)
Technologies & frameworks
• CMake & Craft build system (CMakeLists.txt, KDEConnectMacros.cmake)
• Qt (QtCore, QtDBus, QtNetwork, QtQuick/QML)
• DBus (org.kde.kdeconnect service interfaces in interfaces/ and declarativeplugin/)
• JSON for NetworkPackets, plugin metadata
• TLS via OpenSSL (sslhelper.cpp)
• mDNS (for LAN discovery)
• Bluetooth stack (for Bluetooth discovery/link)