mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -206,16 +206,21 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
_msg = rx_clip_client.recv() => {
|
||||
#[cfg(windows)]
|
||||
match _msg {
|
||||
Some(clip) => {
|
||||
let is_stopping_allowed = clip.is_stopping_allowed();
|
||||
let server_file_transfer_enabled = *self.handler.server_file_transfer_enabled.read().unwrap();
|
||||
let file_transfer_enabled = self.handler.lc.read().unwrap().enable_file_transfer.v;
|
||||
let stop = is_stopping_allowed && !(server_file_transfer_enabled && file_transfer_enabled);
|
||||
log::debug!("Process clipboard message from system, stop: {}, is_stopping_allowed: {}, server_file_transfer_enabled: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, server_file_transfer_enabled, file_transfer_enabled);
|
||||
if stop {
|
||||
ContextSend::set_is_stopped();
|
||||
} else {
|
||||
allow_err!(peer.send(&crate::clipboard_file::clip_2_msg(clip)).await);
|
||||
Some(clip) => match clip {
|
||||
clipboard::ClipboardFile::NotifyCallback{r#type, title, text} => {
|
||||
self.handler.msgbox(&r#type, &title, &text, "");
|
||||
}
|
||||
_ => {
|
||||
let is_stopping_allowed = clip.is_stopping_allowed();
|
||||
let server_file_transfer_enabled = *self.handler.server_file_transfer_enabled.read().unwrap();
|
||||
let file_transfer_enabled = self.handler.lc.read().unwrap().enable_file_transfer.v;
|
||||
let stop = is_stopping_allowed && !(server_file_transfer_enabled && file_transfer_enabled);
|
||||
log::debug!("Process clipboard message from system, stop: {}, is_stopping_allowed: {}, server_file_transfer_enabled: {}, file_transfer_enabled: {}", stop, is_stopping_allowed, server_file_transfer_enabled, file_transfer_enabled);
|
||||
if stop {
|
||||
ContextSend::set_is_stopped();
|
||||
} else {
|
||||
allow_err!(peer.send(&crate::clipboard_file::clip_2_msg(clip)).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
|
||||
@@ -3,6 +3,20 @@ use hbb_common::message_proto::*;
|
||||
|
||||
pub fn clip_2_msg(clip: ClipboardFile) -> Message {
|
||||
match clip {
|
||||
ClipboardFile::NotifyCallback {
|
||||
r#type,
|
||||
title,
|
||||
text,
|
||||
} => Message {
|
||||
union: Some(message::Union::MessageBox(MessageBox {
|
||||
msgtype: r#type,
|
||||
title,
|
||||
text,
|
||||
link: "".to_string(),
|
||||
..Default::default()
|
||||
})),
|
||||
..Default::default()
|
||||
},
|
||||
ClipboardFile::MonitorReady => Message {
|
||||
union: Some(message::Union::Cliprdr(Cliprdr {
|
||||
union: Some(cliprdr::Union::Ready(CliprdrMonitorReady {
|
||||
|
||||
@@ -13,8 +13,6 @@ use hbb_common::platform::register_breakdown_handler;
|
||||
/// If it returns [`Some`], then the process will continue, and flutter gui will be started.
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn core_main() -> Option<Vec<String>> {
|
||||
use crate::flutter;
|
||||
|
||||
let mut args = Vec::new();
|
||||
let mut flutter_args = Vec::new();
|
||||
let mut i = 0;
|
||||
@@ -127,14 +125,6 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
clipboard::ContextSend::enable(true);
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
clipboard::set_notify_callback(flutter::msgbox_clipboard_remote);
|
||||
}
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
{
|
||||
// notify callback for non-flutter is not supported.
|
||||
}
|
||||
}
|
||||
std::thread::spawn(move || crate::start_server(false));
|
||||
} else {
|
||||
|
||||
@@ -1089,41 +1089,6 @@ pub fn stop_global_event_stream(app_type: String) {
|
||||
let _ = GLOBAL_EVENT_STREAM.write().unwrap().remove(&app_type);
|
||||
}
|
||||
|
||||
fn msgbox_clipboard_(channel: &str, r#type: u32, msg: &str, details: &str) -> u32 {
|
||||
let msgtype = format!(
|
||||
"{}-nocancel-nook-hasclose",
|
||||
if r#type == 0 {
|
||||
"info"
|
||||
} else if r#type == 1 {
|
||||
"warn"
|
||||
} else {
|
||||
"error"
|
||||
}
|
||||
);
|
||||
let text = format!("{} {}", msg, details);
|
||||
if let Ok(event) = serde_json::ser::to_string(&HashMap::from([
|
||||
("name", "msgbox"),
|
||||
("type", &msgtype as &str),
|
||||
("title", "clipboard"),
|
||||
("text", &text),
|
||||
("link", ""),
|
||||
("hasRetry", ""),
|
||||
])) {
|
||||
push_global_event(channel, event);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn msgbox_clipboard_remote(r#type: u32, msg: &str, details: &str) -> u32 {
|
||||
msgbox_clipboard_(APP_TYPE_DESKTOP_REMOTE, r#type, msg, details)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn msgbox_clipboard_cm(r#type: u32, msg: &str, details: &str) -> u32 {
|
||||
msgbox_clipboard_(APP_TYPE_CM, r#type, msg, details)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn get_rgba() {}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
Data::ClipboardFileEnabled(_enabled) => {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
self.file_transfer_enabled_peer =_enabled;
|
||||
self.file_transfer_enabled_peer = _enabled;
|
||||
}
|
||||
}
|
||||
Data::Theme(dark) => {
|
||||
@@ -538,14 +538,6 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
ContextSend::enable(Config::get_option("enable-file-transfer").is_empty());
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
clipboard::set_notify_callback(crate::flutter::msgbox_clipboard_cm);
|
||||
}
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
{
|
||||
// notify callback for non-flutter is not supported.
|
||||
}
|
||||
|
||||
match ipc::new_listener("_cm").await {
|
||||
Ok(mut incoming) => {
|
||||
|
||||
Reference in New Issue
Block a user