mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-12 10:19:09 +08:00
Merge pull request #5514 from 21pages/cm
Do not start cm if file permission not allowed
This commit is contained in:
commit
d688e34521
@ -268,12 +268,14 @@ hideCmWindow({bool isStartup = false}) async {
|
|||||||
await windowManager.hide();
|
await windowManager.hide();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (await windowManager.getOpacity() != 0) {
|
||||||
await windowManager.setOpacity(0);
|
await windowManager.setOpacity(0);
|
||||||
bind.mainHideDocker();
|
bind.mainHideDocker();
|
||||||
await windowManager.minimize();
|
await windowManager.minimize();
|
||||||
await windowManager.hide();
|
await windowManager.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _runApp(
|
void _runApp(
|
||||||
String title,
|
String title,
|
||||||
|
@ -36,6 +36,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
String _verificationMethod = "";
|
String _verificationMethod = "";
|
||||||
String _temporaryPasswordLength = "";
|
String _temporaryPasswordLength = "";
|
||||||
String _approveMode = "";
|
String _approveMode = "";
|
||||||
|
int _zeroClientLengthCounter = 0;
|
||||||
|
|
||||||
late String _emptyIdShow;
|
late String _emptyIdShow;
|
||||||
late final IDTextEditingController _serverId;
|
late final IDTextEditingController _serverId;
|
||||||
@ -120,6 +121,17 @@ class ServerModel with ChangeNotifier {
|
|||||||
_emptyIdShow = translate("Generating ...");
|
_emptyIdShow = translate("Generating ...");
|
||||||
_serverId = IDTextEditingController(text: _emptyIdShow);
|
_serverId = IDTextEditingController(text: _emptyIdShow);
|
||||||
|
|
||||||
|
// initital _hideCm at startup
|
||||||
|
final verificationMethod =
|
||||||
|
bind.mainGetOptionSync(key: "verification-method");
|
||||||
|
final approveMode = bind.mainGetOptionSync(key: 'approve-mode');
|
||||||
|
_hideCm = option2bool(
|
||||||
|
'allow-hide-cm', bind.mainGetOptionSync(key: 'allow-hide-cm'));
|
||||||
|
if (!(approveMode == 'password' &&
|
||||||
|
verificationMethod == kUsePermanentPassword)) {
|
||||||
|
_hideCm = false;
|
||||||
|
}
|
||||||
|
|
||||||
timerCallback() async {
|
timerCallback() async {
|
||||||
final connectionStatus =
|
final connectionStatus =
|
||||||
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
|
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
|
||||||
@ -134,6 +146,17 @@ class ServerModel with ChangeNotifier {
|
|||||||
if (res != null) {
|
if (res != null) {
|
||||||
debugPrint("clients not match!");
|
debugPrint("clients not match!");
|
||||||
updateClientState(res);
|
updateClientState(res);
|
||||||
|
} else {
|
||||||
|
if (_clients.isEmpty) {
|
||||||
|
hideCmWindow();
|
||||||
|
if (_zeroClientLengthCounter++ == 12) {
|
||||||
|
// 6 second
|
||||||
|
windowManager.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_zeroClientLengthCounter = 0;
|
||||||
|
if (!_hideCm) showCmWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,6 +445,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final oldClientLenght = _clients.length;
|
||||||
_clients.clear();
|
_clients.clear();
|
||||||
tabController.state.value.tabs.clear();
|
tabController.state.value.tabs.clear();
|
||||||
|
|
||||||
@ -434,6 +458,16 @@ class ServerModel with ChangeNotifier {
|
|||||||
debugPrint("Failed to decode clientJson '$clientJson', error $e");
|
debugPrint("Failed to decode clientJson '$clientJson', error $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (desktopType == DesktopType.cm) {
|
||||||
|
if (_clients.isEmpty) {
|
||||||
|
hideCmWindow();
|
||||||
|
} else if (!_hideCm) {
|
||||||
|
showCmWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_clients.length != oldClientLenght) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addConnection(Map<String, dynamic> evt) {
|
void addConnection(Map<String, dynamic> evt) {
|
||||||
@ -461,6 +495,9 @@ class ServerModel with ChangeNotifier {
|
|||||||
_clients.removeAt(index_disconnected);
|
_clients.removeAt(index_disconnected);
|
||||||
tabController.remove(index_disconnected);
|
tabController.remove(index_disconnected);
|
||||||
}
|
}
|
||||||
|
if (desktopType == DesktopType.cm && !_hideCm) {
|
||||||
|
showCmWindow();
|
||||||
|
}
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
if (isAndroid && !client.authorized) showLoginDialog(client);
|
if (isAndroid && !client.authorized) showLoginDialog(client);
|
||||||
@ -581,6 +618,9 @@ class ServerModel with ChangeNotifier {
|
|||||||
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(id));
|
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(id));
|
||||||
parent.target?.invokeMethod("cancel_notification", id);
|
parent.target?.invokeMethod("cancel_notification", id);
|
||||||
}
|
}
|
||||||
|
if (desktopType == DesktopType.cm && _clients.isEmpty) {
|
||||||
|
hideCmWindow();
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("onClientRemove failed,error:$e");
|
debugPrint("onClientRemove failed,error:$e");
|
||||||
|
@ -135,6 +135,14 @@ struct Session {
|
|||||||
random_password: String,
|
random_password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
struct StartCmIpcPara {
|
||||||
|
rx_to_cm: mpsc::UnboundedReceiver<ipc::Data>,
|
||||||
|
tx_from_cm: mpsc::UnboundedSender<ipc::Data>,
|
||||||
|
rx_desktop_ready: mpsc::Receiver<()>,
|
||||||
|
tx_cm_stream_ready: mpsc::Sender<()>,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Connection {
|
pub struct Connection {
|
||||||
inner: ConnInner,
|
inner: ConnInner,
|
||||||
stream: super::Stream,
|
stream: super::Stream,
|
||||||
@ -193,6 +201,8 @@ pub struct Connection {
|
|||||||
linux_headless_handle: LinuxHeadlessHandle,
|
linux_headless_handle: LinuxHeadlessHandle,
|
||||||
closed: bool,
|
closed: bool,
|
||||||
delay_response_instant: Instant,
|
delay_response_instant: Instant,
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
start_cm_ipc_para: Option<StartCmIpcPara>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConnInner {
|
impl ConnInner {
|
||||||
@ -324,6 +334,13 @@ impl Connection {
|
|||||||
linux_headless_handle,
|
linux_headless_handle,
|
||||||
closed: false,
|
closed: false,
|
||||||
delay_response_instant: Instant::now(),
|
delay_response_instant: Instant::now(),
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
start_cm_ipc_para: Some(StartCmIpcPara {
|
||||||
|
rx_to_cm,
|
||||||
|
tx_from_cm,
|
||||||
|
rx_desktop_ready,
|
||||||
|
tx_cm_stream_ready,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
let addr = hbb_common::try_into_v4(addr);
|
let addr = hbb_common::try_into_v4(addr);
|
||||||
if !conn.on_open(addr).await {
|
if !conn.on_open(addr).await {
|
||||||
@ -332,14 +349,6 @@ impl Connection {
|
|||||||
sleep(1.).await;
|
sleep(1.).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
tokio::spawn(async move {
|
|
||||||
if let Err(err) =
|
|
||||||
start_ipc(rx_to_cm, tx_from_cm, rx_desktop_ready, tx_cm_stream_ready).await
|
|
||||||
{
|
|
||||||
log::error!("ipc to connection manager exit: {}", err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
start_channel(rx_to_cm, tx_from_cm);
|
start_channel(rx_to_cm, tx_from_cm);
|
||||||
if !conn.keyboard {
|
if !conn.keyboard {
|
||||||
@ -1316,6 +1325,24 @@ impl Connection {
|
|||||||
self.video_ack_required = lr.video_ack_required;
|
self.video_ack_required = lr.video_ack_required;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
fn try_start_cm_ipc(&mut self) {
|
||||||
|
if let Some(p) = self.start_cm_ipc_para.take() {
|
||||||
|
tokio::spawn(async move {
|
||||||
|
if let Err(err) = start_ipc(
|
||||||
|
p.rx_to_cm,
|
||||||
|
p.tx_from_cm,
|
||||||
|
p.rx_desktop_ready,
|
||||||
|
p.tx_cm_stream_ready,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
log::error!("ipc to connection manager exit: {}", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn on_message(&mut self, msg: Message) -> bool {
|
async fn on_message(&mut self, msg: Message) -> bool {
|
||||||
if let Some(message::Union::LoginRequest(lr)) = msg.union {
|
if let Some(message::Union::LoginRequest(lr)) = msg.union {
|
||||||
self.handle_login_request_without_validation(&lr).await;
|
self.handle_login_request_without_validation(&lr).await;
|
||||||
@ -1379,6 +1406,9 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
self.try_start_cm_ipc();
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "flatpak",
|
feature = "flatpak",
|
||||||
feature = "appimage",
|
feature = "appimage",
|
||||||
@ -1543,6 +1573,8 @@ impl Connection {
|
|||||||
self.from_switch = true;
|
self.from_switch = true;
|
||||||
self.try_start_cm(lr.my_id.clone(), lr.my_name.clone(), true);
|
self.try_start_cm(lr.my_id.clone(), lr.my_name.clone(), true);
|
||||||
self.send_logon_response().await;
|
self.send_logon_response().await;
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
self.try_start_cm_ipc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user