$capa .= ' COMPRESS=DEFLATE';
} else {
if (!($self->{sock} // $self)->can('accept_SSL') &&
- $self->{imapd}->{accept_tls}) {
+ $self->{imapd}->{ssl_ctx_opt}) {
$capa .= ' STARTTLS';
}
$capa .= ' AUTH=ANONYMOUS';
"$idle_tag OK Idle done\r\n";
}
-sub ensure_slices_exist ($$$) {
- my ($imapd, $ibx, $max) = @_;
- defined(my $mb_top = $ibx->{newsgroup}) or return;
+sub ensure_slices_exist ($$) {
+ my ($imapd, $ibx) = @_;
+ my $mb_top = $ibx->{newsgroup} // return;
my $mailboxes = $imapd->{mailboxes};
- my @created;
- for (my $i = int($max/UID_SLICE); $i >= 0; --$i) {
+ my $list = $imapd->{mailboxlist}; # may be undef, just autoviv + noop
+ for (my $i = int($ibx->art_max/UID_SLICE); $i >= 0; --$i) {
my $sub_mailbox = "$mb_top.$i";
last if exists $mailboxes->{$sub_mailbox};
$mailboxes->{$sub_mailbox} = $ibx;
$sub_mailbox =~ s/\Ainbox\./INBOX./i; # more familiar to users
- push @created, $sub_mailbox;
+ push @$list, qq[* LIST (\\HasNoChildren) "." $sub_mailbox\r\n]
}
- return unless @created;
- my $l = $imapd->{mailboxlist} or return;
- push @$l, map { qq[* LIST (\\HasNoChildren) "." $_\r\n] } @created;
}
sub inbox_lookup ($$;$) {
my $uid_end = $uid_base + UID_SLICE;
$exists = $over->imap_exists($uid_base, $uid_end);
}
- ensure_slices_exist($self->{imapd}, $ibx, $over->max);
+ delete $ibx->{-art_max};
+ ensure_slices_exist($self->{imapd}, $ibx);
} else {
if ($examine) {
$self->{uid_base} = $uid_base;
}
# if "INBOX.foo.bar" is selected and "INBOX.foo.bar.0",
# check for new UID ranges (e.g. "INBOX.foo.bar.1")
- if (my $z = $self->{imapd}->{mailboxes}->{"$mailbox.0"}) {
- ensure_slices_exist($self->{imapd}, $z,
- $z->over(1)->max);
+ if (my $ibx = $self->{imapd}->{mailboxes}->{"$mailbox.0"}) {
+ delete $ibx->{-art_max};
+ ensure_slices_exist($self->{imapd}, $ibx);
}
}
($ibx, $exists, $uidmax + 1, $uid_base);
sub cmd_starttls ($$) {
my ($self, $tag) = @_;
- my $sock = $self->{sock} or return;
- if ($sock->can('stop_SSL') || $self->compressed) {
+ (($self->{sock} // return)->can('stop_SSL') || $self->compressed) and
return "$tag BAD TLS or compression already enabled\r\n";
- }
- my $opt = $self->{imapd}->{accept_tls} or
+ $self->{imapd}->{ssl_ctx_opt} or
return "$tag BAD can not initiate TLS negotiation\r\n";
$self->write(\"$tag OK begin TLS negotiation now\r\n");
- $self->{sock} = IO::Socket::SSL->start_SSL($sock, %$opt);
+ PublicInbox::TLS::start($self->{sock}, $self->{imapd});
$self->requeue if PublicInbox::DS::accept_tls_step($self);
undef;
}