/usr/share/perl5/Mail/Box/Maildir/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 | # 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::Maildir::Message;
use vars '$VERSION';
$VERSION = '2.099';
use base 'Mail::Box::Dir::Message';
use File::Copy;
sub filename(;$)
{ my $self = shift;
my $oldname = $self->SUPER::filename();
return $oldname unless @_;
my $newname = shift;
return $newname if defined $oldname && $oldname eq $newname;
my ($id, $semantics, $flags)
= $newname =~ m!(.*?)(?:\:([12])\,([A-Za-z]*))!
? ($1, $2, $3)
: ($newname, '','');
my %flags;
$flags{$_}++ foreach split //, $flags;
$self->SUPER::label
( draft => (delete $flags{D} || 0)
, flagged => (delete $flags{F} || 0)
, replied => (delete $flags{R} || 0)
, seen => (delete $flags{S} || 0)
, deleted => (delete $flags{T} || 0)
, passed => (delete $flags{P} || 0) # uncommon
, unknown => join('', sort keys %flags) # application specific
);
if(defined $oldname && ! move $oldname, $newname)
{ $self->log(ERROR => "Cannot move $oldname to $newname: $!");
return undef;
}
$self->SUPER::filename($newname);
}
sub guessTimestamp()
{ my $self = shift;
my $timestamp = $self->SUPER::guessTimestamp;
return $timestamp if defined $timestamp;
$self->filename =~ m/^(\d+)/ ? $1 : undef;
}
#-------------------------------------------
sub label(@)
{ my $self = shift;
return $self->SUPER::label unless @_;
my $return = $self->SUPER::label(@_);
$self->labelsToFilename;
$return;
}
sub labelsToFilename()
{ my $self = shift;
my $labels = $self->labels;
my $old = $self->filename;
my ($folderdir, $set, $oldname, $oldflags)
= $old =~ m!(.*)/(new|cur|tmp)/(.+?)(\:2,[^:]*)?$!;
my $newflags # alphabeticly ordered!
= ($labels->{draft} ? 'D' : '')
. ($labels->{flagged} ? 'F' : '')
. ($labels->{passed} ? 'P' : '')
. ($labels->{replied} ? 'R' : '')
. ($labels->{seen} ? 'S' : '')
. ($labels->{deleted} ? 'T' : '')
. ($labels->{unknown} || '');
my $newset = $labels->{accepted} ? 'cur' : 'new';
if($set ne $newset)
{ my $folder = $self->folder;
$folder->modified(1) if defined $folder;
}
my $flags = $newset ne 'new' || $newflags ne '' ? ":2,$newflags"
: length $oldflags ? ':2,' : '';
my $new = File::Spec->catfile($folderdir, $newset, $oldname.$flags);
if($new ne $old)
{ unless(move $old, $new)
{ $self->log(ERROR => "Cannot rename $old to $new: $!");
return;
}
$self->log(PROGRESS => "Moved $old to $new.");
$self->SUPER::filename($new);
}
$new;
}
#-------------------------------------------
sub accept(;$)
{ my $self = shift;
my $accept = @_ ? shift : 1;
$self->label(accepted => $accept);
}
#-------------------------------------------
1;
|