[svn:qpsmtpd] rev 533 - in trunk/lib: . Qpsmtpd
[email protected] 29 Jul 2005 18:05:09 -0000
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
Author: msergeant
Date: Fri Jul 29 11:05:08 2005
New Revision: 533
Modified:
trunk/lib/Qpsmtpd.pm
trunk/lib/Qpsmtpd/SMTP.pm
Log:
Migrate transaction(), reset_transaction() and connection() up to Qpsmtpd.pm
Minor bug fix for auth capability
Modified: trunk/lib/Qpsmtpd.pm
==============================================================================
--- trunk/lib/Qpsmtpd.pm (original)
+++ trunk/lib/Qpsmtpd.pm Fri Jul 29 11:05:08 2005
@@ -4,6 +4,8 @@ use vars qw($VERSION $Logger $TraceLevel
use Sys::Hostname;
use Qpsmtpd::Constants;
+use Qpsmtpd::Transaction;
+use Qpsmtpd::Connection;
$VERSION = "0.31-dev";
@@ -255,7 +257,21 @@ sub _load_plugins {
}
sub transaction {
- return {}; # base class implements empty transaction
+ my $self = shift;
+ return $self->{_transaction} || $self->reset_transaction();
+}
+
+sub reset_transaction {
+ my $self = shift;
+ $self->run_hooks("reset_transaction") if $self->{_transaction};
+ return $self->{_transaction} = Qpsmtpd::Transaction->new();
+}
+
+
+sub connection {
+ my $self = shift;
+ @_ and $self->{_connection} = shift;
+ return $self->{_connection} || ($self->{_connection} = Qpsmtpd::Connection->new());
}
sub run_hooks {
Modified: trunk/lib/Qpsmtpd/SMTP.pm
==============================================================================
--- trunk/lib/Qpsmtpd/SMTP.pm (original)
+++ trunk/lib/Qpsmtpd/SMTP.pm Fri Jul 29 11:05:08 2005
@@ -6,8 +6,6 @@ package Qpsmtpd::SMTP;
use strict;
use Carp;
-use Qpsmtpd::Connection;
-use Qpsmtpd::Transaction;
use Qpsmtpd::Plugin;
use Qpsmtpd::Constants;
use Qpsmtpd::Auth;
@@ -32,7 +30,7 @@ sub new {
my $self = bless ({ args => \%args }, $class);
my (@commands) = qw(ehlo helo rset mail rcpt data help vrfy noop quit);
- my (%commands); @commands{@commands} = ('') x @commands;
+ my (%commands); @commands{@commands} = (1) x @commands;
# this list of valid commands should probably be a method or a set of methods
$self->{_commands} = \%commands;
@@ -130,25 +128,6 @@ sub connect_respond {
}
}
-sub transaction {
- my $self = shift;
- return $self->{_transaction} || $self->reset_transaction();
-}
-
-sub reset_transaction {
- my $self = shift;
- $self->run_hooks("reset_transaction") if $self->{_transaction};
- return $self->{_transaction} = Qpsmtpd::Transaction->new();
-}
-
-
-sub connection {
- my $self = shift;
- @_ and $self->{_connection} = shift;
- return $self->{_connection} || ($self->{_connection} = Qpsmtpd::Connection->new());
-}
-
-
sub helo {
my ($self, $hello_host, @stuff) = @_;
return $self->respond (501,
@@ -217,9 +196,7 @@ sub ehlo_respond {
$conn->hello_host($hello_host);
$self->transaction;
- my @capabilities = $self->transaction->notes('capabilities')
- ? @{ $self->transaction->notes('capabilities') }
- : ();
+ my @capabilities = @{ $self->transaction->notes('capabilities') };
# Check for possible AUTH mechanisms
my %auth_mechanisms;
@@ -237,7 +214,7 @@ HOOK: foreach my $hook ( keys %{$self->{
if ( %auth_mechanisms ) {
push @capabilities, 'AUTH '.join(" ",keys(%auth_mechanisms));
- $self->{_commands}->{'auth'} = "";
+ $self->{_commands}->{'auth'} = "1";
}
$self->respond(250,