mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
plugin_framework, load plugin
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -1436,11 +1436,11 @@ pub fn plugin_set_session_option(_id: String, _peer: String, _key: String, _valu
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plugin_get_local_option(_id: String, _key: String) -> SyncReturn<Option<String>> {
|
||||
pub fn plugin_get_shared_option(_id: String, _key: String) -> SyncReturn<Option<String>> {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
SyncReturn(crate::plugin::LocalConfig::get(&_id, &_key))
|
||||
SyncReturn(crate::plugin::ipc::get_config(&_id, &_key).unwrap_or(None))
|
||||
}
|
||||
#[cfg(any(
|
||||
not(feature = "plugin_framework"),
|
||||
@@ -1453,11 +1453,11 @@ pub fn plugin_get_local_option(_id: String, _key: String) -> SyncReturn<Option<S
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plugin_set_local_option(_id: String, _key: String, _value: String) {
|
||||
pub fn plugin_set_shared_option(_id: String, _key: String, _value: String) {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
let _res = crate::plugin::LocalConfig::set(&_id, &_key, &_value);
|
||||
allow_err!(crate::plugin::ipc::set_config(&_id, &_key, _value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1466,21 +1466,31 @@ pub fn plugin_reload(_id: String) {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
// to-do:
|
||||
// reload plugin
|
||||
allow_err!(crate::plugin::reload_plugin(&_id));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plugin_id_uninstall(_id: String) {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
// to-do: uninstall plugin
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plugin_id_enable(_id: String, v: bool) {
|
||||
pub fn plugin_id_enable(_id: String, _v: bool) {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
if v {
|
||||
allow_err!(crate::plugin::ManagerConfig::set_plugin_enabled(&_id, true));
|
||||
allow_err!(crate::plugin::ipc::set_manager_plugin_config(
|
||||
&_id,
|
||||
"enable",
|
||||
_v.to_string()
|
||||
));
|
||||
if _v {
|
||||
allow_err!(crate::plugin::reload_plugin(&_id));
|
||||
} else {
|
||||
allow_err!(crate::plugin::ManagerConfig::set_plugin_enabled(&_id, false));
|
||||
crate::plugin::unload_plugin(&_id);
|
||||
}
|
||||
}
|
||||
@@ -1491,7 +1501,10 @@ pub fn plugin_id_is_enabled(_id: String) -> SyncReturn<bool> {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
SyncReturn(
|
||||
crate::plugin::ManagerConfig::get_plugin_status(&_id, |s| s.enabled).unwrap_or(false),
|
||||
match crate::plugin::ipc::get_manager_plugin_config(&_id, "enabled") {
|
||||
Ok(Some(enabled)) => bool::from_str(&enabled).unwrap_or(false),
|
||||
_ => false,
|
||||
},
|
||||
)
|
||||
}
|
||||
#[cfg(any(
|
||||
@@ -1504,12 +1517,15 @@ pub fn plugin_id_is_enabled(_id: String) -> SyncReturn<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plugin_enable(v: bool) {
|
||||
pub fn plugin_enable(_v: bool) {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
allow_err!(crate::plugin::ManagerConfig::set_enabled(v));
|
||||
if v {
|
||||
allow_err!(crate::plugin::ipc::set_manager_config(
|
||||
"enable",
|
||||
_v.to_string()
|
||||
));
|
||||
if _v {
|
||||
allow_err!(crate::plugin::load_plugins());
|
||||
} else {
|
||||
crate::plugin::unload_plugins();
|
||||
@@ -1517,11 +1533,35 @@ pub fn plugin_enable(v: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plugin_is_enabled() -> SyncReturn<bool> {
|
||||
pub fn plugin_is_enabled() -> SyncReturn<Option<bool>> {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
SyncReturn(crate::plugin::ManagerConfig::is_enabled())
|
||||
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<bool> {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
#[cfg(debug_assertions)]
|
||||
let enabled = true;
|
||||
#[cfg(not(debug_assertions))]
|
||||
let enabled = is_installed();
|
||||
SyncReturn(enabled)
|
||||
}
|
||||
#[cfg(any(
|
||||
not(feature = "plugin_framework"),
|
||||
@@ -1533,19 +1573,13 @@ pub fn plugin_is_enabled() -> SyncReturn<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plugin_feature_is_enabled() -> SyncReturn<bool> {
|
||||
pub fn plugin_sync_ui() {
|
||||
#[cfg(feature = "plugin_framework")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
SyncReturn(true)
|
||||
}
|
||||
#[cfg(any(
|
||||
not(feature = "plugin_framework"),
|
||||
target_os = "android",
|
||||
target_os = "ios"
|
||||
))]
|
||||
{
|
||||
SyncReturn(false)
|
||||
if plugin_feature_is_enabled().0 {
|
||||
crate::plugin::sync_ui();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user