line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Egg::View::Mail::Plugin::SaveBody; |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# $Id: SaveBody.pm 285 2008-02-28 04:20:55Z lushe $ |
6
|
|
|
|
|
|
|
# |
7
|
2
|
|
|
2
|
|
810
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
76
|
|
8
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
185
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION= '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _setup { |
13
|
0
|
|
|
0
|
|
|
my($class, $e)= @_; |
14
|
0
|
0
|
|
|
|
|
$e->is_model('fsavedate') |
15
|
|
|
|
|
|
|
|| die __PACKAGE__. q{ - I want setup 'Egg::Model::FsaveDate'.}; |
16
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; ## no critic. |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
17
|
2
|
|
|
2
|
|
12
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1209
|
|
18
|
0
|
0
|
|
|
|
|
if ($class->isa('Egg::View::Mail::Plugin::Lot')) { |
19
|
0
|
|
|
|
|
|
require Digest::SHA1; |
20
|
0
|
|
|
|
|
|
$class->mk_accessors(qw/ lot_name savebodys /); |
21
|
0
|
|
|
|
|
|
*{"${class}::__send"} = \&___send_lot; |
|
0
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
*{"${class}::__save_body"}= \&___save_body_lot; |
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} else { |
24
|
0
|
|
|
0
|
|
|
*{"${class}::__send"} = sub {}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
*{"${class}::__save_body"}= \&___save_body_proc; |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
$class->mk_accessors('is_savebody'); |
28
|
0
|
|
|
|
|
|
$class->next::method($e); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
sub send { |
31
|
0
|
|
|
0
|
1
|
|
my $self= shift; |
32
|
0
|
0
|
|
|
|
|
my $data= $_[0] ? ($_[1] ? {@_}: $_[0]): return $self->next::method(@_); |
|
|
0
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$self->is_savebody(undef); |
34
|
0
|
|
|
|
|
|
$self->__send($data); |
35
|
0
|
|
|
|
|
|
$self->next::method($data); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
sub mail_send { |
38
|
0
|
|
|
0
|
1
|
|
my($self, $data)= @_; |
39
|
0
|
|
|
|
|
|
$self->__save_body($data); |
40
|
0
|
|
|
|
|
|
$self->next::method($data); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
sub ___send_lot { |
43
|
0
|
|
|
0
|
|
|
my($self, $data)= @_; |
44
|
0
|
|
0
|
|
|
|
my $to= $data->{to} || $self->config->{to} || return 0; |
45
|
0
|
|
|
|
|
|
$self->lot_name( Digest::SHA1::sha1_hex($to. '-save') ); |
46
|
0
|
0
|
|
|
|
|
$self->savebodys({}) unless $self->savebodys; |
47
|
0
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
sub ___save_body_lot { |
50
|
0
|
|
|
0
|
|
|
my($self, $data)= @_; |
51
|
0
|
0
|
|
|
|
|
return 0 if $self->savebodys->{$self->lot_name}; |
52
|
0
|
|
|
|
|
|
$self->___save_body_proc($data); |
53
|
0
|
|
|
|
|
|
$self->savebodys->{$self->lot_name}= 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
sub ___save_body_proc { |
56
|
0
|
|
|
0
|
|
|
my($self, $data)= @_; |
57
|
0
|
|
|
|
|
|
my $output_path= $self->e->model('fsavedate')->save |
58
|
0
|
|
0
|
|
|
|
( ${$data->{body}}, ($data->{save_body_path} || undef) ); |
59
|
0
|
|
|
|
|
|
$self->is_savebody($output_path); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Egg::View::Mail::Plugin::SaveBody? - The content of the transmission of mail is preserved in the file. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package MyApp::View::Mail::MyComp; |
73
|
|
|
|
|
|
|
use base qw/ Egg::View::Mail::Base /; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
........... |
76
|
|
|
|
|
|
|
..... |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__PACKAGE__->setup_plugin('Lot'); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
It is MAIL plugin to preserve the content of the transmission of mail in the file. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
When 'SaveBody' is passed to 'setup_plugin' method, it is built in. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
It is necessary to set up it and L<Egg::Model::FsaveDate>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
% vi /path/to/MyApp/lib/MyApp/config.pm |
89
|
|
|
|
|
|
|
........... |
90
|
|
|
|
|
|
|
MODEL => ['FsaveDate'], |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Some behavior changes if L<Egg::View::Mail::Plugin::Lot> is built in. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
A large amount of files of the same content are made when preserving it with |
95
|
|
|
|
|
|
|
L<Egg::View::Mail::Plugin::Lot> at the transmission though the content of mail |
96
|
|
|
|
|
|
|
is always usually preserved. |
97
|
|
|
|
|
|
|
Then, if the destination looks similar, the preservation of the content of mail |
98
|
|
|
|
|
|
|
is finished once. |
99
|
|
|
|
|
|
|
The problem of no preservation of the content of the following transmission etc. |
100
|
|
|
|
|
|
|
happens when another content is sent to the same destination in the same process |
101
|
|
|
|
|
|
|
because this is not in the content of mail and is checked by it in the destination. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
When 'save_body_path' is set by the argument and the configuration of 'send' |
104
|
|
|
|
|
|
|
method, it comes to be preserved in a place different from the place that |
105
|
|
|
|
|
|
|
L<Egg::Model::FsaveDate> originally preserves. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$mail->send( |
108
|
|
|
|
|
|
|
body => ......., |
109
|
|
|
|
|
|
|
save_body_path => '/path/to/output', |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 send, mail_send |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
It competes simultaneously with other components that use these methods when |
117
|
|
|
|
|
|
|
using it. Please adjust the order of building in. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__PACKAGE__->setup_plugin(qw/ |
120
|
|
|
|
|
|
|
PortCheck |
121
|
|
|
|
|
|
|
SaveBody |
122
|
|
|
|
|
|
|
Lot |
123
|
|
|
|
|
|
|
/); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 is_savebody |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
PATH to the preserved file is stored. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
After 'send' method is called, it comes to be able to take this out. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$mail->send( to=> '.....', body => '......' ); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
print $mail->is_savebody . '¤ËÊݸ¤µ¤ì¤Þ¤·¤¿¡£'; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 lot_name |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
It is a method of the setup when using it at the same time as |
138
|
|
|
|
|
|
|
L<Egg::View::Mail::Plugin::Lot>. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
ID of SHA1 generated with the value of 'to' is stored. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 savebodys |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
It is a method of the setup when using it at the same time as |
145
|
|
|
|
|
|
|
L<Egg::View::Mail::Plugin::Lot>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Already it has transmitted or the data for the judgment has already been stored. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 SEE ALSO |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L<Egg::Release>, |
152
|
|
|
|
|
|
|
L<Egg::View::Mail>, |
153
|
|
|
|
|
|
|
L<Egg::Model::FsaveDate>, |
154
|
|
|
|
|
|
|
L<Egg::View::Mail::Plugin::Lot>, |
155
|
|
|
|
|
|
|
L<Digest::SHA1>, |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
166
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
167
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|