jpmobile 0.1.6 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -0
- data/README.rdoc +58 -29
- data/Rakefile +1 -1
- data/VERSION.yml +4 -4
- data/lib/jpmobile.rb +3 -0
- data/lib/jpmobile/email.rb +17 -2
- data/lib/jpmobile/emoticon.rb +87 -23
- data/lib/jpmobile/emoticon/au.rb +644 -0
- data/lib/jpmobile/emoticon/softbank.rb +488 -0
- data/lib/jpmobile/emoticon/z_combine.rb +16 -13
- data/lib/jpmobile/hook_action_controller.rb +1 -13
- data/lib/jpmobile/hook_action_view.rb +3 -62
- data/lib/jpmobile/mail.rb +316 -0
- data/lib/jpmobile/mailer.rb +31 -0
- data/lib/jpmobile/mobile/abstract_mobile.rb +66 -0
- data/lib/jpmobile/mobile/au.rb +25 -2
- data/lib/jpmobile/mobile/docomo.rb +23 -1
- data/lib/jpmobile/mobile/emobile.rb +1 -1
- data/lib/jpmobile/mobile/softbank.rb +33 -1
- data/lib/jpmobile/mobile/vodafone.rb +1 -1
- data/lib/jpmobile/mobile/willcom.rb +1 -1
- data/lib/jpmobile/path_set.rb +40 -0
- data/lib/jpmobile/rails.rb +24 -0
- data/lib/jpmobile/resolver.rb +38 -0
- data/lib/jpmobile/util.rb +223 -14
- data/lib/tasks/jpmobile_tasks.rake +41 -48
- data/spec/rack/jpmobile/emoticon_spec.rb +3 -8
- data/spec/rack/jpmobile/filter_spec.rb +1 -1
- data/spec/rack/jpmobile/params_filter_spec.rb +4 -4
- data/spec/rack_helper.rb +5 -9
- data/spec/unit/detect_by_email_spec.rb +29 -0
- data/spec/unit/emoticon_spec.rb +90 -0
- data/spec/unit/encoding_spec.rb +102 -0
- data/spec/unit/mail_spec.rb +117 -0
- data/spec/unit/receive_mail_spec.rb +289 -0
- data/spec/unit/spec_helper.rb +8 -0
- data/spec/unit/util_spec.rb +5 -0
- data/test/rails/overrides/app/controllers/application_controller.rb +3 -2
- data/test/rails/overrides/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/overrides/app/models/mobile_mailer.rb +19 -0
- data/test/rails/overrides/app/models/normal_mailer.rb +9 -0
- data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +737 -0
- data/test/rails/overrides/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/overrides/spec/spec_helper.rb +6 -0
- data/test/rails/rails_root/app/controllers/application_controller.rb +3 -2
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/rails_root/app/models/mobile_mailer.rb +2 -1
- data/test/rails/rails_root/app/models/normal_mailer.rb +9 -0
- data/test/rails/rails_root/config/initializers/secret_token.rb +1 -1
- data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +73 -80
- data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/rails_root/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/rails_root/spec/spec_helper.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +2 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +7 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +1 -13
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +3 -62
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +162 -111
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +31 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +34 -3
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +2 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +4 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +7 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +40 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +24 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +38 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +33 -23
- metadata +43 -14
- data/test/legacy/emoticon_test.rb +0 -63
- data/test/legacy/helper.rb +0 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_mailer.rb +0 -22
@@ -4,30 +4,33 @@ end
|
|
4
4
|
|
5
5
|
module Jpmobile
|
6
6
|
module Emoticon
|
7
|
+
GETA = 0x3013
|
8
|
+
|
7
9
|
SJIS_TO_UNICODE = {}
|
8
10
|
SJIS_TO_UNICODE.update(DOCOMO_SJIS_TO_UNICODE)
|
9
11
|
SJIS_TO_UNICODE.update(AU_SJIS_TO_UNICODE)
|
10
12
|
SJIS_TO_UNICODE.freeze
|
11
13
|
UNICODE_TO_SJIS = SJIS_TO_UNICODE.invert.freeze
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Regexp.compile(Regexp.escape([sjis].pack('n'),"s"),nil,'s')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
SJIS_REGEXP = Regexp.union(*SJIS_TO_UNICODE.keys.map{|s| sjis_regexp[s]})
|
15
|
+
# for au email
|
16
|
+
SJIS_TO_EMAIL_JIS = {0x81ac => 0x222E}
|
17
|
+
SJIS_TO_EMAIL_JIS.update(AU_SJIS_TO_EMAIL_JIS)
|
18
|
+
SJIS_TO_EMAIL_JIS.freeze
|
19
|
+
|
20
|
+
SJIS_REGEXP = Regexp.union(*SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
24
21
|
SOFTBANK_WEBCODE_REGEXP = Regexp.union(*([/(?!)/n]+SOFTBANK_WEBCODE_TO_UNICODE.keys.map{|x| "\x1b\x24#{x}\x0f"}))
|
25
22
|
|
26
|
-
DOCOMO_SJIS_REGEXP = Regexp.union(*DOCOMO_SJIS_TO_UNICODE.keys.map{|s| sjis_regexp
|
27
|
-
AU_SJIS_REGEXP = Regexp.union(*AU_SJIS_TO_UNICODE.keys.map{|s| sjis_regexp
|
23
|
+
DOCOMO_SJIS_REGEXP = Regexp.union(*DOCOMO_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
24
|
+
AU_SJIS_REGEXP = Regexp.union(*AU_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
28
25
|
SOFTBANK_UNICODE_REGEXP = Regexp.union(*SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|x| [x].pack('U')}).freeze
|
29
26
|
|
30
27
|
EMOTICON_UNICODES = UNICODE_TO_SJIS.keys|SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|k|k+0x1000}
|
31
28
|
UTF8_REGEXP = Regexp.union(*EMOTICON_UNICODES.map{|x| [x].pack('U')}).freeze
|
29
|
+
|
30
|
+
# for PC conversion "GETA"
|
31
|
+
CONVERSION_TABLE_TO_PC_EMAIL = Hash[*(CONVERSION_TABLE_TO_SOFTBANK.keys|CONVERSION_TABLE_TO_DOCOMO.keys|CONVERSION_TABLE_TO_AU.keys).map{|k| [k, GETA]}.flatten]
|
32
|
+
|
33
|
+
SOFTBANK_SJIS_REGEXP = Regexp.union(*SOFTBANK_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)}).freeze
|
34
|
+
AU_EMAILJIS_REGEXP = Regexp.union(*AU_EMAILJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.jis_regexp(s)})
|
32
35
|
end
|
33
36
|
end
|
@@ -1,17 +1,4 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
module AbstractController
|
3
|
-
module ViewPaths
|
4
|
-
def lookup_context_with_jpmobile
|
5
|
-
jpmobile_context = lookup_context_without_jpmobile
|
6
|
-
jpmobile_context.view_paths.controller = self
|
7
|
-
|
8
|
-
jpmobile_context
|
9
|
-
end
|
10
|
-
|
11
|
-
alias_method_chain :lookup_context, :jpmobile
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
2
|
module ActionController
|
16
3
|
class Base
|
17
4
|
include Jpmobile::Helpers
|
@@ -29,3 +16,4 @@ module ActionController
|
|
29
16
|
end
|
30
17
|
|
31
18
|
ActionController::Request.send :include, Jpmobile::Encoding
|
19
|
+
ActionView::LookupContext.register_detail(:mobile) {nil}
|
@@ -1,72 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# = viewの自動切り替え
|
3
|
-
#
|
4
2
|
#:stopdoc:
|
5
3
|
# helperを追加
|
6
4
|
ActionView::Base.class_eval { include Jpmobile::Helpers }
|
7
5
|
#:startdoc:
|
8
6
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# index_mobile_vodafone.html.erb
|
12
|
-
# index_mobile_softbank.html.erb
|
13
|
-
# index_mobile.html.erb
|
14
|
-
# index.html.erb
|
15
|
-
# の順にテンプレートが検索される。
|
16
|
-
# BUG: 現状、上記の例では index.html.erb が存在しない場合に振り分けが行われない
|
17
|
-
# (ダミーファイルを置くことで回避可能)。
|
7
|
+
# :stopdoc:
|
8
|
+
# accept-charset に charset を変更できるようにする
|
18
9
|
module ActionView
|
19
|
-
class PathSet
|
20
|
-
attr_accessor :controller
|
21
|
-
|
22
|
-
def find_with_jpmobile(path, prefix = nil, partial = false, details = {}, key = nil) #:nodoc:
|
23
|
-
if controller and controller.kind_of?(ActionController::Base) and
|
24
|
-
(controller.request.mobile? or controller.request.smart_phone?)
|
25
|
-
return path if path.respond_to?(:render)
|
26
|
-
template_candidates = mobile_template_candidates
|
27
|
-
|
28
|
-
each do |load_path|
|
29
|
-
template_candidates.each do |template_postfix|
|
30
|
-
templates = load_path.find_all("#{path}_#{template_postfix}", prefix, partial, details, key)
|
31
|
-
return templates.first unless templates.empty?
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
find_without_jpmobile(path, prefix, partial, details, key)
|
37
|
-
end
|
38
|
-
|
39
|
-
alias_method_chain :find, :jpmobile #:nodoc:
|
40
|
-
|
41
|
-
def mobile_template_candidates #:nodoc:
|
42
|
-
candidates = []
|
43
|
-
|
44
|
-
view_class, parent_class, template_prefix = case controller.request.mobile
|
45
|
-
when ::Jpmobile::Mobile::SmartPhone
|
46
|
-
[controller.request.mobile.class, ::Jpmobile::Mobile::SmartPhone, "smart_phone"]
|
47
|
-
when ::Jpmobile::Mobile::AbstractMobile
|
48
|
-
[controller.request.mobile.class, ::Jpmobile::Mobile::AbstractMobile, "mobile"]
|
49
|
-
else
|
50
|
-
[nil, nil, nil]
|
51
|
-
end
|
52
|
-
|
53
|
-
if view_class and parent_class
|
54
|
-
find_mobile_template(view_class, parent_class, template_prefix).push(template_prefix)
|
55
|
-
else
|
56
|
-
[]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
def find_mobile_template(klass, parent, prefix)
|
62
|
-
if klass == parent
|
63
|
-
[]
|
64
|
-
else
|
65
|
-
find_mobile_template(klass.superclass, parent, prefix).unshift("#{prefix}_#{klass.to_s.split(/::/).last.underscore}")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
10
|
module Helpers
|
71
11
|
module FormTagHelper
|
72
12
|
private
|
@@ -85,3 +25,4 @@ module ActionView
|
|
85
25
|
end
|
86
26
|
end
|
87
27
|
end
|
28
|
+
#:startdoc:
|
@@ -0,0 +1,316 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'mail'
|
3
|
+
|
4
|
+
module Jpmobile
|
5
|
+
module Mail
|
6
|
+
module_function
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Mail
|
11
|
+
# encoding patch
|
12
|
+
if self.const_defined?(:Ruby19)
|
13
|
+
Ruby19.class_eval do
|
14
|
+
def self.b_value_decode(str)
|
15
|
+
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
|
16
|
+
if match
|
17
|
+
encoding = match[1]
|
18
|
+
str = self.decode_base64(match[2])
|
19
|
+
str.force_encoding(fix_encoding(encoding))
|
20
|
+
end
|
21
|
+
# if str contains some emoticon, the following line raises Encoding error
|
22
|
+
str.encode("utf-8", :invalid => :replace, :replace => "") rescue Jpmobile::Util.ascii_8bit(str)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
elsif self.const_defined?(:Ruby18)
|
26
|
+
Ruby18.class_eval do
|
27
|
+
def self.b_value_decode(str)
|
28
|
+
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
|
29
|
+
if match
|
30
|
+
encoding = match[1]
|
31
|
+
str = Ruby18.decode_base64(match[2])
|
32
|
+
end
|
33
|
+
str
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Message
|
39
|
+
attr_accessor :mobile
|
40
|
+
|
41
|
+
def mobile=(m)
|
42
|
+
@mobile = m
|
43
|
+
@charset = m.mail_charset(@charset)
|
44
|
+
|
45
|
+
if @body
|
46
|
+
@body.charset = @charset
|
47
|
+
@body.mobile = m
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def encoded_with_jpmobile
|
52
|
+
if @mobile
|
53
|
+
header['subject'].mobile = @mobile if header['subject']
|
54
|
+
self.charset = @mobile.mail_charset(@charset)
|
55
|
+
|
56
|
+
ready_to_send!
|
57
|
+
|
58
|
+
self.body.charset = @charset
|
59
|
+
self.body.mobile = @mobile
|
60
|
+
self.header['Content-Transfer-Encoding'] = '8bit'
|
61
|
+
|
62
|
+
buffer = header.encoded
|
63
|
+
buffer << "\r\n"
|
64
|
+
buffer = @mobile.utf8_to_mail_encode(buffer)
|
65
|
+
buffer << body.encoded(content_transfer_encoding)
|
66
|
+
buffer
|
67
|
+
else
|
68
|
+
encoded_without_jpmobile
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def parse_message_with_jpmobile
|
73
|
+
header_part, body_part = raw_source.split(/#{CRLF}#{WSP}*#{CRLF}/m, 2)
|
74
|
+
|
75
|
+
self.header = header_part
|
76
|
+
|
77
|
+
@body_part_jpmobile = body_part
|
78
|
+
convert_encoding_jpmobile
|
79
|
+
body_part = @body_part_jpmobile
|
80
|
+
|
81
|
+
self.body = body_part
|
82
|
+
end
|
83
|
+
|
84
|
+
def init_with_string(string)
|
85
|
+
# convert to ASCII-8BIT for ascii incompatible encodings
|
86
|
+
s = Jpmobile::Util.ascii_8bit(string)
|
87
|
+
self.raw_source = s
|
88
|
+
set_envelope_header
|
89
|
+
parse_message
|
90
|
+
@separate_parts = multipart?
|
91
|
+
end
|
92
|
+
|
93
|
+
def process_body_raw_with_jpmobile
|
94
|
+
process_body_raw_without_jpmobile
|
95
|
+
|
96
|
+
@body.charset = @charset
|
97
|
+
@body.mobile = @mobile
|
98
|
+
|
99
|
+
if has_content_transfer_encoding? and
|
100
|
+
["base64", "quoted-printable"].include?(content_transfer_encoding) and
|
101
|
+
["text", nil].include?(@mobile_main_type)
|
102
|
+
@body.decode_transfer_encoding
|
103
|
+
end
|
104
|
+
|
105
|
+
if @body.multipart?
|
106
|
+
@body.parts.each do |p|
|
107
|
+
p.charset = @charset
|
108
|
+
p.mobile = @mobile
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def body_lazy_with_jpmobile(value, index)
|
114
|
+
body_lazy_without_jpmobile(value, index)
|
115
|
+
end
|
116
|
+
|
117
|
+
alias_method :encoded_without_jpmobile, :encoded
|
118
|
+
alias_method :encoded, :encoded_with_jpmobile
|
119
|
+
|
120
|
+
alias_method :parse_message_without_jpmobile, :parse_message
|
121
|
+
alias_method :parse_message, :parse_message_with_jpmobile
|
122
|
+
|
123
|
+
alias_method :process_body_raw_without_jpmobile, :process_body_raw
|
124
|
+
alias_method :process_body_raw, :process_body_raw_with_jpmobile
|
125
|
+
|
126
|
+
alias_method :body_lazy_without_jpmobile, :body_lazy
|
127
|
+
alias_method :body_lazy, :body_lazy_with_jpmobile
|
128
|
+
|
129
|
+
private
|
130
|
+
def convert_encoding_jpmobile
|
131
|
+
# decide mobile carrier
|
132
|
+
if self.header['From']
|
133
|
+
mobile_class = Jpmobile::Email.detect_from_mail_header(self.header['From'].value)
|
134
|
+
@mobile ||= (mobile_class || Jpmobile::Mobile::AbstractMobile ).new(nil, nil)
|
135
|
+
end
|
136
|
+
|
137
|
+
# override charset
|
138
|
+
if self.header['Content-Type']
|
139
|
+
@charset = Jpmobile::Util.extract_charset(self.header['Content-Type'].value)
|
140
|
+
self.header['Content-Type'].parameters[:charset] = @charset
|
141
|
+
@mobile_main_type = self.header['Content-Type'].main_type
|
142
|
+
end
|
143
|
+
|
144
|
+
# convert header(s)
|
145
|
+
if self.header['Subject']
|
146
|
+
subject_charset = Jpmobile::Util.extract_charset(self.header['Subject'].value)
|
147
|
+
|
148
|
+
# override subject encoding if @charset is blank
|
149
|
+
@charset = subject_charset if !subject_charset.blank? and @charset.blank?
|
150
|
+
|
151
|
+
self.header['Subject'].charset = subject_charset
|
152
|
+
|
153
|
+
if @mobile
|
154
|
+
v = @mobile.to_mail_internal(
|
155
|
+
Encodings.value_decode(self.header['Subject'].value), subject_charset)
|
156
|
+
self.header['Subject'].value = Jpmobile::Util.force_encode(v, @mobile.mail_charset(@charset), Jpmobile::Util::UTF8)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
if @body_part_jpmobile and @mobile
|
161
|
+
@body_part_jpmobile = @mobile.decode_transfer_encoding(@body_part_jpmobile, @charset)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
class Part
|
167
|
+
def init_with_string(string)
|
168
|
+
self.raw_source = string
|
169
|
+
set_envelope_header
|
170
|
+
parse_message
|
171
|
+
@separate_parts = multipart?
|
172
|
+
end
|
173
|
+
|
174
|
+
def parse_message_with_jpmobile
|
175
|
+
header_part, body_part = raw_source.split(/#{CRLF}#{WSP}*#{CRLF}/m, 2)
|
176
|
+
|
177
|
+
if header_part =~ HEADER_LINE
|
178
|
+
self.header = header_part
|
179
|
+
else
|
180
|
+
self.header = "Content-Type: text/plain\r\n"
|
181
|
+
end
|
182
|
+
|
183
|
+
@body_part_jpmobile = body_part
|
184
|
+
convert_encoding_jpmobile
|
185
|
+
body_part = @body_part_jpmobile
|
186
|
+
|
187
|
+
self.body = body_part
|
188
|
+
end
|
189
|
+
|
190
|
+
alias_method :parse_message_without_jpmobile, :parse_message
|
191
|
+
alias_method :parse_message, :parse_message_with_jpmobile
|
192
|
+
end
|
193
|
+
|
194
|
+
class Body
|
195
|
+
attr_accessor :mobile
|
196
|
+
|
197
|
+
# convert encoding
|
198
|
+
def encoded_with_jpmobile(transfer_encoding = '8bit')
|
199
|
+
if @mobile and !multipart?
|
200
|
+
if @mobile.to_mail_body_encoded?(@raw_source)
|
201
|
+
@raw_source
|
202
|
+
else
|
203
|
+
@mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, @charset, Jpmobile::Util::UTF8))
|
204
|
+
end
|
205
|
+
else
|
206
|
+
encoded_without_jpmobile(transfer_encoding)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def decoded_with_jpmobile
|
211
|
+
decoded_without_jpmobile
|
212
|
+
end
|
213
|
+
|
214
|
+
# fix charset
|
215
|
+
def set_charset_with_jpmobile
|
216
|
+
@charset ||= only_us_ascii? ? 'US-ASCII' : nil
|
217
|
+
end
|
218
|
+
|
219
|
+
def mobile=(m)
|
220
|
+
@mobile = m
|
221
|
+
|
222
|
+
if self.multipart?
|
223
|
+
self.parts.each do |part|
|
224
|
+
part.charset = @charset
|
225
|
+
part.mobile = @mobile
|
226
|
+
part.body.charset = @charset
|
227
|
+
part.body.mobile = @mobile
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def decode_transfer_encoding
|
233
|
+
_raw_source = Encodings.get_encoding(encoding).decode(@raw_source)
|
234
|
+
_raw_source = Jpmobile::Util.set_encoding(_raw_source, @charset)
|
235
|
+
|
236
|
+
@raw_source = @mobile.decode_transfer_encoding(_raw_source, @charset)
|
237
|
+
end
|
238
|
+
|
239
|
+
def preamble_with_jpmobile
|
240
|
+
if @mobile
|
241
|
+
Jpmobile::Util.encode(@preamble, @charset)
|
242
|
+
else
|
243
|
+
preamble_without_jpmobile
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def epilogue_with_jpmobile
|
248
|
+
if @mobile
|
249
|
+
Jpmobile::Util.encode(@epilogue, @charset)
|
250
|
+
else
|
251
|
+
epilogue_without_jpmobile
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def crlf_boundary_with_jpmobile
|
256
|
+
if @mobile
|
257
|
+
Jpmobile::Util.encode(crlf_boundary_without_jpmobile, @charset)
|
258
|
+
else
|
259
|
+
epilogue_without_jpmobile
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def end_boundary_with_jpmobile
|
264
|
+
if @mobile
|
265
|
+
Jpmobile::Util.encode(end_boundary_without_jpmobile, @charset)
|
266
|
+
else
|
267
|
+
epilogue_without_jpmobile
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
alias_method :encoded_without_jpmobile, :encoded
|
272
|
+
alias_method :encoded, :encoded_with_jpmobile
|
273
|
+
|
274
|
+
alias_method :decoded_without_jpmobile, :decoded
|
275
|
+
alias_method :decoded, :decoded_with_jpmobile
|
276
|
+
|
277
|
+
alias_method :set_charset_without_jpmobile, :set_charset
|
278
|
+
alias_method :set_charset, :set_charset_with_jpmobile
|
279
|
+
|
280
|
+
alias_method :preamble_without_jpmobile, :preamble
|
281
|
+
alias_method :preamble, :preamble_with_jpmobile
|
282
|
+
|
283
|
+
alias_method :crlf_boundary_without_jpmobile, :crlf_boundary
|
284
|
+
alias_method :crlf_boundary, :crlf_boundary_with_jpmobile
|
285
|
+
|
286
|
+
alias_method :end_boundary_without_jpmobile, :end_boundary
|
287
|
+
alias_method :end_boundary, :end_boundary_with_jpmobile
|
288
|
+
|
289
|
+
alias_method :epilogue_without_jpmobile, :epilogue
|
290
|
+
alias_method :epilogue, :epilogue_with_jpmobile
|
291
|
+
end
|
292
|
+
|
293
|
+
class UnstructuredField
|
294
|
+
attr_accessor :mobile
|
295
|
+
end
|
296
|
+
|
297
|
+
# for subject
|
298
|
+
class SubjectField < UnstructuredField
|
299
|
+
# FIXME: not folding subject -> folding
|
300
|
+
def encoded_with_jpmobile
|
301
|
+
if @mobile
|
302
|
+
if @mobile.to_mail_subject_encoded?(value)
|
303
|
+
"#{name}: #{value}\r\n"
|
304
|
+
else
|
305
|
+
# convert encoding
|
306
|
+
"#{name}: " + @mobile.to_mail_subject(value) + "\r\n"
|
307
|
+
end
|
308
|
+
else
|
309
|
+
encoded_without_jpmobile
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
alias_method :encoded_without_jpmobile, :encoded
|
314
|
+
alias_method :encoded, :encoded_with_jpmobile
|
315
|
+
end
|
316
|
+
end
|