diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 29b778afb..e6cfd516a 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -1512,18 +1512,7 @@ class _PluginState extends State<_Plugin> { List _buildCards(DescModel model) => [ _Card( title: 'Plugin', - children: [ - _Checkbox( - label: 'Enable', - getValue: () => bind.pluginIsEnabled() ?? false, - setValue: (bool v) async { - if (!v) { - clearLocations(); - } - await bind.pluginEnable(v: v); - }, - ), - ], + children: [], ), ...model.all.entries .map((entry) => PluginCard(pluginId: entry.key, desc: entry.value)) diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 458313fce..8f795d1f9 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -1545,42 +1545,6 @@ pub fn plugin_id_is_enabled(_id: String) -> SyncReturn { } } -pub fn plugin_enable(_v: bool) { - #[cfg(feature = "plugin_framework")] - #[cfg(not(any(target_os = "android", target_os = "ios")))] - { - allow_err!(crate::plugin::ipc::set_manager_config( - "enabled", - _v.to_string() - )); - if _v { - allow_err!(crate::plugin::load_plugins()); - } else { - crate::plugin::unload_plugins(); - } - } -} - -pub fn plugin_is_enabled() -> SyncReturn> { - #[cfg(feature = "plugin_framework")] - #[cfg(not(any(target_os = "android", target_os = "ios")))] - { - let r = match crate::plugin::ipc::get_manager_config("enabled") { - Ok(Some(enabled)) => Some(bool::from_str(&enabled).unwrap_or(false)), - _ => None, - }; - SyncReturn(r) - } - #[cfg(any( - not(feature = "plugin_framework"), - target_os = "android", - target_os = "ios" - ))] - { - SyncReturn(Some(false)) - } -} - pub fn plugin_feature_is_enabled() -> SyncReturn { #[cfg(feature = "plugin_framework")] #[cfg(not(any(target_os = "android", target_os = "ios")))] diff --git a/src/plugin/config.rs b/src/plugin/config.rs index 076a70a17..f939cf6bc 100644 --- a/src/plugin/config.rs +++ b/src/plugin/config.rs @@ -214,7 +214,6 @@ const MANAGER_VERSION: &str = "0.1.0"; #[derive(Debug, Serialize, Deserialize)] pub struct ManagerConfig { pub version: String, - pub enabled: bool, #[serde(default)] pub options: HashMap, #[serde(default)] @@ -225,7 +224,6 @@ impl Default for ManagerConfig { fn default() -> Self { Self { version: MANAGER_VERSION.to_owned(), - enabled: true, options: HashMap::new(), plugins: HashMap::new(), } @@ -241,43 +239,19 @@ impl ManagerConfig { #[inline] pub fn get_option(key: &str) -> Option { - if key == "enabled" { - Some(CONFIG_MANAGER.lock().unwrap().enabled.to_string()) - } else { - CONFIG_MANAGER - .lock() - .unwrap() - .options - .get(key) - .map(|s| s.to_owned()) - } - } - - fn set_option_enabled(enabled: bool) -> ResultType<()> { - let mut lock = CONFIG_MANAGER.lock().unwrap(); - lock.enabled = enabled; - hbb_common::config::store_path(Self::path(), &*lock) - } - - fn set_option_not_enabled(key: &str, value: &str) -> ResultType<()> { - let mut lock = CONFIG_MANAGER.lock().unwrap(); - lock.options.insert(key.to_owned(), value.to_owned()); - hbb_common::config::store_path(Self::path(), &*lock) + CONFIG_MANAGER + .lock() + .unwrap() + .options + .get(key) + .map(|s| s.to_owned()) } #[inline] pub fn set_option(key: &str, value: &str) { - if key == "enabled" { - let enabled = bool::from_str(value).unwrap_or(false); - allow_err!(Self::set_option_enabled(enabled)); - if enabled { - allow_err!(super::load_plugins()); - } else { - super::unload_plugins(); - } - } else { - allow_err!(Self::set_option_not_enabled(key, value)); - } + let mut lock = CONFIG_MANAGER.lock().unwrap(); + lock.options.insert(key.to_owned(), value.to_owned()); + allow_err!(hbb_common::config::store_path(Self::path(), &*lock)); } #[inline]