aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/plugin')
-rw-r--r--crates/shirabe/src/plugin/plugin_interface.rs8
-rw-r--r--crates/shirabe/src/plugin/plugin_manager.rs6
2 files changed, 8 insertions, 6 deletions
diff --git a/crates/shirabe/src/plugin/plugin_interface.rs b/crates/shirabe/src/plugin/plugin_interface.rs
index ae5e3b6..c0212de 100644
--- a/crates/shirabe/src/plugin/plugin_interface.rs
+++ b/crates/shirabe/src/plugin/plugin_interface.rs
@@ -3,15 +3,17 @@
use crate::composer::ComposerHandle;
use crate::io::IOInterface;
use crate::plugin::Capable;
+use std::cell::RefCell;
+use std::rc::Rc;
pub const PLUGIN_API_VERSION: &'static str = "2.9.0";
pub trait PluginInterface: std::fmt::Debug {
- fn activate(&mut self, composer: &ComposerHandle, io: &dyn IOInterface);
+ fn activate(&mut self, composer: &ComposerHandle, io: Rc<RefCell<dyn IOInterface>>);
- fn deactivate(&mut self, composer: &ComposerHandle, io: &dyn IOInterface);
+ fn deactivate(&mut self, composer: &ComposerHandle, io: Rc<RefCell<dyn IOInterface>>);
- fn uninstall(&mut self, composer: &ComposerHandle, io: &dyn IOInterface);
+ fn uninstall(&mut self, composer: &ComposerHandle, io: Rc<RefCell<dyn IOInterface>>);
fn clone_box(&self) -> Box<dyn PluginInterface> {
todo!()
diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs
index 611ddfa..c917e99 100644
--- a/crates/shirabe/src/plugin/plugin_manager.rs
+++ b/crates/shirabe/src/plugin/plugin_manager.rs
@@ -453,7 +453,7 @@ impl PluginManager {
String::new()
}
));
- plugin.activate(&self.composer_full(), &*self.io.borrow());
+ plugin.activate(&self.composer_full(), self.io.clone());
// TODO(plugin): if plugin is EventSubscriberInterface, hook into the event dispatcher
// The PHP code calls $this->composer->getEventDispatcher()->addSubscriber($plugin);
@@ -480,7 +480,7 @@ impl PluginManager {
self.io
.write_error(&format!("Unloading plugin {}", get_class_obj(plugin)));
let mut removed = self.plugins.remove(index);
- removed.deactivate(&self.composer_full(), &*self.io.borrow());
+ removed.deactivate(&self.composer_full(), self.io.clone());
// TODO(plugin): remove_listener accepts any callable/object in PHP; here we have
// a plugin instance and need to translate to a Callable, which is not portable
@@ -493,7 +493,7 @@ impl PluginManager {
// TODO(plugin): plugin uninstall hook
self.io
.write_error(&format!("Uninstalling plugin {}", get_class_obj(plugin)));
- plugin.uninstall(&self.composer_full(), &*self.io.borrow());
+ plugin.uninstall(&self.composer_full(), self.io.clone());
}
fn load_repository(