| 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::Identity;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '4.01'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
40
|
use parent qw/User::Identity::Item Mail::Reporter/; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
20
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
261
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
71
|
|
|
19
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
187
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
17
|
use Log::Report 'mail-box', import => [ qw/__x error/ ]; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
20
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
484
|
use Mail::Box::Collection (); |
|
|
3
|
|
|
|
|
20
|
|
|
|
3
|
|
|
|
|
4421
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# tests in tests/52message/30collect.t |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#-------------------- |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new(@) |
|
30
|
13
|
|
|
13
|
1
|
528
|
{ my $class = shift; |
|
31
|
13
|
50
|
|
|
|
39
|
unshift @_, 'name' if @_ % 2; |
|
32
|
13
|
|
|
|
|
79
|
$class->Mail::Reporter::new(@_); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub init($) |
|
36
|
13
|
|
|
13
|
0
|
125
|
{ my ($self, $args) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
13
|
|
|
|
|
43
|
$self->Mail::Reporter::init($args); |
|
39
|
13
|
|
|
|
|
74
|
$self->User::Identity::init($args); |
|
40
|
|
|
|
|
|
|
|
|
41
|
13
|
|
|
|
|
400
|
$self->{MBI_location} = delete $args->{location}; |
|
42
|
13
|
|
|
|
|
29
|
$self->{MBI_ftype} = delete $args->{folder_type}; |
|
43
|
13
|
|
|
|
|
31
|
$self->{MBI_manager} = delete $args->{manager}; |
|
44
|
13
|
|
50
|
|
|
75
|
$self->{MBI_subf_type} = delete $args->{subf_type}||'Mail::Box::Collection'; |
|
45
|
13
|
|
|
|
|
29
|
$self->{MBI_only_subs} = delete $args->{only_subs}; |
|
46
|
13
|
|
|
|
|
27
|
$self->{MBI_marked} = delete $args->{marked}; |
|
47
|
13
|
|
|
|
|
25
|
$self->{MBI_deleted} = delete $args->{deleted}; |
|
48
|
13
|
50
|
|
|
|
35
|
$self->{MBI_inferiors} = exists $args->{inferiors} ? $args->{inferiors} : 1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
13
|
|
|
|
|
76
|
$self; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#-------------------- |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
0
|
sub type { "mailbox" } |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub fullname(;$) |
|
59
|
64
|
|
|
64
|
1
|
14595
|
{ my $self = shift; |
|
60
|
64
|
100
|
66
|
|
|
311
|
my $delim = @_ && defined $_[0] ? shift : '/'; |
|
61
|
|
|
|
|
|
|
|
|
62
|
64
|
100
|
|
|
|
174
|
my $parent = $self->parent or return $self->name; |
|
63
|
42
|
|
|
|
|
6377
|
$parent->parent->fullname($delim) . $delim . $self->name; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub location(;$) |
|
68
|
77
|
|
|
77
|
1
|
2527
|
{ my $self = shift; |
|
69
|
77
|
50
|
|
|
|
216
|
return ($self->{MBI_location} = shift) if @_; |
|
70
|
77
|
100
|
|
|
|
396
|
return $self->{MBI_location} if defined $self->{MBI_location}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
52
|
50
|
|
|
|
131
|
my $parent = $self->parent |
|
73
|
|
|
|
|
|
|
or error __x"toplevel directory requires explicit location."; |
|
74
|
|
|
|
|
|
|
|
|
75
|
52
|
|
|
|
|
7624
|
$self->folderType->nameOfSubFolder($self->name, $parent->parent->location) |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub folderType() |
|
81
|
222
|
|
|
222
|
1
|
1647
|
{ my $self = shift; |
|
82
|
222
|
100
|
|
|
|
872
|
return $self->{MBI_ftype} if defined $self->{MBI_ftype}; |
|
83
|
|
|
|
|
|
|
|
|
84
|
147
|
50
|
|
|
|
404
|
my $parent = $self->parent |
|
85
|
|
|
|
|
|
|
or error __x"toplevel directory requires explicit folder type."; |
|
86
|
|
|
|
|
|
|
|
|
87
|
147
|
|
|
|
|
20660
|
$parent->parent->folderType; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub manager() |
|
93
|
1
|
|
|
1
|
1
|
4
|
{ my $self = shift; |
|
94
|
1
|
50
|
|
|
|
8
|
return $self->{MBI_manager} if $self->{MBI_manager}; |
|
95
|
0
|
0
|
|
|
|
0
|
my $parent = $self->parent or return undef; |
|
96
|
0
|
|
|
|
|
0
|
$self->parent->manager; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub topfolder() |
|
102
|
11
|
|
|
11
|
1
|
4094
|
{ my $self = shift; |
|
103
|
11
|
100
|
|
|
|
33
|
my $parent = $self->parent or return $self; |
|
104
|
7
|
|
|
|
|
1051
|
$parent->parent->topfolder; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub onlySubfolders(;$) |
|
110
|
1
|
|
|
1
|
1
|
4
|
{ my $self = shift; |
|
111
|
1
|
50
|
|
|
|
5
|
return($self->{MBI_only_subs} = shift) if @_; |
|
112
|
1
|
50
|
|
|
|
13
|
return $self->{MBI_only_subs} if exists $self->{MBI_only_subs}; |
|
113
|
0
|
0
|
|
|
|
0
|
$self->parent ? 1 : ! $self->folderType->topFolderWithMessages; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub marked(;$) |
|
119
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
|
120
|
0
|
0
|
|
|
|
0
|
@_ ? ($self->{MBI_marked} = shift) : $self->{MBI_marked}; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub inferiors(;$) |
|
126
|
1
|
|
|
1
|
1
|
4
|
{ my $self = shift; |
|
127
|
1
|
50
|
|
|
|
7
|
@_ ? ($self->{MBI_inferiors} = shift) : $self->{MBI_inferiors}; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub deleted(;$) |
|
133
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
|
134
|
0
|
0
|
|
|
|
0
|
@_ ? ($self->{MBI_deleted} = shift) : $self->{MBI_deleted}; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#-------------------- |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub subfolders() |
|
140
|
54
|
|
|
54
|
1
|
9481
|
{ my $self = shift; |
|
141
|
54
|
|
|
|
|
192
|
my $subs = $self->collection('subfolders'); |
|
142
|
54
|
100
|
|
|
|
3313
|
return (wantarray ? $subs->roles : $subs) |
|
|
|
100
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
if defined $subs; |
|
144
|
|
|
|
|
|
|
|
|
145
|
22
|
|
|
|
|
42
|
my @subs; |
|
146
|
22
|
50
|
|
|
|
54
|
if(my $location = $self->location) |
|
147
|
22
|
|
|
|
|
56
|
{ @subs = $self->folderType->listSubFolders(folder => $location); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
else |
|
150
|
0
|
|
|
|
|
0
|
{ my $mgr = $self->manager; |
|
151
|
0
|
0
|
|
|
|
0
|
my $top = defined $mgr ? $mgr->folderdir : '.'; |
|
152
|
0
|
|
|
|
|
0
|
@subs = $self->folderType->listSubFolders(folder => $self->fullname, folderdir => $top); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
22
|
100
|
|
|
|
189
|
@subs or return (); |
|
155
|
|
|
|
|
|
|
|
|
156
|
4
|
|
50
|
|
|
21
|
my $subf_type = $self->{MBI_subf_type} || ref($self->parent) || 'Mail::Box::Collection'; |
|
157
|
|
|
|
|
|
|
|
|
158
|
4
|
|
|
|
|
41
|
$subs = $subf_type->new('subfolders'); |
|
159
|
|
|
|
|
|
|
|
|
160
|
4
|
|
|
|
|
25
|
$self->addCollection($subs); |
|
161
|
4
|
|
|
|
|
213
|
$subs->addRole(name => $_) for @subs; |
|
162
|
4
|
100
|
|
|
|
196
|
wantarray ? $subs->roles : $subs; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
3
|
|
|
3
|
1
|
2203
|
sub subfolderNames() { map $_->name, $_[0]->subfolders } |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub folder(@) |
|
172
|
30
|
|
|
30
|
1
|
12184
|
{ my $self = shift; |
|
173
|
30
|
100
|
66
|
|
|
170
|
return $self unless @_ && defined $_[0]; |
|
174
|
|
|
|
|
|
|
|
|
175
|
22
|
100
|
|
|
|
58
|
my $subs = $self->subfolders or return undef; |
|
176
|
21
|
100
|
|
|
|
2928
|
my $nest = $subs->find(shift) or return undef; |
|
177
|
19
|
|
|
|
|
325
|
$nest->folder(@_); |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub open(@) |
|
182
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
|
183
|
0
|
|
|
|
|
0
|
$self->manager->open($self->fullname, type => $self->folderType, @_); |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub foreach($) |
|
188
|
24
|
|
|
24
|
1
|
705
|
{ my ($self, $code) = @_; |
|
189
|
24
|
|
|
|
|
113
|
$code->($self); |
|
190
|
|
|
|
|
|
|
|
|
191
|
24
|
100
|
|
|
|
448
|
my $subs = $self->subfolders or return (); |
|
192
|
8
|
|
|
|
|
1118
|
$_->foreach($code) for $subs->sorted; |
|
193
|
8
|
|
|
|
|
32
|
$self; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub addSubfolder(@) |
|
199
|
1
|
|
|
1
|
0
|
3
|
{ my $self = shift; |
|
200
|
1
|
|
|
|
|
4
|
my $subs = $self->subfolders; |
|
201
|
|
|
|
|
|
|
|
|
202
|
1
|
50
|
|
|
|
9
|
if(defined $subs) { ; } |
|
|
|
50
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
elsif(!$self->inferiors) |
|
204
|
0
|
|
|
|
|
0
|
{ my $name = $self->fullname; |
|
205
|
0
|
|
|
|
|
0
|
error __x"it is not permitted to add subfolders to {folder}.", folder => $name; |
|
206
|
0
|
|
|
|
|
0
|
return undef; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
else |
|
209
|
1
|
|
|
|
|
11
|
{ $subs = $self->{MBI_subf_type}->new('subfolders'); |
|
210
|
1
|
|
|
|
|
6
|
$self->addCollection($subs); |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
1
|
|
|
|
|
70
|
$subs->addRole(@_); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub remove(;$) |
|
219
|
2
|
|
|
2
|
1
|
5
|
{ my $self = shift; |
|
220
|
|
|
|
|
|
|
|
|
221
|
2
|
50
|
|
|
|
9
|
my $parent = $self->parent |
|
222
|
|
|
|
|
|
|
or error __x"the toplevel folder cannot be removed this way."; |
|
223
|
|
|
|
|
|
|
|
|
224
|
2
|
100
|
|
|
|
317
|
@_ or return $parent->removeRole($self->name); |
|
225
|
|
|
|
|
|
|
|
|
226
|
1
|
|
|
|
|
5
|
my $name = shift; |
|
227
|
1
|
50
|
|
|
|
4
|
my $subs = $self->subfolders or return (); |
|
228
|
1
|
|
|
|
|
139
|
$subs->removeRole($name); |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub rename($;$) |
|
233
|
1
|
|
|
1
|
1
|
440
|
{ my ($self, $folder, $newname) = @_; |
|
234
|
1
|
|
33
|
|
|
6
|
$newname //= $self->name; |
|
235
|
1
|
|
|
|
|
4
|
my $away = $self->remove; |
|
236
|
1
|
|
|
|
|
96
|
$away->name($newname); |
|
237
|
|
|
|
|
|
|
|
|
238
|
1
|
|
|
|
|
10
|
$folder->addSubfolder($away); |
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
1; |