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