fix: win remote and file transfer , simultaneous connection

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-10-31 10:04:59 +08:00
parent e263acef3e
commit d6c9639c5d
7 changed files with 28 additions and 18 deletions

View File

@ -1,5 +1,5 @@
use crate::client::{ use crate::client::{
Client, CodecFormat, FileManager, MediaData, MediaSender, QualityStatus, MILLI1, SEC30, Client, CodecFormat, MediaData, MediaSender, QualityStatus, MILLI1, SEC30,
SERVER_CLIPBOARD_ENABLED, SERVER_FILE_TRANSFER_ENABLED, SERVER_KEYBOARD_ENABLED, SERVER_CLIPBOARD_ENABLED, SERVER_FILE_TRANSFER_ENABLED, SERVER_KEYBOARD_ENABLED,
}; };
use crate::common; use crate::common;
@ -15,7 +15,7 @@ use crate::{client::Data, client::Interface};
use hbb_common::config::{PeerConfig, TransferSerde}; use hbb_common::config::{PeerConfig, TransferSerde};
use hbb_common::fs::{ use hbb_common::fs::{
can_enable_overwrite_detection, get_job, get_string, new_send_confirm, DigestCheckResult, can_enable_overwrite_detection, get_job, get_string, new_send_confirm, DigestCheckResult,
RemoveJobMeta, TransferJobMeta, RemoveJobMeta,
}; };
use hbb_common::message_proto::permission_info::Permission; use hbb_common::message_proto::permission_info::Permission;
use hbb_common::protobuf::Message as _; use hbb_common::protobuf::Message as _;
@ -23,6 +23,7 @@ use hbb_common::rendezvous_proto::ConnType;
use hbb_common::tokio::{ use hbb_common::tokio::{
self, self,
sync::mpsc, sync::mpsc,
sync::Mutex as TokioMutex,
time::{self, Duration, Instant, Interval}, time::{self, Duration, Instant, Interval},
}; };
use hbb_common::{ use hbb_common::{
@ -113,15 +114,23 @@ impl<T: InvokeUiSession> Remote<T> {
// just build for now // just build for now
#[cfg(not(windows))] #[cfg(not(windows))]
let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>(); let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>();
#[cfg(windows)] #[cfg(windows)]
let (client_conn_id, rx_clip_client1) = let (_tx_holder, rx) = mpsc::unbounded_channel();
clipboard::get_rx_cliprdr_client(&self.handler.id);
#[cfg(windows)] #[cfg(windows)]
let mut rx_clip_client = rx_clip_client1.lock().await; let mut rx_clip_client_lock = Arc::new(TokioMutex::new(rx));
#[cfg(windows)] #[cfg(windows)]
{ {
self.client_conn_id = client_conn_id; let is_conn_not_default = self.handler.is_file_transfer()
|| self.handler.is_port_forward()
|| self.handler.is_rdp();
if !is_conn_not_default {
(self.client_conn_id, rx_clip_client_lock) =
clipboard::get_rx_cliprdr_client(&self.handler.id);
};
} }
#[cfg(windows)]
let mut rx_clip_client = rx_clip_client_lock.lock().await;
let mut status_timer = time::interval(Duration::new(1, 0)); let mut status_timer = time::interval(Duration::new(1, 0));

View File

@ -1,5 +1,4 @@
use std::{ use std::{
collections::HashMap,
future::Future, future::Future,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };

View File

@ -725,7 +725,7 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
// disable numlock if press home etc when numlock is on, // disable numlock if press home etc when numlock is on,
// because we will get numpad value (7,8,9 etc) if not // because we will get numpad value (7,8,9 etc) if not
#[cfg(windows)] #[cfg(windows)]
let mut disable_numlock = false; let mut _disable_numlock = false;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
en.reset_flag(); en.reset_flag();
// When long-pressed the command key, then press and release // When long-pressed the command key, then press and release
@ -775,8 +775,8 @@ fn legacy_keyboard_mode(evt: &KeyEvent) {
if let Some(key) = KEY_MAP.get(&ck.value()) { if let Some(key) = KEY_MAP.get(&ck.value()) {
#[cfg(windows)] #[cfg(windows)]
if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) { if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) {
disable_numlock = en.get_key_state(Key::NumLock); _disable_numlock = en.get_key_state(Key::NumLock);
if disable_numlock { if _disable_numlock {
en.key_down(Key::NumLock).ok(); en.key_down(Key::NumLock).ok();
en.key_up(Key::NumLock); en.key_up(Key::NumLock);
} }

View File

@ -468,6 +468,7 @@ fn run(sp: GenericService) -> ResultType<()> {
#[cfg(windows)] #[cfg(windows)]
start_uac_elevation_check(); start_uac_elevation_check();
#[cfg(target_os = "linux")]
let mut would_block_count = 0u32; let mut would_block_count = 0u32;
while sp.ok() { while sp.ok() {
@ -570,9 +571,9 @@ fn run(sp: GenericService) -> ResultType<()> {
try_gdi += 1; try_gdi += 1;
} }
would_block_count += 1;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
{ {
would_block_count += 1;
if !scrap::is_x11() { if !scrap::is_x11() {
if would_block_count >= 100 { if would_block_count >= 100 {
// For now, the user should choose and agree screen sharing agiain. // For now, the user should choose and agree screen sharing agiain.
@ -600,7 +601,10 @@ fn run(sp: GenericService) -> ResultType<()> {
return Err(err.into()); return Err(err.into());
} }
_ => { _ => {
would_block_count = 0; #[cfg(target_os = "linux")]
{
would_block_count = 0;
}
} }
} }

View File

@ -15,7 +15,7 @@ use hbb_common::{
protobuf::Message as _, protobuf::Message as _,
rendezvous_proto::*, rendezvous_proto::*,
tcp::FramedStream, tcp::FramedStream,
tokio::{self, sync::mpsc, time}, tokio::{self, sync::mpsc},
}; };
use crate::common::get_app_name; use crate::common::get_app_name;

View File

@ -18,8 +18,6 @@ use hbb_common::{
allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType, allow_err, fs::TransferJobMeta, log, message_proto::*, rendezvous_proto::ConnType,
}; };
#[cfg(windows)]
use crate::clipboard_file::*;
use crate::{ use crate::{
client::*, client::*,
ui_interface::has_hwcodec, ui_interface::has_hwcodec,

View File

@ -11,7 +11,7 @@ use std::{
}; };
#[cfg(windows)] #[cfg(windows)]
use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, ContextSend}; use clipboard::{cliprdr::CliprdrClientContext, empty_clipboard, set_conn_enabled, ContextSend};
use serde_derive::Serialize; use serde_derive::Serialize;
use crate::ipc::{self, new_listener, Connection, Data}; use crate::ipc::{self, new_listener, Connection, Data};
@ -247,10 +247,10 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
.await .await
); );
} }
clipboard::set_conn_enabled(conn_id, enabled); set_conn_enabled(conn_id, enabled);
if !enabled { if !enabled {
ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 { ContextSend::proc(|context: &mut Box<CliprdrClientContext>| -> u32 {
clipboard::empty_clipboard(context, conn_id); empty_clipboard(context, conn_id);
0 0
}); });
} }