Transport/POP3.pm

filter: Statementstmt 11.0% 23 / 208 Branchbran 0.0% 0 / 130 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 24.1% 7 / 29 Podpod 94.7% 18 / 19 totaltotal 11.0% 48 / 434 SCAR 85.6
CC
79
Cov
6%
login
342.0
status
182.0
message
72.0
CRAP 5221.4
↑ Summary Box/POP3.pm »
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-POP3. 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::Transport::POP3;
10 4 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 $VERSION = '3.005';
12  
13 4 ▶use base 'Mail::Transport::Receive';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 4 ▶use IO::Socket ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use Socket qw/$CRLF/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use Digest::MD5 qw/md5_hex/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 0 ▶sub _OK($) { substr(shift // '', 0, 3) eq '+OK' }
Subroutine _OK: not called CC=2 SCAR=17.9
Condition0%0/2
shift() // ""
l!l
00
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
24  
25 sub init($)
26 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=5 SCAR=34.0
Pod undocumented
27 0 $args->{via} = 'pop3';
28 0 ▶ $args->{port} ||= 110;
Condition0%0/2
$args->{"port"} ||= 110
l!l
00
MC/DC0%0/1
$args->{"port"} ||= 110
$args->{"port"}
Truth table0%0/2
A
A= $args->{"port"}
Aresult
11
00
29  
30 0 ▶ $self->SUPER::init($args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($args) or return 0 0 0
31  
32 0 ▶ $self->{MTP_auth} = $args->{authenticate} || 'AUTO';
Condition0%0/2
$args->{'authenticate'} || 'AUTO'
l!l
00
MC/DC0%0/1
$args->{'authenticate'} || 'AUTO'
$args->{'authenticate'}
Truth table0%0/2
A
A= $args->{'authenticate'}
Aresult
11
00
33 0 $self->{MTP_ssl} = $args->{use_ssl};
34 0 ▶ $self->socket or return; # establish connection
Branch: 1 branch
BranchTrueFalseTotal
$self->socket or return 0 0 0
35  
36 0 $self;
37 }
38  
39 #------------------------------------------
40  
41 0 ▶sub useSSL() { shift->{MTP_ssl} }
Subroutine useSSL: not called CC=1 SCAR=6.9
Pod documented
42  
43 #------------------------------------------
44  
45 sub ids(;@)
46 0 ▶{ my $self = shift;
Subroutine ids: not called CC=3 SCAR=24.8
Pod documented
47 0 ▶ $self->socket or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->socket or return 0 0 0
48 0 ▶ wantarray ? @{$self->{MTP_n2uidl}} : $self->{MTP_n2uidl};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
49 }
50  
51  
52 sub messages()
53 0 ▶{ my $self = shift;
Subroutine messages: not called CC=2 SCAR=17.9
Pod documented
54  
55 0 ▶ $self->log(ERROR =>"Cannot get the messages of pop3 via messages()."), return ()
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
56 if wantarray;
57  
58 0 $self->{MTP_messages};
59 }
60  
61  
62 0 ▶sub folderSize() { shift->{MTP_folder_size} }
Subroutine folderSize: not called CC=1 SCAR=6.9
Pod documented
63  
64  
65 sub header($;$)
66 0 ▶{ my ($self, $uidl) = (shift, shift);
Subroutine header: not called CC=5 SCAR=34.0
Pod documented
67 0 ▶ return unless $uidl;
Branch: 1 branch
BranchTrueFalseTotal
unless $uidl 0 0 0
68 0 ▶ my $bodylines = shift || 0;;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
69  
70 0 ▶ my $socket = $self->socket or return;
Branch: 1 branch
BranchTrueFalseTotal
my $socket = $self->socket or return 0 0 0
71 0 ▶ my $n = $self->id2n($uidl) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $n = $self->id2n($uidl) or return 0 0 0
72  
73 0 $self->sendList($socket, "TOP $n $bodylines$CRLF");
74 }
75  
76  
77 sub message($;$)
78 0 ▶{ my ($self, $uidl) = @_;
Subroutine message: not called CC=8 SCAR=42.8
Pod documented
79 0 ▶ return unless $uidl;
Branch: 1 branch
BranchTrueFalseTotal
unless $uidl 0 0 0
80  
81 0 ▶ my $socket = $self->socket or return;
Branch: 1 branch
BranchTrueFalseTotal
my $socket = $self->socket or return 0 0 0
82 0 ▶ my $n = $self->id2n($uidl) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $n = $self->id2n($uidl) or return 0 0 0
83 0 my $message = $self->sendList($socket, "RETR $n$CRLF");
84  
85 0 ▶ return unless $message;
Branch: 1 branch
BranchTrueFalseTotal
unless $message 0 0 0
86  
87 # Some POP3 servers add a trailing empty line
88 0 ▶ pop @$message if @$message && $message->[-1] =~ m/^[\012\015]*$/;
Branch: 1 branch
BranchTrueFalseTotal
if @$message and $message->[-1] =~ /^[\012\015]*$/ 0 0 0
Condition0%0/3
@$message and $message->[-1] =~ /^[\012\015]*$/
!ll&&!rl&&r
000
MC/DC0%0/2
@$message and $message->[-1] =~ /^[\012\015]*$/
@$message $message->[-1] =~ /^[\012\015]*$/
Truth table0%0/3
A and B
A= @$messageB= $message->[-1] =~ /^[\012\015]*$/
ABresult
0X0
100
111
89  
90 $self->{MTP_fetched}{$uidl} = undef # mark this ID as fetched
91 0 ▶ unless exists $self->{MTP_nouidl};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"MTP_nouidl"} 0 0 0
92  
93 0 $message;
94 }
95  
96  
97 sub messageSize($)
98 0 ▶{ my ($self, $uidl) = @_;
Subroutine messageSize: not called CC=7 SCAR=40.3
Pod documented
99 0 ▶ return unless $uidl;
Branch: 1 branch
BranchTrueFalseTotal
unless $uidl 0 0 0
100  
101 0 my $list;
102 0 ▶ unless($list = $self->{MTP_n2length})
Branch: 1 branch
BranchTrueFalseTotal
unless ($list = $self->{"MTP_n2length"}) 0 0 0
103 0 ▶ { my $socket = $self->socket or return;
Branch: 1 branch
BranchTrueFalseTotal
my $socket = $self->socket or return 0 0 0
104 0 ▶ my $raw = $self->sendList($socket, "LIST$CRLF") or return;
Branch: 1 branch
BranchTrueFalseTotal
my $raw = $self->sendList($socket, "LIST$Mail::Transport::POP3::CRLF") or return 0 0 0
105 0 my @n2length;
106 0 foreach (@$raw)
107 0 { m#^(\d+) (\d+)#;
108 0 $n2length[$1] = $2;
109 }
110 0 $self->{MTP_n2length} = $list = \@n2length;
111 }
112  
113 0 ▶ my $n = $self->id2n($uidl) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $n = $self->id2n($uidl) or return 0 0 0
114 0 $list->[$n];
115 }
116  
117  
118 sub deleted($@)
119 0 ▶{ my $dele = shift->{MTP_dele} ||= {};
Subroutine deleted: not called CC=3 SCAR=24.8
Pod documented
Condition0%0/2
+(shift())->{"MTP_dele"} ||= {}
l!l
00
MC/DC0%0/1
+(shift())->{"MTP_dele"} ||= {}
+(shift())->{"MTP_dele"}
Truth table0%0/2
A
A= +(shift())->{"MTP_dele"}
Aresult
11
00
120 0 ▶ (shift) ? @$dele{ @_ } = () : delete @$dele{ @_ };
Branch: 1 branch
BranchTrueFalseTotal
shift() ? : 0 0 0
121 }
122  
123  
124 sub deleteFetched()
125 0 ▶{ my $self = shift;
Subroutine deleteFetched: not called CC=1 SCAR=6.9
Pod documented
126 0 $self->deleted(1, keys %{$self->{MTP_fetched}});
127 }
128  
129  
130 sub disconnect()
131 0 ▶{ my $self = shift;
Subroutine disconnect: not called CC=7 SCAR=40.3
Pod documented
132  
133 0 my $quit;
134 0 ▶ if($self->{MTP_socket}) # can only disconnect once
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"MTP_socket"}) 0 0 0
135 0 ▶ { if(my $socket = $self->socket)
Branch: 1 branch
BranchTrueFalseTotal
if (my $socket = $self->socket) 0 0 0
136 0 ▶ { my $dele = $self->{MTP_dele} || {};
Condition0%0/2
$self->{'MTP_dele'} || {}
l!l
00
MC/DC0%0/1
$self->{'MTP_dele'} || {}
$self->{'MTP_dele'}
Truth table0%0/2
A
A= $self->{'MTP_dele'}
Aresult
11
00
137 0 ▶ while(my $uidl = each %$dele)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $uidl = each %$dele)) 0 0 0
138 0 ▶ { my $n = $self->id2n($uidl) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $n = $self->id2n($uidl) or next 0 0 0
139 0 ▶ $self->send($socket, "DELE $n$CRLF") or last;
Branch: 1 branch
BranchTrueFalseTotal
$self->send($socket, "DELE $n$Mail::Transport::POP3::CRLF") or last 0 0 0
140 }
141  
142 0 $quit = $self->send($socket, "QUIT$CRLF");
143 0 close $socket;
144 }
145 }
146  
147 0 delete @$self{ qw(
148 MTP_socket
149 MTP_dele
150 MTP_uidl2n
151 MTP_n2uidl
152 MTP_n2length
153 MTP_fetched
154 ) };
155  
156 0 _OK $quit;
157 }
158  
159  
160 sub fetched(;$)
161 0 ▶{ my $self = shift;
Subroutine fetched: not called CC=2 SCAR=17.9
Pod documented
162 0 ▶ return if exists $self->{MTP_nouidl};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"MTP_nouidl"} 0 0 0
163 0 $self->{MTP_fetched};
164 }
165  
166  
167 0 ▶sub id2n($;$) { shift->{MTP_uidl2n}{shift()} }
Subroutine id2n: not called CC=1 SCAR=6.9
Pod documented
168  
169 #------------------------------------------
170  
171  
172 sub socket()
173 0 ▶{ my $self = shift;
Subroutine socket: not called CC=5 SCAR=34.0
Pod documented
174  
175 # Do we (still) have a working connection which accepts commands?
176 0 my $socket = $self->_connection;
177 0 ▶ return $socket if defined $socket;
Branch: 1 branch
BranchTrueFalseTotal
if defined $socket 0 0 0
178  
179 0 ▶ if(exists $self->{MTP_nouidl})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"MTP_nouidl"}) 0 0 0
180 0 { $self->log(ERROR =>
181 "Can not re-connect reliably to server which doesn't support UIDL");
182 0 return;
183 }
184  
185 # (Re-)establish the connection
186 0 ▶ $socket = $self->login or return;
Branch: 1 branch
BranchTrueFalseTotal
$socket = $self->login or return 0 0 0
187 0 ▶ $self->status($socket) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->status($socket) or return 0 0 0
188 0 $self->{MTP_socket} = $socket;
189 }
190  
191  
192  
193 sub send($$)
194 0 ▶{ my $self = shift;
Subroutine send: not called CC=3 SCAR=24.8
Pod documented
195 0 my $socket = shift;
196 0 my $response;
197
198 0 ▶ if(eval {print $socket @_})
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { print $socket @_ } }) { } 0 0 0
199 0 { $response = <$socket>;
200 0 ▶ $self->log(ERROR => "Cannot read POP3 from socket: $!")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $response 0 0 0
201 unless defined $response;
202 }
203 else
204 0 { $self->log(ERROR => "Cannot write POP3 to socket: $@");
205 }
206 0 $response;
207 }
208  
209  
210 sub sendList($$)
211 0 ▶{ my ($self, $socket) = (shift, shift);
Subroutine sendList: not called CC=5 SCAR=34.0
Pod documented
212 0 my $response = $self->send($socket, @_);
213 0 ▶ $response && _OK $response or return;
Branch: 1 branch
BranchTrueFalseTotal
$response and &_OK($response) or return 0 0 0
Condition0%0/3
$response and &_OK($response)
!ll&&!rl&&r
000
MC/DC0%0/2
$response and &_OK($response)
$response &_OK($response)
Truth table0%0/3
A and B
A= $responseB= &_OK($response)
ABresult
0X0
100
111
214  
215 0 my @list;
216 0 ▶ while(my $line = <$socket>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $socket)) 0 0 0
217 0 ▶ { last if $line =~ m#^\.\r?\n#s;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\.\r?\n/s 0 0 0
218 0 $line =~ s#^\.##;
219 0 push @list, $line;
220 }
221  
222 0 \@list;
223 }
224  
225 sub DESTROY()
226 0 ▶{ my $self = shift;
Subroutine DESTROY: not called CC=2 SCAR=17.9
227 0 $self->SUPER::DESTROY;
228 0 ▶ $self->disconnect if $self->{MTP_socket}; # only when open
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MTP_socket"} 0 0 0
229 }
230  
231 sub _connection()
232 0 ▶{ my $self = shift;
Subroutine _connection: not called CC=4 SCAR=30.0
233  
234 0 my $socket = $self->{MTP_socket};
235 0 ▶ defined $socket or return;
Branch: 1 branch
BranchTrueFalseTotal
defined $socket or return 0 0 0
236  
237 # Check if we (still) got a connection
238 0 eval { print $socket "NOOP$CRLF" };
239 0 ▶ if($@ || ! <$socket> )
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not readline $socket) 0 0 0
Condition0%0/3
$@ or not readline $socket
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not readline $socket
$@ not readline $socket
Truth table0%0/3
A or not(B)
A= $@B= not readline $socket
ABresult
1X1
011
000
240 0 { delete $self->{MTP_socket};
241 0 return undef;
242 }
243  
244 0 $socket;
245 }
246  
247  
248  
249 sub login(;$)
250 0 ▶{ my $self = shift;
Subroutine login: not called CC=18 SCAR=58.3
Pod documented
251  
252 # Check if we can make a connection
253  
254 0 my ($host, $port, $username, $password) = $self->remoteHost;
255 0 ▶ unless($username && $password)
Branch: 1 branch
BranchTrueFalseTotal
unless ($username and $password) 0 0 0
Condition0%0/3
$username and $password
!ll&&!rl&&r
000
MC/DC0%0/2
$username and $password
$username $password
Truth table0%0/3
A and B
A= $usernameB= $password
ABresult
0X0
100
111
256 0 { $self->log(ERROR => "POP3 requires a username and password.");
257 0 return;
258 }
259  
260 0 ▶ my $net = $self->useSSL ? 'IO::Socket::SSL' : 'IO::Socket::INET';
Branch: 1 branch
BranchTrueFalseTotal
$self->useSSL ? : 0 0 0
261 0 ▶ eval "require $net" or die $@;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $net" or die $@ 0 0 0
262  
263 0 my $socket = eval { $net->new("$host:$port") };
264 0 ▶ unless($socket)
Branch: 1 branch
BranchTrueFalseTotal
unless ($socket) 0 0 0
265 0 { $self->log(ERROR => "Cannot connect to $host:$port for POP3: $!");
266 0 return;
267 }
268  
269 # Check if it looks like a POP server
270  
271 0 my $connected;
272 0 my $authenticate = $self->{MTP_auth};
273 0 my $welcome = <$socket>;
274 0 ▶ unless(_OK $welcome)
Branch: 1 branch
BranchTrueFalseTotal
unless (&_OK($welcome)) 0 0 0
275 0 { $self->log(ERROR =>
276 "Server at $host:$port does not seem to be talking POP3.");
277 0 return;
278 }
279  
280 # Check APOP login if automatic or APOP specifically requested
281 0 ▶ if($authenticate eq 'AUTO' || $authenticate eq 'APOP')
Branch: 1 branch
BranchTrueFalseTotal
if ($authenticate eq "AUTO" or $authenticate eq "APOP") 0 0 0
Condition0%0/3
$authenticate eq "AUTO" or $authenticate eq "APOP"
l!l&&r!l&&!r
000
MC/DC0%0/2
$authenticate eq "AUTO" or $authenticate eq "APOP"
$authenticate eq "AUTO" $authenticate eq "APOP"
Truth table0%0/3
A or B
A= $authenticate eq "AUTO"B= $authenticate eq "APOP"
ABresult
1X1
011
000
282 0 ▶ { if($welcome =~ m#^\+OK .*(<\d+\.\d+\@[^>]+>)#)
Branch: 1 branch
BranchTrueFalseTotal
if ($welcome =~ /^\+OK .*(<\d+\.\d+\@[^>]+>)/) 0 0 0
283 0 { my $md5 = md5_hex $1.$password;
284 0 my $response = $self->send($socket, "APOP $username $md5$CRLF");
285 0 $connected = _OK $response;
286 }
287 }
288  
289 # Check USER/PASS login if automatic and failed or LOGIN specifically
290 # requested.
291 0 ▶ unless($connected)
Branch: 1 branch
BranchTrueFalseTotal
unless ($connected) 0 0 0
292 0 ▶ { if($authenticate eq 'AUTO' || $authenticate eq 'LOGIN')
Branch: 1 branch
BranchTrueFalseTotal
if ($authenticate eq "AUTO" or $authenticate eq "LOGIN") 0 0 0
Condition0%0/3
$authenticate eq "AUTO" or $authenticate eq "LOGIN"
l!l&&r!l&&!r
000
MC/DC0%0/2
$authenticate eq "AUTO" or $authenticate eq "LOGIN"
$authenticate eq "AUTO" $authenticate eq "LOGIN"
Truth table0%0/3
A or B
A= $authenticate eq "AUTO"B= $authenticate eq "LOGIN"
ABresult
1X1
011
000
293 0 ▶ { my $response = $self->send($socket, "USER $username$CRLF")
Branch: 1 branch
BranchTrueFalseTotal
my $response = $self->send($socket, "USER $username$Mail::Transport::POP3::CRLF") or return 0 0 0
294 or return;
295  
296 0 ▶ if(_OK $response)
Branch: 1 branch
BranchTrueFalseTotal
if (&_OK($response)) 0 0 0
297 0 ▶ { my $response2 = $self->send($socket, "PASS $password$CRLF")
Branch: 1 branch
BranchTrueFalseTotal
my $response2 = $self->send($socket, "PASS $password$Mail::Transport::POP3::CRLF") or return 0 0 0
298 or return;
299 0 $connected = _OK $response2;
300 }
301 }
302 }
303  
304 # If we're still not connected now, we have an error
305 0 ▶ unless($connected)
Branch: 1 branch
BranchTrueFalseTotal
unless ($connected) 0 0 0
306 0 ▶ { $self->log(ERROR => $authenticate eq 'AUTO' ?
Branch: 1 branch
BranchTrueFalseTotal
$authenticate eq 'AUTO' ? : 0 0 0
307 "Could not authenticate using any login method" :
308 "Could not authenticate using '$authenticate' method");
309 0 return;
310 }
311  
312 0 $socket;
313 }
314  
315  
316  
317 sub status($;$)
318 0 ▶{ my ($self, $socket) = @_;
Subroutine status: not called CC=13 SCAR=52.0
Pod documented
319  
320 # Check if we can do a STAT
321  
322 0 ▶ my $stat = $self->send($socket, "STAT$CRLF") or return;
Branch: 1 branch
BranchTrueFalseTotal
my $stat = $self->send($socket, "STAT$Mail::Transport::POP3::CRLF") or return 0 0 0
323 0 ▶ if($stat !~ m#^\+OK (\d+) (\d+)#)
Branch: 1 branch
BranchTrueFalseTotal
unless ($stat =~ /^\+OK (\d+) (\d+)/) 0 0 0
324 0 { delete $self->{MTP_messages};
325 0 delete $self->{MTP_size};
326 0 $self->log(ERROR => "POP3 Could not do a STAT");
327 0 return;
328 }
329 0 $self->{MTP_messages} = my $nr_msgs = $1;
330 0 $self->{MTP_folder_size} = $2;
331  
332 # Check if we can do a UIDL
333  
334 0 ▶ my $uidl = $self->send($socket, "UIDL$CRLF") or return;
Branch: 1 branch
BranchTrueFalseTotal
my $uidl = $self->send($socket, "UIDL$Mail::Transport::POP3::CRLF") or return 0 0 0
335 0 $self->{MTP_nouidl} = undef;
336 0 delete $self->{MTP_uidl2n}; # drop the reverse lookup: UIDL -> number
337  
338 0 ▶ if(_OK $uidl)
Branch: 1 branch
BranchTrueFalseTotal
if (&_OK($uidl)) { } 0 0 0
339 0 { my @n2uidl;
340 0 $n2uidl[$nr_msgs] = undef; # pre-alloc
341  
342 0 ▶ while(my $line = <$socket>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $socket)) 0 0 0
343 0 ▶ { last if substr($line, 0, 1) eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if substr($line, 0, 1) eq "." 0 0 0
344 0 ▶ $line =~ m#^(\d+) (.+?)\r?\n# or next;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^(\d+) (.+?)\r?\n/ or next 0 0 0
345 0 $n2uidl[$1] = $2;
346 }
347  
348 0 shift @n2uidl; # make message 1 into index 0
349 0 $self->{MTP_n2uidl} = \@n2uidl;
350 0 delete $self->{MTP_n2length};
351 0 delete $self->{MTP_nouidl};
352 }
353 else
354 { # We can't do UIDL, we need to fake it
355 0 ▶ my $list = $self->send($socket, "LIST$CRLF") or return;
Branch: 1 branch
BranchTrueFalseTotal
my $list = $self->send($socket, "LIST$Mail::Transport::POP3::CRLF") or return 0 0 0
356 0 my (@n2length, @n2uidl);
357  
358 0 ▶ if(_OK $list)
Branch: 1 branch
BranchTrueFalseTotal
if (&_OK($list)) 0 0 0
359 0 { $n2length[$nr_msgs] = $n2uidl[$nr_msgs] = undef; # alloc all
360  
361 0 my ($host, $port) = $self->remoteHost;
362 0 ▶ while(my $line = <$socket>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $socket)) 0 0 0
363 0 ▶ { last if substr($line, 0, 1) eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if substr($line, 0, 1) eq "." 0 0 0
364 0 ▶ $line =~ m#^(\d+) (\d+)# or next;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^(\d+) (\d+)/ or next 0 0 0
365 0 $n2length[$1] = $2;
366 0 $n2uidl[$1] = "$host:$port:$1"; # fake UIDL, for id only
367 }
368 0 shift @n2length; shift @n2uidl; # make 1st message in index 0
369 }
370 0 $self->{MTP_n2length} = \@n2length;
371 0 $self->{MTP_n2uidl} = \@n2uidl;
372 }
373  
374 0 my $i = 1;
375 0 my %uidl2n = map +($_ => $i++), @{$self->{MTP_n2uidl}};
376 0 $self->{MTP_uidl2n} = \%uidl2n;
377  
378 0 1;
379 }
380  
381 #------------------------------------------
382  
383  
384 sub url(;$)
385 0 ▶{ my $self = shift;
Subroutine url: not called CC=2 SCAR=17.9
Pod documented
386 0 my ($host, $port, $user, $pwd) = $self->remoteHost;
387 0 ▶ my $proto = $self->useSSL ? 'pop3s' : 'pop3';
Branch: 1 branch
BranchTrueFalseTotal
$self->useSSL ? : 0 0 0
388 0 "$proto://$user:$pwd\@$host:$port";
389 }
390  
391 #------------------------------------------
392  
393  
394 4 1;
↑ Summary Box/POP3.pm »