Changeset 5987370
- Timestamp:
- Aug 20, 2008, 2:16:36 AM (16 years ago)
- Branches:
- master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 167044b
- Parents:
- e9bb404
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/ModuleLoader.pm
r965e14d r5987370 8 8 use PAR (BarnOwl::get_config_dir() . "/modules/*.par"); 9 9 10 our %modules; 11 10 12 sub load_all { 13 my $class = shift; 14 $class->rescan_modules; 15 16 for my $mod (keys %modules) { 17 if(!defined eval "use BarnOwl::Module::$mod") { 18 BarnOwl::error("Unable to load module $mod: \n$@\n") if $@; 19 } 20 } 21 22 $BarnOwl::Hooks::startup->add(\®ister_keybindings); 23 } 24 25 sub rescan_modules { 11 26 PAR::reload_libs(); 12 27 PAR->import(BarnOwl::get_data_dir() . "/modules/*.par"); 13 28 PAR->import(BarnOwl::get_config_dir() . "/modules/*.par"); 14 my %modules;15 29 my @modules; 30 31 %modules = (); 16 32 17 33 my @moddirs = (); … … 37 53 } 38 54 } 39 for my $class (keys %modules) { 40 if(!defined eval "use BarnOwl::Module::$class") { 41 # BarnOwl::error("Unable to load module $class: $!") if $!; 42 BarnOwl::error("Unable to load module $class: \n$@\n") if $@; 43 } 55 } 56 57 sub reload_module { 58 my $class = shift; 59 my $module = shift; 60 61 $class->rescan_modules(); 62 63 for my $m (keys %INC) { 64 delete $INC{$m} if $m =~ m{^BarnOwl/Module/$module}; 44 65 } 45 66 46 $BarnOwl::Hooks::startup->add(\®ister_keybindings); 67 local $SIG{__WARN__} = \&squelch_redefine; 68 if(!defined eval "use BarnOwl::Module::$module") { 69 BarnOwl::error("Unable to load module $module: \n$@\n") if $@; 70 } 71 } 72 73 sub reload_cmd { 74 my $class = shift; 75 shift; # Command 76 my $module = shift; 77 unless(defined($module)) { 78 die("Usage: reload [MODULE]"); 79 }; 80 $class->reload_module($module); 47 81 } 48 82 … … 52 86 usage => 'reload-modules', 53 87 description => q{Reloads all modules located in ~/.owl/modules and the system modules directory} 88 }); 89 BarnOwl::new_command('reload', sub {BarnOwl::ModuleLoader->reload_cmd(@_)}, { 90 summary => 'Reload one module', 91 usage => 'reload [MODULE]', 92 description => q{Reloads a single module located in ~/.owl/modules or the system modules directory} 54 93 }); 55 94 }
Note: See TracChangeset
for help on using the changeset viewer.