Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
fix(linux): gate zbus behind target_os = linux and remove unused dbus-monitor parser
Jochen Kirstättera07755c96b82
diff --git a/desktop/app/src/main.rs b/desktop/app/src/main.rsindex 5f846d6..0561206 100644--- a/desktop/app/src/main.rs+++ b/desktop/app/src/main.rs@@ -75,7 +75,9 @@ use std::{time::Duration,};-use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QString, QUrl};+#[cfg(not(target_os = "linux"))]+use cxx_qt_lib::QGuiApplication;+use cxx_qt_lib::{QQmlApplicationEngine, QString, QUrl};use nectarlink_core::{MediaAction, MediaError, MirrorInput, MirrorStart, Platform, PowerAction, StorageEntry, StorageError,StorageReadFile, StorageWriteDone,diff --git a/desktop/app/src/pc_notifications.rs b/desktop/app/src/pc_notifications.rsindex c548e67..80c4458 100644--- a/desktop/app/src/pc_notifications.rs+++ b/desktop/app/src/pc_notifications.rs@@ -56,73 +56,6 @@ pub fn is_blocked_self_source(app_name: &str) -> bool {|| lower == "org.freedesktop.notifications"}-/// Parses a single-line or compact representation of a Freedesktop `Notify` D-Bus call-/// into `(app_name, summary, body)`.-///-/// Supports `dbus-monitor` `string "..."` fields from `org.freedesktop.Notifications.Notify`.-#[cfg(any(target_os = "linux", test))]-pub fn parse_dbus_notify_line(line: &str) -> Option<(String, String, String)> {- let trimmed = line.trim();- if trimmed.is_empty() {- return None;- }-- let mut dbus_strings = Vec::new();- let mut rest = trimmed;- while let Some(idx) = rest.find("string \"") {- let after = &rest[idx + "string \"".len()..];- if let Some((val, tail)) = take_unescaped_quoted(after) {- dbus_strings.push(val);- rest = tail;- } else {- break;- }- }-- // In org.freedesktop.Notifications.Notify(app_name, replaces_id, app_icon, summary, body, ...):- // string[0] = app_name, string[1] = app_icon, string[2] = summary, string[3] = body- if dbus_strings.len() >= 4 {- let app_name = dbus_strings[0].trim().to_string();- let summary = dbus_strings[2].trim().to_string();- let body = dbus_strings[3].trim().to_string();- if summary.is_empty() && body.is_empty() {- return None;- }- return Some((app_name, summary, body));- }-- if dbus_strings.len() == 3 {- let app_name = dbus_strings[0].trim().to_string();- let summary = dbus_strings[1].trim().to_string();- let body = dbus_strings[2].trim().to_string();- if summary.is_empty() && body.is_empty() {- return None;- }- return Some((app_name, summary, body));- }-- None-}--#[cfg(any(target_os = "linux", test))]-fn take_unescaped_quoted(s: &str) -> Option<(String, &str)> {- let mut out = String::new();- let mut escaped = false;- for (idx, ch) in s.char_indices() {- if escaped {- out.push(ch);- escaped = false;- } else if ch == '\\' {- escaped = true;- } else if ch == '"' {- return Some((out, &s[idx + 1..]));- } else {- out.push(ch);- }- }- None-}-/// Forwards a captured PC notification if it is not from a blocked self-source,/// has non-empty content, and `forward_pc_notifications_to_phone` is enabled.#[cfg(any(target_os = "linux", test))]@@ -163,7 +96,7 @@ pub fn forward_to_phones(app_name: &str, title: &str, text: &str) -> bool {/// Deserializes a Freedesktop `org.freedesktop.Notifications.Notify` D-Bus method call/// message into `(app_name, summary, body)`, preserving multi-line notification bodies.-#[cfg(any(target_os = "linux", test))]+#[cfg(target_os = "linux")]pub fn extract_notify_call(msg: &zbus::message::Message) -> Option<(String, String, String)> {let header = msg.header();if header.message_type() != zbus::message::Type::MethodCall {@@ -289,22 +222,13 @@ mod tests {assert!(!is_blocked_self_source("Signal Desktop"));}- #[test]- fn parses_dbus_notify_lines() {- let sample = r#"method call time=1700000.0 sender=:1.42 -> destination=org.freedesktop.Notifications serial=10 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify string "Firefox" uint32 0 string "firefox" string "Download complete" string "ubuntu.iso" array [] array [] int32 -1"#;- let parsed = parse_dbus_notify_line(sample);- assert_eq!(- parsed,- Some(("Firefox".to_string(), "Download complete".to_string(), "ubuntu.iso".to_string()))- );- }-#[test]fn forward_pc_toast_ignores_self_and_empty() {assert!(!forward_pc_toast("NectarLink", "Connected", "Pixel 9"));assert!(!forward_pc_toast("Firefox", " ", ""));}+ #[cfg(target_os = "linux")]#[test]fn extract_notify_call_preserves_multiline_body() {let hints: std::collections::HashMap<&str, zbus::zvariant::Value<'_>> =diff --git a/desktop/packaging/linux/build-appimage.sh b/desktop/packaging/linux/build-appimage.shindex 279e687..665f8cf 100755--- a/desktop/packaging/linux/build-appimage.sh+++ b/desktop/packaging/linux/build-appimage.sh@@ -93,6 +93,7 @@ bundle_qt_runtime() {for pattern in \"libQt6Core.so*" \"libQt6Gui.so*" \+ "libQt6Widgets.so*" \"libQt6Qml*.so*" \"libQt6Quick*.so*" \"libQt6Network.so*" \diff --git a/desktop/packaging/linux/build-deb.sh b/desktop/packaging/linux/build-deb.shindex 6a6d33c..f81790b 100755--- a/desktop/packaging/linux/build-deb.sh+++ b/desktop/packaging/linux/build-deb.sh@@ -77,7 +77,7 @@ QT_DEPENDS=""bundle_private_qt_if_needed() {local qmake_bin="${QMAKE:-}"if [[ -z "${qmake_bin}" || ! -x "${qmake_bin}" ]]; then- QT_DEPENDS=", libqt6core6t64 | libqt6core6, libqt6gui6, libqt6qml6, libqt6quick6, libqt6network6, libqt6opengl6, libqt6dbus6, libqt6svg6, qml6-module-qtquick, qml6-module-qtquick-Window, qml6-module-qtquick-controls, qml6-module-qtquick-layouts, qml6-module-qtqml-workerscript"+ QT_DEPENDS=", libqt6core6t64 | libqt6core6, libqt6gui6, libqt6widgets6, libqt6qml6, libqt6quick6, libqt6network6, libqt6opengl6, libqt6dbus6, libqt6svg6, qml6-module-qtquick, qml6-module-qtquick-Window, qml6-module-qtquick-controls, qml6-module-qtquick-layouts, qml6-module-qtqml-workerscript"return 0filocal qt_libs qt_plugins qt_qml@@ -85,7 +85,7 @@ bundle_private_qt_if_needed() {qt_plugins="$("${qmake_bin}" -query QT_INSTALL_PLUGINS 2>/dev/null || true)"qt_qml="$("${qmake_bin}" -query QT_INSTALL_QML 2>/dev/null || true)"if [[ -z "${qt_libs}" || "${qt_libs}" == /usr/* ]]; then- QT_DEPENDS=", libqt6core6t64 | libqt6core6, libqt6gui6, libqt6qml6, libqt6quick6, libqt6network6, libqt6opengl6, libqt6dbus6, libqt6svg6, qml6-module-qtquick, qml6-module-qtquick-window, qml6-module-qtquick-controls, qml6-module-qtquick-layouts, qml6-module-qtqml-workerscript"+ QT_DEPENDS=", libqt6core6t64 | libqt6core6, libqt6gui6, libqt6widgets6, libqt6qml6, libqt6quick6, libqt6network6, libqt6opengl6, libqt6dbus6, libqt6svg6, qml6-module-qtquick, qml6-module-qtquick-window, qml6-module-qtquick-controls, qml6-module-qtquick-layouts, qml6-module-qtqml-workerscript"return 0fi@@ -97,6 +97,7 @@ bundle_private_qt_if_needed() {for pattern in \"libQt6Core.so*" \"libQt6Gui.so*" \+ "libQt6Widgets.so*" \"libQt6Qml*.so*" \"libQt6Quick*.so*" \"libQt6Network.so*" \@@ -164,7 +165,7 @@ Priority: optionalArchitecture: ${DEB_ARCH}Installed-Size: ${INSTALLED_SIZE}Depends: libc6, libgcc-s1, libstdc++6, libgl1, libx11-6, libxcb1, libxkbcommon0, libwayland-client0, libfontconfig1, libfreetype6, libdbus-1-3${QT_DEPENDS}-Recommends: ffmpeg, libopenh264-7 | libopenh264-6, pulseaudio-utils, pipewire, wl-clipboard, xclip, xdg-utils, avahi-daemon, bluez, v4l2loopback-dkms, policykit-1 | pkexec+Recommends: ffmpeg, libopenh264-7 | libopenh264-6, pulseaudio-utils, pipewire, wl-clipboard, xclip, xdotool, xdg-utils, network-manager, avahi-daemon, bluez, v4l2loopback-dkms, policykit-1 | pkexecMaintainer: thtbee <https://github.com/thtbee/nectarlink>Homepage: https://github.com/thtbee/nectarlinkDescription: Connect your Android phone and Linux PC over LAN