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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sat May 25 09:50:07 2002 UTC (22 years, 6 months ago) by wakaba
Branch: MAIN
2002-05-25  wakaba <w@suika.fam.cx>

	* Default.pm: New module.

1 wakaba 1.1
2     =head1 NAME
3    
4     Message::Header::Default --- Internet Messages -- Definition
5     for Default Namespace of Header Fields
6    
7     =cut
8    
9     package Message::Header::Default;
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;
14    
15     our %OPTION;
16    
17     ## Case sensibility of field name
18     $OPTION{case_sensible} = 1;
19     $OPTION{n11n_name} = \&_name_n11n;
20     $OPTION{n11n_prefix} = \&_name_n11n;
21    
22     ## Namespace URI of this namespace
23     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:default';
24    
25     ## Force & hyphened prefix name of this namespace (ex. "prefix-name")
26     $OPTION{namespace_phname} = 'default';
27     $OPTION{namespace_phname_goodcase} = 'default';
28    
29     ## `Good' & dotted prefix name of this namespace (ex. "prefix.name", "prefix2.name")
30     $OPTION{namespace_good_prefix} = 'DEFAULT';
31    
32     ## Field body data type (specified by package name)
33     $OPTION{value_type} = {
34     ':default' => ['Message::Field::Unstructured'],
35     };
36    
37     ##
38    
39     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
40     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
41    
42     ## $self->_goodcase ($namespace_package_name, $field_name)
43     sub _goodcase ($$$) {
44     no strict 'refs';
45     my $self = shift;
46     my $nspack = shift;
47     my $name = shift;
48     if (${$nspack.'::OPTION'}{goodcase}->{$name}) {
49     return ${$nspack.'::OPTION'}{goodcase}->{$name};
50     }
51     $name =~ s/(?:^|-)[a-z]/uc $&/ge;
52     $name;
53     }
54    
55     sub _name_n11n ($$$) {
56     no strict 'refs';
57     my $self = shift;
58     my $nspack = shift;
59     my $name = shift;
60     unless (${$nspack.'::OPTION'}{case_sensible}) {
61     lc $name;
62     } else {
63     $name;
64     }
65     }
66    
67     package Message::Header::RFC822;
68     our %OPTION = %Message::Header::Default::OPTION;
69     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail-rfc822';
70     $OPTION{namespace_phname} = 'rfc822';
71     $OPTION{namespace_phname_goodcase} = 'RFC822';
72    
73     $OPTION{case_sensible} = 0;
74    
75     $OPTION{goodcase} = {
76     fax => 'FAX',
77     'pics-label' => 'PICS-Label',
78     'list-url' => 'List-URL',
79     'list-id' => 'List-ID',
80     'message-id' => 'Message-ID',
81     'mime-version' => 'MIME-Version',
82     'nic' => 'NIC',
83     'nntp-posting-date' => 'NNTP-Posting-Date',
84     'nntp-posting-host' => 'NNTP-Posting-Host',
85     url => 'URL',
86     'x-dearfriend' => 'X-DearFriend',
87     'x-jsmail-priority' => 'X-JsMail-Priority',
88     'x-mime-autoconverted' => 'X-MIME-Autoconverted',
89     'x-mimeole' => 'X-MimeOLE',
90     'x-msmail-priority' => 'X-MSMail-Priority',
91     'x-nntp-posting-date' => 'X-NNTP-Posting-Date',
92     'x-nntp-posting-host' => 'X-NNTP-Posting-Host',
93     'x-uidl' => 'X-UIDL',
94     'x-uri' => 'X-URI',
95     'x-url' => 'X-URL',
96     };
97     $OPTION{to_be_goodcase} = \&Message::Header::Default::_goodcase;
98    
99     $OPTION{value_type} = {
100     ':default' => ['Message::Field::Unstructured'],
101     'date' => ['Message::Field::Date'],
102     };
103    
104     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
105     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
106    
107     package Message::Header::Resent;
108     our %OPTION = %Message::Header::RFC822::OPTION;
109     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail-rfc822:resent';
110     $OPTION{namespace_phname} = 'resent';
111     $OPTION{namespace_phname_goodcase} = 'Resent';
112     $OPTION{namespace_phname_regex} = 'resent';
113    
114     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
115     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
116    
117     package Message::Header::Content;
118     our %OPTION = %Message::Header::RFC822::OPTION;
119     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:mail-mime-entity';
120     $OPTION{namespace_phname} = 'content';
121     $OPTION{namespace_phname_goodcase} = 'Content';
122     $OPTION{namespace_phname_regex} = 'content';
123    
124     $OPTION{goodcase} = {
125     'id' => 'ID',
126     'md5' => 'MD5',
127     'sgml-entity' => 'SGML-Entity',
128     };
129    
130     $OPTION{value_type} = {
131     ':default' => ['Message::Field::Unstructured'],
132     alias => ['Message::Field::URI'],
133     base => ['Message::Field::URI'],
134     disposition => ['Message::Field::ValueParams'],
135     features => ['Message::Field::Structured'],
136     id => ['Message::Field::MsgID'],
137     length => ['Message::Field::Numval'],
138     location => ['Message::Field::URI'],
139     md5 => ['Message::Field::Structured'],
140     'transfer-encoding' => ['Message::Field::ValueParams'],
141     type => ['Message::Field::ContentType'],
142     };
143    
144     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
145     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
146    
147     package Message::Header::XCGI;
148     our %OPTION = %Message::Header::Default::OPTION;
149     $OPTION{namespace_uri} = 'urn:x-suika-fam-cx:msgpm:header:http:cgi:x';
150     $OPTION{namespace_phname} = 'x-cgi';
151     $OPTION{namespace_phname_goodcase} = 'X-CGI';
152    
153     $OPTION{case_sensible} = 0;
154     $OPTION{to_be_goodcase} = \&Message::Header::Default::_goodcase;
155    
156     $Message::Header::NS_phname2uri{$OPTION{namespace_phname}} = $OPTION{namespace_uri};
157     $Message::Header::NS_uri2phpackage{$OPTION{namespace_uri}} = __PACKAGE__;
158    
159     =head1 LICENSE
160    
161     Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
162    
163     This program is free software; you can redistribute it and/or modify
164     it under the terms of the GNU General Public License as published by
165     the Free Software Foundation; either version 2 of the License, or
166     (at your option) any later version.
167    
168     This program is distributed in the hope that it will be useful,
169     but WITHOUT ANY WARRANTY; without even the implied warranty of
170     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
171     GNU General Public License for more details.
172    
173     You should have received a copy of the GNU General Public License
174     along with this program; see the file COPYING. If not, write to
175     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
176     Boston, MA 02111-1307, USA.
177    
178     =head1 CHANGE
179    
180     See F<ChangeLog>.
181     $Date: 2002/03/21 04:33:44 $
182    
183     =cut
184    
185     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24