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-Box. 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::Box::Maildir::Message; |
10
|
6
|
|
|
6
|
|
976
|
use vars '$VERSION'; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
315
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.010'; |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
44
|
use base 'Mail::Box::Dir::Message'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
656
|
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
39
|
use strict; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
138
|
|
16
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
189
|
|
17
|
|
|
|
|
|
|
|
18
|
6
|
|
|
6
|
|
43
|
use File::Copy; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
5599
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub filename(;$) |
22
|
1085
|
|
|
1085
|
1
|
1815
|
{ my $self = shift; |
23
|
1085
|
|
|
|
|
2178
|
my $oldname = $self->SUPER::filename(); |
24
|
1085
|
100
|
|
|
|
2914
|
return $oldname unless @_; |
25
|
|
|
|
|
|
|
|
26
|
303
|
|
|
|
|
507
|
my $newname = shift; |
27
|
303
|
50
|
33
|
|
|
635
|
return $newname if defined $oldname && $oldname eq $newname; |
28
|
|
|
|
|
|
|
|
29
|
303
|
100
|
|
|
|
1768
|
my ($id, $semantics, $flags) |
30
|
|
|
|
|
|
|
= $newname =~ m!(.*?)(?:\:([12])\,([A-Za-z]*))! |
31
|
|
|
|
|
|
|
? ($1, $2, $3) |
32
|
|
|
|
|
|
|
: ($newname, '',''); |
33
|
|
|
|
|
|
|
|
34
|
303
|
|
|
|
|
501
|
my %flags; |
35
|
303
|
|
|
|
|
1214
|
$flags{$_}++ foreach split //, $flags; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->SUPER::label |
38
|
|
|
|
|
|
|
( draft => (delete $flags{D} || 0) |
39
|
|
|
|
|
|
|
, flagged => (delete $flags{F} || 0) |
40
|
|
|
|
|
|
|
, replied => (delete $flags{R} || 0) |
41
|
|
|
|
|
|
|
, seen => (delete $flags{S} || 0) |
42
|
|
|
|
|
|
|
, deleted => (delete $flags{T} || 0) |
43
|
|
|
|
|
|
|
|
44
|
303
|
|
100
|
|
|
3629
|
, passed => (delete $flags{P} || 0) # uncommon |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
45
|
|
|
|
|
|
|
, unknown => join('', sort keys %flags) # application specific |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
303
|
50
|
33
|
|
|
6214
|
if(defined $oldname && ! move $oldname, $newname) |
49
|
0
|
|
|
|
|
0
|
{ $self->log(ERROR => "Cannot move $oldname to $newname: $!"); |
50
|
0
|
|
|
|
|
0
|
return undef; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
303
|
|
|
|
|
703
|
$self->SUPER::filename($newname); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub guessTimestamp() |
58
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
59
|
0
|
|
|
|
|
0
|
my $timestamp = $self->SUPER::guessTimestamp; |
60
|
0
|
0
|
|
|
|
0
|
return $timestamp if defined $timestamp; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
0
|
$self->filename =~ m/^(\d+)/ ? $1 : undef; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#------------------------------------------- |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub label(@) |
69
|
431
|
|
|
431
|
1
|
1379
|
{ my $self = shift; |
70
|
431
|
50
|
|
|
|
801
|
return $self->SUPER::label unless @_; |
71
|
|
|
|
|
|
|
|
72
|
431
|
|
|
|
|
874
|
my $return = $self->SUPER::label(@_); |
73
|
431
|
|
|
|
|
2735
|
$self->labelsToFilename; |
74
|
431
|
|
|
|
|
1217
|
$return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub labelsToFilename() |
79
|
433
|
|
|
433
|
1
|
575
|
{ my $self = shift; |
80
|
433
|
|
|
|
|
794
|
my $labels = $self->labels; |
81
|
433
|
|
|
|
|
1915
|
my $old = $self->filename; |
82
|
|
|
|
|
|
|
|
83
|
433
|
|
|
|
|
3607
|
my ($folderdir, $set, $oldname, $oldflags) |
84
|
|
|
|
|
|
|
= $old =~ m!(.*)/(new|cur|tmp)/(.+?)(\:2,[^:]*)?$!; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $newflags # alphabeticly ordered! |
87
|
|
|
|
|
|
|
= ($labels->{draft} ? 'D' : '') |
88
|
|
|
|
|
|
|
. ($labels->{flagged} ? 'F' : '') |
89
|
|
|
|
|
|
|
. ($labels->{passed} ? 'P' : '') |
90
|
|
|
|
|
|
|
. ($labels->{replied} ? 'R' : '') |
91
|
|
|
|
|
|
|
. ($labels->{seen} ? 'S' : '') |
92
|
|
|
|
|
|
|
. ($labels->{deleted} ? 'T' : '') |
93
|
433
|
100
|
50
|
|
|
3182
|
. ($labels->{unknown} || ''); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
433
|
100
|
|
|
|
796
|
my $newset = $labels->{accepted} ? 'cur' : 'new'; |
96
|
433
|
100
|
|
|
|
816
|
if($set ne $newset) |
97
|
4
|
|
|
|
|
14
|
{ my $folder = $self->folder; |
98
|
4
|
100
|
|
|
|
18
|
$folder->modified(1) if defined $folder; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
433
|
100
|
66
|
|
|
1067
|
my $flags = $newset ne 'new' || $newflags ne '' ? ":2,$newflags" |
|
|
100
|
|
|
|
|
|
102
|
|
|
|
|
|
|
: $oldflags ? ':2,' : ''; |
103
|
433
|
|
|
|
|
3082
|
my $new = File::Spec->catfile($folderdir, $newset, $oldname.$flags); |
104
|
|
|
|
|
|
|
|
105
|
433
|
100
|
|
|
|
1153
|
if($new ne $old) |
106
|
13
|
50
|
|
|
|
52
|
{ unless(move $old, $new) |
107
|
0
|
|
|
|
|
0
|
{ $self->log(ERROR => "Cannot rename $old to $new: $!"); |
108
|
0
|
|
|
|
|
0
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
13
|
|
|
|
|
1422
|
$self->log(PROGRESS => "Moved $old to $new."); |
111
|
13
|
|
|
|
|
329
|
$self->SUPER::filename($new); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
433
|
|
|
|
|
744
|
$new; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#------------------------------------------- |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub accept(;$) |
121
|
1
|
|
|
1
|
1
|
3
|
{ my $self = shift; |
122
|
1
|
50
|
|
|
|
7
|
my $accept = @_ ? shift : 1; |
123
|
1
|
|
|
|
|
4
|
$self->label(accepted => $accept); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#------------------------------------------- |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |