diff --git a/flutter/lib/desktop/pages/connection_page.dart b/flutter/lib/desktop/pages/connection_page.dart index 671335bf..83e57dba 100644 --- a/flutter/lib/desktop/pages/connection_page.dart +++ b/flutter/lib/desktop/pages/connection_page.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hbb/common/widgets/address_book.dart'; import 'package:flutter_hbb/consts.dart'; @@ -177,12 +178,15 @@ class _ConnectionPageState extends State children: [ Row( children: [ - Text( - translate('Control Remote Desktop'), - style: Theme.of(context) - .textTheme - .titleLarge - ?.merge(TextStyle(height: 1)), + Expanded( + child: AutoSizeText( + translate('Control Remote Desktop'), + maxLines: 1, + style: Theme.of(context) + .textTheme + .titleLarge + ?.merge(TextStyle(height: 1)), + ), ), ], ).marginOnly(bottom: 15), diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index b5aeaa7c..056b1028 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -658,13 +658,9 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { initialKey: modeInitialKey, onChanged: (key) => model.setApproveMode(key), ).marginOnly(left: _kContentHMargin), - Offstage( - offstage: !usePassword, - child: radios[0], - ), - Offstage( - offstage: !usePassword, - child: _SubLabeledWidget( + if (usePassword) radios[0], + if (usePassword) + _SubLabeledWidget( 'One-time password length', Row( children: [ @@ -672,20 +668,13 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { ], ), enabled: tmpEnabled && !locked), - ), - Offstage( - offstage: !usePassword, - child: radios[1], - ), - Offstage( - offstage: !usePassword, - child: _SubButton('Set permanent password', setPasswordDialog, + if (usePassword) radios[1], + if (usePassword) + _SubButton('Set permanent password', setPasswordDialog, permEnabled && !locked), - ), - Offstage( - offstage: !usePassword, - child: radios[2], - ), + if (usePassword) + hide_cm(!locked).marginOnly(left: _kContentHSubMargin - 6), + if (usePassword) radios[2], ]); }))); } @@ -814,6 +803,46 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { ).marginOnly(left: _kCheckBoxLeftMargin); }); } + + Widget hide_cm(bool enabled) { + return ChangeNotifierProvider.value( + value: gFFI.serverModel, + child: Consumer(builder: (context, model, child) { + final enableHideCm = model.approveMode == 'password' && + model.verificationMethod == kUsePermanentPassword; + onHideCmChanged(bool? b) { + if (b != null) { + bind.mainSetOption( + key: 'allow-hide-cm', value: bool2option('allow-hide-cm', b)); + } + } + + return Tooltip( + message: enableHideCm ? "" : translate('hide_cm_tip'), + child: GestureDetector( + onTap: + enableHideCm ? () => onHideCmChanged(!model.hideCm) : null, + child: Row( + children: [ + Checkbox( + value: model.hideCm, + onChanged: enabled && enableHideCm + ? onHideCmChanged + : null) + .marginOnly(right: 5), + Expanded( + child: Text( + translate('Hide connection management window'), + style: TextStyle( + color: _disabledTextColor( + context, enabled && enableHideCm)), + ), + ), + ], + ), + )); + })); + } } class _Network extends StatefulWidget { diff --git a/flutter/lib/main.dart b/flutter/lib/main.dart index e83c4b32..44db1436 100644 --- a/flutter/lib/main.dart +++ b/flutter/lib/main.dart @@ -85,7 +85,7 @@ Future main(List args) async { debugPrint("--cm started"); desktopType = DesktopType.cm; await windowManager.ensureInitialized(); - runConnectionManagerScreen(); + runConnectionManagerScreen(args.contains('--hide')); } else if (args.contains('--install')) { runInstallPage(); } else { @@ -185,16 +185,23 @@ void runMultiWindow( } } -void runConnectionManagerScreen() async { +void runConnectionManagerScreen(bool hide) async { await initEnv(kAppTypeMain); - // initialize window - WindowOptions windowOptions = - getHiddenTitleBarWindowOptions(size: kConnectionManagerWindowSize); _runApp( '', const DesktopServerPage(), MyTheme.currentThemeMode(), ); + if (hide) { + hideCmWindow(); + } else { + showCmWindow(); + } +} + +void showCmWindow() { + WindowOptions windowOptions = + getHiddenTitleBarWindowOptions(size: kConnectionManagerWindowSize); windowManager.waitUntilReadyToShow(windowOptions, () async { await windowManager.show(); await Future.wait([windowManager.focus(), windowManager.setOpacity(1)]); @@ -204,6 +211,15 @@ void runConnectionManagerScreen() async { }); } +void hideCmWindow() { + WindowOptions windowOptions = + getHiddenTitleBarWindowOptions(size: kConnectionManagerWindowSize); + windowManager.setOpacity(0); + windowManager.waitUntilReadyToShow(windowOptions, () async { + await windowManager.hide(); + }); +} + void _runApp( String title, Widget home, diff --git a/flutter/lib/models/server_model.dart b/flutter/lib/models/server_model.dart index be3f02b5..456c3cdd 100644 --- a/flutter/lib/models/server_model.dart +++ b/flutter/lib/models/server_model.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter_hbb/main.dart'; import 'package:flutter_hbb/models/platform_model.dart'; import 'package:get/get.dart'; import 'package:wakelock/wakelock.dart'; @@ -28,6 +29,7 @@ class ServerModel with ChangeNotifier { bool _audioOk = false; bool _fileOk = false; bool _showElevation = true; + bool _hideCm = false; int _connectStatus = 0; // Rendezvous Server status String _verificationMethod = ""; String _temporaryPasswordLength = ""; @@ -56,6 +58,8 @@ class ServerModel with ChangeNotifier { bool get showElevation => _showElevation; + bool get hideCm => _hideCm; + int get connectStatus => _connectStatus; String get verificationMethod { @@ -74,6 +78,10 @@ class ServerModel with ChangeNotifier { setVerificationMethod(String method) async { await bind.mainSetOption(key: "verification-method", value: method); + if (method != kUsePermanentPassword) { + await bind.mainSetOption( + key: 'allow-hide-cm', value: bool2option('allow-hide-cm', false)); + } } String get temporaryPasswordLength { @@ -90,6 +98,10 @@ class ServerModel with ChangeNotifier { setApproveMode(String mode) async { await bind.mainSetOption(key: 'approve-mode', value: mode); + if (mode != 'password') { + await bind.mainSetOption( + key: 'allow-hide-cm', value: bool2option('allow-hide-cm', false)); + } } TextEditingController get serverId => _serverId; @@ -125,7 +137,11 @@ class ServerModel with ChangeNotifier { } if (!isTest) { - Future.delayed(Duration.zero, timerCallback); + Future.delayed(Duration.zero, () async { + if (await bind.optionSynced()) { + await timerCallback(); + } + }); Timer.periodic(Duration(milliseconds: 500), (timer) async { await timerCallback(); }); @@ -166,6 +182,12 @@ class ServerModel with ChangeNotifier { final temporaryPasswordLength = await bind.mainGetOption(key: "temporary-password-length"); final approveMode = await bind.mainGetOption(key: 'approve-mode'); + var hideCm = option2bool( + 'allow-hide-cm', await bind.mainGetOption(key: 'allow-hide-cm')); + if (!(approveMode == 'password' && + verificationMethod == kUsePermanentPassword)) { + hideCm = false; + } if (_approveMode != approveMode) { _approveMode = approveMode; update = true; @@ -190,6 +212,17 @@ class ServerModel with ChangeNotifier { _temporaryPasswordLength = temporaryPasswordLength; update = true; } + if (_hideCm != hideCm) { + _hideCm = hideCm; + if (desktopType == DesktopType.cm) { + if (hideCm) { + hideCmWindow(); + } else { + showCmWindow(); + } + } + update = true; + } if (update) { notifyListeners(); } @@ -436,11 +469,11 @@ class ServerModel with ChangeNotifier { }, page: desktop.buildConnectionCard(client))); Future.delayed(Duration.zero, () async { - window_on_top(null); + if (!hideCm) window_on_top(null); }); if (client.authorized) { cmHiddenTimer = Timer(const Duration(seconds: 3), () { - windowManager.minimize(); + if (!hideCm) windowManager.minimize(); cmHiddenTimer = null; }); } diff --git a/libs/hbb_common/src/password_security.rs b/libs/hbb_common/src/password_security.rs index adaafebb..60290699 100644 --- a/libs/hbb_common/src/password_security.rs +++ b/libs/hbb_common/src/password_security.rs @@ -76,6 +76,12 @@ pub fn approve_mode() -> ApproveMode { } } +pub fn hide_cm() -> bool { + approve_mode() == ApproveMode::Password + && verification_method() == VerificationMethod::OnlyUsePermanentPassword + && !Config::get_option("allow-hide-cm").is_empty() +} + const VERSION_LEN: usize = 2; pub fn encrypt_str_or_original(s: &str, version: &str) -> String { diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index ea33290f..00f9b51e 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -1098,6 +1098,10 @@ pub fn version_to_number(v: String) -> i64 { hbb_common::get_version_number(&v) } +pub fn option_synced() -> bool { + crate::ui_interface::option_synced() +} + pub fn main_is_installed() -> SyncReturn { SyncReturn(is_installed()) } diff --git a/src/lang/ca.rs b/src/lang/ca.rs index f5684b4c..0dd21e16 100644 --- a/src/lang/ca.rs +++ b/src/lang/ca.rs @@ -394,5 +394,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/cn.rs b/src/lang/cn.rs index 7256c5d1..a3b3b47c 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "使用一次性密码"), ("One-time password length", "一次性密码长度"), ("Request access to your device", "请求访问你的设备"), + ("Hide connection management window", "隐藏连接管理窗口"), + ("hide_cm_tip", "在只允许密码连接并且只用固定密码的情况下才允许隐藏"), ].iter().cloned().collect(); } diff --git a/src/lang/cs.rs b/src/lang/cs.rs index 63fac728..450f3971 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/da.rs b/src/lang/da.rs index 4278cdc2..ea7263ac 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/de.rs b/src/lang/de.rs index 3ba0ae0c..66514fa0 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "Einmalpasswort verwenden"), ("One-time password length", "Länge des Einmalpassworts"), ("Request access to your device", "Zugriff zu Ihrem Gerät erbitten"), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/en.rs b/src/lang/en.rs index ee68d443..2550135a 100644 --- a/src/lang/en.rs +++ b/src/lang/en.rs @@ -33,7 +33,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("elevated_foreground_window_tip", "The current window of the remote desktop requires higher privilege to operate, so it's unable to use the mouse and keyboard temporarily. You can request the remote user to minimize the current window, or click elevation button on the connection management window. To avoid this problem, it is recommended to install the software on the remote device."), ("JumpLink", "View"), ("Stop service", "Stop Service"), - ("or", ""), - ("Continue with", ""), + ("hide_cm_tip", "Allow hiding only if accepting sessions via password and using pernament password"), ].iter().cloned().collect(); } diff --git a/src/lang/eo.rs b/src/lang/eo.rs index 3c7ac806..797eb2bb 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/es.rs b/src/lang/es.rs index ef7d8e0f..ca67a68b 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "Usar contraseña de un solo uso"), ("One-time password length", "Longitud de la contraseña de un solo uso"), ("Request access to your device", "Solicitud de acceso a su dispositivo"), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fa.rs b/src/lang/fa.rs index 0ea1f6f5..4dfb2262 100644 --- a/src/lang/fa.rs +++ b/src/lang/fa.rs @@ -394,5 +394,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "استفاده از رمز عبور یکبار مصرف"), ("One-time password length", "طول رمز عبور یکبار مصرف"), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fr.rs b/src/lang/fr.rs index 4b8d0d83..6c9cb6a3 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/hu.rs b/src/lang/hu.rs index 9802ddb6..417c83f4 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/id.rs b/src/lang/id.rs index 00278906..b76bb687 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/it.rs b/src/lang/it.rs index 76e03445..83741d47 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "Usa password monouso"), ("One-time password length", "Lunghezza password monouso"), ("Request access to your device", "Richiedi l'accesso al tuo dispositivo"), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ja.rs b/src/lang/ja.rs index b032fbe7..8d806416 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ko.rs b/src/lang/ko.rs index 338fc7ff..9f8027be 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/kz.rs b/src/lang/kz.rs index 3a343da2..3a8c27cf 100644 --- a/src/lang/kz.rs +++ b/src/lang/kz.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pl.rs b/src/lang/pl.rs index ecc09ce2..dae77ed8 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "Użyj hasła jednorazowego"), ("One-time password length", "Długość hasła jednorazowego"), ("Request access to your device", "Żądanie dostępu do Twojego urządzenia"), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index dbb5fbbe..bc5fbbdf 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index 42d28df7..0d77eb90 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "Usar senha de uso único"), ("One-time password length", "Comprimento da senha de uso único"), ("Request access to your device", "Solicitar acesso ao seu dispositivo"), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ru.rs b/src/lang/ru.rs index ded00af2..e318b7cd 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sk.rs b/src/lang/sk.rs index 8da18e03..33f2be7a 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/template.rs b/src/lang/template.rs index bc9bc95e..8f855d96 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tr.rs b/src/lang/tr.rs index 86283557..a97f832b 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tw.rs b/src/lang/tw.rs index cc8f65e1..4945fd51 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", "使用一次性密碼"), ("One-time password length", "一次性密碼長度"), ("Request access to your device", "請求訪問你的設備"), + ("Hide connection management window", "隱藏連接管理窗口"), + ("hide_cm_tip", "在只允許密碼連接並且只用固定密碼的情況下才允許隱藏"), ].iter().cloned().collect(); } diff --git a/src/lang/ua.rs b/src/lang/ua.rs index 7d14ee7e..3861f059 100644 --- a/src/lang/ua.rs +++ b/src/lang/ua.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/lang/vn.rs b/src/lang/vn.rs index 3ddacdf8..8ddeadfc 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -395,5 +395,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Use one-time password", ""), ("One-time password length", ""), ("Request access to your device", ""), + ("Hide connection management window", ""), + ("hide_cm_tip", ""), ].iter().cloned().collect(); } diff --git a/src/server/connection.rs b/src/server/connection.rs index a337d602..249dadc5 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -1571,17 +1571,18 @@ async fn start_ipc( if let Ok(s) = crate::ipc::connect(1000, "_cm").await { stream = Some(s); } else { + let extra_args = if password::hide_cm() { "--hide" } else { "" }; let run_done; if crate::platform::is_root() { let mut res = Ok(None); for _ in 0..10 { #[cfg(not(target_os = "linux"))] { - res = crate::platform::run_as_user("--cm"); + res = crate::platform::run_as_user(&format!("--cm {}", extra_args)); } #[cfg(target_os = "linux")] { - res = crate::platform::run_as_user("--cm", None); + res = crate::platform::run_as_user(&format!("--cm {}", extra_args), None); } if res.is_ok() { break; @@ -1596,10 +1597,14 @@ async fn start_ipc( run_done = false; } if !run_done { + let mut args = vec!["--cm"]; + if !extra_args.is_empty() { + args.push(&extra_args); + } super::CHILD_PROCESS .lock() .unwrap() - .push(crate::run_me(vec!["--cm"])?); + .push(crate::run_me(args)?); } for _ in 0..10 { sleep(0.3).await; diff --git a/src/server/video_service.rs b/src/server/video_service.rs index 3ccc3af3..db419fc6 100644 --- a/src/server/video_service.rs +++ b/src/server/video_service.rs @@ -192,7 +192,7 @@ fn create_capturer( privacy_mode_id: i32, display: Display, use_yuv: bool, - current: usize, + _current: usize, _portable_service_running: bool, ) -> ResultType> { #[cfg(not(windows))] @@ -256,7 +256,7 @@ fn create_capturer( log::debug!("Create capturer dxgi|gdi"); #[cfg(windows)] return crate::portable_service::client::create_capturer( - current, + _current, display, use_yuv, _portable_service_running, diff --git a/src/ui_cm_interface.rs b/src/ui_cm_interface.rs index 5edf5350..26e5e407 100644 --- a/src/ui_cm_interface.rs +++ b/src/ui_cm_interface.rs @@ -784,11 +784,11 @@ pub fn can_elevate() -> bool { return false; } -pub fn elevate_portable(id: i32) { +pub fn elevate_portable(_id: i32) { #[cfg(windows)] { let lock = CLIENTS.read().unwrap(); - if let Some(s) = lock.get(&id) { + if let Some(s) = lock.get(&_id) { allow_err!(s.tx.send(ipc::Data::DataPortableService( ipc::DataPortableService::RequestStart ))); diff --git a/src/ui_interface.rs b/src/ui_interface.rs index e1dc3005..28ce897b 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -39,6 +39,7 @@ lazy_static::lazy_static! { static ref OPTIONS : Arc>> = Arc::new(Mutex::new(Config::get_options())); static ref ASYNC_JOB_STATUS : Arc> = Default::default(); static ref TEMPORARY_PASSWD : Arc> = Arc::new(Mutex::new("".to_owned())); + pub static ref OPTION_SYNCED : Arc> = Default::default(); } #[cfg(not(any(target_os = "android", target_os = "ios")))] @@ -924,7 +925,8 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver { - *OPTIONS.lock().unwrap() = v + *OPTIONS.lock().unwrap() = v; + *OPTION_SYNCED.lock().unwrap() = true; } Ok(Some(ipc::Data::Config((name, Some(value))))) => { if name == "id" { @@ -967,6 +969,11 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver bool { + OPTION_SYNCED.lock().unwrap().clone() +} + #[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))] #[tokio::main(flavor = "current_thread")] pub(crate) async fn send_to_cm(data: &ipc::Data) { diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 9b00730e..efc82cbc 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -200,6 +200,7 @@ impl Session { h265 = h265 && encoding_265; return (h264, h265); } + #[allow(dead_code)] (false, false) }