mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
refact, tab to window, remove rust cache data
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
@@ -2366,7 +2366,7 @@ pub trait Interface: Send + Clone + 'static + Sized {
|
||||
fn send(&self, data: Data);
|
||||
fn msgbox(&self, msgtype: &str, title: &str, text: &str, link: &str);
|
||||
fn handle_login_error(&mut self, err: &str) -> bool;
|
||||
fn handle_peer_info(&mut self, pi: PeerInfo, is_cached_pi: bool);
|
||||
fn handle_peer_info(&mut self, pi: PeerInfo);
|
||||
fn on_error(&self, err: &str) {
|
||||
self.msgbox("error", "Error", err, "");
|
||||
}
|
||||
|
||||
@@ -125,18 +125,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
.await
|
||||
{
|
||||
Ok((mut peer, direct, pk)) => {
|
||||
let is_secured = peer.is_secured();
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
self.handler
|
||||
.cache_flutter
|
||||
.write()
|
||||
.unwrap()
|
||||
.is_secured_direct
|
||||
.replace((is_secured, direct));
|
||||
}
|
||||
self.handler.set_connection_type(is_secured, direct); // flutter -> connection_ready
|
||||
self.handler.set_connection_type(peer.is_secured(), direct); // flutter -> connection_ready
|
||||
self.handler.update_direct(Some(direct));
|
||||
if conn_type == ConnType::DEFAULT_CONN {
|
||||
self.handler
|
||||
@@ -1021,12 +1010,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
}
|
||||
Some(login_response::Union::PeerInfo(pi)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
self.handler.cache_flutter.write().unwrap().pi = pi.clone();
|
||||
}
|
||||
self.handler.handle_peer_info(pi, false);
|
||||
self.handler.handle_peer_info(pi);
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
self.check_clipboard_file_context();
|
||||
if !(self.handler.is_file_transfer() || self.handler.is_port_forward()) {
|
||||
@@ -1073,22 +1057,9 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
_ => {}
|
||||
},
|
||||
Some(message::Union::CursorData(cd)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
let mut lock = self.handler.cache_flutter.write().unwrap();
|
||||
if !lock.cursor_data.contains_key(&cd.id) {
|
||||
lock.cursor_data.insert(cd.id, cd.clone());
|
||||
}
|
||||
}
|
||||
self.handler.set_cursor_data(cd);
|
||||
}
|
||||
Some(message::Union::CursorId(id)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
self.handler.cache_flutter.write().unwrap().cursor_id = id;
|
||||
}
|
||||
self.handler.set_cursor_id(id.to_string());
|
||||
}
|
||||
Some(message::Union::CursorPosition(cp)) => {
|
||||
@@ -1305,16 +1276,6 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
}
|
||||
Some(misc::Union::SwitchDisplay(s)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
self.handler
|
||||
.cache_flutter
|
||||
.write()
|
||||
.unwrap()
|
||||
.sp
|
||||
.replace(s.clone());
|
||||
}
|
||||
self.handler.handle_peer_switch_display(&s);
|
||||
self.video_sender.send(MediaData::Reset).ok();
|
||||
if s.width > 0 && s.height > 0 {
|
||||
@@ -1506,12 +1467,6 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
}
|
||||
}
|
||||
Some(message::Union::PeerInfo(pi)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
self.handler.cache_flutter.write().unwrap().pi.displays =
|
||||
pi.displays.clone();
|
||||
}
|
||||
self.handler.set_displays(&pi.displays);
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -36,9 +36,11 @@ pub(crate) const APP_TYPE_CM: &str = "cm";
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
pub(crate) const APP_TYPE_CM: &str = "main";
|
||||
|
||||
pub(crate) const APP_TYPE_DESKTOP_REMOTE: &str = "remote";
|
||||
pub(crate) const APP_TYPE_DESKTOP_FILE_TRANSFER: &str = "file transfer";
|
||||
pub(crate) const APP_TYPE_DESKTOP_PORT_FORWARD: &str = "port forward";
|
||||
// Do not remove the following constants.
|
||||
// Uncomment them when they are used.
|
||||
// pub(crate) const APP_TYPE_DESKTOP_REMOTE: &str = "remote";
|
||||
// pub(crate) const APP_TYPE_DESKTOP_FILE_TRANSFER: &str = "file transfer";
|
||||
// pub(crate) const APP_TYPE_DESKTOP_PORT_FORWARD: &str = "port forward";
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub(crate) static ref CUR_SESSION_ID: RwLock<SessionID> = Default::default();
|
||||
|
||||
@@ -597,14 +597,6 @@ pub fn session_change_resolution(session_id: SessionID, display: i32, width: i32
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_ready_to_new_window(session_id: SessionID) {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&session_id) {
|
||||
session.restore_flutter_cache();
|
||||
session.refresh_video();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_set_size(_session_id: SessionID, _width: usize, _height: usize) {
|
||||
#[cfg(feature = "flutter_texture_render")]
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&_session_id) {
|
||||
|
||||
@@ -146,7 +146,7 @@ async fn connect_and_login(
|
||||
return Ok(None);
|
||||
}
|
||||
Some(login_response::Union::PeerInfo(pi)) => {
|
||||
interface.handle_peer_info(pi, false);
|
||||
interface.handle_peer_info(pi);
|
||||
break;
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -325,6 +325,7 @@ impl<T: InvokeUiCM> IpcTaskRunner<T> {
|
||||
|
||||
// for tmp use, without real conn id
|
||||
let mut write_jobs: Vec<fs::TransferJob> = Vec::new();
|
||||
#[cfg(windows)]
|
||||
let is_authorized = self.cm.is_authorized(self.conn_id);
|
||||
|
||||
#[cfg(windows)]
|
||||
|
||||
@@ -48,17 +48,6 @@ pub static IS_IN: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
const CHANGE_RESOLUTION_VALID_TIMEOUT_SECS: u64 = 15;
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
#[derive(Default)]
|
||||
pub struct CacheFlutter {
|
||||
pub pi: PeerInfo,
|
||||
pub sp: Option<SwitchDisplay>,
|
||||
pub cursor_data: HashMap<u64, CursorData>,
|
||||
pub cursor_id: u64,
|
||||
pub is_secured_direct: Option<(bool, bool)>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Session<T: InvokeUiSession> {
|
||||
pub session_id: SessionID, // different from the one in LoginConfigHandler, used for flutter UI message pass
|
||||
@@ -73,9 +62,6 @@ pub struct Session<T: InvokeUiSession> {
|
||||
pub server_file_transfer_enabled: Arc<RwLock<bool>>,
|
||||
pub server_clipboard_enabled: Arc<RwLock<bool>>,
|
||||
pub last_change_display: Arc<Mutex<ChangeDisplayRecord>>,
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub cache_flutter: Arc<RwLock<CacheFlutter>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -1095,7 +1081,7 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
||||
handle_login_error(self.lc.clone(), err, self)
|
||||
}
|
||||
|
||||
fn handle_peer_info(&mut self, mut pi: PeerInfo, is_cached_pi: bool) {
|
||||
fn handle_peer_info(&mut self, mut pi: PeerInfo) {
|
||||
log::debug!("handle_peer_info :{:?}", pi);
|
||||
pi.username = self.lc.read().unwrap().get_username(&pi);
|
||||
if pi.current_display as usize >= pi.displays.len() {
|
||||
@@ -1116,12 +1102,10 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
||||
self.msgbox("error", "Remote Error", "No Display", "");
|
||||
return;
|
||||
}
|
||||
if !is_cached_pi {
|
||||
self.try_change_init_resolution(pi.current_display);
|
||||
let p = self.lc.read().unwrap().should_auto_login();
|
||||
if !p.is_empty() {
|
||||
input_os_password(p, true, self.clone());
|
||||
}
|
||||
self.try_change_init_resolution(pi.current_display);
|
||||
let p = self.lc.read().unwrap().should_auto_login();
|
||||
if !p.is_empty() {
|
||||
input_os_password(p, true, self.clone());
|
||||
}
|
||||
let current = &pi.displays[pi.current_display as usize];
|
||||
self.set_display(
|
||||
@@ -1222,23 +1206,6 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
pub fn ctrl_alt_del(&self) {
|
||||
self.send_key_event(&crate::keyboard::client::event_ctrl_alt_del());
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn restore_flutter_cache(&mut self) {
|
||||
if let Some((is_secured, direct)) = self.cache_flutter.read().unwrap().is_secured_direct {
|
||||
self.set_connection_type(is_secured, direct);
|
||||
}
|
||||
let pi = self.cache_flutter.read().unwrap().pi.clone();
|
||||
self.handle_peer_info(pi, true);
|
||||
if let Some(sp) = self.cache_flutter.read().unwrap().sp.as_ref() {
|
||||
self.handle_peer_switch_display(sp);
|
||||
}
|
||||
for (_, cd) in self.cache_flutter.read().unwrap().cursor_data.iter() {
|
||||
self.set_cursor_data(cd.clone());
|
||||
}
|
||||
self.set_cursor_id(self.cache_flutter.read().unwrap().cursor_id.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
|
||||
Reference in New Issue
Block a user