| 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::Maildir::Message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | $VERSION = '3.009'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use base 'Mail::Box::Dir::Message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub filename(;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $oldname = $self->SUPER::filename(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return $oldname unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $newname = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | return $newname if defined $oldname && $oldname eq $newname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $oldname and $oldname eq $newname
MC/DC0%0/2
defined $oldname and $oldname eq $newname
defined $oldname
$oldname eq $newname
Truth table0%0/3
A and B
A= defined $oldnameB= $oldname eq $newname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my ($id, $semantics, $flags) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | = $newname =~ m!(.*?)(?:\:([12])\,([A-Za-z]*))! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ? ($1, $2, $3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | : ($newname, '',''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my %flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $flags{$_}++ foreach split //, $flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $self->SUPER::label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ( draft => (delete $flags{D} || 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | , flagged => (delete $flags{F} || 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | , replied => (delete $flags{R} || 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | , seen => (delete $flags{S} || 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | , deleted => (delete $flags{T} || 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | , passed => (delete $flags{P} || 0) # uncommon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
delete $flags{'D'} || 0
delete $flags{'F'} || 0
delete $flags{'R'} || 0
delete $flags{'S'} || 0
delete $flags{'T'} || 0
delete $flags{'P'} || 0
MC/DC0%0/1
delete $flags{'D'} || 0
delete $flags{'D'}
MC/DC0%0/1
delete $flags{'F'} || 0
delete $flags{'F'}
MC/DC0%0/1
delete $flags{'R'} || 0
delete $flags{'R'}
MC/DC0%0/1
delete $flags{'S'} || 0
delete $flags{'S'}
MC/DC0%0/1
delete $flags{'T'} || 0
delete $flags{'T'}
MC/DC0%0/1
delete $flags{'P'} || 0
delete $flags{'P'}
Truth table0%0/2
A
A= delete $flags{'D'}
Truth table0%0/2
A
A= delete $flags{'F'}
Truth table0%0/2
A
A= delete $flags{'R'}
Truth table0%0/2
A
A= delete $flags{'S'}
Truth table0%0/2
A
A= delete $flags{'T'}
Truth table0%0/2
A
A= delete $flags{'P'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | , unknown => join('', sort keys %flags) # application specific | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if(defined $oldname && ! move $oldname, $newname) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $oldname and not move($oldname, $newname)
MC/DC0%0/2
defined $oldname and not move($oldname, $newname)
defined $oldname
not move($oldname, $newname)
Truth table0%0/3
A and not(B)
A= defined $oldnameB= not move($oldname, $newname)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | { $self->log(ERROR => "Cannot move $oldname to $newname: $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->SUPER::filename($newname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | sub guessTimestamp() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
guessTimestamp: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $timestamp = $self->SUPER::guessTimestamp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return $timestamp if defined $timestamp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $self->filename =~ m/^(\d+)/ ? $1 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | sub label(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | return $self->SUPER::label unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $return = $self->SUPER::label(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $self->labelsToFilename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | sub labelsToFilename() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
labelsToFilename: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $labels = $self->labels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $old = $self->filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my ($folderdir, $set, $oldname, $oldflags) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | = $old =~ m!(.*)/(new|cur|tmp)/(.+?)(\:2,[^:]*)?$!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | my $newflags # alphabeticly ordered! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | = ($labels->{draft} ? 'D' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | . ($labels->{flagged} ? 'F' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | . ($labels->{passed} ? 'P' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | . ($labels->{replied} ? 'R' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | . ($labels->{seen} ? 'S' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | . ($labels->{deleted} ? 'T' : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | . ($labels->{unknown} || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition0%0/2
$labels->{'unknown'} || ''
MC/DC0%0/1
$labels->{'unknown'} || ''
$labels->{'unknown'}
Truth table0%0/2
A
A= $labels->{'unknown'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my $newset = $labels->{accepted} ? 'cur' : 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if($set ne $newset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | { my $folder = $self->folder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $folder->modified(1) if defined $folder; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my $flags = $newset ne 'new' || $newflags ne '' ? ":2,$newflags" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$newset ne "new" or $newflags ne ""
MC/DC0%0/2
$newset ne "new" or $newflags ne ""
$newset ne "new"
$newflags ne ""
Truth table0%0/3
A or B
A= $newset ne "new"B= $newflags ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | : $oldflags ? ':2,' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $new = File::Spec->catfile($folderdir, $newset, $oldname.$flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if($new ne $old) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | { unless(move $old, $new) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | { $self->log(ERROR => "Cannot rename $old to $new: $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $self->log(PROGRESS => "Moved $old to $new."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->SUPER::filename($new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | sub accept(;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $accept = @_ ? shift : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $self->label(accepted => $accept); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||