diff options
-rw-r--r-- | Plugin.pm | 7 | ||||
-rwxr-xr-x | idalius.pl | 17 |
2 files changed, 18 insertions, 6 deletions
@@ -3,7 +3,11 @@ package Plugin; use strict; use warnings; -my $unload_callback; +my $load_callback; + +sub set_load_callback { + ($load_callback) = @_; +}; sub load_plugin { my ($logger, $config, $module) = @_; @@ -19,6 +23,7 @@ sub load_plugin { $logger->($@); return "Cannot load $module: $!"; }; + $load_callback->($module); return undef; } @@ -23,14 +23,11 @@ sub log_info { print "$stamp | @_\n"; } +Plugin::set_load_callback(\&module_loaded_callback); + eval { for my $module (@{$config->{_}->{plugins}}) { Plugin::load_plugin(\&log_info, $config->{_}, $module); - $module->configure( - \®ister_command, - \&run_command, - $config->{$module}, - $config->{_}); } 1; } or do { @@ -85,6 +82,16 @@ drop_priv(); $poe_kernel->run(); +sub module_loaded_callback { + my ($module) = @_; + + $module->configure( + \®ister_command, + \&run_command, + $config->{$module}, + $config->{_}); +} + sub module_is_enabled { my $module = $_[0]; |