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::{
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,
};
use crate::common;
@ -15,7 +15,7 @@ use crate::{client::Data, client::Interface};
use hbb_common::config::{PeerConfig, TransferSerde};
use hbb_common::fs::{
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::protobuf::Message as _;
@ -23,6 +23,7 @@ use hbb_common::rendezvous_proto::ConnType;
use hbb_common::tokio::{
self,
sync::mpsc,
sync::Mutex as TokioMutex,
time::{self, Duration, Instant, Interval},
};
use hbb_common::{
@ -113,15 +114,23 @@ impl<T: InvokeUiSession> Remote<T> {
// just build for now
#[cfg(not(windows))]
let (_tx_holder, mut rx_clip_client) = mpsc::unbounded_channel::<i32>();
#[cfg(windows)]
let (client_conn_id, rx_clip_client1) =
clipboard::get_rx_cliprdr_client(&self.handler.id);
let (_tx_holder, rx) = mpsc::unbounded_channel();
#[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)]
{
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));

View File

@ -1,5 +1,4 @@
use std::{
collections::HashMap,
future::Future,
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,
// because we will get numpad value (7,8,9 etc) if not
#[cfg(windows)]
let mut disable_numlock = false;
let mut _disable_numlock = false;
#[cfg(target_os = "macos")]
en.reset_flag();
// 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()) {
#[cfg(windows)]
if let Some(_) = NUMPAD_KEY_MAP.get(&ck.value()) {
disable_numlock = en.get_key_state(Key::NumLock);
if disable_numlock {
_disable_numlock = en.get_key_state(Key::NumLock);
if _disable_numlock {
en.key_down(Key::NumLock).ok();
en.key_up(Key::NumLock);
}

View File

@ -468,6 +468,7 @@ fn run(sp: GenericService) -> ResultType<()> {
#[cfg(windows)]
start_uac_elevation_check();
#[cfg(target_os = "linux")]
let mut would_block_count = 0u32;
while sp.ok() {
@ -570,9 +571,9 @@ fn run(sp: GenericService) -> ResultType<()> {
try_gdi += 1;
}
would_block_count += 1;
#[cfg(target_os = "linux")]
{
would_block_count += 1;
if !scrap::is_x11() {
if would_block_count >= 100 {
// For now, the user should choose and agree screen sharing agiain.
@ -600,7 +601,10 @@ fn run(sp: GenericService) -> ResultType<()> {
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 _,
rendezvous_proto::*,
tcp::FramedStream,
tokio::{self, sync::mpsc, time},
tokio::{self, sync::mpsc},
};
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,
};
#[cfg(windows)]
use crate::clipboard_file::*;
use crate::{
client::*,
ui_interface::has_hwcodec,

View File

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