forked from rustdesk/rustdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rustdesk#4107 from fufesou/feat/plugin_framework
plugin framework, handle peer event
- Loading branch information
Showing
10 changed files
with
254 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![allow(dead_code)] | ||
|
||
pub const ERR_SUCCESS: i32 = 0; | ||
|
||
// ====================================================== | ||
// errors that will be handled by RustDesk | ||
|
||
pub const ERR_RUSTDESK_HANDLE_BASE: i32 = 10000; | ||
|
||
// not loaded | ||
pub const ERR_PLUGIN_LOAD: i32 = 10001; | ||
// not initialized | ||
pub const ERR_PLUGIN_MSG_CB: i32 = 10101; | ||
// invalid | ||
pub const ERR_CALL_INVALID_METHOD: i32 = 10201; | ||
pub const ERR_CALL_NOT_SUPPORTED_METHOD: i32 = 10202; | ||
// failed on calling | ||
pub const ERR_CALL_INVALID_ARGS: i32 = 10301; | ||
pub const ERR_PEER_ID_MISMATCH: i32 = 10302; | ||
|
||
// ====================================================== | ||
// errors that should be handled by the plugin | ||
|
||
pub const ERR_PLUGIN_HANDLE_BASE: i32 = 20000; | ||
|
||
pub const EER_CALL_FAILED: i32 = 200021; | ||
pub const ERR_PEER_ON_FAILED: i32 = 30012; | ||
pub const ERR_PEER_OFF_FAILED: i32 = 30012; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
use hbb_common::ResultType; | ||
use std::ffi::{c_char, CStr}; | ||
use std::ffi::{c_char, c_void, CStr}; | ||
|
||
mod callback_msg; | ||
mod config; | ||
pub mod desc; | ||
mod errno; | ||
mod plugins; | ||
|
||
pub use plugins::load_plugins; | ||
pub use plugins::{ | ||
handle_client_event, handle_server_event, handle_ui_event, load_plugin, load_plugins, | ||
reload_plugin, unload_plugin, | ||
}; | ||
|
||
#[inline] | ||
fn cstr_to_string(cstr: *const c_char) -> ResultType<String> { | ||
Ok(String::from_utf8(unsafe { | ||
CStr::from_ptr(cstr).to_bytes().to_vec() | ||
})?) | ||
} | ||
|
||
#[inline] | ||
fn get_code_msg_from_ret(ret: *const c_void) -> (i32, String) { | ||
assert!(ret.is_null() == false); | ||
let code_bytes = unsafe { std::slice::from_raw_parts(ret as *const u8, 4) }; | ||
let code = i32::from_le_bytes([code_bytes[0], code_bytes[1], code_bytes[2], code_bytes[3]]); | ||
let msg = unsafe { CStr::from_ptr((ret as *const u8).add(4) as _) } | ||
.to_str() | ||
.unwrap_or("") | ||
.to_string(); | ||
(code, msg) | ||
} |
Oops, something went wrong.