line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2020 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.02. |
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
|
|
1029
|
use vars '$VERSION'; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
314
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.009'; |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
36
|
use base 'Mail::Box::Dir::Message'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
637
|
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
77
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
138
|
|
16
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
517
|
|
17
|
|
|
|
|
|
|
|
18
|
6
|
|
|
6
|
|
42
|
use File::Copy; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
5324
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub filename(;$) |
22
|
1085
|
|
|
1085
|
1
|
1948
|
{ my $self = shift; |
23
|
1085
|
|
|
|
|
2232
|
my $oldname = $self->SUPER::filename(); |
24
|
1085
|
100
|
|
|
|
2784
|
return $oldname unless @_; |
25
|
|
|
|
|
|
|
|
26
|
303
|
|
|
|
|
455
|
my $newname = shift; |
27
|
303
|
50
|
33
|
|
|
630
|
return $newname if defined $oldname && $oldname eq $newname; |
28
|
|
|
|
|
|
|
|
29
|
303
|
100
|
|
|
|
1862
|
my ($id, $semantics, $flags) |
30
|
|
|
|
|
|
|
= $newname =~ m!(.*?)(?:\:([12])\,([A-Za-z]*))! |
31
|
|
|
|
|
|
|
? ($1, $2, $3) |
32
|
|
|
|
|
|
|
: ($newname, '',''); |
33
|
|
|
|
|
|
|
|
34
|
303
|
|
|
|
|
505
|
my %flags; |
35
|
303
|
|
|
|
|
1060
|
$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
|
|
|
3721
|
, 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
|
|
|
6428
|
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
|
|
|
|
|
715
|
$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
|
1386
|
{ my $self = shift; |
70
|
431
|
50
|
|
|
|
824
|
return $self->SUPER::label unless @_; |
71
|
|
|
|
|
|
|
|
72
|
431
|
|
|
|
|
903
|
my $return = $self->SUPER::label(@_); |
73
|
431
|
|
|
|
|
2656
|
$self->labelsToFilename; |
74
|
431
|
|
|
|
|
1183
|
$return; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub labelsToFilename() |
79
|
433
|
|
|
433
|
1
|
599
|
{ my $self = shift; |
80
|
433
|
|
|
|
|
793
|
my $labels = $self->labels; |
81
|
433
|
|
|
|
|
1949
|
my $old = $self->filename; |
82
|
|
|
|
|
|
|
|
83
|
433
|
|
|
|
|
3560
|
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
|
|
|
2730
|
. ($labels->{unknown} || ''); |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
433
|
100
|
|
|
|
779
|
my $newset = $labels->{accepted} ? 'cur' : 'new'; |
96
|
433
|
100
|
|
|
|
865
|
if($set ne $newset) |
97
|
4
|
|
|
|
|
18
|
{ my $folder = $self->folder; |
98
|
4
|
100
|
|
|
|
22
|
$folder->modified(1) if defined $folder; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
433
|
100
|
66
|
|
|
1111
|
my $flags = $newset ne 'new' || $newflags ne '' ? ":2,$newflags" |
|
|
100
|
|
|
|
|
|
102
|
|
|
|
|
|
|
: $oldflags ? ':2,' : ''; |
103
|
433
|
|
|
|
|
3173
|
my $new = File::Spec->catfile($folderdir, $newset, $oldname.$flags); |
104
|
|
|
|
|
|
|
|
105
|
433
|
100
|
|
|
|
1211
|
if($new ne $old) |
106
|
13
|
50
|
|
|
|
48
|
{ unless(move $old, $new) |
107
|
0
|
|
|
|
|
0
|
{ $self->log(ERROR => "Cannot rename $old to $new: $!"); |
108
|
0
|
|
|
|
|
0
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
13
|
|
|
|
|
1538
|
$self->log(PROGRESS => "Moved $old to $new."); |
111
|
13
|
|
|
|
|
293
|
$self->SUPER::filename($new); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
433
|
|
|
|
|
739
|
$new; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#------------------------------------------- |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub accept(;$) |
121
|
1
|
|
|
1
|
1
|
4
|
{ my $self = shift; |
122
|
1
|
50
|
|
|
|
5
|
my $accept = @_ ? shift : 1; |
123
|
1
|
|
|
|
|
4
|
$self->label(accepted => $accept); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#------------------------------------------- |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |