Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv4335/Classifier
Modified Files:
Bayes.pm
Log Message:
"Unixification of POPFile"
--------------------------
1. Change command line parsing to use Getopt so that in future
we can have real command line options. In the past an option
was equivalent to a configuration file item. So you could set
module_param value
inside popfile.cfg, but you could also to
popfile.pl -module_param value
on the command line. The new form of the latter is
popfile.pl --set module_param=value
For the ultimate in laziness you can also use the old style
if you precede the first old style parameter with --, e.g.
the old style command line above would work in the new scheme
if specified as follows
popfile.pl -- -module_param value
It is still even possible to use very old style parameters
from pre-OO days of POPFile with the addition of the --
popfile.pl -- -ui_port 8080
2. Make it possible for a module to disable itself and hence be
unloaded. Unloadable modules have an 'enabled' paramter (currently
supported by all proxies (POP3, NNTP and SMTP) and XML-RPC). If
this parameter is 0 then use if to return the value '2' from start()
which indicates to Loader that the module wishes to be removed.
POPFile/Configuration.pm:
Use Getopt to handle new style command line options. Make
parse_command_line return 0 if there's an error.
POPFile/Module.pm:
Update documentation on start().
POPFile/Loader.pm:
Check the return code from start() and if it is 2 unload the module.
Check the return code from parse_command_line so we halt if there's an
error in command-line parsing.
Proxy/Proxy.pm:
Initialize the 'enabled' parameter to 1.
Proxy/POP3.pm
Proxy/SMTP.pm
Proxy/NNTP.pm:
Use the 'enabled' parameter to return 2 from start() so that if we
are not enabled we get unloaded. Also if not enabled don't register
any UI components.
UI/XMLRPC.pm:
Use the 'enabled' parameter to return 2 from start() so that if we
are not enabled we get unloaded. Also if not enabled don't register
any UI components.
Classifier/Bayes.pm:
When classifying a message without saving to disk, still add the
XPL link.
tests.pl:
Code layout clean up.
tests/TestConfiguration.pm:
Update and improve tests for command-line parsing.
tests/TestProxy.pm:
Check for the initial setting of the 'enabled' parameter.
tests/TestPOP3.pm:
Check that the enabled parameter is interpreted by start() to mean
no start and return 2. Make the XTP tests less time sensitive.
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.222
retrieving revision 1.223
diff -C2 -d -r1.222 -r1.223
*** Bayes.pm 10 Nov 2003 19:55:35 -0000 1.222
--- Bayes.pm 10 Nov 2003 20:15:15 -0000 1.223
***************
*** 1591,1595 ****
$xpl .= ":" . $self->module_config_( 'html', 'port' ) . "/jump_to_message?view=$nopath_temp_file$crlf";
! if ( $self->global_config_( 'xpl' ) && ( $self->{parameters__}{$classification}{quarantine} == 0 ) && ( !$nosave ) ) {
$msg_head_after .= 'X-POPFile-Link: ' . $xpl;
}
--- 1591,1595 ----
$xpl .= ":" . $self->module_config_( 'html', 'port' ) . "/jump_to_message?view=$nopath_temp_file$crlf";
! if ( $self->global_config_( 'xpl' ) && ( $self->{parameters__}{$classification}{quarantine} == 0 ) ) {
$msg_head_after .= 'X-POPFile-Link: ' . $xpl;
}
***************
*** 1618,1622 ****
print $client "Subject:$msg_subject$crlf";
print $client "X-Text-Classification: $classification$crlf" if ( $self->global_config_( 'xtc' ) );
! print $client 'X-POPFile-Link: ' . $xpl if ( $self->global_config_( 'xpl' ) && !$nosave );
print $client "MIME-Version: 1.0$crlf";
print $client "Content-Type: multipart/report; boundary=\"$nopath_temp_file\"$crlf$crlf--$nopath_temp_file$crlf";
--- 1618,1622 ----
print $client "Subject:$msg_subject$crlf";
print $client "X-Text-Classification: $classification$crlf" if ( $self->global_config_( 'xtc' ) );
! print $client 'X-POPFile-Link: ' . $xpl if ( $self->global_config_( 'xpl' ) );
print $client "MIME-Version: 1.0$crlf";
print $client "Content-Type: multipart/report; boundary=\"$nopath_temp_file\"$crlf$crlf--$nopath_temp_file$crlf";
***************
*** 1628,1632 ****
print $client "Original Subject: " . $self->{parser__}->get_header('subject') . "$crlf";
print $client "To examine the email open the attachment. ";
! print $client "To change this mail's classification go to $xpl" unless $nosave;
print $client "$crlf";
print $client "The first 20 words found in the email are:$crlf$crlf";
--- 1628,1632 ----
print $client "Original Subject: " . $self->{parser__}->get_header('subject') . "$crlf";
print $client "To examine the email open the attachment. ";
! print $client "To change this mail's classification go to $xpl";
print $client "$crlf";
print $client "The first 20 words found in the email are:$crlf$crlf";
|