From cbd0a8ca3557a87a544809782a0804b5476c8175 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Fri, 2 Feb 2007 03:45:37 +0000 Subject: [PATCH] normalize general framework events to be like other events git-svn-id: file:///home/svn/framework3/trunk@4307 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/base/simple/framework.rb | 17 +++++++++++------ lib/msf/core/event_dispatcher.rb | 15 +++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/msf/base/simple/framework.rb b/lib/msf/base/simple/framework.rb index 7fc1a8c62b..eda3312730 100644 --- a/lib/msf/base/simple/framework.rb +++ b/lib/msf/base/simple/framework.rb @@ -36,8 +36,19 @@ module Framework end + # + # We extend modules when we're created, and we do it by registering a + # general event subscriber. + # include GeneralEventSubscriber + # + # Simplifies module instances when they're created. + # + def on_module_created(instance) + Msf::Simple::Framework.simplify_module(instance) + end + ModuleSimplifiers = { MODULE_ENCODER => Msf::Simple::Encoder, @@ -100,12 +111,6 @@ module Framework framework.modules.add_module_path(Msf::Config.user_module_directory) end - # Set the on_module_created procedure to simplify any module - # instance that is created - framework.on_module_created_proc = Proc.new { |instance| - simplify_module(instance) - } - # Register the framework as its own general event subscriber in this # instance framework.events.add_general_subscriber(framework) diff --git a/lib/msf/core/event_dispatcher.rb b/lib/msf/core/event_dispatcher.rb index d9fbb26c01..48e11f7d77 100644 --- a/lib/msf/core/event_dispatcher.rb +++ b/lib/msf/core/event_dispatcher.rb @@ -12,11 +12,14 @@ module GeneralEventSubscriber # # Called when a module is loaded # - attr_accessor :on_module_load_proc + def on_module_load(refname, klass) + end + # # Called when a new module instance is created # - attr_accessor :on_module_created_proc + def on_module_created(instance) + end end ### @@ -128,9 +131,7 @@ class EventDispatcher def on_module_load(name, mod) subscribers_rwlock.synchronize_read { general_event_subscribers.each { |subscriber| - next if (!subscriber.on_module_load_proc) - - subscriber.on_module_load_proc.call(name, mod) + subscriber.on_module_load(name, mod) } } end @@ -142,9 +143,7 @@ class EventDispatcher def on_module_created(instance) subscribers_rwlock.synchronize_read { general_event_subscribers.each { |subscriber| - next if (!subscriber.on_module_created_proc) - - subscriber.on_module_created_proc.call(instance) + subscriber.on_module_created(instance) } } end