tmp commit

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-06-29 15:06:45 +08:00
parent fc8db69d9e
commit 47fa90741f
3 changed files with 27 additions and 6 deletions

View File

@ -13,6 +13,8 @@ use hbb_common::platform::register_breakdown_handler;
/// If it returns [`Some`], then the process will continue, and flutter gui will be started. /// If it returns [`Some`], then the process will continue, and flutter gui will be started.
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn core_main() -> Option<Vec<String>> { pub fn core_main() -> Option<Vec<String>> {
use crate::flutter;
let mut args = Vec::new(); let mut args = Vec::new();
let mut flutter_args = Vec::new(); let mut flutter_args = Vec::new();
let mut i = 0; let mut i = 0;
@ -123,7 +125,17 @@ pub fn core_main() -> Option<Vec<String>> {
init_plugins(&args); init_plugins(&args);
if args.is_empty() { if args.is_empty() {
#[cfg(windows)] #[cfg(windows)]
clipboard::ContextSend::enable(true); {
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)); std::thread::spawn(move || crate::start_server(false));
} else { } else {
#[cfg(windows)] #[cfg(windows)]

View File

@ -1089,7 +1089,7 @@ pub fn stop_global_event_stream(app_type: String) {
let _ = GLOBAL_EVENT_STREAM.write().unwrap().remove(&app_type); let _ = GLOBAL_EVENT_STREAM.write().unwrap().remove(&app_type);
} }
fn msgbox_clipboard_(channel: &str, r#type: u32, msg: &str, details: &str) { fn msgbox_clipboard_(channel: &str, r#type: u32, msg: &str, details: &str) -> u32 {
let msgtype = format!( let msgtype = format!(
"{}-nocancel-nook-hasclose", "{}-nocancel-nook-hasclose",
if r#type == 0 { if r#type == 0 {
@ -1110,16 +1110,17 @@ fn msgbox_clipboard_(channel: &str, r#type: u32, msg: &str, details: &str) {
])) { ])) {
push_global_event(channel, event); push_global_event(channel, event);
} }
0
} }
#[inline] #[inline]
pub fn msgbox_clipboard_remote(r#type: u32, msg: &str, details: &str) { pub fn msgbox_clipboard_remote(r#type: u32, msg: &str, details: &str) -> u32 {
msgbox_clipboard_(APP_TYPE_DESKTOP_REMOTE, r#type, msg, details); msgbox_clipboard_(APP_TYPE_DESKTOP_REMOTE, r#type, msg, details)
} }
#[inline] #[inline]
pub fn msgbox_clipboard_cm(r#type: u32, msg: &str, details: &str) { pub fn msgbox_clipboard_cm(r#type: u32, msg: &str, details: &str) -> u32 {
msgbox_clipboard_(APP_TYPE_CM, r#type, msg, details); msgbox_clipboard_(APP_TYPE_CM, r#type, msg, details)
} }
#[no_mangle] #[no_mangle]

View File

@ -538,6 +538,14 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
ContextSend::enable(Config::get_option("enable-file-transfer").is_empty()); 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 { match ipc::new_listener("_cm").await {
Ok(mut incoming) => { Ok(mut incoming) => {