add ui event

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-04-20 20:57:47 +08:00
parent d9755abbc2
commit 9a08e0bed4
9 changed files with 262 additions and 63 deletions

View File

@@ -1405,6 +1405,54 @@ pub fn plugin_event(_id: String, _event: Vec<u8>) {
}
}
#[inline]
pub fn plugin_get_session_option(_id: String, _peer: String, _key: String) -> SyncReturn<String> {
#[cfg(feature = "plugin_framework")]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
{
return SyncReturn(crate::plugin::PeerConfig::get(&_id, &_peer, &_key));
}
#[cfg(any(
not(feature = "plugin_framework"),
target_os = "android",
target_os = "ios"
))]
return SyncReturn("".to_owned());
}
#[inline]
pub fn plugin_set_session_option(_id: String, _peer: String, _key: String, _value: String) {
#[cfg(feature = "plugin_framework")]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
{
crate::plugin::PeerConfig::set(&_id, &_peer, &_key, &_value);
}
}
#[inline]
pub fn plugin_get_local_option(_id: String, _key: String) -> SyncReturn<String> {
#[cfg(feature = "plugin_framework")]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
{
allow_err!(crate::plugin::LocalConfig::get(&_id, &key));
}
#[cfg(any(
not(feature = "plugin_framework"),
target_os = "android",
target_os = "ios"
))]
return SyncReturn("".to_owned());
}
#[inline]
pub fn plugin_set_local_option(_id: String, _key: String, _value: String) {
#[cfg(feature = "plugin_framework")]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
{
crate::plugin::LocalConfig::set(&_id, &_key, &_value);
}
}
#[cfg(target_os = "android")]
pub mod server_side {
use hbb_common::{config, log};

View File

@@ -15,9 +15,9 @@ lazy_static::lazy_static! {
}
#[derive(Debug, Default, Serialize, Deserialize)]
struct LocalConfig(HashMap<String, String>);
pub struct LocalConfig(HashMap<String, String>);
#[derive(Debug, Default, Serialize, Deserialize)]
struct PeerConfig(HashMap<String, String>);
pub struct PeerConfig(HashMap<String, String>);
type PeersConfig = HashMap<String, PeerConfig>;
#[inline]

View File

@@ -12,6 +12,8 @@ pub use plugins::{
reload_plugin, unload_plugin,
};
pub use config::{LocalConfig, PeerConfig};
#[inline]
fn cstr_to_string(cstr: *const c_char) -> ResultType<String> {
Ok(String::from_utf8(unsafe {