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
|
#-*- perl -*-
#
# Copyright (C) 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: thread.pm,v 1.2 2003/03/18 10:42:43 fukachan Exp $
#
package FML::Command::Admin::thread;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
use FML::Log qw(Log LogWarn LogError);
=head1 NAME
FML::Command::Admin::thread - show article thread or update its status.
=head1 SYNOPSIS
See C<FML::Command> for more details.
=head1 DESCRIPTION
show status article thread or manipulate it.
=head1 METHODS
=head2 C<process($curproc, $command_args)>
=cut
# Descriptions: constructor.
# Arguments: OBJ($self)
# Side Effects: none
# Return Value: OBJ
sub new
{
my ($self) = @_;
my ($type) = ref($self) || $self;
my $me = {};
return bless $me, $type;
}
# Descriptions: need lock or not
# Arguments: none
# Side Effects: none
# Return Value: NUM( 1 or 0)
sub need_lock { 1;}
# Descriptions: lock channel
# Arguments: none
# Side Effects: none
# Return Value: STR
sub lock_channel { return 'article_thread';}
# Descriptions: change delivery mode from real time to digest.
# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args)
# Side Effects: update $recipient_map
# Return Value: none
sub process
{
my ($self, $curproc, $command_args) = @_;
my $config = $curproc->config();
my $myname = $curproc->myname();
# prepare argumente for thread track module (Mail::ThreadTrack).
my $ml_name = $config->{ ml_name };
my $thread_db_dir = $config->{ thread_db_dir };
my $spool_dir = $config->{ spool_dir };
my $max_id = $curproc->article_max_id();
my $ttargs = {
myname => $myname,
logfp => \&Log,
fd => \*STDOUT,
db_base_dir => $thread_db_dir,
ml_name => $ml_name,
spool_dir => $spool_dir,
max_id => $max_id,
reverse_order => 1,
};
# if (defined $options->{ f }) {
# _read_filter_list($thread, $options->{ f });
# }
$self->_switch($curproc, $command_args, $ttargs);
}
# Descriptions: switch thread library command
# Arguments: OBJ($self) OBJ($curproc) HASH_REF($command_args)
# HASH_REF($ttargs)
# Side Effects: thread db may be updated
# Return Value: none
sub _switch
{
my ($self, $curproc, $command_args, $ttargs) = @_;
my $options = $command_args->{ options };
my $command = $options->[ 0 ] || 'list';
my $max_id = $ttargs->{ max_id };
# utility functions for spool in fml side.
use FML::Article::Thread;
my $a_thread = new FML::Article::Thread $curproc;
# functions to manipulate thread db.
use Mail::ThreadTrack;
my $thread = new Mail::ThreadTrack $ttargs;
$thread->set_mode('text');
if ($command eq 'list' || $command eq 'summary') {
$thread->$command();
}
elsif ($command eq 'review') {
my $str = $options->[ 1 ] || 'last:100';
$thread->review( $str , 1, $max_id );
}
elsif ($command eq 'db_dump') {
my $type = $options->[ 1 ] || 'status';
$thread->db_open();
$thread->db_dump( $type );
$thread->db_close();
}
elsif ($command eq 'db_update') {
my $last_id = $a_thread->speculate_last_id($curproc, $thread);
print STDERR "db_update: $last_id -> $max_id\n";
$thread->db_mkdb($last_id, $max_id);
}
elsif ($command eq 'db_rebuild') {
print STDERR "\$thread->db_mkdb(1, $max_id);\n";
$thread->db_mkdb(1, $max_id);
}
elsif ($command eq 'db_clear') {
$thread->db_open();
$thread->db_clear();
$thread->db_close();
}
elsif ($command eq 'close') {
my $thread_id = $options->[ 1 ];
if (defined $thread_id) {
$a_thread->close($thread, $thread_id, 1, $max_id);
}
else {
croak("specify \$thread_id");
}
}
elsif ($command eq 'cui') {
# XXX-TODO: hmm, run interactive session unless @ARGV ?
# XXX-TODO: showing help is appropriate ?
if ($options->[ 1 ]) {
push(@ISA, 'FML::Article::Thread::CUI');
# $ttargs->{ ml_name } = $argv->[ 0 ];
$a_thread->interactive($thread, $ttargs);
}
else {
help();
}
}
else {
croak("subcommand not specified");
}
}
=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) 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
FML::Command::Admin::thread first appeared in fml8 mailing list driver package.
See C<http://www.fml.org/> for more details.
=cut
1;
|