cvsuser     04/06/11 13:01:17

  Modified:    lib      Qpsmtpd.pm
               lib/Qpsmtpd Plugin.pm
  Log:
  Add unshift parameter to register_hook, allowing you to put the hook at the
  start of the queue
  
  Revision  Changes    Path
  1.34      +7 -2      qpsmtpd/lib/Qpsmtpd.pm
  
  Index: Qpsmtpd.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd.pm,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -w -r1.33 -r1.34
  --- Qpsmtpd.pm        5 Jun 2004 10:09:30 -0000       1.33
  +++ Qpsmtpd.pm        11 Jun 2004 20:01:17 -0000      1.34
  @@ -241,13 +241,18 @@
   
   sub _register_hook {
     my $self = shift;
  -  my ($hook, $code) = @_;
  +  my ($hook, $code, $unshift) = @_;
   
     #my $plugin = shift;  # see comment in Plugin.pm:register_hook
   
     $self->{_hooks} = $Qpsmtpd::_hooks;
     my $hooks = $self->{_hooks};
  +  if ($unshift) {
  +    unshift @{$hooks->{$hook}}, $code;
  +  }
  +  else {
     push @{$hooks->{$hook}}, $code;
   }
  +}
   
   1;
  
  
  
  1.7       +4 -3      qpsmtpd/lib/Qpsmtpd/Plugin.pm
  
  Index: Plugin.pm
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Plugin.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- Plugin.pm 5 Mar 2004 12:46:23 -0000       1.6
  +++ Plugin.pm 11 Jun 2004 20:01:17 -0000      1.7
  @@ -14,15 +14,16 @@
   }
   
   sub register_hook {
  -  my ($plugin, $hook, $method) = @_;
  +  my ($plugin, $hook, $method, $unshift) = @_;
     
     die $plugin->plugin_name . " : Invalid hook: $hook" unless $hooks{$hook};
   
     # 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 { local $plugin->{_qp} = shift; 
$plugin->$method(@_) },
  -                                    name => $plugin->plugin_name 
  -                                  }
  +                                    name => $plugin->plugin_name,
  +                                  },
  +                                  $unshift,
                             );
   }
   
  
  
  

Reply via email to