line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2023 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.03. |
5
|
|
|
|
|
|
|
# This code is part of distribution Mail-Message. 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::Message::Part; |
10
|
34
|
|
|
34
|
|
232
|
use vars '$VERSION'; |
|
34
|
|
|
|
|
72
|
|
|
34
|
|
|
|
|
1781
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.013'; |
12
|
|
|
|
|
|
|
|
13
|
34
|
|
|
34
|
|
200
|
use base 'Mail::Message'; |
|
34
|
|
|
|
|
69
|
|
|
34
|
|
|
|
|
3967
|
|
14
|
|
|
|
|
|
|
|
15
|
34
|
|
|
34
|
|
237
|
use strict; |
|
34
|
|
|
|
|
91
|
|
|
34
|
|
|
|
|
1089
|
|
16
|
34
|
|
|
34
|
|
347
|
use warnings; |
|
34
|
|
|
|
|
95
|
|
|
34
|
|
|
|
|
1312
|
|
17
|
|
|
|
|
|
|
|
18
|
34
|
|
|
34
|
|
232
|
use Scalar::Util 'weaken'; |
|
34
|
|
|
|
|
70
|
|
|
34
|
|
|
|
|
1875
|
|
19
|
34
|
|
|
34
|
|
558
|
use Carp; |
|
34
|
|
|
|
|
76
|
|
|
34
|
|
|
|
|
26959
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init($) |
23
|
61
|
|
|
61
|
0
|
148
|
{ my ($self, $args) = @_; |
24
|
61
|
|
66
|
|
|
542
|
$args->{head} ||= Mail::Message::Head::Complete->new; |
25
|
|
|
|
|
|
|
|
26
|
61
|
|
|
|
|
261
|
$self->SUPER::init($args); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
confess "No container specified for part.\n" |
29
|
61
|
50
|
|
|
|
154
|
unless exists $args->{container}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
weaken($self->{MMP_container}) |
32
|
61
|
100
|
|
|
|
271
|
if $self->{MMP_container} = $args->{container}; |
33
|
|
|
|
|
|
|
|
34
|
61
|
|
|
|
|
168
|
$self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub coerce($@) |
39
|
66
|
|
|
66
|
1
|
158
|
{ my ($class, $thing, $container) = (shift, shift, shift); |
40
|
66
|
100
|
|
|
|
299
|
if($thing->isa($class)) |
41
|
35
|
|
|
|
|
98
|
{ $thing->container($container); |
42
|
35
|
|
|
|
|
90
|
return $thing; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
31
|
100
|
|
|
|
132
|
return $class->buildFromBody($thing, $container, @_) |
46
|
|
|
|
|
|
|
if $thing->isa('Mail::Message::Body'); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Although cloning is a Bad Thing(tm), we must avoid modifying |
49
|
|
|
|
|
|
|
# header fields of messages which reside in a folder. |
50
|
13
|
50
|
|
|
|
64
|
my $message = $thing->isa('Mail::Box::Message') ? $thing->clone : $thing; |
51
|
|
|
|
|
|
|
|
52
|
13
|
|
|
|
|
70
|
my $part = $class->SUPER::coerce($message); |
53
|
13
|
|
|
|
|
38
|
$part->container($container); |
54
|
13
|
|
|
|
|
34
|
$part; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub buildFromBody($$;@) |
59
|
18
|
|
|
18
|
1
|
38
|
{ my ($class, $body, $container) = (shift, shift, shift); |
60
|
18
|
|
|
|
|
66
|
my @log = $body->logSettings; |
61
|
|
|
|
|
|
|
|
62
|
18
|
|
|
|
|
88
|
my $head = Mail::Message::Head::Complete->new(@log); |
63
|
18
|
|
|
|
|
63
|
while(@_) |
64
|
0
|
0
|
|
|
|
0
|
{ if(ref $_[0]) {$head->add(shift)} |
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
|
|
|
0
|
else {$head->add(shift, shift)} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
18
|
|
|
|
|
77
|
my $part = $class->new |
69
|
|
|
|
|
|
|
( head => $head |
70
|
|
|
|
|
|
|
, container => $container |
71
|
|
|
|
|
|
|
, @log |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
18
|
|
|
|
|
106
|
$part->body($body); |
75
|
18
|
|
|
|
|
55
|
$part; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub container(;$) |
79
|
87
|
|
|
87
|
1
|
135
|
{ my $self = shift; |
80
|
87
|
100
|
|
|
|
200
|
return $self->{MMP_container} unless @_; |
81
|
|
|
|
|
|
|
|
82
|
74
|
|
|
|
|
122
|
$self->{MMP_container} = shift; |
83
|
74
|
|
|
|
|
230
|
weaken($self->{MMP_container}); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub toplevel() |
87
|
0
|
0
|
|
0
|
1
|
0
|
{ my $body = shift->container or return; |
88
|
0
|
0
|
|
|
|
0
|
my $msg = $body->message or return; |
89
|
0
|
|
|
|
|
0
|
$msg->toplevel; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub isPart() { 1 } |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub partNumber() |
95
|
11
|
|
|
11
|
1
|
26
|
{ my $self = shift; |
96
|
11
|
50
|
|
|
|
23
|
my $body = $self->container or confess 'no container'; |
97
|
11
|
|
|
|
|
53
|
$body->partNumberOf($self); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub readFromParser($;$) |
101
|
14
|
|
|
14
|
1
|
40
|
{ my ($self, $parser, $bodytype) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $head = $self->readHead($parser) |
104
|
|
|
|
|
|
|
|| Mail::Message::Head::Complete->new |
105
|
|
|
|
|
|
|
( message => $self |
106
|
|
|
|
|
|
|
, field_type => $self->{MM_field_type} |
107
|
14
|
|
33
|
|
|
54
|
, $self->logSettings |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
|
110
|
14
|
|
33
|
|
|
85
|
my $body = $self->readBody($parser, $head, $bodytype) |
111
|
|
|
|
|
|
|
|| Mail::Message::Body::Lines->new(data => []); |
112
|
|
|
|
|
|
|
|
113
|
14
|
|
|
|
|
57
|
$self->head($head); |
114
|
14
|
|
|
|
|
48
|
$self->storeBody($body->contentInfoFrom($head)); |
115
|
14
|
|
|
|
|
51
|
$self; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#----------------- |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub printEscapedFrom($) |
121
|
0
|
|
|
0
|
1
|
|
{ my ($self, $out) = @_; |
122
|
0
|
|
|
|
|
|
$self->head->print($out); |
123
|
0
|
|
|
|
|
|
$self->body->printEscapedFrom($out); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub destruct() |
128
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
129
|
0
|
|
|
|
|
|
$self->log(ERROR =>'You cannot destruct message parts, only whole messages'); |
130
|
0
|
|
|
|
|
|
undef; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |