remove hide_cm

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-08-30 11:48:42 +08:00
parent 0ee2b02700
commit 76a18f5ed3
5 changed files with 28 additions and 12 deletions

View File

@ -707,8 +707,8 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
if (usePassword)
_SubButton('Set permanent password', setPasswordDialog,
permEnabled && !locked),
if (usePassword)
hide_cm(!locked).marginOnly(left: _kContentHSubMargin - 6),
// if (usePassword)
// hide_cm(!locked).marginOnly(left: _kContentHSubMargin - 6),
if (usePassword) radios[2],
]);
})));

View File

@ -223,6 +223,7 @@ void runConnectionManagerScreen(bool hide) async {
const DesktopServerPage(),
MyTheme.currentThemeMode(),
);
gFFI.serverModel.hideCm = hide;
if (hide) {
await hideCmWindow(isStartup: true);
} else {

View File

@ -31,7 +31,7 @@ class ServerModel with ChangeNotifier {
bool _audioOk = false;
bool _fileOk = false;
bool _showElevation = false;
bool _hideCm = false;
bool hideCm = false;
int _connectStatus = 0; // Rendezvous Server status
String _verificationMethod = "";
String _temporaryPasswordLength = "";
@ -61,8 +61,6 @@ class ServerModel with ChangeNotifier {
bool get showElevation => _showElevation;
bool get hideCm => _hideCm;
int get connectStatus => _connectStatus;
String get verificationMethod {
@ -121,6 +119,7 @@ class ServerModel with ChangeNotifier {
_emptyIdShow = translate("Generating ...");
_serverId = IDTextEditingController(text: _emptyIdShow);
/*
// initital _hideCm at startup
final verificationMethod =
bind.mainGetOptionSync(key: "verification-method");
@ -131,6 +130,7 @@ class ServerModel with ChangeNotifier {
verificationMethod == kUsePermanentPassword)) {
_hideCm = false;
}
*/
timerCallback() async {
final connectionStatus =
@ -155,7 +155,7 @@ class ServerModel with ChangeNotifier {
}
} else {
_zeroClientLengthCounter = 0;
if (!_hideCm) showCmWindow();
if (!hideCm) showCmWindow();
}
}
}
@ -210,12 +210,14 @@ 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;
@ -247,6 +249,7 @@ class ServerModel with ChangeNotifier {
_temporaryPasswordLength = temporaryPasswordLength;
update = true;
}
/*
if (_hideCm != hideCm) {
_hideCm = hideCm;
if (desktopType == DesktopType.cm) {
@ -258,6 +261,7 @@ class ServerModel with ChangeNotifier {
}
update = true;
}
*/
if (update) {
notifyListeners();
}
@ -461,7 +465,7 @@ class ServerModel with ChangeNotifier {
if (desktopType == DesktopType.cm) {
if (_clients.isEmpty) {
hideCmWindow();
} else if (!_hideCm) {
} else if (!hideCm) {
showCmWindow();
}
}
@ -495,7 +499,7 @@ class ServerModel with ChangeNotifier {
_clients.removeAt(index_disconnected);
tabController.remove(index_disconnected);
}
if (desktopType == DesktopType.cm && !_hideCm) {
if (desktopType == DesktopType.cm && !hideCm) {
showCmWindow();
}
scrollToBottom();

View File

@ -1,4 +1,8 @@
use std::{collections::HashMap, sync::Mutex, time::Duration};
use std::{
collections::HashMap,
sync::{Arc, Mutex},
time::Duration,
};
#[cfg(not(any(target_os = "ios")))]
use crate::Connection;
@ -16,6 +20,7 @@ const TIME_CONN: Duration = Duration::from_secs(3);
#[cfg(not(any(target_os = "ios")))]
lazy_static::lazy_static! {
static ref SENDER : Mutex<broadcast::Sender<Vec<i32>>> = Mutex::new(start_hbbs_sync());
static ref PRO: Arc<Mutex<bool>> = Default::default();
}
#[cfg(not(any(target_os = "ios")))]
@ -54,6 +59,7 @@ async fn start_hbbs_sync_async() {
_ = interval.tick() => {
let url = heartbeat_url();
if url.is_empty() {
*PRO.lock().unwrap() = false;
continue;
}
if !Config::get_option("stop-service").is_empty() {
@ -62,6 +68,7 @@ async fn start_hbbs_sync_async() {
let conns = Connection::alive_conns();
if info_uploaded.0 && url != info_uploaded.1 {
info_uploaded.0 = false;
*PRO.lock().unwrap() = false;
}
if !info_uploaded.0 && info_uploaded.2.map(|x| x.elapsed() >= UPLOAD_SYSINFO_TIMEOUT).unwrap_or(true){
let mut v = crate::get_sysinfo();
@ -73,6 +80,7 @@ async fn start_hbbs_sync_async() {
if x == "SYSINFO_UPDATED" {
info_uploaded = (true, url.clone(), None);
hbb_common::log::info!("sysinfo updated");
*PRO.lock().unwrap() = true;
} else if x == "ID_NOT_FOUND" {
info_uploaded.2 = None; // next heartbeat will upload sysinfo again
} else {
@ -148,3 +156,7 @@ fn handle_config_options(config_options: HashMap<String, String>) {
.count();
Config::set_options(options);
}
pub fn is_pro() -> bool {
PRO.lock().unwrap().clone()
}

View File

@ -2393,10 +2393,9 @@ async fn start_ipc(
stream = Some(s);
} else {
let mut args = vec!["--cm"];
if password::hide_cm() {
if crate::hbbs_http::sync::is_pro() && password::hide_cm() {
args.push("--hide");
};
}
#[allow(unused_mut)]
#[cfg(target_os = "linux")]
let mut user = None;