From b5a716501588b35b42bb3fafad730aed97fa28ae Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:02:19 +0800 Subject: [PATCH] feat: android, controlled side, clipboard text (#8677) Signed-off-by: fufesou --- src/server/connection.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/server/connection.rs b/src/server/connection.rs index cc43650e0..fd3dd2a03 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -2049,11 +2049,27 @@ impl Connection { } self.update_auto_disconnect_timer(); } - Some(message::Union::Clipboard(_cb)) => - { - #[cfg(not(any(target_os = "android", target_os = "ios")))] + Some(message::Union::Clipboard(cb)) => { if self.clipboard { - update_clipboard(_cb, None); + #[cfg(not(any(target_os = "android", target_os = "ios")))] + update_clipboard(cb, None); + #[cfg(all(feature = "flutter", target_os = "android"))] + { + let content = if cb.compress { + hbb_common::compress::decompress(&cb.content) + } else { + cb.content.into() + }; + if let Ok(content) = String::from_utf8(content) { + let data = HashMap::from([ + ("name", "clipboard"), + ("content", &content), + ]); + if let Ok(data) = serde_json::to_string(&data) { + let _ = crate::flutter::push_global_event(crate::flutter::APP_TYPE_MAIN, data); + } + } + } } } Some(message::Union::Cliprdr(_clip)) =>