mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-16 04:56:18 +00:00
fix: clipboard, windows, controlled side, formats (#8885)
* fix: clipboard, windows, controlled side, formats Signed-off-by: fufesou <linlong1266@gmail.com> * Clipboard, reuse ipc conn and send_raw() Signed-off-by: fufesou <linlong1266@gmail.com> * Clipboard, merge content buffer Signed-off-by: fufesou <linlong1266@gmail.com> * refact: clipboard service, ipc stream Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -1,16 +1,5 @@
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||
use std::iter::FromIterator;
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::{
|
||||
atomic::{AtomicI64, Ordering},
|
||||
RwLock,
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::ipc::ClipboardNonFile;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::ipc::Connection;
|
||||
#[cfg(not(any(target_os = "ios")))]
|
||||
@@ -36,6 +25,18 @@ use hbb_common::{
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
use hbb_common::{tokio::sync::Mutex as TokioMutex, ResultType};
|
||||
use serde_derive::Serialize;
|
||||
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
|
||||
use std::iter::FromIterator;
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::{
|
||||
atomic::{AtomicI64, Ordering},
|
||||
RwLock,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
pub struct Client {
|
||||
@@ -486,6 +487,41 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
Data::CloseVoiceCall(reason) => {
|
||||
self.cm.voice_call_closed(self.conn_id, reason.as_str());
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
Data::ClipboardNonFile(_) => {
|
||||
match crate::clipboard::check_clipboard_cm() {
|
||||
Ok(multi_clipoards) => {
|
||||
let mut raw_contents = bytes::BytesMut::new();
|
||||
let mut main_data = vec![];
|
||||
for c in multi_clipoards.clipboards.into_iter() {
|
||||
let (content, content_len, next_raw) = {
|
||||
// TODO: find out a better threshold
|
||||
let content_len = c.content.len();
|
||||
if content_len > 1024 * 3 {
|
||||
(c.content, content_len, false)
|
||||
} else {
|
||||
raw_contents.extend(c.content);
|
||||
(bytes::Bytes::new(), content_len, true)
|
||||
}
|
||||
};
|
||||
main_data.push(ClipboardNonFile {
|
||||
compress: c.compress,
|
||||
content,
|
||||
content_len,
|
||||
next_raw,
|
||||
width: c.width,
|
||||
height: c.height,
|
||||
format: c.format.value(),
|
||||
});
|
||||
}
|
||||
allow_err!(self.stream.send(&Data::ClipboardNonFile(Some(("".to_owned(), main_data)))).await);
|
||||
allow_err!(self.stream.send_raw(raw_contents.into()).await);
|
||||
}
|
||||
Err(e) => {
|
||||
allow_err!(self.stream.send(&Data::ClipboardNonFile(Some((format!("{}", e), vec![])))).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user