| 1 | # Copyrights 2001-2020 by [Mark Overmeer]. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of distribution Mail-Box. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | package Mail::Box; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 34 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 34 | $VERSION = '3.009'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 34 | ▶ | use base 'Mail::Reporter'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 34 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 34 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 34 | ▶ | use Mail::Box::Message; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 34 | ▶ | use Mail::Box::Locker; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 34 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 34 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 34 | ▶ | use Scalar::Util 'weaken'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 34 | ▶ | use List::Util qw/sum first/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 34 | ▶ | use Devel::GlobalDestruction 'in_global_destruction'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | use overload '@{}' => sub { shift->{MB_messages} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | , '""' => 'name' | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 34 | ▶ | , 'cmp' => sub {$_[0]->name cmp "${_[1]}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub new(@) | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 24 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=26.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 24 | ▶ | if($class eq __PACKAGE__) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | { my $package = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | croak <<USAGE; | |||||||||||||||||||||||||||||||||||||||||
| 45 | You should not instantiate $package directly, but rather one of the | ||||||||||||||||||||||||||||||||||||||||||
| 46 | sub-classes, such as Mail::Box::Mbox. If you need automatic folder | ||||||||||||||||||||||||||||||||||||||||||
| 47 | type detection then use Mail::Box::Manager. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 24 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 24 | weaken $args{manager}; # otherwise, the manager object may live too long | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 24 | ▶ | my $self = $class->SUPER::new | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | ( @_ | ||||||||||||||||||||||||||||||||||||||||||
| 56 | , init_options => \%args # for clone | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | $self->read or return | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if $self->{MB_access} =~ /r|a/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$self->{'MB_access'} =~ /r|a/ && ($self->read || (return))
$self->read or return
MC/DC0%0/2
$self->{'MB_access'} =~ /r|a/ && ($self->read || (return))
$self->{'MB_access'} =~ /r|a/
$self->read
Truth table0%0/3
A && B
A= $self->{'MB_access'} =~ /r|a/B= $self->read
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 24 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=28 SCAR=39.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 24 | ▶ | return unless defined $self->SUPER::init($args); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 24 | my $class = ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 24 | ▶ | my $foldername = $args->{folder} || $ENV{MAIL}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args->{'folder'} || $ENV{'MAIL'}
MC/DC0%0/2
$args->{'folder'} || $ENV{'MAIL'}
$args->{'folder'}
$ENV{'MAIL'}
Truth table33%1/3
A || B
A= $args->{'folder'}B= $ENV{'MAIL'}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 24 | ▶ | unless($foldername) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | { $self->log(ERROR => "No folder name specified."); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 24 | $self->{MB_foldername} = $foldername; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 24 | $self->{MB_init_options} = $args->{init_options}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 24 | ▶ | $self->{MB_coerce_opts} = $args->{coerce_options} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'coerce_options'} || []
MC/DC0%0/1
$args->{'coerce_options'} || []
$args->{'coerce_options'}
Truth table50%1/2
A
A= $args->{'coerce_options'}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 24 | ▶ | $self->{MB_access} = $args->{access} || 'r'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{'access'} || 'r'
MC/DC100%1/1
$args->{'access'} || 'r'
$args->{'access'}
Truth table100%2/2
A
A= $args->{'access'}
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | $self->{MB_remove_empty} | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 24 | ▶ | = defined $args->{remove_when_empty} ? $args->{remove_when_empty} : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | $self->{MB_save_on_exit} | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 24 | ▶ | = defined $args->{save_on_exit} ? $args->{save_on_exit} : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 24 | $self->{MB_messages} = []; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 24 | $self->{MB_msgid} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 24 | ▶ | $self->{MB_organization} = $args->{organization} || 'FILE'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'organization'} || 'FILE'
MC/DC0%0/1
$args->{'organization'} || 'FILE'
$args->{'organization'}
Truth table50%1/2
A
A= $args->{'organization'}
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 24 | $self->{MB_linesep} = "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 24 | ▶ | $self->{MB_keep_dups} = !$self->writable || $args->{keep_dups}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!$self->writable || $args->{'keep_dups'}
MC/DC50%1/2
!$self->writable || $args->{'keep_dups'}
!$self->writable
$args->{'keep_dups'}
Truth table66%2/3
not(A) || B
A= !$self->writableB= $args->{'keep_dups'}
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 24 | $self->{MB_fix_headers} = $args->{fix_headers}; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 24 | my $folderdir = $self->folderdir($args->{folderdir}); | |||||||||||||||||||||||||||||||||||||||||
| 95 | $self->{MB_trusted} = exists $args->{trusted} ? $args->{trusted} | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 24 | ▶ | : substr($foldername, 0, 1) eq '=' ? 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | : !defined $folderdir ? 0 | ||||||||||||||||||||||||||||||||||||||||||
| 98 | : substr($foldername, 0, length $folderdir) eq $folderdir; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 24 | ▶ | if(exists $args->{manager}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 10 | { $self->{MB_manager} = $args->{manager}; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 10 | weaken($self->{MB_manager}); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | my $message_type = $self->{MB_message_type} | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 24 | ▶ | = $args->{message_type} || $class . '::Message'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'message_type'} || $class . '::Message'
MC/DC0%0/1
$args->{'message_type'} || $class . '::Message'
$args->{'message_type'}
Truth table50%1/2
A
A= $args->{'message_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | $self->{MB_body_type} | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 24 | ▶ | = $args->{body_type} || 'Mail::Message::Body::Lines'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'body_type'} || 'Mail::Message::Body::Lines'
MC/DC0%0/1
$args->{'body_type'} || 'Mail::Message::Body::Lines'
$args->{'body_type'}
Truth table50%1/2
A
A= $args->{'body_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | $self->{MB_body_delayed_type} | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 24 | ▶ | = $args->{body_delayed_type}|| 'Mail::Message::Body::Delayed'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'body_delayed_type'} || 'Mail::Message::Body::Delayed'
MC/DC0%0/1
$args->{'body_delayed_type'} || 'Mail::Message::Body::Delayed'
$args->{'body_delayed_type'}
Truth table50%1/2
A
A= $args->{'body_delayed_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | $self->{MB_head_delayed_type} | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 24 | ▶ | = $args->{head_delayed_type}|| 'Mail::Message::Head::Delayed'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'head_delayed_type'} || 'Mail::Message::Head::Delayed'
MC/DC0%0/1
$args->{'head_delayed_type'} || 'Mail::Message::Head::Delayed'
$args->{'head_delayed_type'}
Truth table50%1/2
A
A= $args->{'head_delayed_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | $self->{MB_multipart_type} | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 24 | ▶ | = $args->{multipart_type} || 'Mail::Message::Body::Multipart'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'multipart_type'} || 'Mail::Message::Body::Multipart'
MC/DC0%0/1
$args->{'multipart_type'} || 'Mail::Message::Body::Multipart'
$args->{'multipart_type'}
Truth table50%1/2
A
A= $args->{'multipart_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 24 | $self->{MB_field_type} = $args->{field_type}; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | my $headtype = $self->{MB_head_type} | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 24 | ▶ | = $args->{head_type} || 'Mail::Message::Head::Complete'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'head_type'} || 'Mail::Message::Head::Complete'
MC/DC0%0/1
$args->{'head_type'} || 'Mail::Message::Head::Complete'
$args->{'head_type'}
Truth table50%1/2
A
A= $args->{'head_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 24 | ▶ | my $extract = $args->{extract} || 'extractDefault'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{'extract'} || 'extractDefault'
MC/DC100%1/1
$args->{'extract'} || 'extractDefault'
$args->{'extract'}
Truth table100%2/2
A
A= $args->{'extract'}
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | $self->{MB_extract} | ||||||||||||||||||||||||||||||||||||||||||
| 122 | = ref $extract eq 'CODE' ? $extract | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | : $extract eq 'ALWAYS' ? sub {1} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | : $extract eq 'LAZY' ? sub {0} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | : $extract eq 'NEVER' ? sub {1} # compatibility | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 34 | ▶ | : $extract =~ m/\D/ ? sub {no strict 'refs';shift->$extract(@_)} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | : sub { my $size = $_[1]->guessBodySize; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | defined $size && $size < $extract; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 24 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | # | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # Create a locker. | ||||||||||||||||||||||||||||||||||||||||||
| 133 | # | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | $self->{MB_locker} | ||||||||||||||||||||||||||||||||||||||||||
| 136 | = $args->{locker} | ||||||||||||||||||||||||||||||||||||||||||
| 137 | || Mail::Box::Locker->new | ||||||||||||||||||||||||||||||||||||||||||
| 138 | ( folder => $self | ||||||||||||||||||||||||||||||||||||||||||
| 139 | , method => $args->{lock_type} | ||||||||||||||||||||||||||||||||||||||||||
| 140 | , timeout => $args->{lock_timeout} | ||||||||||||||||||||||||||||||||||||||||||
| 141 | , expires => $args->{lock_wait} | ||||||||||||||||||||||||||||||||||||||||||
| 142 | , file => ($args->{lockfile} || $args->{lock_file}) | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 24 | ▶ | , $self->logSettings | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$args->{'locker'} || 'Mail::Box::Locker'->new('folder', $self, 'method', $args->{'lock_type'}, 'timeout', $args->{'lock_timeout'}, 'expires', $args->{'lock_wait'}, 'file', $args->{'lockfile'} || $args->{'lock_file'}, $self->logSettings)
$args->{'lockfile'} || $args->{'lock_file'}
MC/DC0%0/2
$args->{'locker'} || 'Mail::Box::Locker'->new('folder', $self, 'method', $args->{'lock_type'}, 'timeout', $args->{'lock_timeout'}, 'expires', $args->{'lock_wait'}, 'file', $args->{'lockfile'} || $args->{'lock_file'}, $self->logSettings)
$args->{'locker'}
'Mail::Box::Locker'->new('folder', $self, 'method', $args->{'lock_type'}, 'timeout', $args->{'lock_timeout'}, 'expires', $args->{'lock_wait'}, 'file', $args->{'lockfile'} || $args->{'lock_file'}, $self->logSettings)
MC/DC50%1/2
$args->{'lockfile'} || $args->{'lock_file'}
$args->{'lockfile'}
$args->{'lock_file'}
Truth table33%1/3
A || B
A= $args->{'locker'}B= 'Mail::Box::Locker'->new('folder', $self, 'method', $args->{'lock_type'}, 'timeout', $args->{'lock_timeout'}, 'expires', $args->{'lock_wait'}, 'file', $args->{'lockfile'} || $args->{'lock_file'}, $self->logSettings)
Truth table66%2/3
A || B
A= $args->{'lockfile'}B= $args->{'lock_file'}
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | sub folderdir(;$) | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 24 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
folderdir: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 24 | ▶ | $self->{MB_folderdir} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 24 | $self->{MB_folderdir}; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub foundIn($@) { shift->notImplemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foundIn: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 57 | ▶ | sub name() {shift->{MB_foldername}} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub type() {shift->notImplemented} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | sub url() | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
url: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->type . ':' . $self->name; | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | sub size() { sum map { $_->size } shift->messages('ACTIVE') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | sub update(@) | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | $self->updateMessages | ||||||||||||||||||||||||||||||||||||||||||
| 180 | ( trusted => $self->{MB_trusted} | ||||||||||||||||||||||||||||||||||||||||||
| 181 | , head_type => $self->{MB_head_type} | ||||||||||||||||||||||||||||||||||||||||||
| 182 | , field_type => $self->{MB_field_type} | ||||||||||||||||||||||||||||||||||||||||||
| 183 | , message_type => $self->{MB_message_type} | ||||||||||||||||||||||||||||||||||||||||||
| 184 | , body_delayed_type => $self->{MB_body_delayed_type} | ||||||||||||||||||||||||||||||||||||||||||
| 185 | , head_delayed_type => $self->{MB_head_delayed_type} | ||||||||||||||||||||||||||||||||||||||||||
| 186 | , @_ | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub organization() { shift->notImplemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
organization: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | sub addMessage($@) | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addMessage: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | my $message = shift or return $self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | confess <<ERROR if $message->can('folder') && defined $message->folder; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$message->can("folder") and defined $message->folder
MC/DC0%0/2
$message->can("folder") and defined $message->folder
$message->can("folder")
defined $message->folder
Truth table0%0/3
A and B
A= $message->can("folder")B= defined $message->folder
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | You cannot add a message which is already part of a folder to a new | ||||||||||||||||||||||||||||||||||||||||||
| 203 | one. Please use moveTo or copyTo. | ||||||||||||||||||||||||||||||||||||||||||
| 204 | ERROR | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | # Force the message into the right folder-type. | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $coerced = $self->coerce($message); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $coerced->folder($self); | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | unless($coerced->head->isDelayed) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | { # Do not add the same message twice, unless keep_dups. | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $msgid = $coerced->messageId; | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | unless($self->{MB_keep_dups}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | { if(my $found = $self->messageId($msgid)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | { $coerced->label(deleted => 1); | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | return $found; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->messageId($msgid, $coerced); | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $self->toBeThreaded($coerced); | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->storeMessage($coerced); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $coerced; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | sub addMessages(@) | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addMessages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | map $self->addMessage($_), @_; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | sub copyTo($@) | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | { my ($self, $to, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copyTo: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my $select = $args{select} || 'ACTIVE'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'select'} || 'ACTIVE'
MC/DC0%0/1
$args{'select'} || 'ACTIVE'
$args{'select'}
Truth table0%0/2
A
A= $args{'select'}
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $subfolders = exists $args{subfolders} ? $args{subfolders} : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $can_recurse = not $self->isa('Mail::Box::POP3'); | |||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my ($flatten, $recurse) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | = $subfolders eq 'FLATTEN' ? (1, 0) | ||||||||||||||||||||||||||||||||||||||||||
| 245 | : $subfolders eq 'RECURSE' ? (0, 1) | ||||||||||||||||||||||||||||||||||||||||||
| 246 | : !$subfolders ? (0, 0) | ||||||||||||||||||||||||||||||||||||||||||
| 247 | : $can_recurse ? (0, 1) | ||||||||||||||||||||||||||||||||||||||||||
| 248 | : (1, 0); | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $delete = $args{delete_copied} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'delete_copied'} || 0
MC/DC0%0/1
$args{'delete_copied'} || 0
$args{'delete_copied'}
Truth table0%0/2
A
A= $args{'delete_copied'}
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | my $share = $args{share} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'share'} || 0
MC/DC0%0/1
$args{'share'} || 0
$args{'share'}
Truth table0%0/2
A
A= $args{'share'}
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $self->_copy_to($to, $select, $flatten, $recurse, $delete, $share); | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # Interface may change without warning. | ||||||||||||||||||||||||||||||||||||||||||
| 257 | sub _copy_to($@) | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | { my ($self, $to, @options) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_copy_to: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($select, $flatten, $recurse, $delete, $share) = @options; | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $self->log(ERROR => "Destination folder $to is not writable."), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | return unless $to->writable; | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | # Take messages from this folder. | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my @select = $self->messages($select); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $self->log(PROGRESS => | |||||||||||||||||||||||||||||||||||||||||
| 267 | "Copying ".@select." messages from $self to $to."); | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | foreach my $msg (@select) | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | { if($msg->copyTo($to, share => $share)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | { $msg->label(deleted => 1) if $delete } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | else { $self->log(ERROR => "Copying failed for one message.") } | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | return $self unless $flatten || $recurse; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$flatten or $recurse
MC/DC0%0/2
$flatten or $recurse
$flatten
$recurse
Truth table0%0/3
A or B
A= $flattenB= $recurse
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # Take subfolders | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | SUBFOLDER: | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | foreach ($self->listSubFolders(check => 1)) | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | { my $subfolder = $self->openSubFolder($_, access => 'r'); | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | $self->log(ERROR => "Unable to open subfolder $_"), next | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | unless defined $subfolder; | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if($flatten) # flatten | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | { unless($subfolder->_copy_to($to, @options)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | { $subfolder->close; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | else # recurse | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | { my $subto = $to->openSubFolder($_, create => 1, access => 'rw'); | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | unless($subto) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | { $self->log(ERROR => "Unable to create subfolder $_ of $to"); | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | next SUBFOLDER; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | unless($subfolder->_copy_to($subto, @options)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | { $subfolder->close; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $subto->close; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $subto->close; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $subfolder->close; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | sub close(@) | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 28 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=17 SCAR=38.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 28 | ▶ | my $force = $args{force} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'force'} || 0
MC/DC0%0/1
$args{'force'} || 0
$args{'force'}
Truth table50%1/2
A
A= $args{'force'}
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 28 | ▶ | return 1 if $self->{MB_is_closed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 28 | $self->{MB_is_closed}++; | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | # Inform manager that the folder is closed. | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 28 | my $manager = delete $self->{MB_manager}; | |||||||||||||||||||||||||||||||||||||||||
| 323 | $manager->close($self, close_by_self =>1) | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 28 | ▶ | if defined $manager && !$args{close_by_manager}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $manager and not $args{"close_by_manager"}
MC/DC50%1/2
defined $manager and not $args{"close_by_manager"}
defined $manager
not $args{"close_by_manager"}
Truth table66%2/3
A and not(B)
A= defined $managerB= not $args{"close_by_manager"}
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 28 | my $write; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 28 | ▶ | for($args{write} || 'MODIFIED') | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'write'} || 'MODIFIED'
MC/DC0%0/1
$args{'write'} || 'MODIFIED'
$args{'write'}
Truth table50%1/2
A
A= $args{'write'}
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 28 | ▶ | { $write = $_ eq 'MODIFIED' ? $self->isModified | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | : $_ eq 'ALWAYS' ? 1 | ||||||||||||||||||||||||||||||||||||||||||
| 330 | : $_ eq 'NEVER' ? 0 | ||||||||||||||||||||||||||||||||||||||||||
| 331 | : croak "Unknown value to folder->close(write => $_)."; | ||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 28 | my $locker = $self->locker; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 28 | ▶ | if($write && !$force && !$self->writable) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$write and not $force and not $self->writable
$write and not $force
MC/DC0%0/3
$write and not $force and not $self->writable
$write
not $force
not $self->writable
Truth table25%1/4
A and not(B) and not(C)
A= $writeB= not $forceC= not $self->writable
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | { $self->log(WARNING => "Changes not written to read-only folder $self. | |||||||||||||||||||||||||||||||||||||||||
| 337 | Suggestion: \$folder->close(write => 'NEVER')"); | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $locker->unlock if $locker; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $self->{MB_messages} = []; # Boom! | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | my $rc = !$write | ||||||||||||||||||||||||||||||||||||||||||
| 344 | || $self->write | ||||||||||||||||||||||||||||||||||||||||||
| 345 | ( force => $force | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 28 | ▶ | , save_deleted => $args{save_deleted} || 0 | ||||||||||||||||||||||||||||||||||||||||
|
Condition20%1/5
!$write || $self->write('force', $force, 'save_deleted', $args{'save_deleted'} || 0)
$args{'save_deleted'} || 0
MC/DC0%0/2
!$write || $self->write('force', $force, 'save_deleted', $args{'save_deleted'} || 0)
!$write
$self->write('force', $force, 'save_deleted', $args{'save_deleted'} || 0)
MC/DC0%0/1
$args{'save_deleted'} || 0
$args{'save_deleted'}
Truth table33%1/3
not(A) || B
A= !$writeB= $self->write('force', $force, 'save_deleted', $args{'save_deleted'} || 0)
Truth table0%0/2
A
A= $args{'save_deleted'}
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 28 | ▶ | $locker->unlock if $locker; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 28 | $self->{MB_messages} = []; # Boom! | |||||||||||||||||||||||||||||||||||||||||
| 351 | 28 | $rc; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | sub delete(@) | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | my $recurse = exists $args{recursive} ? $args{recursive} : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | # Extra protection: do not remove read-only folders. | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | unless($self->writable) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | { $self->log(ERROR => "Folder $self not deleted: not writable."); | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->close(write => 'NEVER'); | |||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | # Sub-directories need to be removed first. | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if($recurse) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | { foreach ($self->listSubFolders) | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | { my $sub = $self->openRelatedFolder | |||||||||||||||||||||||||||||||||||||||||
| 370 | (folder => "$self/$_", access => 'd', create => 0); | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | defined $sub && $sub->delete(%args); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $self->close(write => 'NEVER'); | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub appendMessages(@) {shift->notImplemented} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
appendMessages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 24 | ▶ | sub writable() {shift->{MB_access} =~ /w|a|d/ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
writable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub writeable() {shift->writable} # compatibility [typo] | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
writeable: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | sub readable() {1} # compatibility | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | sub access() {shift->{MB_access}} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
access: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | sub modified(;$) | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modified: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | return $self->isModified unless @_; # compat 2.036 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | return | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if $self->{MB_modified} = shift; # force modified flag | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | # unmodify all messages | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $_->modified(0) foreach $self->messages; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | sub isModified() | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 28 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isModified: called CC=5 SCAR=21.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 28 | ▶ | return 1 if $self->{MB_modified}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 28 | foreach (@{$self->{MB_messages}}) | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | { return $self->{MB_modified} = 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_->isDeleted or $_->isModified
MC/DC0%0/2
$_->isDeleted or $_->isModified
$_->isDeleted
$_->isModified
Truth table0%0/3
A or B
A= $_->isDeletedB= $_->isModified
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | if $_->isDeleted || $_->isModified; | ||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 28 | 0; | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | sub message(;$$) | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | { my ($self, $index) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | @_ ? $self->{MB_messages}[$index] = shift : $self->{MB_messages}[$index]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | sub messageId($;$) | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | { my ($self, $msgid) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
messageId: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | if($msgid =~ m/\<([^>]+)\>/s ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | { $msgid = $1; | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $msgid =~ s/\s//gs; | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | $self->log(WARNING => "Message-id '$msgid' does not contain a domain.") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | unless index($msgid, '@') >= 0; | ||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | return $self->{MB_msgid}{$msgid} unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | # Undefine message? | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | unless($message) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | { delete $self->{MB_msgid}{$msgid}; | |||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $double = $self->{MB_msgid}{$msgid}; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if(defined $double && !$self->{MB_keep_dups}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $double and not $self->{"MB_keep_dups"}
MC/DC0%0/2
defined $double and not $self->{"MB_keep_dups"}
defined $double
not $self->{"MB_keep_dups"}
Truth table0%0/3
A and not(B)
A= defined $doubleB= not $self->{"MB_keep_dups"}
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | { my $head1 = $message->head; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $head2 = $double->head; | |||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | my $subj1 = $head1->get('subject') || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$head1->get('subject') || ''
MC/DC0%0/1
$head1->get('subject') || ''
$head1->get('subject')
Truth table0%0/2
A
A= $head1->get('subject')
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | my $subj2 = $head2->get('subject') || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$head2->get('subject') || ''
MC/DC0%0/1
$head2->get('subject') || ''
$head2->get('subject')
Truth table0%0/2
A
A= $head2->get('subject')
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | my $to1 = $head1->get('to') || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$head1->get('to') || ''
MC/DC0%0/1
$head1->get('to') || ''
$head1->get('to')
Truth table0%0/2
A
A= $head1->get('to')
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | my $to2 = $head2->get('to') || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$head2->get('to') || ''
MC/DC0%0/1
$head2->get('to') || ''
$head2->get('to')
Truth table0%0/2
A
A= $head2->get('to')
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | # Auto-delete doubles. | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | return $message->label(deleted => 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$subj1 eq $subj2 and $to1 eq $to2
MC/DC0%0/2
$subj1 eq $subj2 and $to1 eq $to2
$subj1 eq $subj2
$to1 eq $to2
Truth table0%0/3
A and B
A= $subj1 eq $subj2B= $to1 eq $to2
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | if $subj1 eq $subj2 && $to1 eq $to2; | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $self->log(WARNING => "Different messages with id $msgid"); | |||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $msgid = $message->takeMessageId(undef); | |||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $self->{MB_msgid}{$msgid} = $message; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | weaken($self->{MB_msgid}{$msgid}); | |||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $message; | |||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | sub messageID(@) {shift->messageId(@_)} # compatibility | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
messageID: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | sub find($) | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | { my ($self, $msgid) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $msgids = $self->{MB_msgid}; | |||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if($msgid =~ m/\<([^>]*)\>/s) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | { $msgid = $1; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $msgid =~ s/\s//gs; | |||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 485 | else | ||||||||||||||||||||||||||||||||||||||||||
| 486 | { # Illegal message-id | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $msgid =~ s/\s/+/gs; | |||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | $self->scanForMessages(undef, $msgid, 'EVER', 'ALL') | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | unless exists $msgids->{$msgid}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $msgids->{$msgid}; | |||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | sub messages($;$) | ||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
messages: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | return @{$self->{MB_messages}} unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $nr = @{$self->{MB_messages}}; | |||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if(@_==2) # range | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | { my ($begin, $end) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | $begin += $nr if $begin < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | $begin = 0 if $begin < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | $end += $nr if $end < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | $end = $nr-1 if $end >= $nr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | return () if $begin > $end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my @range = @{$self->{MB_messages}}[$begin..$end]; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | return @range; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $what = shift; | |||||||||||||||||||||||||||||||||||||||||
| 517 | my $action | ||||||||||||||||||||||||||||||||||||||||||
| 518 | = ref $what eq 'CODE'? $what | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | : $what eq 'DELETED' ? sub {$_[0]->isDeleted} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | : $what eq 'ACTIVE' ? sub {not $_[0]->isDeleted} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | : $what eq 'ALL' ? sub {1} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | : $what =~ s/^\!// ? sub {not $_[0]->label($what)} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | : sub {$_[0]->label($what)}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | grep {$action->($_)} @{$self->{MB_messages}}; | |||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub nrMessages(@) { scalar shift->messages(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nrMessages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | sub messageIds() { map {$_->messageId} shift->messages } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
messageIds: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | sub allMessageIds() {shift->messageIds} # compatibility | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allMessageIds: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | sub allMessageIDs() {shift->messageIds} # compatibility | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allMessageIDs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | sub current(;$) | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | unless(@_) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | { return $self->{MB_current} | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | if exists $self->{MB_current}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | # Which one becomes current? | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | my $current | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$self->findFirstLabeled('current', 1) || $self->findFirstLabeled('seen', 0) || $self->message(-1) || (return undef)
$self->findFirstLabeled("current", 1) or $self->findFirstLabeled("seen", 0) or $self->message(-1)
$self->findFirstLabeled("current", 1) or $self->findFirstLabeled("seen", 0)
MC/DC0%0/3
$self->findFirstLabeled('current', 1) || $self->findFirstLabeled('seen', 0) || $self->message(-1) || (return undef)
$self->findFirstLabeled("current", 1)
$self->findFirstLabeled("seen", 0)
$self->message(-1)
Truth table0%0/4
A or B or C
A= $self->findFirstLabeled("current", 1)B= $self->findFirstLabeled("seen", 0)C= $self->message(-1)
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | = $self->findFirstLabeled(current => 1) | ||||||||||||||||||||||||||||||||||||||||||
| 547 | || $self->findFirstLabeled(seen => 0) | ||||||||||||||||||||||||||||||||||||||||||
| 548 | || $self->message(-1) | ||||||||||||||||||||||||||||||||||||||||||
| 549 | || return undef; | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $current->label(current => 1); | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $self->{MB_current} = $current; | |||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | return $current; | |||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my $next = shift; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if(my $previous = $self->{MB_current}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | { $previous->label(current => 0); | |||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ($self->{MB_current} = $next)->label(current => 1); | |||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $next; | |||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | sub scanForMessages($$$$) | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | { my ($self, $startid, $msgids, $moment, $window) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scanForMessages: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | # Set-up msgid-list | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | my %search = map +($_ => 1), ref $msgids ? @$msgids : $msgids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | return () unless keys %search; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | # do not run on empty folder | ||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | my $nr_messages = $self->messages | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | or return keys %search; | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | my $startmsg = defined $startid ? $self->messageId($startid) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | # Set-up window-bound. | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my $bound = 0; | |||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | if($window ne 'ALL' && defined $startmsg) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$window ne "ALL" and defined $startmsg
MC/DC0%0/2
$window ne "ALL" and defined $startmsg
$window ne "ALL"
defined $startmsg
Truth table0%0/3
A and B
A= $window ne "ALL"B= defined $startmsg
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | { $bound = $startmsg->seqnr - $window; | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | $bound = 0 if $bound < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | my $last = ($self->{MBM_last} || $nr_messages) -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'MBM_last'} || $nr_messages
MC/DC0%0/2
$self->{'MBM_last'} || $nr_messages
$self->{'MBM_last'}
$nr_messages
Truth table0%0/3
A || B
A= $self->{'MBM_last'}B= $nr_messages
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | return keys %search if defined $bound && $bound > $last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $bound and $bound > $last
MC/DC0%0/2
defined $bound and $bound > $last
defined $bound
$bound > $last
Truth table0%0/3
A and B
A= defined $boundB= $bound > $last
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | # Set-up time-bound | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | my $after = $moment eq 'EVER' ? 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | : $moment =~ m/^\d+$/ ? $moment | ||||||||||||||||||||||||||||||||||||||||||
| 592 | : !$startmsg ? 0 | ||||||||||||||||||||||||||||||||||||||||||
| 593 | : $startmsg->timestamp - $self->timespan2seconds($moment); | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | while($last >= $bound) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | { my $message = $self->message($last); | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $msgid = $message->messageId; # triggers load | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if(delete $search{$msgid}) # where we looking for this one? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | { last unless keys %search; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | last if $message->timestamp < $after; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $last--; | |||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $self->{MBM_last} = $last; | |||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | keys %search; | |||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | sub findFirstLabeled($;$$) | ||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | { my ($self, $label, $set, $msgs) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
findFirstLabeled: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | if(!defined $set || $set) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $set or $set
MC/DC0%0/2
not defined $set or $set
not defined $set
$set
Truth table0%0/3
not(A) or B
A= not defined $setB= $set
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | { my $f = first { $_->label($label) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | (defined $msgs ? @$msgs : $self->messages); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||
| 619 | else | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | { return first { not $_->label($label) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | (defined $msgs ? @$msgs : $self->messages); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | sub listSubFolders(@) { () } # by default no sub-folders | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listSubFolders: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | sub openRelatedFolder(@) | ||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
openRelatedFolder: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my @options = (%{$self->{MB_init_options}}, @_); | |||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | $self->{MB_manager} | ||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | ? $self->{MB_manager}->open(type => ref($self), @options) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | : (ref $self)->new(@options); | ||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | sub openSubFolder($@) | ||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
openSubFolder: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my $name = $self->nameOfSubFolder(shift); | |||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $self->openRelatedFolder(@_, folder => $name); | |||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | sub nameOfSubFolder($;$) | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | { my ($thing, $name) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nameOfSubFolder: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | my $parent = @_ ? shift : ref $thing ? $thing->name : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | defined $parent ? "$parent/$name" : $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | sub topFolderWithMessages() { 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | sub read(@) | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $self->{MB_open_time} = time; | |||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | local $self->{MB_lazy_permitted} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | # Read from existing folder. | ||||||||||||||||||||||||||||||||||||||||||
| 667 | return unless $self->readMessages | ||||||||||||||||||||||||||||||||||||||||||
| 668 | ( trusted => $self->{MB_trusted} | ||||||||||||||||||||||||||||||||||||||||||
| 669 | , head_type => $self->{MB_head_type} | ||||||||||||||||||||||||||||||||||||||||||
| 670 | , field_type => $self->{MB_field_type} | ||||||||||||||||||||||||||||||||||||||||||
| 671 | , message_type => $self->{MB_message_type} | ||||||||||||||||||||||||||||||||||||||||||
| 672 | , body_delayed_type => $self->{MB_body_delayed_type} | ||||||||||||||||||||||||||||||||||||||||||
| 673 | , head_delayed_type => $self->{MB_head_delayed_type} | ||||||||||||||||||||||||||||||||||||||||||
| 674 | , @_ | ||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | if($self->{MB_modified}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | { $self->log(INTERNAL => "Modified $self->{MB_modified}"); | |||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $self->{MB_modified} = 0; #after reading, no changes found yet. | |||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | sub write(@) | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | unless($args{force} || $self->writable) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"force"} or $self->writable
MC/DC0%0/2
$args{"force"} or $self->writable
$args{"force"}
$self->writable
Truth table0%0/3
A or B
A= $args{"force"}B= $self->writable
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | { $self->log(ERROR => "Folder $self is opened read-only."); | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | my (@keep, @destroy); | |||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | if($args{save_deleted}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | { @keep = $self->messages; | |||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | else | ||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | { foreach ($self->messages) | |||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | { if($_->isDeleted) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | { push @destroy, $_; | |||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | $_->diskDelete; | |||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | else {push @keep, $_} | |||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | unless(@destroy || $self->isModified) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@destroy or $self->isModified
MC/DC0%0/2
@destroy or $self->isModified
@destroy
$self->isModified
Truth table0%0/3
A or B
A= @destroyB= $self->isModified
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | { $self->log(PROGRESS => "Folder $self not changed, so not updated."); | |||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | $args{messages} = \@keep; | |||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | unless($self->writeMessages(\%args)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | { $self->log(WARNING => "Writing folder $self failed."); | |||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | $self->modified(0); | |||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | $self->{MB_messages} = \@keep; | |||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | sub determineBodyType($$) | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | { my ($self, $message, $head) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
determineBodyType: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | return $self->{MB_body_delayed_type} | ||||||||||||||||||||||||||||||||||||||||||
| 732 | if $self->{MB_lazy_permitted} | ||||||||||||||||||||||||||||||||||||||||||
| 733 | && ! $message->isPart | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | && ! $self->{MB_extract}->($self, $head); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"MB_lazy_permitted"} and not $message->isPart and not $self->{"MB_extract"}->($self, $head)
$self->{"MB_lazy_permitted"} and not $message->isPart
MC/DC0%0/3
$self->{"MB_lazy_permitted"} and not $message->isPart and not $self->{"MB_extract"}->($self, $head)
$self->{"MB_lazy_permitted"}
not $message->isPart
not $self->{"MB_extract"}->($self, $head)
Truth table0%0/4
A and not(B) and not(C)
A= $self->{"MB_lazy_permitted"}B= not $message->isPartC= not $self->{"MB_extract"}->($self, $head)
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $bodytype = $self->{MB_body_type}; | |||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | ref $bodytype ? $bodytype->($head) : $bodytype; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | sub extractDefault($) | ||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | { my ($self, $head) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractDefault: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | my $size = $head->guessBodySize; | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | defined $size ? $size < 10000 : 0 # immediately extract < 10kb | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | sub lazyPermitted($) | ||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lazyPermitted: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $self->{MB_lazy_permitted} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | sub storeMessage($) | ||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | { my ($self, $message) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
storeMessage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | push @{$self->{MB_messages}}, $message; | |||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | $message->seqnr( @{$self->{MB_messages}} -1); | |||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | $message; | |||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | 34 | my %seps = (CR => "\015", LF => "\012", CRLF => "\015\012"); | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | sub lineSeparator(;$) | ||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lineSeparator: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | return $self->{MB_linesep} unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my $sep = shift; | |||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | ▶ | $sep = $seps{$sep} if exists $seps{$sep}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | $self->{MB_linesep} = $sep; | |||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | $_->lineSeparator($sep) foreach $self->messages; | |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | $sep; | |||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | sub create($@) {shift->notImplemented} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | sub coerce($@) | ||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | ▶ | { my ($self, $message) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coerce: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | my $mmtype = $self->{MB_message_type}; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ▶ | $message->isa($mmtype) ? $message : $mmtype->coerce($message, @_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | sub readMessages(@) {shift->notImplemented} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readMessages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | sub updateMessages(@) { shift } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
updateMessages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | sub writeMessages(@) {shift->notImplemented} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
writeMessages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | 28 | ▶ | sub locker() { shift->{MB_locker} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locker: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | sub toBeThreaded(@) | ||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toBeThreaded: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | my $manager = $self->{MB_manager} | ||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | or return $self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $manager->toBeThreaded($self, @_); | |||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||
| 810 | sub toBeUnthreaded(@) | ||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toBeUnthreaded: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | my $manager = $self->{MB_manager} | ||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | or return $self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | $manager->toBeThreaded($self, @_); | |||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | sub timespan2seconds($) | ||||||||||||||||||||||||||||||||||||||||||
| 824 | { | ||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | if( $_[1] =~ /^\s*(\d+\.?\d*|\.\d+)\s*(hour|day|week)s?\s*$/ ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timespan2seconds: not called CC=4 SCAR=30.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | { $2 eq 'hour' ? $1 * 3600 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 827 | : $2 eq 'day' ? $1 * 86400 | ||||||||||||||||||||||||||||||||||||||||||
| 828 | : $1 * 604800; # week | ||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||
| 830 | else | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | { $_[0]->log(ERROR => "Invalid timespan '$_' specified."); | |||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||
| 836 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||
| 839 | sub DESTROY | ||||||||||||||||||||||||||||||||||||||||||
| 840 | 28 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||
| 841 | 28 | ▶ | $self->close unless in_global_destruction || $self->{MB_is_closed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&in_global_destruction() or $self->{"MB_is_closed"}
MC/DC0%0/2
&in_global_destruction() or $self->{"MB_is_closed"}
&in_global_destruction()
$self->{"MB_is_closed"}
Truth table33%1/3
A or B
A= &in_global_destruction()B= $self->{"MB_is_closed"}
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||
| 847 | 34 | 1; | |||||||||||||||||||||||||||||||||||||||||