/usr/share/perl5/Mail/Box/IMAP4/Message.pm is in libmail-box-perl 2.099-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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | # Copyrights 2001-2011 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.00.
use strict;
use warnings;
package Mail::Box::IMAP4::Message;
use vars '$VERSION';
$VERSION = '2.099';
use base 'Mail::Box::Net::Message';
use Date::Parse 'str2time';
sub init($)
{ my ($self, $args) = @_;
$self->SUPER::init($args);
$self->{MBIM_write_labels}
= exists $args->{write_labels} ? $args->{write_labels} : 1;
$self->{MBIM_cache_labels} = $args->{cache_labels};
$self->{MBIM_cache_head} = $args->{cache_head};
$self->{MBIM_cache_body} = $args->{cache_body};
$self;
}
sub size($)
{ my $self = shift;
return $self->SUPER::size
unless $self->isDelayed;
$self->fetch('RFC822.SIZE');
}
sub recvstamp()
{ my $date = shift->fetch('INTERNALDATE');
defined $date ? str2time($date) : undef;
}
sub label(@)
{ my $self = shift;
my $imap = $self->folder->transporter or return;
my $id = $self->unique or return;
if(@_ == 1)
{ # get one value only
my $label = shift;
my $labels = $self->{MM_labels};
return $labels->{$label}
if exists $labels->{$label} || exists $labels->{seen};
my $flags = $imap->getFlags($id);
if($self->{MBIM_cache_labels})
{ # the program may have added own labels
@{$labels}{keys %$flags} = values %$flags;
delete $self->{MBIM_labels_changed};
}
return $flags->{$label};
}
my @private;
if($self->{MBIM_write_labels})
{ @private = $imap->setFlags($id, @_);
delete $self->{MBIM_labels_changed};
}
else
{ @private = @_;
}
my $labels = $self->{MM_labels};
my @keep = $self->{MBIM_cache_labels} ? @_ : @private;
while(@keep)
{ my ($k, $v) = (shift @keep, shift @keep);
next if defined $labels->{$k} && $labels->{$k} eq $v;
$self->{MBIM_labels_changed}++;
$labels->{$k} = $v;
}
$self->modified(1) if @private && $self->{MBIM_labels_changed};
$self;
}
sub labels()
{ my $self = shift;
my $id = $self->unique;
my $labels = $self->SUPER::labels;
$labels = { %$labels } unless $self->{MBIM_cache_labels};
if($id && !exists $labels->{seen})
{ my $imap = $self->folder->transporter or return;
my $flags = $imap->getFlags($id);
@{$labels}{keys %$flags} = values %$flags;
}
$labels;
}
#-------------------------------------------
sub loadHead()
{ my $self = shift;
my $head = $self->head;
return $head unless $head->isDelayed;
$head = $self->folder->getHead($self);
$self->head($head) if $self->{MBIM_cache_head};
$head;
}
sub loadBody()
{ my $self = shift;
my $body = $self->body;
return $body unless $body->isDelayed;
(my $head, $body) = $self->folder->getHeadAndBody($self);
return undef unless defined $head;
$self->head($head) if $self->{MBIM_cache_head} && $head->isDelayed;
$self->storeBody($body) if $self->{MBIM_cache_body};
$body;
}
sub fetch(@)
{ my ($self, @info) = @_;
my $folder = $self->folder;
my $answer = ($folder->fetch( [$self], @info))[0];
@info==1 ? $answer->{$info[0]} : @{$answer}{@info};
}
sub writeDelayed($$)
{ my ($self, $foldername, $imap) = @_;
my $id = $self->unique;
my $labels = $self->labels;
if($self->head->modified || $self->body->modified || !$id)
{
$imap->appendMessage($self, $foldername);
if($id)
{ $self->delete;
$self->unique(undef);
}
}
elsif($self->{MBIM_labels_changed})
{ $imap->setFlags($id, %$labels); # non-IMAP4 labels disappear
delete $self->{MBIM_labels_changed};
}
$self;
}
#-------------------------------------------
1;
|