plugin_framework, flutter event handlers

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-04-21 21:40:34 +08:00
parent ae6d80cebe
commit 67413b7419
15 changed files with 301 additions and 192 deletions

View File

@@ -14,6 +14,9 @@ lazy_static::lazy_static! {
static ref CONFIG_PEER_ITEMS: Arc<Mutex<HashMap<String, Vec<ConfigItem>>>> = Default::default();
}
pub(super) const CONFIG_TYPE_LOCAL: &str = "local";
pub(super) const CONFIG_TYPE_PEER: &str = "peer";
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct LocalConfig(HashMap<String, String>);
#[derive(Debug, Default, Serialize, Deserialize)]
@@ -72,14 +75,6 @@ impl LocalConfig {
CONFIG_LOCAL.lock().unwrap().insert(id.to_owned(), conf);
}
#[inline]
fn save(id: &str) -> ResultType<()> {
match CONFIG_LOCAL.lock().unwrap().get(id) {
Some(config) => hbb_common::config::store_path(Self::path(id), config),
None => bail!("No such plugin {}", id),
}
}
#[inline]
pub fn get(id: &str, key: &str) -> Option<String> {
if let Some(conf) = CONFIG_LOCAL.lock().unwrap().get(id) {
@@ -136,17 +131,6 @@ impl PeerConfig {
}
}
#[inline]
fn save(id: &str, peer: &str) -> ResultType<()> {
match CONFIG_PEERS.lock().unwrap().get(id) {
Some(peers) => match peers.get(peer) {
Some(config) => hbb_common::config::store_path(Self::path(id, peer), config),
None => bail!("No such peer {}", peer),
},
None => bail!("No such plugin {}", id),
}
}
#[inline]
pub fn get(id: &str, peer: &str, key: &str) -> Option<String> {
if let Some(peers) = CONFIG_PEERS.lock().unwrap().get(id) {