Merge remote-tracking branch 'rd/master' into feat/x11/clipboard-file/init

Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
This commit is contained in:
ClSlaid
2023-10-07 17:32:25 +08:00
88 changed files with 1434 additions and 871 deletions

View File

@@ -106,7 +106,7 @@ impl<T: InvokeUiSession> Remote<T> {
}
}
pub async fn io_loop(&mut self, key: &str, token: &str) {
pub async fn io_loop(&mut self, key: &str, token: &str, round: u32) {
let mut last_recv_time = Instant::now();
let mut received = false;
let conn_type = if self.handler.is_file_transfer() {
@@ -125,6 +125,11 @@ impl<T: InvokeUiSession> Remote<T> {
.await
{
Ok((mut peer, direct, pk)) => {
self.handler
.connection_round_state
.lock()
.unwrap()
.set_connected();
self.handler.set_connection_type(peer.is_secured(), direct); // flutter -> connection_ready
self.handler.update_direct(Some(direct));
if conn_type == ConnType::DEFAULT_CONN {
@@ -246,11 +251,21 @@ impl<T: InvokeUiSession> Remote<T> {
self.handler.on_establish_connection_error(err.to_string());
}
}
// set_disconnected_ok is used to check if new connection round is started.
let _set_disconnected_ok = self
.handler
.connection_round_state
.lock()
.unwrap()
.set_disconnected(round);
#[cfg(not(any(target_os = "android", target_os = "ios")))]
Client::try_stop_clipboard(&self.handler.session_id);
if _set_disconnected_ok {
Client::try_stop_clipboard(&self.handler.session_id);
}
#[cfg(any(target_os = "windows", target_os = "linux"))]
{
if _set_disconnected_ok {
let conn_id = self.client_conn_id;
log::debug!("try empty cliprdr for conn_id {}", conn_id);
let _ = ContextSend::proc(|context| -> ResultType<()> {
@@ -803,7 +818,7 @@ impl<T: InvokeUiSession> Remote<T> {
job: &fs::TransferJob,
elapsed: i32,
last_update_jobs_status: &mut (Instant, HashMap<i32, u64>),
handler: &mut Session<T>,
handler: &Session<T>,
) {
if elapsed <= 0 {
return;
@@ -830,7 +845,7 @@ impl<T: InvokeUiSession> Remote<T> {
job,
elapsed,
&mut self.last_update_jobs_status,
&mut self.handler,
&self.handler,
);
}
for job in self.write_jobs.iter() {
@@ -1305,9 +1320,10 @@ impl<T: InvokeUiSession> Remote<T> {
}
}
Some(misc::Union::Uac(uac)) => {
let keyboard = self.handler.server_keyboard_enabled.read().unwrap().clone();
#[cfg(feature = "flutter")]
{
if uac {
if uac && keyboard {
self.handler.msgbox(
"on-uac",
"Prompt",
@@ -1326,7 +1342,7 @@ impl<T: InvokeUiSession> Remote<T> {
let title = "Prompt";
let text = "Please wait for confirmation of UAC...";
let link = "";
if uac {
if uac && keyboard {
self.handler.msgbox(msgtype, title, text, link);
} else {
self.handler.cancel_msgbox(&format!(
@@ -1337,9 +1353,10 @@ impl<T: InvokeUiSession> Remote<T> {
}
}
Some(misc::Union::ForegroundWindowElevated(elevated)) => {
let keyboard = self.handler.server_keyboard_enabled.read().unwrap().clone();
#[cfg(feature = "flutter")]
{
if elevated {
if elevated && keyboard {
self.handler.msgbox(
"on-foreground-elevated",
"Prompt",
@@ -1358,7 +1375,7 @@ impl<T: InvokeUiSession> Remote<T> {
let title = "Prompt";
let text = "elevated_foreground_window_tip";
let link = "";
if elevated {
if elevated && keyboard {
self.handler.msgbox(msgtype, title, text, link);
} else {
self.handler.cancel_msgbox(&format!(
@@ -1372,6 +1389,7 @@ impl<T: InvokeUiSession> Remote<T> {
if err.is_empty() {
self.handler.msgbox("wait-uac", "", "", "");
} else {
self.handler.cancel_msgbox("wait-uac");
self.handler
.msgbox("elevation-error", "Elevation Error", &err, "");
}