2023-05-03 22:37:43 +08:00
|
|
|
// External support for callback.
|
|
|
|
// 1. Support block input for some plugins.
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
const EXT_SUPPORT_BLOCK_INPUT: &str = "block-input";
|
|
|
|
|
|
|
|
pub(super) fn ext_support_callback(
|
|
|
|
id: &str,
|
|
|
|
peer: &str,
|
|
|
|
msg: &super::callback_msg::MsgToExtSupport,
|
2023-05-05 13:37:43 +08:00
|
|
|
) -> PluginReturn {
|
2023-05-03 22:37:43 +08:00
|
|
|
match &msg.r#type as _ {
|
|
|
|
EXT_SUPPORT_BLOCK_INPUT => {
|
|
|
|
// let supported_plugins = [];
|
|
|
|
// let supported = supported_plugins.contains(&id);
|
|
|
|
let supported = true;
|
|
|
|
if supported {
|
2023-05-04 16:27:44 +08:00
|
|
|
if msg.data.len() != 1 {
|
2023-05-05 13:37:43 +08:00
|
|
|
return PluginReturn::new(
|
2023-05-03 22:37:43 +08:00
|
|
|
errno::ERR_CALLBACK_INVALID_ARGS,
|
2023-05-04 16:27:44 +08:00
|
|
|
"Invalid data length",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
let block = msg.data[0] != 0;
|
|
|
|
if crate::server::plugin_block_input(peer, block) == block {
|
2023-05-05 13:37:43 +08:00
|
|
|
PluginReturn::success()
|
2023-05-04 16:27:44 +08:00
|
|
|
} else {
|
2023-05-05 13:37:43 +08:00
|
|
|
PluginReturn::new(errno::ERR_CALLBACK_FAILED, "")
|
2023-05-03 22:37:43 +08:00
|
|
|
}
|
|
|
|
} else {
|
2023-05-05 13:37:43 +08:00
|
|
|
PluginReturn::new(
|
2023-05-03 22:37:43 +08:00
|
|
|
errno::ERR_CALLBACK_PLUGIN_ID,
|
|
|
|
&format!("This operation is not supported for plugin '{}', please contact the RustDesk team for support.", id),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2023-05-05 13:37:43 +08:00
|
|
|
_ => PluginReturn::new(
|
2023-05-03 22:37:43 +08:00
|
|
|
errno::ERR_CALLBACK_TARGET_TYPE,
|
|
|
|
&format!("Unknown target type '{}'", &msg.r#type),
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|