1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
use strict;
use warnings;
package Mail::Box::Message;
use vars '$VERSION';
$VERSION = '2.068';
use base 'Mail::Message';
use Date::Parse;
use Scalar::Util 'weaken';
#-------------------------------------------
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{MBM_body_type} = $args->{body_type};
$self->{MBM_folder} = $args->{folder};
weaken($self->{MBM_folder});
return $self if $self->isDummy;
$self;
}
#-------------------------------------------
sub head(;$)
{ my $self = shift;
return $self->SUPER::head unless @_;
my $new = shift;
my $old = $self->head;
$self->SUPER::head($new);
return unless defined $new || defined $old;
my $folder = $self->folder
or return $new;
if(!defined $new && defined $old && !$old->isDelayed)
{ $folder->messageId($self->messageId, undef);
$folder->toBeUnthreaded($self);
}
elsif(defined $new && !$new->isDelayed)
{ $folder->messageId($self->messageId, $self);
$folder->toBeThreaded($self);
}
$new || $old;
}
#-------------------------------------------
sub folder(;$)
{ my $self = shift;
if(@_)
{ $self->{MBM_folder} = shift;
weaken($self->{MBM_folder});
$self->modified(1);
}
$self->{MBM_folder};
}
#-------------------------------------------
sub seqnr(;$)
{ my $self = shift;
@_ ? $self->{MBM_seqnr} = shift : $self->{MBM_seqnr};
}
#-------------------------------------------
sub copyTo($@)
{ my ($self, $folder) = (shift, shift);
my $clone = $self->clone(@_);
$folder->addMessage($clone);
}
#-------------------------------------------
sub moveTo($@)
{ my ($self, $folder, %args) = @_;
$args{share} = 1
unless exists $args{share} || exists $args{shallow_body};
my $added = $self->copyTo($folder, %args);
$self->label(deleted => 1);
$added;
}
#-------------------------------------------
sub readBody($$;$)
{ my ($self, $parser, $head, $getbodytype) = @_;
unless($getbodytype)
{ my $folder = $self->{MBM_folder};
$getbodytype = sub {$folder->determineBodyType(@_)} if defined $folder;
}
$self->SUPER::readBody($parser, $head, $getbodytype);
}
#-------------------------------------------
sub diskDelete() { shift }
#-------------------------------------------
sub forceLoad() { # compatibility
my $self = shift;
$self->loadBody(@_);
$self;
}
#-------------------------------------------
sub destruct()
{ require Mail::Box::Message::Destructed;
Mail::Box::Message::Destructed->coerce(shift);
}
#-------------------------------------------
1;
|