/[suikacvs]/messaging/manakai/lib/Message/Header/RFC822.pm
Suika

Contents of /messaging/manakai/lib/Message/Header/RFC822.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed May 29 11:05:53 2002 UTC (22 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +2 -2 lines
2002-05-29  wakaba <w@suika.fam.cx>

	* Entity.pm:
	- (%ENCODE, %DECODE): Removed.  (Moved to Message::MIME::Encoding)
	- Uses \x0D\x0A instead of \n.  (Temporary.  `linebreak-strict'
	and related options should be implemented /strictly/.)
	- (_encode_body): Checks media type to choose CTE.
	- (accept_coderange): New option.
	- (body_default_media_type, body_default_charset): Likewise.
	- (fill_ct): Likewise.
	- Uses %Message::Header::NS_phname2uri instead of direct
	access to namespace definition package.
	- (content_type): Returns (type, subtype) list when wantarray'ed.
	- (media_type): New method.  (Alias of content_type)
	* Header.pm (_replace_hash_shift): Checks namespace of field name.

1 wakaba 1.1
2     =head1 NAME
3    
4     Message::Header::RFC822 --- Internet Messages -- Definition
5     for RFC822 Namespaces of Header Fields
6    
7     =cut
8    
9     package Message::Header::RFC822;
10     use strict;
11     use vars qw($VERSION);
12     $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
13     require Message::Header::Default;
14    
15     our %OPTION = %Message::Header::Default::OPTION;
16     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822';
17     $OPTION{namespace_phname} = 'rfc822';
18     $OPTION{namespace_phname_goodcase} = 'RFC822';
19    
20     $OPTION{case_sensible} = 0;
21    
22     $OPTION{goodcase} = {
23     fax => 'FAX',
24     'pics-label' => 'PICS-Label',
25     'list-url' => 'List-URL',
26     'list-id' => 'List-ID',
27     'message-id' => 'Message-ID',
28     'mime-version' => 'MIME-Version',
29     'nic' => 'NIC',
30     'nntp-posting-date' => 'NNTP-Posting-Date',
31     'nntp-posting-host' => 'NNTP-Posting-Host',
32     url => 'URL',
33     'x-dearfriend' => 'X-DearFriend',
34     'x-jsmail-priority' => 'X-JsMail-Priority',
35     'x-mime-autoconverted' => 'X-MIME-Autoconverted',
36     'x-mimeole' => 'X-MimeOLE',
37     'x-msmail-priority' => 'X-MSMail-Priority',
38     'x-nntp-posting-date' => 'X-NNTP-Posting-Date',
39     'x-nntp-posting-host' => 'X-NNTP-Posting-Host',
40     'x-uidl' => 'X-UIDL',
41     'x-uri' => 'X-URI',
42     'x-url' => 'X-URL',
43     };
44     $OPTION{to_be_goodcase} = \&_goodcase;
45    
46     $OPTION{value_type} = {
47     ':default' => ['Message::Field::Unstructured'],
48    
49     date => ['Message::Field::Date'],
50    
51     received => ['Message::Field::Received'],
52     'x-received' => ['Message::Field::Received'],
53    
54     archive => ['Message::Field::ValueParams'],
55     'auto-submitted' => ['Message::Field::ValueParams'],
56     'injector-info' => ['Message::Field::ValueParams'],
57     p3p => ['Message::Field::Params'],
58     'posted-and-mailed' => ['Message::Field::ValueParams'],
59     'x-face-type' => ['Message::Field::ValueParams'],
60     'x-mozilla-draft-info' => ['Message::Field::ValueParams'],
61    
62     ## A message id
63     'message-id' => ['Message::Field::MsgID'],
64     'resent-message-id' => ['Message::Field::MsgID'],
65    
66     ## Numeric value
67     lines => ['Message::Field::Numval'],
68     'max-forwards' => ['Message::Field::Numval'],
69     'mime-version' => ['Message::Field::Numval'],
70     'x-jsmail-priority' => ['Message::Field::Numval'],
71     'x-mail-count' => ['Message::Field::Numval'],
72     'x-ml-count' => ['Message::Field::Numval'],
73     'x-priority' => ['Message::Field::Numval'],
74    
75     path => ['Message::Field::Path'],
76     'user-agent' => ['Message::Field::UA'],
77    
78     subject => ['Message::Field::Subject'],
79     'x-nsubject' => ['Message::Field::Subject'],
80    
81     };
82     for (qw(cancel-lock disposition-notification-options encoding
83     importance pics-label precedence message-type
84     priority x-list-id sensitivity x-face x-msmail-priority xref))
85     {$OPTION{value_type}->{$_} = ['Message::Field::Structured']}
86     for (qw(abuse-reports-to apparently-to approved approved-by bcc cc complaints-to
87     delivered-to disposition-notification-to envelope-to
88     errors-to from mail-copies-to mail-followup-to mail-reply-to
89     notice-requested-upon-delivery-to read-receipt-to register-mail-reply-requested-by
90     reply-to return-path
91     return-receipt-to return-receipt-requested-to sender to x-abuse-reports-to
92 wakaba 1.2 x-admin x-approved x-beenthere x-biglobe-sender x-confirm-reading-to
93 wakaba 1.1 x-complaints-to x-envelope-from x-envelope-sender
94     x-envelope-to x-ml-address x-ml-command x-ml-to x-nfrom x-nto
95     x-rcpt-to x-sender x-x-sender))
96     {$OPTION{value_type}->{$_} = ['Message::Field::Addresses']}
97     for (qw(client-date date date-received delivery-date expires
98     expire-date nntp-posting-date posted posted-date received-date
99     reply-by resent-date x-originalarrivaltime x-tcup-date))
100     {$OPTION{value_type}->{$_} = ['Message::Field::Date']}
101     for (qw(article-updates in-reply-to
102     obsoletes references replaces see-also supersedes))
103     {$OPTION{value_type}->{$_} = ['Message::Field::MsgIDs']}
104     for (qw(encrypted followup-to keywords uri newsgroups posted-to))
105     {$OPTION{value_type}->{$_} = ['Message::Field::CSV']}
106     for (qw(x-brother x-boss x-classmate x-daughter x-dearfriend x-favoritesong
107     x-friend x-me
108     x-moe x-respect
109     x-sublimate x-son x-sister x-wife))
110     {$OPTION{value_type}->{$_} =[ 'Message::Field::CSV']} ## NOT M::F::XMOE!
111     for (qw(url x-home-page x-http_referer
112     x-info x-pgp-key x-ml-url x-uri x-url x-web))
113     {$OPTION{value_type}->{$_} = ['Message::Field::URI']}
114    
115     $OPTION{uri_mailto_safe} = {
116     ## 1 all (no check) 2 no trace & bcc & from
117     ## 3 no sender's info 4 (default) (currently not used)
118     ## 5 only a few
119     ':default' => 4,
120     'cc' => 5,
121     'bcc' => 1,
122     'body' => 1, ## Not entity body, but "body:" field.
123     'comments' => 5,
124     'date' => 1,
125     'from' => 1,
126     'keywords' => 5,
127     'list-id' => 1,
128     'mail-from' => 1,
129     'message-id' => 1,
130     'mime-version' => 1,
131     'received' => 1,
132     'return-path' => 1,
133     'sender' => 1,
134     'subject' => 5,
135     'summary' => 5,
136     'to' => 5,
137     'user-agent' => 3,
138     'x-face' => 2,
139     'x-mailer' => 3,
140     'x-nsubject' => 5,
141     'x-received' => 1,
142     'x400-received' => 1,
143     };
144    
145     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
146     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
147    
148     ## $self->_goodcase ($namespace_package_name, $field_name, \%option)
149     sub _goodcase ($$$\%) {
150     no strict 'refs';
151     my $self = shift;
152     my ($nspack, $name, $option) = @_;
153     return $name if $option->{format} =~ /uri-url-mailto/;
154     if ($option->{format} =~ /mail-rfc822/) {
155     if ($name eq 'cc' || $name eq 'bcc') {
156     return $name;
157     }
158     }
159     if (${$nspack.'::OPTION'}{goodcase}->{$name}) {
160     return ${$nspack.'::OPTION'}{goodcase}->{$name};
161     }
162     $name =~ s/(?:^|-)[a-z]/uc $&/ge;
163     $name;
164     }
165    
166     package Message::Header::RFC822::Resent;
167     our %OPTION = %Message::Header::RFC822::OPTION;
168     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:resent';
169     $OPTION{namespace_phname} = 'resent';
170     $OPTION{namespace_phname_goodcase} = 'Resent';
171     $OPTION{namespace_phname_regex} = 'resent';
172    
173     $OPTION{uri_mailto_safe} = {
174     ':default' => 1,
175     };
176    
177     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
178     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
179    
180     package Message::Header::RFC822::Original;
181     our %OPTION = %Message::Header::RFC822::OPTION;
182     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:original';
183     $OPTION{namespace_phname} = 'original';
184     $OPTION{namespace_phname_goodcase} = 'Original';
185    
186     $OPTION{value_type}->{recipient} = ['Message::Header::Structured'];
187    
188     $OPTION{uri_mailto_safe} = {
189     ':default' => 1,
190     };
191    
192     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
193     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
194    
195     package Message::Header::RFC822::Content;
196     our %OPTION = %Message::Header::RFC822::OPTION;
197     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:content';
198     $OPTION{namespace_phname} = 'content';
199     $OPTION{namespace_phname_goodcase} = 'Content';
200     $OPTION{namespace_phname_regex} = 'content';
201    
202     $OPTION{goodcase} = {
203     'id' => 'ID',
204     'md5' => 'MD5',
205     'sgml-entity' => 'SGML-Entity',
206     };
207    
208     $OPTION{value_type} = {
209     ':default' => ['Message::Field::Unstructured'],
210     alias => ['Message::Field::URI'],
211     base => ['Message::Field::URI'],
212     disposition => ['Message::Field::ValueParams'],
213     duration => ['Message::Field::Numval'],
214     encoding => ['Message::Field::CSV'],
215     features => ['Message::Field::Structured'],
216     id => ['Message::Field::MsgID'],
217     language => ['Message::Field::CSV'],
218     length => ['Message::Field::Numval'],
219     location => ['Message::Field::URI'],
220     md5 => ['Message::Field::Structured'],
221     range => ['Message::Field::Structured'],
222     'script-type' => ['Message::Field::ContentType'],
223     'style-type' => ['Message::Field::ContentType'],
224     'transfer-encoding' => ['Message::Field::ValueParams'],
225     type => ['Message::Field::ContentType'],
226     version => ['Message::Field::Structured'],
227     };
228    
229     $OPTION{uri_mailto_safe} = {
230     ':default' => 1,
231     };
232    
233     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
234     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
235    
236     package Message::Header::RFC822::List;
237     our %OPTION = %Message::Header::RFC822::OPTION;
238     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail:rfc822:list';
239     $OPTION{namespace_phname} = 'list';
240     $OPTION{namespace_phname_goodcase} = 'List';
241    
242     $OPTION{goodcase} = {
243     'id' => 'ID',
244     };
245    
246     $OPTION{value_type} = {
247     ':default' => ['Message::Field::Unstructured'],
248    
249     id => ['Message::Field::Structured'],
250     software => ['Message::Field::UA'],
251    
252     archive => ['Message::Field::CSV'],
253     digest => ['Message::Field::CSV'],
254     help => ['Message::Field::CSV'],
255     owner => ['Message::Field::CSV'],
256     post => ['Message::Field::CSV'],
257     subscribe => ['Message::Field::CSV'],
258     unsubscribe => ['Message::Field::CSV'],
259     url => ['Message::Field::CSV'],
260     };
261    
262     $OPTION{uri_mailto_safe} = {
263     ':default' => 1,
264     };
265    
266     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
267     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
268    
269     =head1 LICENSE
270    
271     Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
272    
273     This program is free software; you can redistribute it and/or modify
274     it under the terms of the GNU General Public License as published by
275     the Free Software Foundation; either version 2 of the License, or
276     (at your option) any later version.
277    
278     This program is distributed in the hope that it will be useful,
279     but WITHOUT ANY WARRANTY; without even the implied warranty of
280     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
281     GNU General Public License for more details.
282    
283     You should have received a copy of the GNU General Public License
284     along with this program; see the file COPYING. If not, write to
285     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
286     Boston, MA 02111-1307, USA.
287    
288     =head1 CHANGE
289    
290     See F<ChangeLog>.
291 wakaba 1.2 $Date: 2002/05/26 01:18:48 $
292 wakaba 1.1
293     =cut
294    
295     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24