refact text clipboard

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-02-16 20:01:06 +08:00
parent 95ffac5bb9
commit 10305ab548
5 changed files with 207 additions and 82 deletions

View File

@@ -464,6 +464,9 @@ pub fn session_add(
let session: Session<FlutterHandler> = Session {
id: session_id.clone(),
server_keyboard_enabled: Arc::new(RwLock::new(true)),
server_file_transfer_enabled: Arc::new(RwLock::new(true)),
server_clipboard_enabled: Arc::new(RwLock::new(true)),
..Default::default()
};
@@ -514,6 +517,31 @@ pub fn session_start_(id: &str, event_stream: StreamSink<EventToUI>) -> ResultTy
}
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn update_text_clipboard_required() {
let is_required = SESSIONS
.read()
.unwrap()
.iter()
.any(|(_id, session)| session.is_text_clipboard_required());
Client::set_is_text_clipboard_required(is_required);
}
#[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn other_sessions_running(id: &str) -> bool {
SESSIONS.read().unwrap().keys().filter(|k| *k != id).count() != 0
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn send_text_clipboard_msg(msg: Message) {
for (_id, session) in SESSIONS.read().unwrap().iter() {
if session.is_text_clipboard_required() {
session.send(Data::Message(msg.clone()));
}
}
}
// Server Side
#[cfg(not(any(target_os = "ios")))]
pub mod connection_manager {