cvs commit: qpsmtpd/lib/Qpsmtpd Plugin.pm

[email protected] (Matt Sergeant)
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
cvsuser     03/11/02 03:13:08

  Modified:    lib      Qpsmtpd.pm
               lib/Qpsmtpd Plugin.pm
  Log:
  Don't keep the _qp around - just pass it in to each hook.
  
  Revision  Changes    Path
  1.29      +4 -5      qpsmtpd/lib/Qpsmtpd.pm
  
  Index: Qpsmtpd.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd.pm,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -w -r1.28 -r1.29
  --- Qpsmtpd.pm	23 Oct 2003 08:48:56 -0000	1.28
  +++ Qpsmtpd.pm	2 Nov 2003 11:13:08 -0000	1.29
  @@ -2,7 +2,7 @@
   use strict;
   
   $Qpsmtpd::VERSION = "0.27-dev";
  -sub TRACE_LEVEL { 6 }
  +sub TRACE_LEVEL () { 6 }
   
   use Sys::Hostname;
   use Qpsmtpd::Constants;
  @@ -88,7 +88,6 @@
   }
   
   
  -
   sub load_plugins {
     my $self = shift;
     my @plugins = $self->config('plugins');
  @@ -163,7 +162,7 @@
       my @r;
       for my $code (@{$self->{_hooks}->{$hook}}) {
         $self->log(5, "running plugin ", $code->{name});
  -      eval { (@r) = &{$code->{code}}($self->can('transaction') ? $self->transaction : {}, @_); };
  +      eval { (@r) = $code->{code}->($self, $self->can('transaction') ? $self->transaction : {}, @_); };
         $@ and $self->log(0, "FATAL PLUGIN ERROR: ", $@) and next;
         !defined $r[0] 
   	  and $self->log(1, "plugin ".$code->{name}
  
  
  
  1.4       +2 -1      qpsmtpd/lib/Qpsmtpd/Plugin.pm
  
  Index: Plugin.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Plugin.pm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -r1.3 -r1.4
  --- Plugin.pm	24 Sep 2002 10:56:35 -0000	1.3
  +++ Plugin.pm	2 Nov 2003 11:13:08 -0000	1.4
  @@ -12,10 +12,11 @@
     my ($plugin, $hook, $method) = @_;
     # I can't quite decide if it's better to parse this code ref or if
     # we should pass the plugin object and method name ... hmn.
  -  $plugin->qp->_register_hook($hook, { code => sub { $plugin->$method(@_) },
  +  $plugin->qp->_register_hook($hook, { code => sub { local $plugin->{_qp} = shift; $plugin->$method(@_) },
   				       name => $plugin->plugin_name 
   				     }
   			     );
  +  delete $plugin->{_qp};
   }
   
   sub qp {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.