Merge pull request #4193 from fufesou/feat/plugin_framework

Feat/plugin framework
This commit is contained in:
RustDesk 2023-04-25 22:39:46 +08:00 committed by GitHub
commit 6fba54d48f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -61,7 +61,7 @@ struct MsgToConfig {
/// content: The content.
/// len: The length of the content.
#[no_mangle]
pub extern "C" fn cb_msg(
pub(super) extern "C" fn cb_msg(
peer: *const c_char,
target: *const c_char,
id: *const c_char,

View File

@ -13,7 +13,7 @@ fn is_level(level: *const c_char, level_bytes: &[u8]) -> bool {
}
#[no_mangle]
pub(super) extern "C" fn log(level: *const c_char, msg: *const c_char) {
pub(super) extern "C" fn plugin_log(level: *const c_char, msg: *const c_char) {
if level.is_null() || msg.is_null() {
return;
}

View File

@ -302,7 +302,7 @@ fn load_plugin_path(path: &str) -> ResultType<()> {
msg: callback_msg::cb_msg,
get_conf: config::cb_get_conf,
get_id: config::cb_get_local_peer_id,
log: super::plog::log,
log: super::plog::plugin_log,
},
};
plugin.init(&init_data, path)?;
@ -409,6 +409,12 @@ pub fn handle_client_event(id: &str, peer: &str, event: &[u8]) -> Option<Message
let (code, msg) = get_code_msg_from_ret(ret);
free_c_ptr(ret as _);
if code > ERR_RUSTDESK_HANDLE_BASE && code < ERR_PLUGIN_HANDLE_BASE {
log::debug!(
"Plugin {} failed to handle client event, code: {}, msg: {}",
id,
code,
msg
);
let name = match PLUGIN_INFO.read().unwrap().get(id) {
Some(plugin) => plugin.desc.name(),
None => "???",
@ -429,7 +435,8 @@ pub fn handle_client_event(id: &str, peer: &str, event: &[u8]) -> Option<Message
}
} else {
log::error!(
"Failed to handle client event, code: {}, msg: {}",
"Plugin {} failed to handle client event, code: {}, msg: {}",
id,
code,
msg
);