|
From: <jgr...@us...> - 2003-03-03 22:02:09
|
Update of /cvsroot/popfile/engine/Proxy
In directory sc8-pr-cvs1:/tmp/cvs-serv19388/Proxy
Modified Files:
POP3.pm
Log Message:
Fix up the constructors so that they call the parent classes, add new parameter method to POPFile::Configuration, fix up calls to child and flush_child_data for proxies; various other minor tweaks. With this commit POPFile OO is limping along... my guess is the next commit and you'll be able to try it out
Index: POP3.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/POP3.pm,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** POP3.pm 3 Mar 2003 15:21:46 -0000 1.41
--- POP3.pm 3 Mar 2003 22:01:35 -0000 1.42
***************
*** 28,32 ****
{
my $type = shift;
! my $self = {};
# Must call bless before attempting to call any methods
--- 28,32 ----
{
my $type = shift;
! my $self = Proxy::Proxy->new();
# Must call bless before attempting to call any methods
***************
*** 36,39 ****
--- 36,42 ----
$self->name( 'pop3' );
+ $self->{child_} = \&child__;
+ $self->{flush_child_data_} = \&flush_child_data__;
+
return $self;
}
***************
*** 51,81 ****
# Default ports for POP3 service and the user interface
! $self->config_( 'port', 110, 1 );
# Subject modification (global setting is on)
! $self->config_( 'subject', 1, 1 );
# Adding the X-Text-Classification on
! $self->config_( 'xtc', 1, 1 );
# Adding the X-POPFile-Link is no
! $self->config_( 'xpl', 1, 1 );
# There is no default setting for the secure server
! $self->config_( 'server', '', 1 );
! $self->config_( 'sport', 110, 1 );
# The default timeout in seconds for POP3 commands
! $self->config_( 'timeout', 60, 1 );
# Only accept connections from the local machine for POP3
! $self->config_( 'local', 1, 1 ); # TODO localpop
# Whether to do classification on TOP as well
! $self->config_( 'toptoo', 0, 1 );
# Start with no messages downloaded and no error
! $self->config_( 'mcount', 0, 1 );
! $self->config_( 'ecount', 0, 1 );
# This counter is used when creating unique IDs for message stored
--- 54,84 ----
# Default ports for POP3 service and the user interface
! $self->config_( 'port', 110 );
# Subject modification (global setting is on)
! $self->config_( 'subject', 1 );
# Adding the X-Text-Classification on
! $self->config_( 'xtc', 1 );
# Adding the X-POPFile-Link is no
! $self->config_( 'xpl', 1 );
# There is no default setting for the secure server
! $self->config_( 'server', '' );
! $self->config_( 'sport', 110 );
# The default timeout in seconds for POP3 commands
! $self->config_( 'timeout', 60 );
# Only accept connections from the local machine for POP3
! $self->config_( 'local', 1 ); # TODO localpop
# Whether to do classification on TOP as well
! $self->config_( 'toptoo', 0 );
# Start with no messages downloaded and no error
! $self->config_( 'mcount', 0 );
! $self->config_( 'ecount', 0 );
# This counter is used when creating unique IDs for message stored
***************
*** 87,94 ****
# message_count is a local counter within that download, for sorting
# purposes must sort on download_count and then message_count
! $self->config_( 'download_count', 0, 1 );
# The separator within the POP3 username is :
! $self->config_( 'separator', ':', 1 );
return 1;
--- 90,97 ----
# message_count is a local counter within that download, for sorting
# purposes must sort on download_count and then message_count
! $self->config_( 'download_count', 0 );
# The separator within the POP3 username is :
! $self->config_( 'separator', ':' );
return 1;
***************
*** 97,101 ****
# ---------------------------------------------------------------------------------------------
#
! # flush_child_data
#
# Called to flush data from the pipe of each child as we go, I did this because there
--- 100,104 ----
# ---------------------------------------------------------------------------------------------
#
! # flush_child_data__
#
# Called to flush data from the pipe of each child as we go, I did this because there
***************
*** 108,112 ****
#
# ---------------------------------------------------------------------------------------------
! sub flush_child_data
{
my ( $self, $kid, $handle ) = @_;
--- 111,115 ----
#
# ---------------------------------------------------------------------------------------------
! sub flush_child_data__
{
my ( $self, $kid, $handle ) = @_;
***************
*** 121,125 ****
$class =~ s/[\r\n]//g;
! $self->{classifier__}->{parameters}{$class}{count} += 1;
$self->config_( 'mcount' ) += 1;
$stats_changed = 1;
--- 124,128 ----
$class =~ s/[\r\n]//g;
! # TODO $self->{classifier__}->{parameters}{$class}{count} += 1;
$self->config_( 'mcount' ) += 1;
$stats_changed = 1;
***************
*** 145,149 ****
# ---------------------------------------------------------------------------------------------
#
! # child
#
# The worker method that is called when we get a good connection from a client
--- 148,152 ----
# ---------------------------------------------------------------------------------------------
#
! # child__
#
# The worker method that is called when we get a good connection from a client
***************
*** 153,157 ****
#
# ---------------------------------------------------------------------------------------------
! sub child
{
my ( $self, $client, $download_count, $pipe ) = @_;
--- 156,160 ----
#
# ---------------------------------------------------------------------------------------------
! sub child__
{
my ( $self, $client, $download_count, $pipe ) = @_;
***************
*** 164,168 ****
# Tell the client that we are ready for commands and identify our version number
! $self->tee_( $client, "+OK POP3 POPFile (v$self->{configuration}->{major_version}.$self->{configuration}->{minor_version}.$self->{configuration}->{build_version}) server ready$eol" );
# Retrieve commands from the client and process them until the client disconnects or
--- 167,171 ----
# Tell the client that we are ready for commands and identify our version number
! $self->tee_( $client, "+OK POP3 POPFile (vTODO.TODO.TODO) server ready$eol" );
# Retrieve commands from the client and process them until the client disconnects or
***************
*** 184,193 ****
# will pull email from. Doing this means we can act as a proxy for multiple mail clients
# and mail accounts
! if ( $command =~ /USER (.+)(:(\d+))?$self->config_( 'separator' )(.+)/i ) {
if ( $1 ne '' ) {
! if ( $mail = verify_connected( $self, $mail, $client, $1, $3 || 110 ) ) {
# Pass through the USER command with the actual user name for this server,
# and send the reply straight to the client
! echo_response( $self, $mail, $client, 'USER ' . $4 );
} else {
last;
--- 187,197 ----
# will pull email from. Doing this means we can act as a proxy for multiple mail clients
# and mail accounts
! my $user_command = 'USER (.+)(:(\d+))?' . $self->config_( 'separator' ) . '(.+)';
! if ( $command =~ /$user_command/i ) {
if ( $1 ne '' ) {
! if ( $mail = $self->verify_connected_( $mail, $client, $1, $3 || 110 ) ) {
# Pass through the USER command with the actual user name for this server,
# and send the reply straight to the client
! $self->echo_response_($mail, $client, 'USER ' . $4 );
} else {
last;
***************
*** 198,202 ****
}
! flush_extra( $self, $mail, $client, 0 );
next;
}
--- 202,206 ----
}
! $self->flush_extra_( $mail, $client, 0 );
next;
}
***************
*** 204,216 ****
# User is issuing the APOP command to start a session with the remote server
if ( $command =~ /APOP (.*):((.*):)?(.*) (.*)/i ) {
! if ( $mail = verify_connected( $self, $mail, $client, $1, $3 || 110 ) ) {
# Pass through the USER command with the actual user name for this server,
# and send the reply straight to the client
! echo_response( $self, $mail, $client, "APOP $4 $5" );
} else {
last;
}
! flush_extra( $self, $mail, $client, 0 );
next;
}
--- 208,220 ----
# User is issuing the APOP command to start a session with the remote server
if ( $command =~ /APOP (.*):((.*):)?(.*) (.*)/i ) {
! if ( $mail = $self->verify_connected_( $mail, $client, $1, $3 || 110 ) ) {
# Pass through the USER command with the actual user name for this server,
# and send the reply straight to the client
! $self->echo_response_($mail, $client, "APOP $4 $5" );
} else {
last;
}
! $self->flush_extra_( $mail, $client, 0 );
next;
}
***************
*** 219,223 ****
if ( $command =~ /AUTH ([^ ]+)/ ) {
if ( $self->config_( 'server' ) ne '' ) {
! if ( $mail = verify_connected( $self, $mail, $client, $self->config_( 'server' ), $self->config_( 'sport' ) ) ) {
# Loop until we get -ERR or +OK
my $response;
--- 223,227 ----
if ( $command =~ /AUTH ([^ ]+)/ ) {
if ( $self->config_( 'server' ) ne '' ) {
! if ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'server' ), $self->config_( 'sport' ) ) ) {
# Loop until we get -ERR or +OK
my $response;
***************
*** 239,243 ****
}
! flush_extra( $self, $mail, $client, 0 );
} else {
$self->tee_( $client, "-ERR No secure server specified$eol" );
--- 243,247 ----
}
! $self->flush_extra_( $mail, $client, 0 );
} else {
$self->tee_( $client, "-ERR No secure server specified$eol" );
***************
*** 249,255 ****
if ( $command =~ /AUTH/ ) {
if ( $self->config_( 'server' ) ne '' ) {
! if ( $mail = verify_connected( $self, $mail, $client, $self->config_( 'server' ), $self->config_( 'sport' ) ) ) {
! if ( echo_response( $self, $mail, $client, "AUTH" ) ) {
! echo_to_dot_( $self, $mail, $client );
}
} else {
--- 253,259 ----
if ( $command =~ /AUTH/ ) {
if ( $self->config_( 'server' ) ne '' ) {
! if ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'server' ), $self->config_( 'sport' ) ) ) {
! if ( $self->echo_response_($mail, $client, "AUTH" ) ) {
! $self->echo_to_dot_( $mail, $client );
}
} else {
***************
*** 257,261 ****
}
! flush_extra( $self, $mail, $client, 0 );
} else {
$self->tee_( $client, "-ERR No secure server specified$eol" );
--- 261,265 ----
}
! $self->flush_extra_( $mail, $client, 0 );
} else {
$self->tee_( $client, "-ERR No secure server specified$eol" );
***************
*** 268,276 ****
if ( ( $command =~ /LIST ?(.*)?/i ) ||
( $command =~ /UIDL ?(.*)?/i ) ) {
! if ( echo_response( $self, $mail, $client, $command ) ) {
! echo_to_dot_( $self, $mail, $client ) if ( $1 eq '' );
}
! flush_extra( $self, $mail, $client, 0 );
next;
}
--- 272,280 ----
if ( ( $command =~ /LIST ?(.*)?/i ) ||
( $command =~ /UIDL ?(.*)?/i ) ) {
! if ( $self->echo_response_($mail, $client, $command ) ) {
! $self->echo_to_dot_( $mail, $client ) if ( $1 eq '' );
}
! $self->flush_extra_( $mail, $client, 0 );
next;
}
***************
*** 310,316 ****
if ( $2 ne '99999999' ) {
if ( $self->config_( 'toptoo' ) ) {
! if ( echo_response( $self, $mail, $client, "RETR $1" ) ) {
my $class = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 1, '' );
! if ( echo_response( $self, $mail, $client, $command ) ) {
$self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, $class );
--- 314,320 ----
if ( $2 ne '99999999' ) {
if ( $self->config_( 'toptoo' ) ) {
! if ( $self->echo_response_($mail, $client, "RETR $1" ) ) {
my $class = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 1, '' );
! if ( $self->echo_response_($mail, $client, $command ) ) {
$self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, $class );
***************
*** 320,326 ****
}
} else {
! echo_to_dot_( $self, $mail, $client ) if ( echo_response( $self, $mail, $client, $command ) );
}
! flush_extra( $self, $mail, $client, 0 );
next;
}
--- 324,330 ----
}
} else {
! $self->echo_to_dot_( $mail, $client ) if ( $self->echo_response_($mail, $client, $command ) );
}
! $self->flush_extra_( $mail, $client, 0 );
next;
}
***************
*** 333,338 ****
if ( $command =~ /CAPA/i ) {
if ( $self->config_( 'server' ) ne '' ) {
! if ( $mail = verify_connected( $self, $mail, $client, $self->config_( 'server' ), $self->config_( 'sport' ) ) ) {
! echo_to_dot_( $self, $mail, $client ) if ( echo_response( $self, $mail, $client, "CAPA" ) );
} else {
last;
--- 337,342 ----
if ( $command =~ /CAPA/i ) {
if ( $self->config_( 'server' ) ne '' ) {
! if ( $mail = $self->verify_connected_( $mail, $client, $self->config_( 'server' ), $self->config_( 'sport' ) ) ) {
! $self->echo_to_dot_( $mail, $client ) if ( $self->echo_response_($mail, $client, "CAPA" ) );
} else {
last;
***************
*** 342,346 ****
}
! flush_extra( $self, $mail, $client, 0 );
next;
}
--- 346,350 ----
}
! $self->flush_extra_( $mail, $client, 0 );
next;
}
***************
*** 361,366 ****
( $command =~ /DELE (.*)/i ) ||
( $command =~ /RSET/i ) ) {
! echo_response( $self, $mail, $client, $command );
! flush_extra( $self, $mail, $client, 0 );
next;
}
--- 365,370 ----
( $command =~ /DELE (.*)/i ) ||
( $command =~ /RSET/i ) ) {
! $self->echo_response_($mail, $client, $command );
! $self->flush_extra_( $mail, $client, 0 );
next;
}
***************
*** 372,376 ****
# Get the message from the remote server, if there's an error then we're done, but if not then
# we echo each line of the message until we hit the . at the end
! if ( echo_response( $self, $mail, $client, $command ) ) {
$count += 1;
my $class = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, '' );
--- 376,380 ----
# Get the message from the remote server, if there's an error then we're done, but if not then
# we echo each line of the message until we hit the . at the end
! if ( $self->echo_response_($mail, $client, $command ) ) {
$count += 1;
my $class = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, '' );
***************
*** 379,383 ****
print $pipe "$class$eol";
! flush_extra( $self, $mail, $client, 0 );
next;
}
--- 383,387 ----
print $pipe "$class$eol";
! $self->flush_extra_( $mail, $client, 0 );
next;
}
***************
*** 389,393 ****
if ( $command =~ /QUIT/i ) {
if ( $mail ) {
! echo_response( $self, $mail, $client, $command );
close $mail;
} else {
--- 393,397 ----
if ( $command =~ /QUIT/i ) {
if ( $mail ) {
! $self->echo_response_($mail, $client, $command );
close $mail;
} else {
***************
*** 399,404 ****
# Don't know what this is so let's just pass it through and hope for the best
if ( $mail && $mail->connected ) {
! echo_response( $self, $mail, $client, $command );
! flush_extra( $self, $mail, $client, 0 );
next;
} else {
--- 403,408 ----
# Don't know what this is so let's just pass it through and hope for the best
if ( $mail && $mail->connected ) {
! $self->echo_response_($mail, $client, $command );
! $self->flush_extra_( $mail, $client, 0 );
next;
} else {
|