line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# email::mbox Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Email::Mbox; |
7
|
1
|
|
|
1
|
|
540
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use base qw(Metabrik); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
547
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
input => [ qw(mbox_file) ], |
20
|
|
|
|
|
|
|
_folder => [ qw(INTERNAL) ], |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
commands => { |
23
|
|
|
|
|
|
|
open => [ qw(mbox_file|OPTIONAL) ], |
24
|
|
|
|
|
|
|
read => [ ], |
25
|
|
|
|
|
|
|
read_next => [ ], |
26
|
|
|
|
|
|
|
close => [ ], |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
require_modules => { |
29
|
|
|
|
|
|
|
'Email::Folder' => [ ], |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub open { |
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
36
|
0
|
|
|
|
|
|
my ($input) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
0
|
|
|
|
$input ||= $self->input; |
39
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('open', $input) or return; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $folder = Email::Folder->new($input); |
42
|
0
|
0
|
|
|
|
|
if (! defined($folder)) { |
43
|
0
|
|
|
|
|
|
return $self->log->error("open: Email::Folder new failed for mbox [$input]"); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self->_folder($folder); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub read { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $folder = $self->_folder; |
53
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('open', $folder) or return; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my @messages = (); |
56
|
0
|
|
|
|
|
|
for my $message ($folder->messages) { |
57
|
0
|
|
|
|
|
|
my $subject = $message->header('Subject'); |
58
|
0
|
|
|
|
|
|
$self->log->verbose("read: Subject [$subject]"); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
push @messages, $message; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return \@messages; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub read_next { |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $folder = $self->_folder; |
70
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('open', $folder) or return; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $message = $folder->next_message; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $message; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub close { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return 1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |