plugin_framework, return C structure

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-05-05 13:37:43 +08:00
parent 357028b222
commit 8f0d696304
5 changed files with 95 additions and 108 deletions

View File

@@ -3,7 +3,6 @@
// -----------------------------------------------------------------------------
use super::*;
use std::{ffi::c_void, ptr::null};
const EXT_SUPPORT_BLOCK_INPUT: &str = "block-input";
@@ -11,7 +10,7 @@ pub(super) fn ext_support_callback(
id: &str,
peer: &str,
msg: &super::callback_msg::MsgToExtSupport,
) -> *const c_void {
) -> PluginReturn {
match &msg.r#type as _ {
EXT_SUPPORT_BLOCK_INPUT => {
// let supported_plugins = [];
@@ -19,25 +18,25 @@ pub(super) fn ext_support_callback(
let supported = true;
if supported {
if msg.data.len() != 1 {
return make_return_code_msg(
return PluginReturn::new(
errno::ERR_CALLBACK_INVALID_ARGS,
"Invalid data length",
);
}
let block = msg.data[0] != 0;
if crate::server::plugin_block_input(peer, block) == block {
null()
PluginReturn::success()
} else {
make_return_code_msg(errno::ERR_CALLBACK_FAILED, "")
PluginReturn::new(errno::ERR_CALLBACK_FAILED, "")
}
} else {
make_return_code_msg(
PluginReturn::new(
errno::ERR_CALLBACK_PLUGIN_ID,
&format!("This operation is not supported for plugin '{}', please contact the RustDesk team for support.", id),
)
}
}
_ => make_return_code_msg(
_ => PluginReturn::new(
errno::ERR_CALLBACK_TARGET_TYPE,
&format!("Unknown target type '{}'", &msg.r#type),
),