| 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::File::Message;{ | ||||||||||||||||||||
| 13 | 25 | our $VERSION = '4.02'; | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 25 | ▶ | use parent 'Mail::Box::Message'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 25 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 25 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 25 | ▶ | use Log::Report 'mail-box', import => [ qw/__x error trace/ ]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 25 | ▶ | use List::Util qw/sum/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | #-------------------- | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | sub init($) | ||||||||||||||||||||
| 28 | 1304 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 29 | 1304 | $self->SUPER::init($args); | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 1304 | ▶ | $self->fromLine($args->{from_line}) if exists $args->{from_line}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 1304 | $self; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | #-------------------- | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | sub fromLine(;$) | ||||||||||||||||||||
| 37 | 171 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
fromLine: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||
| 38 | 171 | ▶ | $self->{MBMM_from_line} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 171 | ▶ | $self->{MBMM_from_line} ||= $self->head->createFromLine; | ||||||||||||||||||
|
Condition66%2/3
$self->{"MBMM_from_line"} ||= $self->head->createFromLine
MC/DC0%0/2
$self->{"MBMM_from_line"} ||= $self->head->createFromLine
$self->{"MBMM_from_line"}
$self->head->createFromLine
Truth table66%2/3
A ||= B
A= $self->{"MBMM_from_line"}B= $self->head->createFromLine
| |||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | #-------------------- | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | sub coerce($) | ||||||||||||||||||||
| 45 | 98 | ▶ | { my ($self, $message) = @_; | ||||||||||||||||||
|
Subroutine
coerce: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 46 | 98 | ▶ | $message->isa(__PACKAGE__) ? $message : $self->SUPER::coerce($message)->labelsToStatus; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | sub write(;$) | ||||||||||||||||||||
| 51 | 126 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
write: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||
| 52 | 126 | ▶ | my $out = shift || select; | ||||||||||||||||||
|
Condition33%1/3
shift() || select()
MC/DC0%0/2
shift() || select()
shift()
select()
Truth table33%1/3
A || B
A= shift()B= select()
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 126 | my $escaped = $self->escapedBody; | |||||||||||||||||||
| 55 | 126 | $out->print($self->fromLine); | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 126 | my $size = sum 0, map length, @$escaped; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 126 | my $head = $self->head; | |||||||||||||||||||
| 60 | 126 | $head->set('Content-Length' => $size); | |||||||||||||||||||
| 61 | 126 | $head->set('Lines' => scalar @$escaped); | |||||||||||||||||||
| 62 | 126 | $head->print($out); | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 126 | $out->print($_) for @$escaped; | |||||||||||||||||||
| 65 | 126 | $out->print("\n"); | |||||||||||||||||||
| 66 | 126 | $self; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | sub clone() | ||||||||||||||||||||
| 70 | 45 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 71 | 45 | my $clone = $self->SUPER::clone; | |||||||||||||||||||
| 72 | 45 | $clone->{MBMM_from_line} = $self->fromLine; | |||||||||||||||||||
| 73 | 45 | $clone; | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | sub escapedBody() | ||||||||||||||||||||
| 78 | 126 | ▶ | { my @lines = shift->body->lines; | ||||||||||||||||||
|
Subroutine
escapedBody: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 79 | 126 | s/^(\>*From )/>$1/ for @lines; | |||||||||||||||||||
| 80 | 126 | \@lines; | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | #-------------------- | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | sub readFromParser($) | ||||||||||||||||||||
| 86 | 1304 | ▶ | { my ($self, $parser) = @_; | ||||||||||||||||||
|
Subroutine
readFromParser: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 87 | 1304 | my ($start, $fromline) = $parser->readSeparator; | |||||||||||||||||||
| 88 | 1304 | ▶ | $fromline or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 1264 | $self->{MBMM_from_line} = $fromline; | |||||||||||||||||||
| 91 | 1264 | $self->{MBMM_begin} = $start; | |||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 1264 | $self->SUPER::readFromParser($parser); | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 4255 | ▶ | sub loadHead() { $_[0]->head } | ||||||||||||||||||
|
Subroutine
loadHead: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | sub loadBody() | ||||||||||||||||||||
| 100 | 27 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
loadBody: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 27 | my $body = $self->body; | |||||||||||||||||||
| 103 | 27 | ▶ | $body->isDelayed or return $body; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 21 | my ($begin, $end) = $body->fileLocation; | |||||||||||||||||||
| 106 | 21 | my $parser = $self->folder->parser; | |||||||||||||||||||
| 107 | 21 | $parser->filePosition($begin); | |||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 21 | my $msgid = $self->messageId; | |||||||||||||||||||
| 110 | 21 | ▶ | my $newbody = $self->readBody($parser, $self->head) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 111 | or error __x"unable to read delayed body for {msgid}", msgid => $msgid; | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | 21 | trace "Loaded delayed body for $msgid"; | |||||||||||||||||||
| 114 | 21 | $self->storeBody($newbody->contentInfoFrom($self->head)); | |||||||||||||||||||
| 115 | 21 | $newbody; | |||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | sub fileLocation() | ||||||||||||||||||||
| 120 | 626 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
fileLocation: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | wantarray | ||||||||||||||||||||
| 123 | ? ($self->{MBMM_begin}, ($self->body->fileLocation)[1]) | ||||||||||||||||||||
| 124 | 626 | ▶ | : $self->{MBMM_begin}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 125 | } | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | sub moveLocation($) | ||||||||||||||||||||
| 129 | 271 | ▶ | { my ($self, $dist) = @_; | ||||||||||||||||||
|
Subroutine
moveLocation: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 130 | 271 | $self->{MBMM_begin} -= $dist; | |||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 271 | $self->head->moveLocation($dist); | |||||||||||||||||||
| 133 | 271 | $self->body->moveLocation($dist); | |||||||||||||||||||
| 134 | 271 | $self; | |||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | 25 | 1; | |||||||||||||||||||