line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Stats::Config; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
372022
|
use AppConfig qw(:argcount); |
|
1
|
|
|
|
|
6512
|
|
|
1
|
|
|
|
|
142
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
492
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
|
|
|
my $cfg = shift; |
10
|
0
|
|
|
|
|
|
my $this = { |
11
|
|
|
|
|
|
|
raw_cfg => $cfg, |
12
|
|
|
|
|
|
|
message => "%% count %% new messages in %% mbox %%\n", |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Now we set up the sort routines |
16
|
0
|
|
|
|
|
|
bless $this, $class; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$this->_parse_config(); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$this->_parse_args(); |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
return $this; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _parse_args { |
26
|
0
|
|
|
0
|
|
|
my $this = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# First set sorts |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $sort = $this->{raw_cfg}->{s}; # default just in case |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if($sort eq 'A') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
33
|
0
|
|
|
0
|
|
|
$this->{sort} = sub {$Mail::Stats::b cmp $Mail::Stats::a}; |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} elsif($sort eq 'N') { |
35
|
0
|
|
|
0
|
|
|
$this->{sort} = sub {my $hash = shift; $hash->{$Mail::Stats::b}->num_unread() <=> $hash->{$Mail::Stats::a}->num_unread()}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} elsif($sort eq 'n') { |
37
|
0
|
|
|
0
|
|
|
$this->{sort} = sub {my $hash = shift; $hash->{$Mail::Stats::a}->num_unread() <=> $hash->{$Mail::Stats::b}->num_unread()}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} elsif($sort eq 'a') { # defaults to 'a' |
39
|
0
|
|
|
0
|
|
|
$this->{sort} = sub {$Mail::Stats::a cmp $Mail::Stats::b}; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if($this->{raw_cfg}->{m}) { |
43
|
0
|
|
|
|
|
|
$this->{mboxen} = [split(/:/,$this->{raw_cfg}->{m})]; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
0
|
|
|
|
|
$this->{showall} = 1 if $this->{raw_cfg}->{a}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _parse_config { |
50
|
0
|
|
|
0
|
|
|
my $this = shift; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
|
|
my $config = AppConfig->new( |
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
CASE => 0, |
55
|
|
|
|
|
|
|
CREATE => 1, |
56
|
|
|
|
|
|
|
ERROR => sub {return}, |
57
|
0
|
|
|
|
|
|
GLOBAL => { |
58
|
|
|
|
|
|
|
ARGCOUNT => ARGCOUNT_ONE, |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
); |
62
|
0
|
|
|
|
|
|
$config->define("mailbox" => {ARGCOUNT => ARGCOUNT_LIST}); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
0
|
|
|
|
my $cfgfile = $this->{raw_cfg}->{c} || "$ENV{HOME}/.countmailrc"; |
65
|
0
|
|
|
|
|
|
$config->file($cfgfile); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$this->{mboxen} = $config->mailbox; |
68
|
0
|
0
|
|
|
|
|
if($config->message()) { |
69
|
0
|
|
|
|
|
|
my $temp = $config->message(); |
70
|
|
|
|
|
|
|
# do some quick fix ups so you can put tabs or newlines in |
71
|
|
|
|
|
|
|
# the message format |
72
|
0
|
|
|
|
|
|
$temp =~ s/\\n/\n/; |
73
|
0
|
|
|
|
|
|
$temp =~ s/\\t/\t/; |
74
|
0
|
|
|
|
|
|
$this->{message} = $temp; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|