diff options
| author | fukachan <fukachan> | 2004-03-31 12:53:50 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-03-31 12:53:50 +0000 |
| commit | 5432a7011fcb4386b56fc044a54ec4c4dd2da0e5 (patch) | |
| tree | 0d73b11db0e7a903d7b020323b97f6aaaa8cd10d /fml/lib/Mail/ThreadTrack/Print | |
| parent | 408f950159c3aae27154eaaceb15d6d91095d9d9 (diff) | |
| download | fml8-5432a7011fcb4386b56fc044a54ec4c4dd2da0e5.tar.gz fml8-5432a7011fcb4386b56fc044a54ec4c4dd2da0e5.tar.bz2 fml8-5432a7011fcb4386b56fc044a54ec4c4dd2da0e5.zip | |
Mail::ThreadTrack is obsoleted. remove related codes.
Diffstat (limited to 'fml/lib/Mail/ThreadTrack/Print')
| -rw-r--r-- | fml/lib/Mail/ThreadTrack/Print/HTML.pm | 291 | ||||
| -rw-r--r-- | fml/lib/Mail/ThreadTrack/Print/Message.pm | 253 | ||||
| -rw-r--r-- | fml/lib/Mail/ThreadTrack/Print/Sort.pm | 124 | ||||
| -rw-r--r-- | fml/lib/Mail/ThreadTrack/Print/Text.pm | 247 | ||||
| -rw-r--r-- | fml/lib/Mail/ThreadTrack/Print/Utils.pm | 115 |
5 files changed, 0 insertions, 1030 deletions
diff --git a/fml/lib/Mail/ThreadTrack/Print/HTML.pm b/fml/lib/Mail/ThreadTrack/Print/HTML.pm deleted file mode 100644 index 220c6e09..00000000 --- a/fml/lib/Mail/ThreadTrack/Print/HTML.pm +++ /dev/null @@ -1,291 +0,0 @@ -#-*- perl -*- -# -# Copyright (C) 2001,2002,2003 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: HTML.pm,v 1.17 2003/02/11 11:22:56 fukachan Exp $ -# - -package Mail::ThreadTrack::Print::HTML; - -use strict; -use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); -use Carp; - - -=head1 NAME - -Mail::ThreadTrack::Print::HTML - print thread summary as HTML - -=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) - -show articles as HTML in this thread. - -=cut - - -use CGI qw/:standard/; -use Mail::ThreadTrack::Print::Utils qw(decode_mime_string STR2EUC); - - -# Descriptions: show articles as HTML 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 }; - - # XXX-TODO: who validates $thread_id ? - print "<B>"; - print "show contents related with thread_id=$thread_id\n"; - print "</B>"; - print "<HR>"; - print "<PRE>\n"; - - if (defined($articles) && defined($spool_dir) && -d $spool_dir) { - use FileHandle; - - my $s = ''; - for my $article (split(/\s+/, $articles)) { - my $file = $self->filepath({ - base_dir => $spool_dir, - id => $article, - }); - - # XXX-TODO: care for non Japanese char(s). - # XXX-TODO: to avoid CSS bug, convert all special char(s). - # XXX-TODO: create method safe_html_string() in Mail::Message ? - if (-f $file) { - my $fh = new FileHandle $file; - - if (defined $fh) { - my $buf; - - while (defined($buf = $fh->getline())) { - # ignore header part. - next if 1 .. $buf =~ /^$/o; - - $s = STR2EUC($buf); - $s =~ s/&/&/g; - $s =~ s/</</g; - $s =~ s/>/>/g; - $s =~ s/\"/"/g; - print $s; - } - $fh->close; - } - } - } - } - - print "</PRE>"; -} - - -# Descriptions: show guide -# Arguments: OBJ($self) HASH_REF($args) -# Side Effects: none -# Return Value: none -sub __start_thread_summary -{ - my ($self, $args) = @_; - my $config = $self->{ _config }; - my $ml_name = $config->{ ml_name }; - my $fd = $self->{ _fd } || \*STDOUT; - my $action = $curproc->safe_cgi_action_name(); - my $target = '_top'; - - # statistics - if (defined $self->{ _ticket_id_stat }) { - my $stat = $self->{ _ticket_id_stat }; - for my $key ('open', 'analyzed', 'closed') { - print $fd "$key: "; - print $fd defined $stat->{ $key } ? $stat->{ $key } : 0; - print $fd ", "; - } - print $fd br, "\n"; - } - - # XXX-TODO: validate $action ? - print $fd start_form(-action=>$action, -target=>$target); - print $fd submit(-name => 'submit'); - print $fd reset(-name => 'reset'); - print $fd "\n"; - - # XXX-TODO: validate $ml_name ? - print $fd hidden(-name => 'ml_name', - -default => [ $ml_name ], - ), "\n"; - - param('action', 'change_status'); # we need to override - print $fd hidden(-name => 'action', - -default => [ 'change_status ' ], - ), "\n"; - - print $fd "<TABLE BORDER=4>\n"; - print $fd "<TD>id\n"; - print $fd "<TD>change\n"; - print $fd "<TD>summary\n"; - print $fd "<TD>age\n"; - print $fd "<TD>status\n"; -} - - -# Descriptions: finalize thread list. -# close TABLE tag. -# Arguments: OBJ($self) HASH_REF($args) -# Side Effects: none -# Return Value: none -sub __end_thread_summary -{ - my ($self, $args) = @_; - my $fd = $self->{ _fd } || \*STDOUT; - - print $fd "</TABLE>\n"; - - print submit(-name => 'submit'); - print reset(-name => 'reset'); - print $fd end_form; -} - - -# Descriptions: This shows summary on C<$thread_id> in HTML language. -# It is used in C<FML::CGI::ThreadSystem>. -# Arguments: OBJ($self) HASH_REF($optargs) -# Side Effects: none -# Return Value: none -sub __print_thread_summary -{ - my ($self, $optargs) = @_; - my $config = $self->{ _config }; - my $ml_name = $config->{ ml_name }; - my $spool_dir = $config->{ spool_dir }; - my $action = $curproc->safe_cgi_action_name(); - my $target = $config->{ thread_cgi_target_window } || '_top'; - - my $date = $optargs->{ date }; - my $age = $optargs->{ age }; - my $status = $optargs->{ status }; - my $tid = $optargs->{ thread_id }; - my $articles = $optargs->{ articles }; - my $aid = (split(/\s+/, $articles))[0]; - - # do nothing if the $thread_id is unknown. - return unless $tid; - - # XXX-TODO: validate $action, $ml_name, $aid ... - # <FORM ACTION=> ..> - my $xtid = CGI::escape($tid); - $action = "${action}?ml_name=${ml_name}&article_id=$aid"; - - $self->{ _table_count } = 1 unless defined $self->{ _table_count }; - if (($self->{ _table_count }++ % 5) == 0) { - print "<TR>\n<TD>\n"; - print submit(-name => 'submit'); - print reset(-name => 'reset'); - } - - print "<TR>\n"; - - # XXX-TODO: validate $msg_base_url ? - # show articles in this thread id - print "<TD>"; - if (defined $config->{ msg_base_url }) { - my $msg_base_url = $config->{ msg_base_url }; - my $url = "$msg_base_url/msg$aid.html"; - print "<A HREF=\"$url\" TARGET=\"article\">\n"; - print $tid; - print "\n</A>\n"; - } - else { - # XXX-TODO: validate $action ? - print "<A HREF=\"$action&action=show\" TARGET=\"article\">\n"; - print $tid; - print "\n</A>\n"; - } - - # action - print "<TD>"; - my $name = "change_status.$tid"; - my $values = ["open", "analyzed", "closed"]; - my $default = $status; - print radio_group(-name => $name, - -values => $values, - -default => $default, - -linebreak => 'true', - ); - - # message (article) brief summary - print "<TD>"; - if (defined $articles) { - $aid = (split(/\s+/, $articles))[0]; - my $f = $self->filepath({ - base_dir => $spool_dir, - id => $aid, - }); - if (-f $f) { - # XXX-TODO: care for non Japanese. - my $buf = $self->message_summary($f); - $self->print( STR2EUC($buf) ); - } - } - - # addional information: age, status - print "<TD>$age\n"; - print "<TD>$status\n"; - - print "\n\n"; -} - - -# Descriptions: dummy, defined for symmetry -# Arguments: none -# Side Effects: none -# Return Value: none -sub __print_message_summary -{ - ; -} - - -=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,2003 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::HTML first appeared in fml8 mailing list driver package. -See C<http://www.fml.org/> for more details. - -=cut - - -1; diff --git a/fml/lib/Mail/ThreadTrack/Print/Message.pm b/fml/lib/Mail/ThreadTrack/Print/Message.pm deleted file mode 100644 index 7c61a63a..00000000 --- a/fml/lib/Mail/ThreadTrack/Print/Message.pm +++ /dev/null @@ -1,253 +0,0 @@ -#-*- perl -*- -# -# Copyright (C) 2001,2002,2003 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: Message.pm,v 1.9 2002/12/22 03:19:15 fukachan Exp $ -# - -package Mail::ThreadTrack::Print::Message; -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::Message - summarize message et.al. - -=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 message_summary($file) - -make message summary for specified $file (article). - -=cut - - -# Descriptions: make summary of the specified $file (article). -# Arguments: OBJ($self) STR($file) -# Side Effects: none -# Return Value: STR -sub message_summary -{ - my ($self, $file) = @_; - my (@header) = (); - my $msgbuf = ''; - my $line = $self->{ _article_summary_lines } || 3; - my $mode = $self->get_mode || 'text'; - my $padding = $mode eq 'text' ? ' ' : ''; - - use FileHandle; - my $fh = new FileHandle $file; - - if (defined $fh) { - my $buf; - - LINE: - while ($buf = <$fh>) { - # remove useless lines - next LINE if $buf =~ /^\>/o; - next LINE if $buf =~ /^\-/o; - - # header part - if (1 .. $buf =~ /^$/o) { - push(@header, $buf); - } - # body part - else { - next LINE if $buf =~ /^\s*$/o; - - # ignore mail header like patterns. - next LINE if $buf =~ /^X-[-A-Za-z0-9]+:/io; - next LINE if $buf =~ /^Return-[-A-Za-z0-9]+:/io; - next LINE if $buf =~ /^Mime-[-A-Za-z0-9]+:/io; - next LINE if $buf =~ /^Content-[-A-Za-z0-9]+:/io; - next LINE if $buf =~ /^(To|From|Subject|Reply-To|Received):/io; - next LINE if $buf =~ /^(Message-ID|Date):/io; - - # pick up effetive the first $line lines - if (_is_valid_buf($buf)) { - $line--; - $msgbuf .= $padding . $buf; - } - - last LINE if $line < 0; - } - } - - $fh->close(); - - # XXX-TODO: WHO CARE FOR CSS ? return raw messages from here. - # XXX-TODO: care for non Japanese. - if (defined $self->{ _no_header_summary }) { - return STR2EUC( $msgbuf ); - } - else { - use Mail::Header; - my $header = new Mail::Header \@header; - my $header_info = $self->header_summary({ - header => $header, - padding => $padding, - }); - return STR2EUC( $header_info ."\n". $msgbuf ); - } - } - else { - return undef; - } -} - - -# Descriptions: check if $str looks effective, not quotation et.al. ? -# Arguments: STR($str) -# Side Effects: none -# Return Value: 1 or 0 -sub _is_valid_buf -{ - my ($str) = @_; - $str = STR2EUC( $str ); - - if ($str =~ /^[\>\#\|\*\:\;\=]/o) { - return 0; - } - elsif ($str =~ /^in /o) { # quotation ? - return 0; - } - elsif ($str =~ /\w+\@\w+/o) { # mail address ? - return 0; - } - elsif ($str =~ /^\S+\>/o) { # quotation ? - return 0; - } - - return 1; -} - - -# Descriptions: remove subject tag like string in $str e.g. [elena 100]. -# Arguments: STR($str) -# Side Effects: none -# Return Value: STR -sub _delete_subject_tag_like_string -{ - my ($str) = @_; - - if (defined $str) { - # XXX-TODO: hmm, method-ify Mail::Message::Utils ? - use Mail::Message::Utils; - return Mail::Message::Utils::remove_subject_tag_like_string($str); - } - else { - return undef; - } -} - - -# Descriptions: make summary of header $args->{ header }. -# Arguments: OBJ($self) HASH_REF($args) -# Side Effects: none -# Return Value: STR -sub header_summary -{ - my ($self, $args) = @_; - my $date = $args->{ header }->get('date'); - my $from = $args->{ header }->get('from'); - my $subject = $args->{ header }->get('subject'); - my $padding = $args->{ padding } || ' '; - - # XXX-TODO: care for non Japanese. - if (defined $subject) { - $subject = decode_mime_string($subject, { charset => 'euc-japan' }); - $subject =~ s/\n/ /g; - $subject = _delete_subject_tag_like_string($subject); - $subject =~ s/[\s\n]*$//g; - } - - if (defined $from) { - $from = $self->_who_of_address( $from ); - $from =~ s/\n/ /g; - $from =~ s/[\s\n]*$//g; - } - - # XXX-TODO: WHO CARE FOR CSS ? return raw messages from here. - # XXX-TODO: care for non Japanese. - # return buffer - my $r = $padding. $date; - $r .= $padding. "$subject, $from\n"; - return STR2EUC( $r ); -} - - -# Descriptions: get gecos field in $address. -# return $address itself if the extraction failed. -# Arguments: OBJ($self) STR($address) -# Side Effects: none -# Return Value: STR -sub _who_of_address -{ - my ($self, $address) = @_; - my ($user); - - use Mail::Address; - my (@addrs) = Mail::Address->parse($address); - - for my $addr (@addrs) { - if (defined( $addr->phrase() )) { - # XXX-TODO: care for non Japanese. - my $phrase = decode_mime_string( $addr->phrase(), { - charset => 'euc-japan', - }); - - if ($phrase) { - return($phrase); - } - } - - $user = $addr->user(); - } - - # XXX-TODO: hmm, CROSS SITE SCRIPTING may cause ? - if ($self->get_mode() eq 'html') { - return( $user ? "$user\@xxx.xxx.xxx.xxx" : $address ); - } - else { - return $address; - } -} - - -=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,2003 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::Message first appeared in fml8 mailing list driver package. -See C<http://www.fml.org/> for more details. - -=cut - - -1; diff --git a/fml/lib/Mail/ThreadTrack/Print/Sort.pm b/fml/lib/Mail/ThreadTrack/Print/Sort.pm deleted file mode 100644 index 6b0fa5bf..00000000 --- a/fml/lib/Mail/ThreadTrack/Print/Sort.pm +++ /dev/null @@ -1,124 +0,0 @@ -#-*- perl -*- -# -# Copyright (C) 2001,2002,2004 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: Sort.pm,v 1.9 2002/12/22 03:21:33 fukachan Exp $ -# - -package Mail::ThreadTrack::Print::Sort; -use strict; -use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); -use Carp; - - -=head1 NAME - -Mail::ThreadTrack::Print::Sort - sort function for printing - -=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 sort_thread_id($thread_id_list) - -=cut - - -# Descriptions: sort ARRAY REFERENCE $thread_id_list -# Arguments: OBJ($self) ARRAY_REF($thread_id_list) -# Side Effects: initialize $self->{ _age } and $self->{ _cost } -# Return Value: ARRAY_REF -sub sort_thread_id -{ - my ($self, $thread_id_list) = @_; - - # get age HASH TABLE - my ($age, $cost) = $self->_calculate_age($thread_id_list); - $self->{ _age } = $age; - $self->{ _cost } = $cost; - - @$thread_id_list = sort { - $cost->{$b} <=> $cost->{$a} - } @$thread_id_list; - - return $thread_id_list; -} - - -my $status_cost = { - open => ( 1 << 10 ), - analyzed => ( 1 << 9 ), -}; - - -# Descriptions: evaluate how old and status each thread is -# Arguments: OBJ($self) ARRAY_REF($thread_id_list) -# Side Effects: none -# Return Value: ARRAY( HASH_REF, HASH_REF ) -sub _calculate_age -{ - my ($self, $thread_id_list) = @_; - my (%age, %cost) = (); - my $now = time; # save the current UTC for convenience - my $rh = $self->{ _hash_table } || {}; - my $day = 24*3600; - - # $age hash referehence = { $thread_id => $age }; - my (@aid, $last, $age, $date, $status, $tid) = (); - for $tid (sort @$thread_id_list) { - next unless defined $rh->{ _articles }->{ $tid }; - - # $last: get the latest one of article_id's - (@aid) = split(/\s+/, $rh->{ _articles }->{ $tid }); - $last = $aid[ $#aid ] || 0; - - # how long this thread is not concerned ? - $age = sprintf("%2.1f%s", ($now - $rh->{ _date }->{ $last })/$day); - $age{ $tid } = $age; - - # evaluate cost hash table which is { $thread_id => $cost } - my $status = $rh->{ _status }->{ $tid }; - $cost{ $tid } = $status_cost->{ $status } + $age; - } - - return (\%age, \%cost); -} - - - -=head1 CODING STYLE - -See C<http://www.fml.org/software/FNF/> on fml coding style guide. - -=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,2004 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::Sort first appeared in fml8 mailing list driver package. -See C<http://www.fml.org/> for more details. - -=cut - - -1; diff --git a/fml/lib/Mail/ThreadTrack/Print/Text.pm b/fml/lib/Mail/ThreadTrack/Print/Text.pm deleted file mode 100644 index c6d5a6a1..00000000 --- a/fml/lib/Mail/ThreadTrack/Print/Text.pm +++ /dev/null @@ -1,247 +0,0 @@ -#-*- perl -*- -# -# Copyright (C) 2001,2002,2003 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.14 2003/01/11 15:16:37 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); - -# -# XXX-TODO: insert more examples on format in each function. -# - -=head1 NAME - -Mail::ThreadTrack::Print::Text - printing suitable for text - -=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) - -show articles as text in this thread. - -=cut - -# XXX-TODO: $is_show_cost_indicate hard-coded. -my $is_show_cost_indicate = 0; - -# XXX-TODO: $format hard-coded. -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 = ''; - # $articles = "1 2 3 4 5"; - for my $id (split(/\s+/, $articles)) { - my $file = $self->filepath({ - base_dir => $spool_dir, - id => $id, - }); - - my $fh = new FileHandle $file; - if (defined $fh) { - my $buf; - - LINE: - while (defined($buf = $fh->getline())) { - next LINE if 1 .. $buf =~ /^$/o; - - # XXX-TODO: we suppose Japanese only here. - $s = STR2EUC($buf); - 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; - - # XXX-TODO: guide line is hard-coded. o.k.? - printf($fd $format, 'id', 'date', 'age', 'status', 'articles'); - print $fd "-" x60; - print $fd "\n"; -} - - -# Descriptions: print formatted brief summary -# Arguments: OBJ($self) HASH_REF($optargs) -# 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]; # the head of this thread - - printf($fd $format, $thread_id, $date, $age, $status, - _format_list(25, $articles)); -} - - -# Descriptions: print closing string, empty now (dummy). -# 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($max) STR($str) -# Side Effects: none -# Return Value: STR -sub _format_list -{ - my ($max, $str) = @_; - my (@idlist) = split(/\s+/, $str); - my $r = ''; - - ID: - for my $id (@idlist) { - $r .= $id . " "; - if (length($r) > $max) { - $r .= "..."; - last ID; - } - } - - 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 = $self->filepath({ - base_dir => $spool_dir, - id => $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; - - # XXX-TODO: cost indicator is broken ? - 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,2003 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 first appeared in fml8 mailing list driver package. -See C<http://www.fml.org/> for more details. - -=cut - - -1; diff --git a/fml/lib/Mail/ThreadTrack/Print/Utils.pm b/fml/lib/Mail/ThreadTrack/Print/Utils.pm deleted file mode 100644 index 45bfcbcf..00000000 --- a/fml/lib/Mail/ThreadTrack/Print/Utils.pm +++ /dev/null @@ -1,115 +0,0 @@ -#-*- perl -*- -# -# Copyright (C) 2001,2002,2004 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: Utils.pm,v 1.6 2002/12/22 03:21:33 fukachan Exp $ -# - -package Mail::ThreadTrack::Print::Utils; -use strict; -use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); -use Carp; - -require Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(decode_mime_string STR2EUC); - - -=head1 NAME - -Mail::ThreadTrack::Print::Utils - utility functions - -=head1 SYNOPSIS - - use Mail::ThreadTrack::Print::Utils qw(decode_mime_string STR2EUC); - -=head1 DESCRIPTION - -utility functions to manipulate Japanese string. - -=head1 METHODS - -=head2 decode_mime_string(string, [$options]) - -decode a base64/quoted-printable encoded string to a plain message. -The encoding method is automatically detected. - -C<$options> is a HASH REFERENCE. -You can specify the charset of the string to return -by $options->{ charset }. - -=head2 STR2EUC(str) - -convert str to Japanese EUC. - -=cut - - -# Descriptions: decode $str -# Arguments: STR($str) HASH_REF($options) -# Side Effects: none -# Return Value: STR -sub decode_mime_string -{ - my ($str, $options) = @_; - my $charset = $options->{ 'charset' } || 'euc-japan'; - - # XXX-TODO: care for non Japanese. - if ($charset eq 'euc-japan') { - if ($str =~ /=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/i) { - eval q{ use MIME::Base64; }; - $str =~ s/=\?ISO\-2022\-JP\?B\?(\S+\=*)\?=/decode_base64($1)/gie; - } - - if ($str =~ /=\?ISO\-2022\-JP\?Q\?(\S+\=*)\?=/i) { - eval q{ use MIME::QuotedPrint;}; - $str =~ s/=\?ISO\-2022\-JP\?Q\?(\S+\=*)\?=/decode_qp($1)/gie; - } - } - - use Jcode; - &Jcode::convert(\$str, 'euc'); - $str; -} - - -# Descriptions: convert $str to Japanese EUC -# Arguments: STR($str) -# Side Effects: none -# Return Value: STR -sub STR2EUC -{ - my ($str) = @_; - - use Jcode; - &Jcode::convert(\$str, 'euc'); - return $str; -} - - -=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,2004 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::Utils first appeared in fml8 mailing list driver package. -See C<http://www.fml.org/> for more details. - -=cut - - -1; |
