summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
68a4ee3)
or log_headers here.
(filter_mail): .mincfilters, mincspam, and .minchooks are now just one
file, .minc. Now we don't magically know the name of some
spam_start_hook, spam_stop_hook, spam_check, and post_store_hook, but
instead run all the hooks in the @start_hooks, @stop_hooks,
@filter_hooks, and @post_store_hooks lists. Call get_headers and
log_headers here so we can pass them to the hooks.
sub find_mh_folder {
my $msg = shift;
sub find_mh_folder {
my $msg = shift;
my $filterref;
my @filter;
my $header;
my $filterref;
my @filter;
my $header;
my $expression;
my $result;
my $expression;
my $result;
- %headers = get_headers($msg);
if (not %headers) {
return 'malformed';
}
if (not %headers) {
return 'malformed';
}
- log_headers(%headers);
-
# Walk the list of filters. This structure is documented in
# pod at the end of the program.
foreach $filterref (@FILTERS) {
# Walk the list of filters. This structure is documented in
# pod at the end of the program.
foreach $filterref (@FILTERS) {
my $msgnum;
my %FOLDERS = ('SPAM'=>1);
my $msgnum;
my %FOLDERS = ('SPAM'=>1);
- if (-f "$HOME/.mincspam") {
- require "$HOME/.mincspam";
- } else {
- eval "sub spam_start_hook { return (); }";
- eval "sub spam_stop_hook { }";
- eval "sub spam_check { return 0; }";
+ if (-f "$HOME/.minc") {
+ require "$HOME/.minc";
- if (-f "$HOME/.mincfilter") {
- require "$HOME/.mincfilter";
- }
-
- if (-f "$HOME/.minchooks") {
- require "$HOME/.minchooks";
- } else {
- eval "sub post_store_hook { }";
+ our (@start_hooks, @stop_hooks, @filter_hooks, @post_store_hooks);
+ my %batons;
+ for my $hook (@start_hooks) {
+ my ($handle, @baton) = $hook->();
+ if (defined($handle)) {
+ $batons{$handle} = [@baton];
+ }
- @baton = spam_start_hook();
-
foreach $msg (@msglist) {
($msg eq '.' or $msg eq '..') and next;
foreach $msg (@msglist) {
($msg eq '.' or $msg eq '..') and next;
- if (spam_check($msg, @baton)) {
- $mhfolder = 'SPAM';
- $spam = @SPAM + 1;
+ my %headers = get_headers($msg);
+ log_headers(%headers);
+
+ undef($mhfolder);
+ for my $hook (@filter_hooks) {
+ my $result = $hook->(\%batons, \%headers, $msg);
+ defined($result) and ($mhfolder = $result);
+ }
+
+ defined($mhfolder) or ($mhfolder = find_mh_folder($msg, %headers));
+
+ if ($mhfolder eq 'SPAM') {
+ $spam++;
- $mhfolder = find_mh_folder($msg);
$saved++;
}
$msgnum = store_message($msg, $mhfolder);
$saved++;
}
$msgnum = store_message($msg, $mhfolder);
- post_store_hook($mhfolder, $msgnum);
+ for my $hook (@post_store_hooks) {
+ $hook->(\%batons, \%headers, $mhfolder, $msgnum);
+ }
print("\r");
if (not $FOLDERS{$mhfolder}) {
print("\r");
if (not $FOLDERS{$mhfolder}) {
- spam_stop_hook(@baton);
+ for my $hook (@stop_hooks) {
+ $hook->(\%batons);
+ }