
=head1 NAME

Mail::Box::MH::Index - keep index files for messages.

=head1 CLASS INHERITANCE

 Mail::Box::MH::Index
   is a Mail::Reporter

=head1 SYNOPSIS

 my $index = Mail::Box::MH::Index->new;
 $index->read(...)
 $index->write(...)

=head1 DESCRIPTION

Message folders which store their data in one single file per message are
very inefficient for producing subject overviews and for computing message
threads.  The Mail::Box::MH::Index object is able to store and read a the
headers of all messages in one file.

When the Mail::Box::MH::Index functionality is enabled by specifying
C<keep_index> when opening a folder, the index file is automatically read.
When the folder is closed, a new index file is created.

Special care is taken to avoid problems which occur when the user changes
or removes message files without updating the index. If the index is not
trustworthy it will not be used (costing some performance for the reader
of the folder).

=head1 METHODS

=head2 Initiation

=over 4

=item B<new> OPTIONS

(Class method)

 OPTION               DEFAULT
 filename             <obligatory>
 head_type            'Mail::Message::Head::Subset'
 head_wrap            72
 log                  'WARNINGS'
 trace                'WARNINGS'

=over 4

=item B<filename> =E<gt> FILENAME

The FILENAME which is used to store the headers of all the e-mails for
one folder. This must be an absolute pathname.

=item B<head_type> =E<gt> CLASS

The type of headers which will be used to store header information when
it is read from the index file.  You can not be sure the index contains
all header line (the mailbox may have been updated without updating
the index) so this will usually be (an sub-class of)
Mail::Message::Head::Subset.

=item B<head_wrap> =E<gt> INTEGER

The preferred number of character in each header line.

=item B<log> =E<gt> LEVEL

See Mail::Reporter::new(log)

=item B<trace> =E<gt> LEVEL

See Mail::Reporter::new(trace)

=back

=back

=head2 The Index

=over 4

=item B<filename> 

Returns the name of the index file.

=item B<get> MSGFILE

Look if there is header info for the specified MSGFILE.  The filename
represents one message in folder type which are organized as directory.
This method will return an object of the C<head_type> as specified
during creation of the index object, or C<undef> if the information
is not known or not trustworthy -i.e. the file size changed.

=item B<read> 

Read the index file.  The header objects can after this be requested
with the get() method.

=item B<write> MESSAGES

Write an index file containing the headers specified MESSAGES
(Mail::Message objects).

=back

=head2 Logging and Tracing

=over 4

=item B<defaultTrace> [LEVEL, [LEVEL]

See Mail::Reporter::defaultTrace()

=item B<errors> 

See Mail::Reporter::errors()

=item B<log> [LEVEL [,STRINGS]]

See Mail::Reporter::log()

=item B<report> [LEVEL]

See Mail::Reporter::report()

=item B<reportAll> [LEVEL]

See Mail::Reporter::reportAll()

=item B<trace> [LEVEL]

See Mail::Reporter::trace()

=item B<warnings> 

See Mail::Reporter::warnings()

=back

=head2 Other Methods

=over 4

=item B<AUTOLOAD> 

See Mail::Reporter::AUTOLOAD()

=item B<DESTROY> 

See Mail::Reporter::DESTROY()

=item B<inGlobalDestruction> 

See Mail::Reporter::inGlobalDestruction()

=item B<logPriority> LEVEL

See Mail::Reporter::logPriority()

=item B<logSettings> 

See Mail::Reporter::logSettings()

=item B<notImplemented> 

See Mail::Reporter::notImplemented()

=back

=head1 SEE ALSO

A good start to read is Mail::Box-Overview.
More documentation and a mailinglist are available from the project's
website at L<http://perl.overmeer.net/mailbox/>.

=head1 AUTHOR

Written by Mark Overmeer (L<mark@overmeer.net|mailto:mark@overmeer.net>)
with the help of many.  See the ChangeLog for details.

=head1 VERSION

This code is beta, version 2.037.

Copyright (c) 2001-2003 by the authors. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
