An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
buildin options and add to mobile (#8759)
21pages2b54a553c72b
diff --git a/flutter/lib/common.dart b/flutter/lib/common.dartindex 3e5689d35..0ce9433f4 100644--- a/flutter/lib/common.dart+++ b/flutter/lib/common.dart@@ -3319,7 +3319,8 @@ Widget buildPresetPasswordWarning() {return Text('Error: ${snapshot.error}'); // Show an error message if the Future completed with an error} else if (snapshot.hasData && snapshot.data == true) {- if (bind.mainGetLocalOption(key: "remove-preset-password-warning") !=+ if (bind.mainGetBuildinOption(+ key: kOptionRemovePresetPasswordWarning) !='N') {return SizedBox.shrink();}diff --git a/flutter/lib/common/widgets/peer_card.dart b/flutter/lib/common/widgets/peer_card.dartindex 9f828c190..1b099cbeb 100644--- a/flutter/lib/common/widgets/peer_card.dart+++ b/flutter/lib/common/widgets/peer_card.dart@@ -133,7 +133,7 @@ class _PeerCardState extends State<_PeerCard>Widget _buildPeerTile(BuildContext context, Peer peer, Rx<BoxDecoration?>? deco) {hideUsernameOnCard ??=- bind.mainGetLocalOption(key: kHideUsernameOnCard) == 'Y';+ bind.mainGetBuildinOption(key: kHideUsernameOnCard) == 'Y';final name = hideUsernameOnCard == true? peer.hostname: '${peer.username}${peer.username.isNotEmpty && peer.hostname.isNotEmpty ? '@' : ''}${peer.hostname}';@@ -245,7 +245,7 @@ class _PeerCardState extends State<_PeerCard>Widget _buildPeerCard(BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {hideUsernameOnCard ??=- bind.mainGetLocalOption(key: kHideUsernameOnCard) == 'Y';+ bind.mainGetBuildinOption(key: kHideUsernameOnCard) == 'Y';final name = hideUsernameOnCard == true? peer.hostname: '${peer.username}${peer.username.isNotEmpty && peer.hostname.isNotEmpty ? '@' : ''}${peer.hostname}';diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dartindex b54ff15dd..5af3f6d25 100644--- a/flutter/lib/consts.dart+++ b/flutter/lib/consts.dart@@ -136,8 +136,16 @@ const String kOptionAllowRemoveWallpaper = "allow-remove-wallpaper";const String kOptionStopService = "stop-service";const String kOptionDirectxCapture = "enable-directx-capture";const String kOptionAllowRemoteCmModification = "allow-remote-cm-modification";++// buildin opitonsconst String kOptionHideServerSetting = "hide-server-settings";const String kOptionHideProxySetting = "hide-proxy-settings";+const String kOptionHideSecuritySetting = "hide-security-settings";+const String kOptionHideNetworkSetting = "hide-network-settings";+const String kOptionRemovePresetPasswordWarning =+ "remove-preset-password-warning";+const kHideUsernameOnCard = "hide-username-on-card";+const String kOptionHideHelpCards = "hide-help-cards";const String kOptionToggleViewOnly = "view-only";@@ -306,8 +314,6 @@ const kRequestIgnoreBatteryOptimizations =const kSystemAlertWindow = "android.permission.SYSTEM_ALERT_WINDOW";const kAndroid13Notification = "android.permission.POST_NOTIFICATIONS";-const kHideUsernameOnCard = "hide-username-on-card";-/// Android channel invoke type keyclass AndroidChannel {static final kStartAction = "start_action";diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dartindex addfacec3..31a8e1374 100644--- a/flutter/lib/desktop/pages/desktop_home_page.dart+++ b/flutter/lib/desktop/pages/desktop_home_page.dart@@ -546,7 +546,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>String? link,bool? closeButton,String? closeOption}) {- if (bind.mainGetLocalOption(key: 'hide-help-cards') == 'Y' &&+ if (bind.mainGetBuildinOption(key: kOptionHideHelpCards) == 'Y' &&content != 'install_daemon_tip') {return const SizedBox();}diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dartindex c69ba186a..70aa6c54e 100644--- a/flutter/lib/desktop/pages/desktop_setting_page.dart+++ b/flutter/lib/desktop/pages/desktop_setting_page.dart@@ -63,10 +63,10 @@ class DesktopSettingPage extends StatefulWidget {SettingsTabKey.general,if (!bind.isOutgoingOnly() &&!bind.isDisableSettings() &&- bind.mainGetLocalOption(key: "hide-security-settings") != 'Y')+ bind.mainGetBuildinOption(key: kOptionHideSecuritySetting) != 'Y')SettingsTabKey.safety,if (!bind.isDisableSettings() &&- bind.mainGetLocalOption(key: "hide-network-settings") != 'Y')+ bind.mainGetBuildinOption(key: kOptionHideNetworkSetting) != 'Y')SettingsTabKey.network,if (!bind.isIncomingOnly()) SettingsTabKey.display,if (!isWeb && !bind.isIncomingOnly() && bind.pluginFeatureIsEnabled())@@ -1289,9 +1289,9 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {bool enabled = !locked;final scrollController = ScrollController();final hideServer =- bind.mainGetLocalOption(key: kOptionHideServerSetting) == 'Y';+ bind.mainGetBuildinOption(key: kOptionHideServerSetting) == 'Y';final hideProxy =- bind.mainGetLocalOption(key: kOptionHideProxySetting) == 'Y';+ bind.mainGetBuildinOption(key: kOptionHideProxySetting) == 'Y';return DesktopScrollWrapper(scrollController: scrollController,child: ListView(diff --git a/flutter/lib/mobile/pages/server_page.dart b/flutter/lib/mobile/pages/server_page.dartindex 3609564ec..664496176 100644--- a/flutter/lib/mobile/pages/server_page.dart+++ b/flutter/lib/mobile/pages/server_page.dart@@ -23,7 +23,22 @@ class ServerPage extends StatefulWidget implements PageShape {final icon = const Icon(Icons.mobile_screen_share);@override- final appBarActions = [+ final appBarActions = (!bind.isDisableSettings() &&+ bind.mainGetBuildinOption(key: kOptionHideSecuritySetting) != 'Y')+ ? [_DropDownAction()]+ : [];++ ServerPage({Key? key}) : super(key: key);++ @override+ State<StatefulWidget> createState() => _ServerPageState();+}++class _DropDownAction extends StatelessWidget {+ _DropDownAction();++ // should only have one action+ final actions = [PopupMenuButton<String>(tooltip: "",icon: const Icon(Icons.more_vert),@@ -136,10 +151,10 @@ class ServerPage extends StatefulWidget implements PageShape {})];- ServerPage({Key? key}) : super(key: key);-@override- State<StatefulWidget> createState() => _ServerPageState();+ Widget build(BuildContext context) {+ return actions[0];+ }}class _ServerPageState extends State<ServerPage> {diff --git a/flutter/lib/mobile/pages/settings_page.dart b/flutter/lib/mobile/pages/settings_page.dartindex 2fc776348..63972d0ea 100644--- a/flutter/lib/mobile/pages/settings_page.dart+++ b/flutter/lib/mobile/pages/settings_page.dart@@ -86,6 +86,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {var _autoDisconnectTimeout = "";var _hideServer = false;var _hideProxy = false;+ var _hideNetwork = false;@overridevoid initState() {@@ -112,8 +113,11 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {bind.mainGetOptionSync(key: kOptionAllowAutoDisconnect));_autoDisconnectTimeout =bind.mainGetOptionSync(key: kOptionAutoDisconnectTimeout);- _hideServer = bind.mainGetLocalOption(key: kOptionHideServerSetting) == 'Y';- _hideProxy = bind.mainGetLocalOption(key: kOptionHideProxySetting) == 'Y';+ _hideServer =+ bind.mainGetBuildinOption(key: kOptionHideServerSetting) == 'Y';+ _hideProxy = bind.mainGetBuildinOption(key: kOptionHideProxySetting) == 'Y';+ _hideNetwork =+ bind.mainGetBuildinOption(key: kOptionHideNetworkSetting) == 'Y';() async {var update = false;@@ -535,6 +539,8 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {));final disabledSettings = bind.isDisableSettings();+ final hideSecuritySettings =+ bind.mainGetBuildinOption(key: kOptionHideSecuritySetting) == 'Y';final settings = SettingsList(sections: [customClientSection,@@ -558,14 +564,14 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {],),SettingsSection(title: Text(translate("Settings")), tiles: [- if (!disabledSettings && !_hideServer)+ if (!disabledSettings && !_hideNetwork && !_hideServer)SettingsTile(title: Text(translate('ID/Relay Server')),leading: Icon(Icons.cloud),onPressed: (context) {showServerSettings(gFFI.dialogManager);}),- if (!isIOS && !_hideProxy)+ if (!isIOS && !_hideNetwork && !_hideProxy)SettingsTile(title: Text(translate('Socks5/Http(s) Proxy')),leading: Icon(Icons.network_ping),@@ -637,13 +643,19 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {),],),- if (isAndroid && !disabledSettings && !outgoingOnly)+ if (isAndroid &&+ !disabledSettings &&+ !outgoingOnly &&+ !hideSecuritySettings)SettingsSection(title: Text(translate("Share Screen")),tiles: shareScreenTiles,),if (!bind.isIncomingOnly()) defaultDisplaySection(),- if (isAndroid && !disabledSettings && !outgoingOnly)+ if (isAndroid &&+ !disabledSettings &&+ !outgoingOnly &&+ !hideSecuritySettings)SettingsSection(title: Text(translate("Enhancements")),tiles: enhancementsTiles,diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rsindex 51a33a00b..e33cf8ebb 100644--- a/libs/hbb_common/src/config.rs+++ b/libs/hbb_common/src/config.rs@@ -69,6 +69,7 @@ lazy_static::lazy_static! {pub static ref DEFAULT_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default();pub static ref OVERWRITE_LOCAL_SETTINGS: RwLock<HashMap<String, String>> = Default::default();pub static ref HARD_SETTINGS: RwLock<HashMap<String, String>> = Default::default();+ pub static ref BUILDIN_SETTINGS: RwLock<HashMap<String, String>> = Default::default();}lazy_static::lazy_static! {@@ -2096,12 +2097,22 @@ pub mod keys {pub const OPTION_KEY: &str = "key";pub const OPTION_PRESET_ADDRESS_BOOK_NAME: &str = "preset-address-book-name";pub const OPTION_PRESET_ADDRESS_BOOK_TAG: &str = "preset-address-book-tag";- pub const OPTION_PRESET_USERNAME: &str = "preset-user-name";- pub const OPTION_PRESET_STRATEGY_NAME: &str = "preset-strategy-name";pub const OPTION_ENABLE_DIRECTX_CAPTURE: &str = "enable-directx-capture";pub const OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE: &str ="enable-android-software-encoding-half-scale";++ // buildin options+ pub const OPTION_DISPLAY_NAME: &str = "display-name";pub const OPTION_DISABLE_UDP: &str = "disable-udp";+ pub const OPTION_PRESET_USERNAME: &str = "preset-user-name";+ pub const OPTION_PRESET_STRATEGY_NAME: &str = "preset-strategy-name";+ pub const OPTION_REMOVE_PRESET_PASSWORD_WARNING: &str = "remove-preset-password-warning";+ pub const OPTION_HIDE_SECURITY_SETTINGS: &str = "hide-security-settings";+ pub const OPTION_HIDE_NETWORK_SETTINGS: &str = "hide-network-settings";+ pub const OPTION_HIDE_SERVER_SETTINGS: &str = "hide-server-settings";+ pub const OPTION_HIDE_PROXY_SETTINGS: &str = "hide-proxy-settings";+ pub const OPTION_HIDE_USERNAME_ON_CARD: &str = "hide-username-on-card";+ pub const OPTION_HIDE_HELP_CARDS: &str = "hide-help-cards";// flutter local optionspub const OPTION_FLUTTER_REMOTE_MENUBAR_STATE: &str = "remoteMenubarState";@@ -2126,8 +2137,6 @@ pub mod keys {pub const OPTION_DISABLE_GROUP_PANEL: &str = "disable-group-panel";pub const OPTION_PRE_ELEVATE_SERVICE: &str = "pre-elevate-service";- pub const OPTION_DISPLAY_NAME: &str = "display-name";-// proxy settings// The following options are not real keys, they are just used for custom client advanced settings.// The real keys are in Config2::socks.@@ -2191,15 +2200,7 @@ pub mod keys {OPTION_KEEP_SCREEN_ON,OPTION_DISABLE_GROUP_PANEL,OPTION_PRE_ELEVATE_SERVICE,- OPTION_DISPLAY_NAME,- "remove-preset-password-warning",- "hide-security-settings",- "hide-network-settings",- "hide-server-settings",- "hide-proxy-settings",- "hide-username-on-card",OPTION_ALLOW_REMOTE_CM_MODIFICATION,- "hide-help-cards",];// DEFAULT_SETTINGS, OVERWRITE_SETTINGSpub const KEYS_SETTINGS: &[&str] = &[@@ -2238,9 +2239,21 @@ pub mod keys {OPTION_PRESET_ADDRESS_BOOK_TAG,OPTION_ENABLE_DIRECTX_CAPTURE,OPTION_ENABLE_ANDROID_SOFTWARE_ENCODING_HALF_SCALE,+ ];++ // BUILDIN_SETTINGS+ pub const KEYS_BUILDIN_SETTINGS: &[&str] = &[+ OPTION_DISPLAY_NAME,OPTION_DISABLE_UDP,OPTION_PRESET_USERNAME,OPTION_PRESET_STRATEGY_NAME,+ OPTION_REMOVE_PRESET_PASSWORD_WARNING,+ OPTION_HIDE_SECURITY_SETTINGS,+ OPTION_HIDE_NETWORK_SETTINGS,+ OPTION_HIDE_SERVER_SETTINGS,+ OPTION_HIDE_PROXY_SETTINGS,+ OPTION_HIDE_USERNAME_ON_CARD,+ OPTION_HIDE_HELP_CARDS,];}diff --git a/src/client.rs b/src/client.rsindex d0c0c6635..163aae1a1 100644--- a/src/client.rs+++ b/src/client.rs@@ -60,7 +60,7 @@ use crate::{check_port,common::input::{MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_TYPE_DOWN, MOUSE_TYPE_UP},create_symmetric_key_msg, decode_id_pk, get_rs_pk, is_keyboard_mode_supported, secure_tcp,- ui_interface::use_texture_render,+ ui_interface::{get_buildin_option, use_texture_render},ui_session_interface::{InvokeUiSession, Session},};@@ -2027,7 +2027,7 @@ impl LoginConfigHandler {} else {(my_id, self.id.clone())};- let mut display_name = LocalConfig::get_option(&config::keys::OPTION_DISPLAY_NAME);+ let mut display_name = get_buildin_option(config::keys::OPTION_DISPLAY_NAME);if display_name.is_empty() {display_name = crate::username();}diff --git a/src/common.rs b/src/common.rsindex 27135b568..740b5d9e3 100644--- a/src/common.rs+++ b/src/common.rs@@ -1341,6 +1341,7 @@ fn read_custom_client_advanced_settings(map_display_settings: &HashMap<String, &&str>,map_local_settings: &HashMap<String, &&str>,map_settings: &HashMap<String, &&str>,+ map_buildin_settings: &HashMap<String, &&str>,is_override: bool,) {let mut display_settings = if is_override {@@ -1358,6 +1359,8 @@ fn read_custom_client_advanced_settings(} else {config::DEFAULT_SETTINGS.write().unwrap()};+ let mut buildin_settings = config::BUILDIN_SETTINGS.write().unwrap();+if let Some(settings) = settings.as_object() {for (k, v) in settings {let Some(v) = v.as_str() else {@@ -1369,6 +1372,8 @@ fn read_custom_client_advanced_settings(local_settings.insert(k2.to_string(), v.to_owned());} else if let Some(k2) = map_settings.get(k) {server_settings.insert(k2.to_string(), v.to_owned());+ } else if let Some(k2) = map_buildin_settings.get(k) {+ buildin_settings.insert(k2.to_string(), v.to_owned());} else {let k2 = k.replace("_", "-");let k = k2.replace("-", "_");@@ -1381,6 +1386,9 @@ fn read_custom_client_advanced_settings(// serverserver_settings.insert(k.clone(), v.to_owned());server_settings.insert(k2.clone(), v.to_owned());+ // buildin+ buildin_settings.insert(k.clone(), v.to_owned());+ buildin_settings.insert(k2.clone(), v.to_owned());}}}@@ -1443,12 +1451,17 @@ pub fn read_custom_client(config: &str) {for s in config::keys::KEYS_SETTINGS {map_settings.insert(s.replace("_", "-"), s);}+ let mut buildin_settings = HashMap::new();+ for s in config::keys::KEYS_BUILDIN_SETTINGS {+ buildin_settings.insert(s.replace("_", "-"), s);+ }if let Some(default_settings) = data.remove("default-settings") {read_custom_client_advanced_settings(default_settings,&map_display_settings,&map_local_settings,&map_settings,+ &buildin_settings,false,);}@@ -1458,6 +1471,7 @@ pub fn read_custom_client(config: &str) {&map_display_settings,&map_local_settings,&map_settings,+ &buildin_settings,true,);}diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rsindex a7eda9d9b..700c08704 100644--- a/src/flutter_ffi.rs+++ b/src/flutter_ffi.rs@@ -2213,6 +2213,10 @@ pub fn main_get_hard_option(key: String) -> SyncReturn<String> {SyncReturn(get_hard_option(key))}+pub fn main_get_buildin_option(key: String) -> SyncReturn<String> {+ SyncReturn(get_buildin_option(&key))+}+pub fn main_check_hwcodec() {check_hwcodec()}diff --git a/src/hbbs_http/sync.rs b/src/hbbs_http/sync.rsindex a1e1a2568..f2717a42c 100644--- a/src/hbbs_http/sync.rs+++ b/src/hbbs_http/sync.rs@@ -5,7 +5,7 @@ use std::{};#[cfg(not(any(target_os = "ios")))]-use crate::Connection;+use crate::{ui_interface::get_buildin_option, Connection};use hbb_common::{config::{keys, Config, LocalConfig},tokio::{self, sync::broadcast, time::Instant},@@ -91,11 +91,11 @@ async fn start_hbbs_sync_async() {if !ab_tag.is_empty() {v[keys::OPTION_PRESET_ADDRESS_BOOK_TAG] = json!(ab_tag);}- let username = Config::get_option(keys::OPTION_PRESET_USERNAME);+ let username = get_buildin_option(keys::OPTION_PRESET_USERNAME);if !username.is_empty() {v[keys::OPTION_PRESET_USERNAME] = json!(username);}- let strategy_name = Config::get_option(keys::OPTION_PRESET_STRATEGY_NAME);+ let strategy_name = get_buildin_option(keys::OPTION_PRESET_STRATEGY_NAME);if !strategy_name.is_empty() {v[keys::OPTION_PRESET_STRATEGY_NAME] = json!(strategy_name);}diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rsindex 94fe128be..dcb538179 100644--- a/src/rendezvous_mediator.rs+++ b/src/rendezvous_mediator.rs@@ -29,6 +29,7 @@ use hbb_common::{use crate::{check_port,server::{check_zombie, new as new_server, ServerPtr},+ ui_interface::get_buildin_option,};type Message = RendezvousMessage;@@ -387,7 +388,7 @@ impl RendezvousMediator {};if (cfg!(debug_assertions) && option_env!("TEST_TCP").is_some())|| is_http_proxy- || Config::get_option(config::keys::OPTION_DISABLE_UDP) == "Y"+ || get_buildin_option(config::keys::OPTION_DISABLE_UDP) == "Y"{Self::start_tcp(server, host).await} else {diff --git a/src/ui_interface.rs b/src/ui_interface.rsindex ead6b4168..fec0380b5 100644--- a/src/ui_interface.rs+++ b/src/ui_interface.rs@@ -202,6 +202,16 @@ pub fn get_hard_option(key: String) -> String {.unwrap_or_default()}+#[inline]+pub fn get_buildin_option(key: &str) -> String {+ config::BUILDIN_SETTINGS+ .read()+ .unwrap()+ .get(key)+ .cloned()+ .unwrap_or_default()+}+#[inline]pub fn set_local_option(key: String, value: String) {LocalConfig::set_option(key, value);