| 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::Box::IMAP4::Message; | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | $VERSION = '3.007'; | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use base 'Mail::Box::Net::Message'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Date::Parse 'str2time'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | $self->{MBIM_write_labels} | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | = exists $args->{write_labels} ? $args->{write_labels} : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $self->{MBIM_cache_labels} = $args->{cache_labels}; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $self->{MBIM_cache_head} = $args->{cache_head}; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $self->{MBIM_cache_body} = $args->{cache_body}; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | sub size($) | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return $self->SUPER::size | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | unless $self->isDelayed; | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $self->fetch('RFC822.SIZE'); | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | sub recvstamp() | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | { my $date = shift->fetch('INTERNALDATE'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recvstamp: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | defined $date ? str2time($date) : undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | sub label(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $imap = $self->folder->transporter or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $id = $self->unique or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if(@_ == 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | { # get one value only | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $label = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $labels = $self->{MM_labels}; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | return $labels->{$label} | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if exists $labels->{$label} || exists $labels->{seen}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $labels->{$label} or exists $labels->{"seen"}
MC/DC0%0/2
exists $labels->{$label} or exists $labels->{"seen"}
exists $labels->{$label}
exists $labels->{"seen"}
Truth table0%0/3
A or B
A= exists $labels->{$label}B= exists $labels->{"seen"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $flags = $imap->getFlags($id); | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if($self->{MBIM_cache_labels}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | { # the program may have added own labels | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | @{$labels}{keys %$flags} = values %$flags; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | delete $self->{MBIM_labels_changed}; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return $flags->{$label}; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my @private; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if($self->{MBIM_write_labels}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | { @private = $imap->setFlags($id, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | delete $self->{MBIM_labels_changed}; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | { @private = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $labels = $self->{MM_labels}; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my @keep = $self->{MBIM_cache_labels} ? @_ : @private; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | while(@keep) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | { my ($k, $v) = (shift @keep, shift @keep); | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | next if defined $labels->{$k} && $labels->{$k} eq $v; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $labels->{$k} and $labels->{$k} eq $v
MC/DC0%0/2
defined $labels->{$k} and $labels->{$k} eq $v
defined $labels->{$k}
$labels->{$k} eq $v
Truth table0%0/3
A and B
A= defined $labels->{$k}B= $labels->{$k} eq $v
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->{MBIM_labels_changed}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $labels->{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | $self->modified(1) if @private && $self->{MBIM_labels_changed}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@private and $self->{"MBIM_labels_changed"}
MC/DC0%0/2
@private and $self->{"MBIM_labels_changed"}
@private
$self->{"MBIM_labels_changed"}
Truth table0%0/3
A and B
A= @privateB= $self->{"MBIM_labels_changed"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | sub labels() | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
labels: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $id = $self->unique; | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $labels = $self->SUPER::labels; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $labels = { %$labels } unless $self->{MBIM_cache_labels}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if($id && !exists $labels->{seen}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$id and not exists $labels->{"seen"}
MC/DC0%0/2
$id and not exists $labels->{"seen"}
$id
not exists $labels->{"seen"}
Truth table0%0/3
A and not(B)
A= $idB= not exists $labels->{"seen"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | { my $imap = $self->folder->transporter or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $flags = $imap->getFlags($id); | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | @{$labels}{keys %$flags} = values %$flags; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $labels; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | sub loadHead() | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadHead: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $head = $self->head; | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return $head unless $head->isDelayed; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $head = $self->folder->getHead($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $self->head($head) if $self->{MBIM_cache_head}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $head; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | sub loadBody() | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadBody: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $body = $self->body; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return $body unless $body->isDelayed; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | (my $head, $body) = $self->folder->getHeadAndBody($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | return undef unless defined $head; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $self->head($head) if $self->{MBIM_cache_head} && $head->isDelayed; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"MBIM_cache_head"} and $head->isDelayed
MC/DC0%0/2
$self->{"MBIM_cache_head"} and $head->isDelayed
$self->{"MBIM_cache_head"}
$head->isDelayed
Truth table0%0/3
A and B
A= $self->{"MBIM_cache_head"}B= $head->isDelayed
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $self->storeBody($body) if $self->{MBIM_cache_body}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $body; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | sub fetch(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | { my ($self, @info) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $folder = $self->folder; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $answer = ($folder->fetch( [$self], @info))[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | @info==1 ? $answer->{$info[0]} : @{$answer}{@info}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | sub writeDelayed($$) | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | { my ($self, $foldername, $imap) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
writeDelayed: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $id = $self->unique; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $labels = $self->labels; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if($self->head->modified || $self->body->modified || !$id) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$self->head->modified or $self->body->modified or not $id
$self->head->modified or $self->body->modified
MC/DC0%0/3
$self->head->modified or $self->body->modified or not $id
$self->head->modified
$self->body->modified
not $id
Truth table0%0/4
A or B or not(C)
A= $self->head->modifiedB= $self->body->modifiedC= not $id
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $imap->appendMessage($self, $foldername); | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if($id) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | { $self->delete; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $self->unique(undef); | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | elsif($self->{MBIM_labels_changed}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | { $imap->setFlags($id, %$labels); # non-IMAP4 labels disappear | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | delete $self->{MBIM_labels_changed}; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | #------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||