summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2003-07-20 04:58:29 +0000
committerfukachan <fukachan>2003-07-20 04:58:29 +0000
commitfe92e3864d015017ef5af02fd20391d040829dc9 (patch)
treecce8fd5ed575b55861b334402567102a5e89daf0 /fml
parentef282d24fb94e436331fcb1231e026adce11326a (diff)
downloadfml8-fe92e3864d015017ef5af02fd20391d040829dc9.tar.gz
fml8-fe92e3864d015017ef5af02fd20391d040829dc9.tar.bz2
fml8-fe92e3864d015017ef5af02fd20391d040829dc9.zip
moved analyzer dispatcher to ::Thread module to use analyzer independetly.
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/Mail/Message/Thread.pm150
-rw-r--r--fml/lib/Mail/Message/ToHTML.pm40
2 files changed, 164 insertions, 26 deletions
diff --git a/fml/lib/Mail/Message/Thread.pm b/fml/lib/Mail/Message/Thread.pm
new file mode 100644
index 00000000..21d92d64
--- /dev/null
+++ b/fml/lib/Mail/Message/Thread.pm
@@ -0,0 +1,150 @@
+#-*- 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/07/19 10:23:33 fukachan Exp $
+#
+
+package Mail::Message::Thread;
+use strict;
+use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
+use Carp;
+use File::Spec;
+
+=head1 NAME
+
+Mail::Message::Thread - Thread interface
+
+=head1 SYNOPSIS
+
+ ... lock by something ...
+
+ ... unlock by something ...
+
+This module itself provides no lock function.
+please use flock() built in perl or CPAN lock modules for it.
+
+=head1 DESCRIPTION
+
+=head1 METHODS
+
+=head2 new()
+
+initialize DB (udb) interface.
+
+=cut
+
+
+# Descriptions: constructor.
+# Arguments: OBJ($self) HASH_REF($args)
+# Side Effects: none
+# Return Value: OBJ
+sub new
+{
+ my ($self, $args) = @_;
+ my ($type) = ref($self) || $self;
+ my $me = {};
+
+ my $ndb = _init_db($me, $args);
+ $me->{ _ndb } = $ndb;
+
+ return bless $me, $type;
+}
+
+
+# Descriptions: initialize Mail::Message::DB object.
+# Arguments: OBJ($self) HASH_REF($args)
+# Side Effects: DB object created.
+# Return Value: OBJ
+sub _init_db
+{
+ my ($self, $args) = @_;
+ my $db_type = $args->{ db_type } || 'AnyDBM_File';
+ my $db_base = $args->{ db_base_dir } || croak("specify db_base_dir\n");
+ my $db_name = $args->{ db_name } || croak("specify db_name\n");
+
+ use File::Spec;
+ my $db_dir = File::Spec->catfile($db_base, $db_name);
+ unless (-d $db_base) { mkdir($db_base, 0755);}
+ unless (-d $db_dir) { mkdir($db_dir, 0755);}
+
+ my $_db_args = {
+ db_module => $db_type, # AnyDBM_File
+ db_base_dir => $db_dir, # /var/spool/ml/@udb@/elena
+ db_name => $db_name, # elena
+
+ # old db_dir in non UDB age: ~fml/public_html/.../elena/
+ old_db_base_dir => $args->{ output_dir },
+ };
+
+ # Firstly, prepare db object.
+ use Mail::Message::DB;
+ return new Mail::Message::DB $_db_args;
+}
+
+
+=head2 db()
+
+return database object.
+
+=head2 analyze($msg)
+
+top level dispatcher to run thread analyzer.
+
+=cut
+
+
+# Descriptions: get database object.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: OBJ
+sub db
+{
+ my ($self) = @_;
+ return( $self->{ _ndb } || undef );
+}
+
+
+# Descriptions: top level dispatcher to run thread analyzer.
+# Arguments: OBJ($self) OBJ($msg)
+# Side Effects: update database
+# Return Value: none
+sub analyze
+{
+ my ($self, $msg) = @_;
+ my $db = $self->db();
+
+ $db->analyze($msg);
+}
+
+
+=head1 TODO
+
+=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
+
+Mail::Message::Thread first appeared in fml8 mailing list driver package.
+See C<http://www.fml.org/> for more details.
+
+This class is renamed from C<Mail::HTML::Lite> 1.40 (2001-2002).
+
+=cut
+
+
+1;
diff --git a/fml/lib/Mail/Message/ToHTML.pm b/fml/lib/Mail/Message/ToHTML.pm
index 726da403..e318e47d 100644
--- a/fml/lib/Mail/Message/ToHTML.pm
+++ b/fml/lib/Mail/Message/ToHTML.pm
@@ -4,21 +4,20 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: ToHTML.pm,v 1.44 2003/07/19 10:23:35 fukachan Exp $
+# $FML: ToHTML.pm,v 1.45 2003/07/19 12:58:47 fukachan Exp $
#
package Mail::Message::ToHTML;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
-use File::Spec;
my $is_strict_warn = 0;
my $debug = 0;
my $URL =
"<A HREF=\"http://www.fml.org/software/\">Mail::Message::ToHTML</A>";
-my $version = q$FML: ToHTML.pm,v 1.44 2003/07/19 10:23:35 fukachan Exp $;
+my $version = q$FML: ToHTML.pm,v 1.45 2003/07/19 12:58:47 fukachan Exp $;
if ($version =~ /,v\s+([\d\.]+)\s+/) {
$version = "$URL $1";
}
@@ -93,8 +92,8 @@ stored.
sub new
{
my ($self, $args) = @_;
- my ($type) = ref($self) || $self;
- my $me = {};
+ my ($type) = ref($self) || $self;
+ my $me = {};
$me->{ _charset } = $args->{ charset } || 'us-ascii';
$me->{ _html_base_directory } = $args->{ output_dir };
@@ -108,25 +107,9 @@ sub new
$me->{ _subdir_style } = 'yyyymm';
$me->{ _html_id_order } = $args->{ index_order } || 'normal';
- my $db_type = $me->{ _db_type };
- my $db_base = $me->{ _db_base_dir } || croak("specify db_base_dir\n");
- my $db_name = $me->{ _db_name } || croak("specify db_name\n");
- my $db_dir = File::Spec->catfile($db_base, $db_name);
- unless (-d $db_base) { mkdir($db_base, 0755);}
- unless (-d $db_dir) { mkdir($db_dir, 0755);}
- my $_db_args = {
- db_module => $db_type,
- db_base_dir => $db_dir,
- db_name => $db_name, # mailing list identifier
-
- # db_dir for non UDB
- old_db_base_dir => $args->{ output_dir },
- };
-
- # Firstly, prepare db object.
- use Mail::Message::DB;
- my $ndb = new Mail::Message::DB $_db_args;
- $me->{ _ndb } = $ndb;
+ use Mail::Message::Thread;
+ my $t = new Mail::Message::Thread $args;
+ $me->{ _thread_object } = $t;
return bless $me, $type;
}
@@ -944,7 +927,10 @@ sub cache_message_info
$ndb->set('html_filename', $id, $self->html_filename($id));
$ndb->set('html_filepath', $id, $dst);
- $ndb->analyze($msg);
+ unless ($ndb->get('message_id', $id)) {
+ # analyze $msg only if not yet analyzed.
+ $ndb->analyze($msg);
+ }
}
@@ -955,7 +941,9 @@ sub cache_message_info
sub ndb
{
my ($self) = @_;
- return $self->{ _ndb };
+ my $t = $self->{ _thread_object };
+
+ return $t->db();
}