| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is part of Perl distribution Mail-Box version 4.01. |
|
2
|
|
|
|
|
|
|
# The POD got stripped from this file by OODoc version 3.05. |
|
3
|
|
|
|
|
|
|
# For contributors see file ChangeLog. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# This software is copyright (c) 2001-2025 by Mark Overmeer. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
9
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Mail::Box::Maildir::Message;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '4.01'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
6
|
|
|
6
|
|
2651
|
use parent 'Mail::Box::Dir::Message'; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
39
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
6
|
|
|
6
|
|
656
|
use strict; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
147
|
|
|
19
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
445
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
6
|
|
|
6
|
|
35
|
use Log::Report 'mail-box', import => [ qw/__x fault info trace/ ]; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
60
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
6
|
|
|
6
|
|
1242
|
use File::Copy qw/move/; |
|
|
6
|
|
|
|
|
21
|
|
|
|
6
|
|
|
|
|
519
|
|
|
24
|
6
|
|
|
6
|
|
39
|
use File::Spec::Functions qw/catfile/; |
|
|
6
|
|
|
|
|
19
|
|
|
|
6
|
|
|
|
|
6596
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#-------------------- |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub filename(;$) |
|
29
|
1135
|
|
|
1135
|
1
|
2018
|
{ my $self = shift; |
|
30
|
1135
|
|
|
|
|
2556
|
my $oldname = $self->SUPER::filename; |
|
31
|
1135
|
100
|
|
|
|
3663
|
@_ or return $oldname; |
|
32
|
|
|
|
|
|
|
|
|
33
|
303
|
|
|
|
|
515
|
my $newname = shift; |
|
34
|
303
|
50
|
33
|
|
|
991
|
! defined $oldname || $oldname ne $newname |
|
35
|
|
|
|
|
|
|
or return $newname; |
|
36
|
|
|
|
|
|
|
|
|
37
|
303
|
100
|
|
|
|
2273
|
my ($id, $semantics, $flags) = |
|
38
|
|
|
|
|
|
|
$newname =~ m!(.*?)(?:\:([12])\,([A-Za-z]*))! ? ($1, $2, $3) : ($newname, '', ''); |
|
39
|
|
|
|
|
|
|
|
|
40
|
303
|
|
|
|
|
628
|
my %flags; |
|
41
|
303
|
|
|
|
|
1284
|
$flags{$_}++ for split //, $flags; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->SUPER::label( |
|
44
|
|
|
|
|
|
|
draft => (delete $flags{D} || 0), |
|
45
|
|
|
|
|
|
|
flagged => (delete $flags{F} || 0), |
|
46
|
|
|
|
|
|
|
replied => (delete $flags{R} || 0), |
|
47
|
|
|
|
|
|
|
seen => (delete $flags{S} || 0), |
|
48
|
|
|
|
|
|
|
deleted => (delete $flags{T} || 0), |
|
49
|
|
|
|
|
|
|
|
|
50
|
303
|
|
100
|
|
|
4065
|
passed => (delete $flags{P} || 0), # uncommon |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
51
|
|
|
|
|
|
|
unknown => join('', sort keys %flags) # application specific |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
303
|
50
|
33
|
|
|
7554
|
! defined $oldname || move $oldname, $newname |
|
55
|
|
|
|
|
|
|
or fault __x"cannot rename file {from} to {to}", from => $oldname, to => $newname; |
|
56
|
|
|
|
|
|
|
|
|
57
|
303
|
|
|
|
|
859
|
$self->SUPER::filename($newname); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#-------------------- |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub guessTimestamp() |
|
64
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
|
65
|
0
|
|
|
|
|
0
|
my $timestamp = $self->SUPER::guessTimestamp; |
|
66
|
0
|
0
|
|
|
|
0
|
return $timestamp if defined $timestamp; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
0
|
$self->filename =~ m/^(\d+)/ ? $1 : undef; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#-------------------- |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub label(@) |
|
74
|
413
|
|
|
413
|
1
|
1355
|
{ my $self = shift; |
|
75
|
413
|
50
|
|
|
|
894
|
@_ or return $self->SUPER::label; |
|
76
|
|
|
|
|
|
|
|
|
77
|
413
|
|
|
|
|
945
|
my $labels = $self->SUPER::label(@_); |
|
78
|
413
|
|
|
|
|
3284
|
$self->labelsToFilename; |
|
79
|
413
|
|
|
|
|
1314
|
$labels; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub labelsToFilename() |
|
84
|
415
|
|
|
415
|
1
|
562
|
{ my $self = shift; |
|
85
|
415
|
|
|
|
|
825
|
my $labels = $self->labels; |
|
86
|
415
|
|
|
|
|
1933
|
my $old = $self->filename; |
|
87
|
|
|
|
|
|
|
|
|
88
|
415
|
|
|
|
|
4026
|
my ($folderdir, $set, $oldname, $oldflags) = $old =~ m!(.*)/(new|cur|tmp)/(.+?)(\:2,[^:]*)?$!; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $newflags # alphabeticly ordered! |
|
91
|
|
|
|
|
|
|
= ($labels->{draft} ? 'D' : '') |
|
92
|
|
|
|
|
|
|
. ($labels->{flagged} ? 'F' : '') |
|
93
|
|
|
|
|
|
|
. ($labels->{passed} ? 'P' : '') |
|
94
|
|
|
|
|
|
|
. ($labels->{replied} ? 'R' : '') |
|
95
|
|
|
|
|
|
|
. ($labels->{seen} ? 'S' : '') |
|
96
|
|
|
|
|
|
|
. ($labels->{deleted} ? 'T' : '') |
|
97
|
415
|
100
|
50
|
|
|
2763
|
. ($labels->{unknown} || ''); |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
415
|
100
|
|
|
|
826
|
my $newset = $labels->{accepted} ? 'cur' : 'new'; |
|
100
|
415
|
100
|
|
|
|
2265
|
if($set ne $newset) |
|
101
|
4
|
|
|
|
|
20
|
{ my $folder = $self->folder; |
|
102
|
4
|
100
|
|
|
|
24
|
$folder->modified(1) if defined $folder; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
415
|
100
|
66
|
|
|
1122
|
my $flags = $newset ne 'new' || $newflags ne '' ? ":2,$newflags" : $oldflags ? ':2,' : ''; |
|
|
|
100
|
|
|
|
|
|
|
106
|
415
|
|
|
|
|
1993
|
my $new = catfile $folderdir, $newset, $oldname.$flags; |
|
107
|
|
|
|
|
|
|
|
|
108
|
415
|
100
|
|
|
|
1029
|
if($new ne $old) |
|
109
|
13
|
50
|
|
|
|
119
|
{ move $old, $new |
|
110
|
|
|
|
|
|
|
or fault __x"cannot rename file {from} to {to}", from => $old, to => $new; |
|
111
|
|
|
|
|
|
|
|
|
112
|
13
|
|
|
|
|
3234
|
trace "Moved $old to $new."; |
|
113
|
13
|
|
|
|
|
525
|
$self->SUPER::filename($new); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
415
|
|
|
|
|
745
|
$new; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
#-------------------- |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub accept(;$) |
|
122
|
1
|
|
|
1
|
1
|
2
|
{ my $self = shift; |
|
123
|
1
|
50
|
|
|
|
3
|
my $accept = @_ ? shift : 1; |
|
124
|
1
|
|
|
|
|
3
|
$self->label(accepted => $accept); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#-------------------- |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |