From d069b733038cf86b3750909a09dcb8afbcc74df7 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sat, 15 Jan 2022 02:16:00 +0800 Subject: [PATCH] refactor --- libs/hbb_common/src/config.rs | 1 + src/client.rs | 2 +- src/common.rs | 10 +--------- src/rendezvous_mediator.rs | 3 +-- src/server.rs | 1 - src/server/connection.rs | 8 +++++--- src/ui/ab.tis | 2 +- src/ui/header.tis | 2 +- src/ui/index.css | 18 ++++++++++++++++++ 9 files changed, 29 insertions(+), 18 deletions(-) diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs index 85dcfd984..66ce5070a 100644 --- a/libs/hbb_common/src/config.rs +++ b/libs/hbb_common/src/config.rs @@ -15,6 +15,7 @@ use std::{ pub const APP_NAME: &str = "RustDesk"; pub const RENDEZVOUS_TIMEOUT: u64 = 12_000; pub const CONNECT_TIMEOUT: u64 = 18_000; +pub const REG_INTERVAL: i64 = 12_000; pub const COMPRESS_LEVEL: i32 = 3; const SERIAL: i32 = 1; // 128x128 diff --git a/src/client.rs b/src/client.rs index 946b923d2..69ab838fd 100644 --- a/src/client.rs +++ b/src/client.rs @@ -941,7 +941,7 @@ impl LoginConfigHandler { if !pi.version.is_empty() { self.support_press = true; self.support_refresh = true; - self.version = crate::get_version_number(&pi.version); + self.version = hbb_common::get_version_number(&pi.version); } let serde = PeerInfoSerde { username, diff --git a/src/common.rs b/src/common.rs index d5390fe69..f4653e50c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -4,7 +4,7 @@ use hbb_common::{ anyhow::bail, compress::{compress as compress_func, decompress}, config::{Config, COMPRESS_LEVEL, RENDEZVOUS_TIMEOUT}, - log, + get_version_number, log, message_proto::*, protobuf::Message as _, protobuf::ProtobufEnum, @@ -413,14 +413,6 @@ pub fn is_modifier(evt: &KeyEvent) -> bool { } } -pub fn get_version_number(v: &str) -> i64 { - let mut n = 0; - for x in v.split(".") { - n = n * 1000 + x.parse::().unwrap_or(0); - } - n -} - pub fn check_software_update() { std::thread::spawn(move || allow_err!(_check_software_update())); } diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index 5e1564536..87b35dc25 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -2,7 +2,7 @@ use crate::server::{check_zombie, new as new_server, ServerPtr}; use hbb_common::{ allow_err, anyhow::bail, - config::{self, Config, RENDEZVOUS_PORT, RENDEZVOUS_TIMEOUT}, + config::{self, Config, REG_INTERVAL, RENDEZVOUS_PORT, RENDEZVOUS_TIMEOUT}, futures::future::join_all, log, protobuf::Message as _, @@ -31,7 +31,6 @@ lazy_static::lazy_static! { static ref SOLVING_PK_MISMATCH: Arc> = Default::default(); } static SHOULD_EXIT: AtomicBool = AtomicBool::new(false); -const REG_INTERVAL: i64 = 12_000; #[derive(Clone)] pub struct RendezvousMediator { diff --git a/src/server.rs b/src/server.rs index 66d889263..b2ec31bc3 100644 --- a/src/server.rs +++ b/src/server.rs @@ -23,7 +23,6 @@ use service::{GenericService, Service, ServiceTmpl, Subscriber}; use std::{ collections::HashMap, net::SocketAddr, - path::PathBuf, sync::{Arc, Mutex, RwLock, Weak}, time::Duration, }; diff --git a/src/server/connection.rs b/src/server/connection.rs index ac971aafd..75a9071f8 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -904,10 +904,12 @@ async fn start_ipc( mut rx_to_cm: mpsc::UnboundedReceiver, tx_from_cm: mpsc::UnboundedSender, ) -> ResultType<()> { - if crate::platform::is_prelogin() { - return Ok(()); + loop { + if !crate::platform::is_prelogin() { + break; + } + sleep(1.).await; } - let mut stream = None; if let Ok(s) = crate::ipc::connect(1000, "_cm").await { stream = Some(s); diff --git a/src/ui/ab.tis b/src/ui/ab.tis index 5365949e5..12a198b04 100644 --- a/src/ui/ab.tis +++ b/src/ui/ab.tis @@ -287,7 +287,7 @@ class MultipleSessions: Reactor.Component { function onSize() { var w = this.$(.sessions-bar).box(#width) - 220; this.$(#sessions-type span).style.set{ - "max-width": (w / 2) + "px", + "max-width": (w / (handler.is_installed() ? 2 : 3)) + "px", }; } } diff --git a/src/ui/header.tis b/src/ui/header.tis index 0c40df158..57ef01e78 100644 --- a/src/ui/header.tis +++ b/src/ui/header.tis @@ -233,7 +233,7 @@ class Header: Reactor.Component { event click $(#ctrl-alt-del) { handler.ctrl_alt_del(); } - + event click $(#lock-screen) { handler.lock_screen(); } diff --git a/src/ui/index.css b/src/ui/index.css index 552a2e317..971ad30ce 100644 --- a/src/ui/index.css +++ b/src/ui/index.css @@ -361,3 +361,21 @@ div#myid svg#menu { position: absolute; right: -1em; } + +div.remote-session svg#menu { + position: absolute; + right: 0; + top: 0; +} + +.install-me .button { + height: 2em; + line-height: 2em; + text-align: center; + font-weight: bold; + font-size: 1.6em; + margin-top: 1em; + border-color: white; + border: 1px; + background: none; +}