1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
#-*- perl -*-
#
# Copyright (C) 2001,2002 Ken'ichi Fukamachi
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
# $FML: Text.pm,v 1.6 2002/01/13 14:51:26 fukachan Exp $
#
package Mail::ThreadTrack::Print::Text;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
use Mail::ThreadTrack::Print::Utils qw(decode_mime_string STR2EUC);
=head1 NAME
Mail::ThreadTrack::Print::Text - what is this
=head1 SYNOPSIS
See C<Mail::ThreadTrack::Print> for usage of this subclass.
=head1 DESCRIPTION
See C<Mail::ThreadTrack::Print> for usage of this subclass.
=head1 METHODS
=head2 show_articles_in_thread(thread_id)
=cut
my $is_show_cost_indicate = 0;
my $format = "%-20s %10s %5s %8s %s\n";
# Descriptions: show articles as text in this thread
# Arguments: OBJ($self) STR($thread_id)
# Side Effects: none
# Return Value: none
sub show_articles_in_thread
{
my ($self, $thread_id) = @_;
my $mode = $self->get_mode || 'text';
my $config = $self->{ _config };
my $spool_dir = $config->{ spool_dir };
my $articles = $self->{ _hash_table }->{ _articles }->{ $thread_id };
my $wh = $self->{ _fd } || \*STDOUT;
use FileHandle;
if (defined($articles) && defined($spool_dir) && -d $spool_dir) {
my $s = '';
for (split(/\s+/, $articles)) {
my $file = File::Spec->catfile($spool_dir, $_);
my $fh = new FileHandle $file;
while (defined($_ = $fh->getline())) {
next if 1 .. /^$/;
$s = STR2EUC($_);
print $wh $s;
}
$fh->close;
}
}
}
# Descriptions: show guide line
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
sub __start_thread_summary
{
my ($self, $args) = @_;
my $fd = $self->{ _fd } || \*STDOUT;
printf($fd $format, 'id', 'date', 'age', 'status', 'articles');
print $fd "-" x60;
print $fd "\n";
}
# Descriptions: print formated brief summary
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
sub __print_thread_summary
{
my ($self, $optargs) = @_;
my $fd = $self->{ _fd } || \*STDOUT;
my $date = $optargs->{ date };
my $age = $optargs->{ age };
my $status = $optargs->{ status };
my $thread_id = $optargs->{ thread_id };
my $articles = $optargs->{ articles };
my $aid = (split(/\s+/, $articles))[0];
printf($fd $format, $thread_id, $date, $age, $status,
_format_list(25, $articles));
}
# Descriptions: print closing string, empty now
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
sub __end_thread_summary
{
my ($self, $args) = @_;
my $fd = $self->{ _fd } || \*STDOUT;
}
# Descriptions: create a string of "a b c .." style up to $num bytes
# Arguments: NUM($num) STR($str)
# Side Effects: none
# Return Value: STR
sub _format_list
{
my ($max, $str) = @_;
my (@idlist) = split(/\s+/, $str);
my $r = '';
for (@idlist) {
$r .= $_ . " ";
if (length($r) > $max) {
$r .= "...";
last;
}
}
return $r;
}
# Descriptions: print message summary
# Arguments: OBJ($self) STR($thread_id)
# Side Effects: none
# Return Value: none
sub __print_message_summary
{
my ($self, $thread_id) = @_;
my $config = $self->{ _config };
my $age = $self->{ _age } || {};
my $cost = $self->{ _cost } || {};
my $fd = $self->{ _fd } || \*STDOUT;
my $rh = $self->{ _hash_table };
if (defined $config->{ spool_dir }) {
my ($aid, @aid, $file);
my $spool_dir = $config->{ spool_dir };
THREAD_ID_LIST:
for my $thread_id (@$thread_id) {
if ($is_show_cost_indicate) {
my $how_bad = _cost_to_indicator( $cost->{ $thread_id } );
printf $fd "\n%6s %-10s %s\n", $how_bad, $thread_id;
}
else {
printf $fd "\n>Thread-Id: %-10s %s\n", $thread_id;
}
# show only the first article of this thread $thread_id
if (defined $rh->{ _articles }->{ $thread_id }) {
(@aid) = split(/\s+/, $rh->{ _articles }->{ $thread_id });
$aid = $aid[0];
$file = File::Spec->catfile($spool_dir, $aid);
if (-f $file) {
$self->print( $self->message_summary($file) );
}
}
}
}
}
# Descriptions: for example, cost -> '!!!'
# broken now ;-)
# Arguments: STR($cost)
# Side Effects: none
# Return Value: STR
sub _cost_to_indicator
{
my ($cost) = @_;
my $how_bad = 0;
if ($cost =~ /(\w+)\-(\d+)/) {
$how_bad += $2;
$how_bad += 2 if $1 =~ /open/;
$how_bad = "!" x ($how_bad > 6 ? 6 : $how_bad);
}
$how_bad;
}
=head1 CODING STYLE
See C<http://www.fml.org/software/FNF/> on fml coding style guide.
=head1 AUTHOR
Ken'ichi Fukamachi
=head1 COPYRIGHT
Copyright (C) 2001,2002 Ken'ichi Fukamachi
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
=head1 HISTORY
Mail::ThreadTrack::Print::Text appeared in fml5 mailing list driver package.
See C<http://www.fml.org/> for more details.
=cut
1;
|