fix: custom client, options, option2bool() (#8302)

* fix: custom client, options, option2bool()

Signed-off-by: fufesou <linlong1266@gmail.com>

* format

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-06-10 00:11:59 +08:00
committed by GitHub
Unverified
parent 78d7bfac01
commit 32ab56f864
8 changed files with 45 additions and 7 deletions

View File

@@ -2018,6 +2018,24 @@ pub fn is_disable_installation() -> bool {
is_some_hard_opton("disable-installation")
}
// This function must be kept the same as the one in flutter and sciter code.
// flutter: flutter/lib/common.dart -> option2bool()
// sciter: Does not have the function, but it should be kept the same.
pub fn option2bool(option: &str, value: &str) -> bool {
if option.starts_with("enable-") {
value != "N"
} else if option.starts_with("allow-")
|| option == "stop-service"
|| option == keys::OPTION_DIRECT_SERVER
|| option == "stop-rendezvous-service"
|| option == "force-always-relay"
{
value == "Y"
} else {
value != "N"
}
}
pub mod keys {
pub const OPTION_VIEW_ONLY: &str = "view_only";
pub const OPTION_SHOW_MONITORS_TOOLBAR: &str = "show_monitors_toolbar";

View File

@@ -79,7 +79,7 @@ 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()
&& crate::config::option2bool("allow-hide-cm", &Config::get_option("allow-hide-cm"))
}
const VERSION_LEN: usize = 2;