-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
+1 looks good to me! - --j. Michael Parker writes: > Howdy, as I've written previously, the LEARN and COLLABREPORT commands > are being replaced by a single TELL command. Here is the latest diff > that implements the TELL command. I'm pretty happy with everything, > even the C portion, which was broken but I've just discovered the > problem so is now ready to go. It has the added benefit that it also > fixes some wonkiness on the Solaris platform with the report/revoke > spamc stuffs (probably bad C code). > > Feel free to take a look, I probably want to clean up the Client.pm > interface a bit, but other than that I believe it is ready to go. If I > don't hear anything in the next day or so I'll go ahead and commit. > > Michael > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.2 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFCiTOnG4km+uS4gOIRAucJAKCSXJQkyRg0VyE1317UFuHxGnnOIgCfT1yf > GKZUE5ohkKwGGZnn1tz4qp0�F9 > -----END PGP SIGNATURE----- > > --=_mail-15291-1116287919-0001-2 > Content-Type: text/plain; name="tell.diff"; charset=iso-8859-1 > Content-Transfer-Encoding: 7bit > Content-Disposition: inline; > filename="tell.diff" > > Index: lib/Mail/SpamAssassin/Client.pm > ==================================================================--- > lib/Mail/SpamAssassin/Client.pm (revision 170485) > +++ lib/Mail/SpamAssassin/Client.pm (working copy) > @@ -219,10 +219,27 @@ > > my $msgsize = length($msg.$EOL); > > - print $remote "LEARN $PROTOVERSION$EOL"; > + print $remote "TELL $PROTOVERSION$EOL"; > print $remote "Content-length: $msgsize$EOL"; > print $remote "User: $self->{username}$EOL" if ($self->{username}); > - print $remote "Learn-type: $learntype$EOL"; > + > + if ($learntype == 0) { > + print $remote "Message-class: spam$EOL"; > + print $remote "Set: local$EOL"; > + } > + elsif ($learntype == 1) { > + print $remote "Message-class: ham$EOL"; > + print $remote "Set: local$EOL"; > + } > + elsif ($learntype == 2) { > + print $remote "Remove: local$EOL"; > + } > + else { # bad learntype > + $self->{resp_code} = 00; > + $self->{resp_msg} = 'do not know'; > + return undef; > + } > + > print $remote "$EOL"; > print $remote $msg; > print $remote "$EOL"; > @@ -236,17 +253,19 @@ > > return undef unless ($resp_code == 0); > > - my $learned_p = 0; > my $found_blank_line_p = 0; > > + my $did_set; > + my $did_remove; > + > while (!$found_blank_line_p) { > $line = <$remote>; > > - if ($line =~ /Learned: yes/i) { > - $learned_p = 1; > + if ($line =~ /DidSet: (.*)/i) { > + $did_set = $1; > } > - elsif ($line =~ /Learned: no/i) { > - $learned_p = 0; > + elsif ($line =~ /DidRemove: (.*)/i) { > + $did_remove = $1; > } > elsif ($line =~ /$EOL/) { > $found_blank_line_p = 1; > @@ -255,7 +274,12 @@ > > close $remote; > > - return $learned_p; > + if ($learntype == 0 || $learntype == 1) { > + return $did_set =~ /local/; > + } > + else { #safe since we've already checked the $learntype values > + return $did_remove =~ /local/; > + } > } > > =head2 report > @@ -270,7 +294,49 @@ > sub report { > my ($self, $msg) = @_; > > - return $self->_report_or_revoke($msg, 0); > + $self->_clear_errors(); > + > + my $remote = $self->_create_connection(); > + > + return undef unless ($remote); > + > + my $msgsize = length($msg.$EOL); > + > + print $remote "TELL $PROTOVERSION$EOL"; > + print $remote "Content-length: $msgsize$EOL"; > + print $remote "User: $self->{username}$EOL" if ($self->{username}); > + print $remote "Message-class: spam$EOL"; > + print $remote "Set: local,remote$EOL"; > + print $remote "$EOL"; > + print $remote $msg; > + print $remote "$EOL"; > + > + my $line = <$remote>; > + > + my ($version, $resp_code, $resp_msg) = $self->_parse_response_line($line); > + > + $self->{resp_code} = $resp_code; > + $self->{resp_msg} = $resp_msg; > + > + return undef unless ($resp_code == 0); > + > + my $reported_p = 0; > + my $found_blank_line_p = 0; > + > + while (!$reported_p && !$found_blank_line_p) { > + $line = <$remote>; > + > + if ($line =~ /DidSet:\s+.*remote/i) { > + $reported_p = 1; > + } > + elsif ($line =~ /^$EOL$/) { > + $found_blank_line_p = 1; > + } > + } > + > + close $remote; > + > + return $reported_p; > } > > =head2 revoke > @@ -285,7 +351,50 @@ > sub revoke { > my ($self, $msg) = @_; > > - return $self->_report_or_revoke($msg, 1); > + $self->_clear_errors(); > + > + my $remote = $self->_create_connection(); > + > + return undef unless ($remote); > + > + my $msgsize = length($msg.$EOL); > + > + print $remote "TELL $PROTOVERSION$EOL"; > + print $remote "Content-length: $msgsize$EOL"; > + print $remote "User: $self->{username}$EOL" if ($self->{username}); > + print $remote "Message-class: ham$EOL"; > + print $remote "Set: local$EOL"; > + print $remote "Remove: remote$EOL"; > + print $remote "$EOL"; > + print $remote $msg; > + print $remote "$EOL"; > + > + my $line = <$remote>; > + > + my ($version, $resp_code, $resp_msg) = $self->_parse_response_line($line); > + > + $self->{resp_code} = $resp_code; > + $self->{resp_msg} = $resp_msg; > + > + return undef unless ($resp_code == 0); > + > + my $revoked_p = 0; > + my $found_blank_line_p = 0; > + > + while (!$revoked_p && !$found_blank_line_p) { > + $line = <$remote>; > + > + if ($line =~ /DidRemove:\s+remote/i) { > + $revoked_p = 1; > + } > + elsif ($line =~ /^$EOL$/) { > + $found_blank_line_p = 1; > + } > + } > + > + close $remote; > + > + return $revoked_p; > } > > > @@ -393,72 +502,5 @@ > $self->{resp_msg} = undef; > } > > - > -=head2 _report_or_revoke > - > -public instance (Boolean) report_or_revoke (String $msg, Integer $reporttype) > - > -Description: > -This method implements the report or revoke call. C<$learntype> should > -be an integer, 0 for report or 1 for revoke. The return value is a > -boolean indicating if the message was learned or not. > - > -An undef return value indicates that there was an error and you > -should check the resp_code/resp_error values to determine what > -the error was. > - > -=cut > - > -sub _report_or_revoke { > - my ($self, $msg, $reporttype) = @_; > - > - $self->_clear_errors(); > - > - my $remote = $self->_create_connection(); > - > - return undef unless ($remote); > - > - my $msgsize = length($msg.$EOL); > - > - print $remote "COLLABREPORT $PROTOVERSION$EOL"; > - print $remote "Content-length: $msgsize$EOL"; > - print $remote "User: $self->{username}$EOL" if ($self->{username}); > - print $remote "CollabReport-type: $reporttype$EOL"; > - print $remote "$EOL"; > - print $remote $msg; > - print $remote "$EOL"; > - > - my $line = <$remote>; > - > - my ($version, $resp_code, $resp_msg) = $self->_parse_response_line($line); > - > - $self->{resp_code} = $resp_code; > - $self->{resp_msg} = $resp_msg; > - > - return undef unless ($resp_code == 0); > - > - my $reported_p = 0; > - my $found_blank_line_p = 0; > - > - while (!$found_blank_line_p) { > - $line = <$remote>; > - > - if ($line =~ /Reported: yes/i) { > - $reported_p = 1; > - } > - elsif ($line =~ /Reported: no/i) { > - $reported_p = 0; > - } > - elsif ($line =~ /$EOL/) { > - $found_blank_line_p = 1; > - } > - } > - > - close $remote; > - > - return $reported_p; > -} > - > - > 1; > > > Property changes on: spamc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Exmh CVS iD8DBQFCiiIbMJF5cimLx9ARAlXZAKClG7EP4DXYAXQbRKrDRNQR2O9xkgCfQSHe 2S5PZlrX7g4ZvYkfeucJhsk= =U2wq -----END PGP SIGNATURE-----
