Merge pull request #4193 from fufesou/feat/plugin_framework
Feat/plugin framework
This commit is contained in:
commit
6fba54d48f
@ -61,7 +61,7 @@ struct MsgToConfig {
|
|||||||
/// content: The content.
|
/// content: The content.
|
||||||
/// len: The length of the content.
|
/// len: The length of the content.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn cb_msg(
|
pub(super) extern "C" fn cb_msg(
|
||||||
peer: *const c_char,
|
peer: *const c_char,
|
||||||
target: *const c_char,
|
target: *const c_char,
|
||||||
id: *const c_char,
|
id: *const c_char,
|
||||||
|
@ -13,7 +13,7 @@ fn is_level(level: *const c_char, level_bytes: &[u8]) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[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() {
|
if level.is_null() || msg.is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ fn load_plugin_path(path: &str) -> ResultType<()> {
|
|||||||
msg: callback_msg::cb_msg,
|
msg: callback_msg::cb_msg,
|
||||||
get_conf: config::cb_get_conf,
|
get_conf: config::cb_get_conf,
|
||||||
get_id: config::cb_get_local_peer_id,
|
get_id: config::cb_get_local_peer_id,
|
||||||
log: super::plog::log,
|
log: super::plog::plugin_log,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
plugin.init(&init_data, path)?;
|
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);
|
let (code, msg) = get_code_msg_from_ret(ret);
|
||||||
free_c_ptr(ret as _);
|
free_c_ptr(ret as _);
|
||||||
if code > ERR_RUSTDESK_HANDLE_BASE && code < ERR_PLUGIN_HANDLE_BASE {
|
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) {
|
let name = match PLUGIN_INFO.read().unwrap().get(id) {
|
||||||
Some(plugin) => plugin.desc.name(),
|
Some(plugin) => plugin.desc.name(),
|
||||||
None => "???",
|
None => "???",
|
||||||
@ -429,7 +435,8 @@ pub fn handle_client_event(id: &str, peer: &str, event: &[u8]) -> Option<Message
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to handle client event, code: {}, msg: {}",
|
"Plugin {} failed to handle client event, code: {}, msg: {}",
|
||||||
|
id,
|
||||||
code,
|
code,
|
||||||
msg
|
msg
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user