On Wed, 6 Jul 2005, Charlie Brady wrote:

In other good news from YAPC, I got most of STARTTLS support working, with forkserver 0.29. I should be able to post usable patches late this week -
...

One thing I need to do is add some additional state information in the Qpsmtpd::Connection object, and modify slightly what is already there (e.g. I want to be able to unset "hello"). I'd rather not add more cut & paste to what is already there, and would rather use Class::Frame (http://search.cpan.org/~denysv/Class-Frame-1.0/Frame.pm) or something similar.

Thoughts?

Starter patch would be something like this:

--- Connection.pm       (revision 468)
+++ Connection.pm       (working copy)
@@ -1,13 +1,16 @@
 package Qpsmtpd::Connection;
 use strict;

-sub new {
-  my $proto = shift;
-  my $class = ref($proto) || $proto;
-  my $self = {};
-  bless ($self, $class);
-}
+use base qw( Class::Frame );
+use Class::Frame;

+DEFINE_FIELDS(
+    map { $_ => undef }
+        qw(remote_host remote_ip remote_info remote_port
+               local_ip local_port
+               relay_client hello hello_host)
+        );
+
 sub start {
   my $self = shift;
   $self = $self->new(@_) unless ref $self;
@@ -22,61 +25,6 @@
   return $self;
 }

-sub remote_host {
-  my $self = shift;
-  @_ and $self->{_remote_host} = shift;
-  $self->{_remote_host};
-}
-
-sub remote_ip {
-  my $self = shift;
-  @_ and $self->{_remote_ip} = shift;
-  $self->{_remote_ip};
-}
-
-sub remote_port {
-  my $self = shift;
-  @_ and $self->{_remote_port} = shift;
-  $self->{_remote_port};
-}
-
-sub local_ip {
-  my $self = shift;
-  @_ and $self->{_local_ip} = shift;
-  $self->{_local_ip};
-}
-
-sub local_port {
-  my $self = shift;
-  @_ and $self->{_local_port} = shift;
-  $self->{_local_port};
-}
-
-
-sub remote_info {
-  my $self = shift;
-  @_ and $self->{_remote_info} = shift;
-  $self->{_remote_info};
-}
-
-sub relay_client {
-  my $self = shift;
-  @_ and $self->{_relay_client} = shift;
-  $self->{_relay_client};
-}
-
-sub hello {
-  my $self = shift;
-  @_ and $self->{_hello} = shift;
-  $self->{_hello};
-}
-
-sub hello_host {
-  my $self = shift;
-  @_ and $self->{_hello_host} = shift;
-  $self->{_hello_host};
-}
-
 sub notes {
   my $self = shift;
   my $key  = shift;

Reply via email to