Merge pull request #1879 from fufesou/fix_win_crash
fix: win remote and file transfer , simultaneous connection
This commit is contained in:
commit
fc695fd453
@ -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));
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
future::Future,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
@ -418,6 +418,7 @@ pub fn session_start_(id: &str, event_stream: StreamSink<EventToUI>) -> ResultTy
|
||||
pub mod connection_manager {
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(any(target_os = "android"))]
|
||||
use hbb_common::log;
|
||||
#[cfg(any(target_os = "android"))]
|
||||
use scrap::android::call_main_service_set_by_name;
|
||||
|
@ -7,13 +7,14 @@ use std::{
|
||||
use flutter_rust_bridge::{StreamSink, SyncReturn, ZeroCopyBuffer};
|
||||
use serde_json::json;
|
||||
|
||||
use hbb_common::ResultType;
|
||||
use hbb_common::{
|
||||
config::{self, LocalConfig, PeerConfig, ONLINE},
|
||||
fs, log,
|
||||
};
|
||||
use hbb_common::{message_proto::Hash, ResultType};
|
||||
|
||||
use crate::flutter::{self, SESSIONS};
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::start_server;
|
||||
use crate::ui_interface::{self, *};
|
||||
use crate::{
|
||||
@ -362,7 +363,7 @@ pub fn session_create_dir(id: String, act_id: i32, path: String, is_remote: bool
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_read_local_dir_sync(id: String, path: String, show_hidden: bool) -> String {
|
||||
pub fn session_read_local_dir_sync(_id: String, path: String, show_hidden: bool) -> String {
|
||||
if let Ok(fd) = fs::read_dir(&fs::get_path(&path), show_hidden) {
|
||||
return make_fd_to_json(fd.id, path, &fd.entries);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,9 +601,12 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
return Err(err.into());
|
||||
}
|
||||
_ => {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
would_block_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut fetched_conn_ids = HashSet::new();
|
||||
let timeout_millis = 3_000u64;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user