line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2019 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-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
|
|
209888
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
41
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.006'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
15
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
552
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new($) |
19
|
2
|
|
|
2
|
1
|
7450
|
{ my ($class, %args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
5
|
my $self = bless {}, $class; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
8
|
my $user = $self->{MSIL_user} = $args{user}; |
24
|
2
|
|
|
|
|
5
|
$self->{MSIL_folders} = $args{folders}; |
25
|
2
|
|
|
|
|
3
|
$self->{MSIL_inbox} = $args{inbox}; |
26
|
2
|
50
|
|
|
|
6
|
$self->{MSIL_delim} = exists $args{delimiter} ? $args{delimiter} : '/'; |
27
|
2
|
|
|
|
|
10
|
$self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#------------------------------------------ |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub delimiter(;$) |
34
|
32
|
|
|
32
|
1
|
48
|
{ my $delim = shift->{MSIL_delim}; |
35
|
32
|
100
|
|
|
|
74
|
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
|
33
|
{ my $self = shift; |
48
|
28
|
50
|
|
|
|
64
|
$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
|
15621
|
{ my ($self, $base, $pattern) = @_; |
64
|
|
|
|
|
|
|
|
65
|
32
|
100
|
|
|
|
78
|
return [ '(\Noselect)', $self->delimiter($base), '' ] |
66
|
|
|
|
|
|
|
if $pattern eq ''; |
67
|
|
|
|
|
|
|
|
68
|
28
|
|
|
|
|
47
|
my $delim = $self->delimiter($base); |
69
|
28
|
|
|
|
|
273
|
my @path = split $delim, $base; |
70
|
28
|
|
|
|
|
68
|
my $folder = $self->folders; |
71
|
|
|
|
|
|
|
|
72
|
28
|
|
66
|
|
|
98
|
while(@path && defined $folder) |
73
|
35
|
|
|
|
|
1038
|
{ $folder = $folder->folder(shift @path); |
74
|
|
|
|
|
|
|
} |
75
|
28
|
100
|
|
|
|
1347
|
defined $folder or return (); |
76
|
|
|
|
|
|
|
|
77
|
26
|
|
|
|
|
168
|
my @pattern = split $delim, $pattern; |
78
|
26
|
|
|
|
|
65
|
return $self->_list($folder, $delim, @pattern); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _list($$@) |
82
|
127
|
|
|
127
|
|
334
|
{ my ($self, $folder, $delim) = (shift, shift, shift); |
83
|
|
|
|
|
|
|
|
84
|
127
|
100
|
|
|
|
209
|
if(!@_) |
85
|
36
|
|
|
|
|
40
|
{ my @flags; |
86
|
36
|
100
|
100
|
|
|
62
|
push @flags, '\Noselect' |
87
|
|
|
|
|
|
|
if $folder->onlySubfolders || $folder->deleted; |
88
|
|
|
|
|
|
|
|
89
|
36
|
100
|
|
|
|
364
|
push @flags, '\Noinferiors' unless $folder->inferiors; |
90
|
36
|
|
|
|
|
155
|
my $marked = $folder->marked; |
91
|
36
|
100
|
|
|
|
151
|
push @flags, ($marked ? '\Marked' : '\Unmarked') |
|
|
100
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if defined $marked; |
93
|
|
|
|
|
|
|
|
94
|
36
|
|
|
|
|
51
|
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
|
|
|
|
|
62
|
my $name = $folder->fullname; |
99
|
36
|
|
|
|
|
3403
|
for($name) |
100
|
36
|
|
|
|
|
128
|
{ s/^=//; |
101
|
36
|
|
|
|
|
139
|
s![/\\]!$delim!g; |
102
|
|
|
|
|
|
|
} |
103
|
36
|
|
|
|
|
182
|
return [ "(@flags)", $delim, $name ]; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
91
|
|
|
|
|
148
|
my $pat = shift; |
107
|
91
|
100
|
|
|
|
176
|
if($pat eq '%') |
108
|
3
|
100
|
|
|
|
7
|
{ my $subs = $folder->subfolders |
109
|
|
|
|
|
|
|
or return $self->_list($folder, $delim); |
110
|
2
|
|
|
|
|
142
|
return map { $self->_list($_, $delim, @_) } $subs->sorted; |
|
6
|
|
|
|
|
88
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
88
|
100
|
|
|
|
126
|
if($pat eq '*') |
114
|
40
|
|
|
|
|
76
|
{ my @own = $self->_list($folder, $delim, @_); |
115
|
40
|
100
|
|
|
|
391
|
my $subs = $folder->subfolders or return @own; |
116
|
13
|
|
|
|
|
891
|
return @own, map { $self->_list($_, $delim, '*', @_) } $subs->sorted; |
|
34
|
|
|
|
|
2892
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
48
|
100
|
|
|
|
100
|
$folder = $folder->find(subfolders => $pat) or return (); |
120
|
20
|
|
|
|
|
667
|
$self->_list($folder, $delim, @_); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
#------------------------------------------ |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |