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