summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-02-11 08:29:45 +0000
committerfukachan <fukachan>2001-02-11 08:29:45 +0000
commit5f38f013d827351f03e84a8e7713477709cbbbdf (patch)
treeeb0a5cb743ce7bfa07bda0a428d34f86b74a4a4a
parentad921ed156969d18acc50a67abe4290983b46fb0 (diff)
downloadfml8-5f38f013d827351f03e84a8e7713477709cbbbdf.tar.gz
fml8-5f38f013d827351f03e84a8e7713477709cbbbdf.tar.bz2
fml8-5f38f013d827351f03e84a8e7713477709cbbbdf.zip
define build_mime_multipart_chain() to chain messages.
move %content_type definition to the top
-rw-r--r--fml/lib/MailingList/Messages.pm71
1 files changed, 57 insertions, 14 deletions
diff --git a/fml/lib/MailingList/Messages.pm b/fml/lib/MailingList/Messages.pm
index ab475ac1..2f4f58d9 100644
--- a/fml/lib/MailingList/Messages.pm
+++ b/fml/lib/MailingList/Messages.pm
@@ -17,6 +17,16 @@ require Exporter;
@ISA = qw(Exporter);
+# virtual content-type
+my %content_type =
+ (
+ 'preamble' => 'multipart.preamble/plain',
+ 'delimiter' => 'multipart.delimiter/plain',
+ 'close-delimiter' => 'multipart.close-delimiter/plain',
+ 'trailer' => 'multipart.trailer/plain',
+ );
+
+
sub new
{
my ($self, $args) = @_;
@@ -168,7 +178,7 @@ build a template message following the given $args (a hash reference).
# Descriptions: adapter to forward the request to object builders
# by following content-type. The real work is done at
-# &build_mime_multipart_chain() if multipart
+# &parse_and_build_mime_multipart_chain() if multipart
# &_create() if not
# Arguments: $self $args
# Side Effects: none
@@ -182,7 +192,7 @@ sub create
# parse the non multipart mail and build a chain
if ($args->{ content_type } =~ /multipart/i) {
- $self->build_mime_multipart_chain($args);
+ $self->parse_and_build_mime_multipart_chain($args);
}
else {
$self->_create($args);
@@ -262,6 +272,49 @@ sub prev_chain
}
+sub build_mime_multipart_chain
+{
+ my ($self, $args) = @_;
+ my ($head, $prev_m);
+
+ my $base_content_type = $args->{ base_content_type };
+ my $msglist = $args->{ message_list };
+ my $boundary = $args->{ boundary } || "---". time ."-$$-";
+ my $buffer = $boundary."\n";
+ my $buffer_end = $boundary . "--\n";
+
+ for my $m (@$msglist) {
+ # delimeter: --boundary
+ my $msg = new MailingList::Messages {
+ base_content_type => $base_content_type,
+ content_type => $content_type{'delimeter'},
+ boundary => $boundary,
+ content => \$buffer,
+ };
+
+ $head = $msg unless $head; # save the head $msg
+
+ # boundary -> content -> boundary ...
+ if (defined $prev_m) { $prev_m->next_chain( $msg );}
+ $msg->next_chain( $m );
+
+ # for the next loop
+ $prev_m = $m;
+ }
+
+ # close delimeter: --boundary--
+ my $msg = new MailingList::Messages {
+ base_content_type => $base_content_type,
+ content_type => $content_type{'close-delimeter'},
+ boundary => $boundary,
+ content => \$buffer_end,
+ };
+ $prev_m->next_chain( $msg ); # ... -> content -> close-delimeter
+
+ return $head; # return the pointer to the head of a chain
+}
+
+
=head2 C<next_chain( $reference_to_message )>
The next one of this message is $reference_to_message.
@@ -421,7 +474,7 @@ sub _print_messsage_on_disk
}
-=head2 C<build_mime_multipart_chain($args)>
+=head2 C<parse_and_build_mime_multipart_chain($args)>
parse the multipart mail. Actually it calculates the begin and end
offset for each part of content, not split() and so on.
@@ -442,20 +495,10 @@ C<new()> calls this routine if the message looks MIME multipart.
# ---boundary--
# ... trailor ...
#
-sub build_mime_multipart_chain
+sub parse_and_build_mime_multipart_chain
{
my ($self, $args) = @_;
- # virtual content-type
- my %content_type =
- (
- 'preamble' => 'multipart.preamble/plain',
- 'delimiter' => 'multipart.delimiter/plain',
- 'close-delimiter' => 'multipart.close-delimiter/plain',
- 'trailer' => 'multipart.trailer/plain',
- );
-
-
# check input parameters
return undef unless $args->{ boundary };
return undef unless $args->{ content };