/usr/share/perl5/Mail/Message/Part.pm is in libmail-message-perl 3.006-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | # Copyrights 2001-2018 by [Mark Overmeer].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.02.
# This code is part of distribution Mail-Message. Meta-POD processed with
# OODoc into POD and HTML manual-pages. See README.md
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
package Mail::Message::Part;
use vars '$VERSION';
$VERSION = '3.006';
use base 'Mail::Message';
use strict;
use warnings;
use Scalar::Util 'weaken';
use Carp;
sub init($)
{ my ($self, $args) = @_;
$args->{head} ||= Mail::Message::Head::Complete->new;
$self->SUPER::init($args);
confess "No container specified for part.\n"
unless exists $args->{container};
weaken($self->{MMP_container})
if $self->{MMP_container} = $args->{container};
$self;
}
sub coerce($@)
{ my ($class, $thing, $container) = (shift, shift, shift);
if($thing->isa($class))
{ $thing->container($container);
return $thing;
}
return $class->buildFromBody($thing, $container, @_)
if $thing->isa('Mail::Message::Body');
# Although cloning is a Bad Thing(tm), we must avoid modifying
# header fields of messages which reside in a folder.
my $message = $thing->isa('Mail::Box::Message') ? $thing->clone : $thing;
my $part = $class->SUPER::coerce($message);
$part->container($container);
$part;
}
sub buildFromBody($$;@)
{ my ($class, $body, $container) = (shift, shift, shift);
my @log = $body->logSettings;
my $head = Mail::Message::Head::Complete->new(@log);
while(@_)
{ if(ref $_[0]) {$head->add(shift)}
else {$head->add(shift, shift)}
}
my $part = $class->new
( head => $head
, container => $container
, @log
);
$part->body($body);
$part;
}
sub container(;$)
{ my $self = shift;
return $self->{MMP_container} unless @_;
$self->{MMP_container} = shift;
weaken($self->{MMP_container});
}
sub toplevel()
{ my $body = shift->container or return;
my $msg = $body->message or return;
$msg->toplevel;
}
sub isPart() { 1 }
sub partNumber()
{ my $self = shift;
my $body = $self->container or confess 'no container';
$body->partNumberOf($self);
}
sub readFromParser($;$)
{ my ($self, $parser, $bodytype) = @_;
my $head = $self->readHead($parser)
|| Mail::Message::Head::Complete->new
( message => $self
, field_type => $self->{MM_field_type}
, $self->logSettings
);
my $body = $self->readBody($parser, $head, $bodytype)
|| Mail::Message::Body::Lines->new(data => []);
$self->head($head);
$self->storeBody($body->contentInfoFrom($head));
$self;
}
#-----------------
sub printEscapedFrom($)
{ my ($self, $out) = @_;
$self->head->print($out);
$self->body->printEscapedFrom($out);
}
sub destruct()
{ my $self = shift;
$self->log(ERROR =>'You cannot destruct message parts, only whole messages');
undef;
}
1;
|