MailFolder
view release on metacpan or search on metacpan
Mail/Folder.pm view on Meta::CPAN
while (@_) {
my $val = $href->get(shift);
push(@results, $val || '');
}
return (wantarray) ? @results : $results[0];
}
###############################################################################
=head2 append_message($mref)
Add a message to a folder. Given a reference to a C<Mail::Internet>
object, it appends it to the end of the folder. The result is not
committed to the original folder until a C<sync> is performed.
The C<Content-Length> field is added to the written file if the
C<Content-Length> option is enabled.
This method will, under certain circumstances, alter the message
reference that was passed to it. If you are writing a folder
interface, make sure you pass a dup of the message reference when
calling the SUPER of the method. For examples, see the code for the
stock folder interfaces provided with Mail::Folder.
=cut
sub append_message {
my $self = shift;
my $mref = shift;
return 0 if ($self->foldername eq '');
$self->_update_content_length($mref);
return 1;
}
=head2 update_message($msg_number, $mref)
Replaces the message identified by C<$msg_number> with the contents of
the message in reference to a B<Mail::Internet> object C<$mref>.
The result is not committed to the original folder until a C<sync> is
performed.
This method will, under certain circumstances, alter the message
reference that was passed to it. If you are writing a folder
interface, make sure you pass a dup of the message reference when
calling the SUPER of the method. For examples, see the code for the
stock folder interfaces provided with Mail::Folder.
Folder interfaces are expected to perform the following tasks:
=over 2
=item * Call the superclass C<update_message> method.
=item * Replace the specified message in the working copy of the folder.
=back
=cut
sub update_message {
my $self = shift;
my $key = shift;
my $mref = shift;
return 0 if (($self->foldername eq '') ||
!defined($self->{Messages}{$key}));
$self->invalidate_header($key);
$self->_update_content_length($mref) if $self->get_option('Content-Length');
$self->add_label($key, 'edited');
return 1;
}
=head2 refile($msg_number, $folder_ref)
Moves a message from one folder to another. Note that this method
uses C<delete_message> and C<append_message> so the changes will show
up in the folder objects, but will need a C<sync>s performed in order
for the changes to show up in the actual folders.
=cut
sub refile {
my $self = shift;
my $msg = shift;
my $folder = shift;
my $mref = $self->get_message($msg);
return 0 if (!$mref ||
!$folder->append_message($mref) ||
!$self->delete_message($msg));
return 1;
}
=head2 dup($msg_number, $folder_ref)
Copies a message to a folder. Works like C<refile>, but does not
delete the original message. Note that this method uses
C<append_message> so the change will show up in the folder object, but
will need a C<sync> performed in order for the change to show up in
the actual folder.
A fatal error is generated if no folder is currently open or if
C<$msg_number> isn\'t in the folder.
=cut
sub dup {
my $self = shift;
my $msg = shift;
my $folder = shift;
my $mref = $self->get_message($msg);
return($mref && $folder->append_message($mref));
}
###############################################################################
( run in 0.613 second using v1.01-cache-2.11-cpan-39bf76dae61 )