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-IMAP4. 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::Server::IMAP4::List; |
10
|
1
|
|
|
1
|
|
203210
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
52
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.008'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
15
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
742
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new($) |
19
|
2
|
|
|
2
|
1
|
11437
|
{ my ($class, %args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
6
|
my $self = bless {}, $class; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
9
|
my $user = $self->{MSIL_user} = $args{user}; |
24
|
2
|
|
|
|
|
3
|
$self->{MSIL_folders} = $args{folders}; |
25
|
2
|
|
|
|
|
5
|
$self->{MSIL_inbox} = $args{inbox}; |
26
|
2
|
50
|
|
|
|
6
|
$self->{MSIL_delim} = exists $args{delimiter} ? $args{delimiter} : '/'; |
27
|
2
|
|
|
|
|
12
|
$self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#------------------------------------------ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub delimiter(;$) |
34
|
32
|
|
|
32
|
1
|
58
|
{ my $delim = shift->{MSIL_delim}; |
35
|
32
|
100
|
|
|
|
87
|
ref $delim ? $delim->(shift) : $delim; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#------------------------------------------ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
0
|
sub user() { shift->{MSIL_user} } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#------------------------------------------ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub folders() |
47
|
28
|
|
|
28
|
1
|
39
|
{ my $self = shift; |
48
|
28
|
50
|
|
|
|
86
|
$self->{MSIL_folders} || $self->user->topfolder; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#------------------------------------------ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub inbox() |
55
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
56
|
0
|
0
|
|
|
|
0
|
$self->{MSIL_inbox} || $self->user->inbox; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#------------------------------------------ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub list($$) |
63
|
32
|
|
|
32
|
1
|
19434
|
{ my ($self, $base, $pattern) = @_; |
64
|
|
|
|
|
|
|
|
65
|
32
|
100
|
|
|
|
95
|
return [ '(\Noselect)', $self->delimiter($base), '' ] |
66
|
|
|
|
|
|
|
if $pattern eq ''; |
67
|
|
|
|
|
|
|
|
68
|
28
|
|
|
|
|
90
|
my $delim = $self->delimiter($base); |
69
|
28
|
|
|
|
|
339
|
my @path = split $delim, $base; |
70
|
28
|
|
|
|
|
81
|
my $folder = $self->folders; |
71
|
|
|
|
|
|
|
|
72
|
28
|
|
66
|
|
|
118
|
while(@path && defined $folder) |
73
|
35
|
|
|
|
|
2330
|
{ $folder = $folder->folder(shift @path); |
74
|
|
|
|
|
|
|
} |
75
|
28
|
100
|
|
|
|
3199
|
defined $folder or return (); |
76
|
|
|
|
|
|
|
|
77
|
26
|
|
|
|
|
221
|
my @pattern = split $delim, $pattern; |
78
|
26
|
|
|
|
|
75
|
return $self->_list($folder, $delim, @pattern); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _list($$@) |
82
|
127
|
|
|
127
|
|
440
|
{ my ($self, $folder, $delim) = (shift, shift, shift); |
83
|
|
|
|
|
|
|
|
84
|
127
|
100
|
|
|
|
242
|
if(!@_) |
85
|
36
|
|
|
|
|
51
|
{ my @flags; |
86
|
36
|
100
|
100
|
|
|
85
|
push @flags, '\Noselect' |
87
|
|
|
|
|
|
|
if $folder->onlySubfolders || $folder->deleted; |
88
|
|
|
|
|
|
|
|
89
|
36
|
100
|
|
|
|
441
|
push @flags, '\Noinferiors' unless $folder->inferiors; |
90
|
36
|
|
|
|
|
190
|
my $marked = $folder->marked; |
91
|
36
|
100
|
|
|
|
187
|
push @flags, ($marked ? '\Marked' : '\Unmarked') |
|
|
100
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if defined $marked; |
93
|
|
|
|
|
|
|
|
94
|
36
|
|
|
|
|
72
|
local $" = ' '; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# This is not always correct... should compose the name from the |
97
|
|
|
|
|
|
|
# parts... but in nearly all cases, the following is sufficient. |
98
|
36
|
|
|
|
|
73
|
my $name = $folder->fullname; |
99
|
36
|
|
|
|
|
7386
|
for($name) |
100
|
36
|
|
|
|
|
169
|
{ s/^=//; |
101
|
36
|
|
|
|
|
166
|
s![/\\]!$delim!g; |
102
|
|
|
|
|
|
|
} |
103
|
36
|
|
|
|
|
238
|
return [ "(@flags)", $delim, $name ]; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
91
|
|
|
|
|
144
|
my $pat = shift; |
107
|
91
|
100
|
|
|
|
174
|
if($pat eq '%') |
108
|
3
|
100
|
|
|
|
9
|
{ my $subs = $folder->subfolders |
109
|
|
|
|
|
|
|
or return $self->_list($folder, $delim); |
110
|
2
|
|
|
|
|
377
|
return map { $self->_list($_, $delim, @_) } $subs->sorted; |
|
6
|
|
|
|
|
219
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
88
|
100
|
|
|
|
156
|
if($pat eq '*') |
114
|
40
|
|
|
|
|
82
|
{ my @own = $self->_list($folder, $delim, @_); |
115
|
40
|
100
|
|
|
|
709
|
my $subs = $folder->subfolders or return @own; |
116
|
13
|
|
|
|
|
2317
|
return @own, map { $self->_list($_, $delim, '*', @_) } $subs->sorted; |
|
34
|
|
|
|
|
4068
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
48
|
100
|
|
|
|
118
|
$folder = $folder->find(subfolders => $pat) or return (); |
120
|
20
|
|
|
|
|
1713
|
$self->_list($folder, $delim, @_); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
#------------------------------------------ |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |