| 1 | package Net::IMAP::Server::Command::Lsub; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use base qw/Net::IMAP::Server::Command::List/; | ||
| 7 | |||
| 8 | sub traverse { | ||
| 9 | my $self = shift; | ||
| 10 | my $node = shift; | ||
| 11 | my $regex = shift; | ||
| 12 | |||
| 13 | $self->list_out($node) if $node->parent and $node->full_path =~ $regex and $node->subscribed; | ||
| 14 | my @kids = grep {$_} map {$self->traverse( $_, $regex )} @{ $node->children }; | ||
| 15 | if (@kids and $node->parent and not $node->subscribed) { | ||
| 16 | if ($node->full_path =~ $regex) { | ||
| 17 | $self->list_out($node, '\NoSelect'); | ||
| 18 | return 0; | ||
| 19 | } else { | ||
| 20 | return 1; | ||
| 21 | } | ||
| 22 | } | ||
| 23 | return 1 if $node->parent and not $node->full_path =~ $regex and $node->subscribed; | ||
| 24 | return 0; | ||
| 25 | } | ||
| 26 | |||
| 27 | 1; |