Cover V12, I10
oct2003.tar

Listing 3 Mail::Archive:Manager

package Mail::Archive::Manager;

use Mail::Archive::Account;
use Mail::SpamAssassin;

sub new(@) {
    my $class = shift;
    my %params = @_;
    my @accounts = ();
    my $self = {};

    die unless (exists($params{accounts}));

    $self->{$_} = $params{$_} for (keys %params);

    $self->{spamtest} = Mail::SpamAssassin->new();
    $self->{spamtest}->init_learner();

    $self->{accounts} = [
    map {
        my $account = $_;
        for $default (keys %params) {
            $account->{$default} = $self->{$default} unless 
            (exists $account->{$default});
        }
        $account->{spamtest} = $self->{spamtest};
        Mail::Archive::Account->new(%{$account})
    } (@{$self->{accounts}})
    ];

    bless($self, $class);

    return $self;
}


sub fetch() {
    $self = shift;

    $_->fetch() for (@{$self->{accounts}}); 
}


sub get_accounts {
    $self = shift;

    return $self->{accounts};
}

1;