jpmobile 2.0.11 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -4
- data/README.rdoc +5 -12
- data/Rakefile +1 -1
- data/VERSION.yml +2 -2
- data/jpmobile.gemspec +3 -2
- data/lib/jpmobile.rb +1 -15
- data/lib/jpmobile/emoticon.rb +2 -65
- data/lib/jpmobile/emoticon/z_combine.rb +1 -17
- data/lib/jpmobile/lookup_context.rb +1 -1
- data/lib/jpmobile/mail.rb +29 -59
- data/lib/jpmobile/mailer.rb +1 -1
- data/lib/jpmobile/mobile/abstract_mobile.rb +36 -60
- data/lib/jpmobile/mobile/android.rb +0 -2
- data/lib/jpmobile/mobile/iphone.rb +25 -1
- data/lib/jpmobile/rack.rb +1 -6
- data/lib/jpmobile/rails.rb +2 -2
- data/lib/jpmobile/resolver.rb +18 -13
- data/lib/jpmobile/trans_sid.rb +9 -8
- data/lib/jpmobile/util.rb +1 -54
- data/lib/tasks/jpmobile_tasks.rake +4 -4
- data/spec/rack/jpmobile/emoticon_spec.rb +0 -167
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +1 -5
- data/spec/unit/emoticon_spec.rb +0 -60
- data/spec/unit/mail_spec.rb +0 -86
- data/spec/unit/receive_mail_spec.rb +0 -46
- data/spec/unit/util_spec.rb +0 -43
- data/test/rails/overrides/Gemfile +4 -19
- data/test/rails/overrides/app/controllers/template_path_controller.rb +0 -12
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +0 -10
- data/test/rails/overrides/spec/requests/template_path_spec.rb +0 -72
- metadata +43 -166
- data/lib/jpmobile/emoticon/google.rb +0 -2421
- data/lib/jpmobile/emoticon/unicode.rb +0 -2253
- data/lib/jpmobile/mobile/android_tablet.rb +0 -12
- data/lib/jpmobile/mobile/black_berry.rb +0 -10
- data/lib/jpmobile/mobile/google_emoticon.rb +0 -29
- data/lib/jpmobile/mobile/ipad.rb +0 -12
- data/lib/jpmobile/mobile/tablet.rb +0 -16
- data/lib/jpmobile/mobile/unicode_emoticon.rb +0 -43
- data/spec/rack/jpmobile/black_berry_spec.rb +0 -20
- data/spec/unit/email-fixtures/bounce_with_utf8_part.eml +0 -42
- data/spec/unit/email-fixtures/iphone-mail3.eml +0 -56
- data/spec/unit/email-fixtures/iphone-message.eml +0 -27
- data/spec/unit/mobile/iphone_spec.rb +0 -34
- data/spec/unit/variants_spec.rb +0 -128
- data/test/rails/overrides/app/views/template_path/smart_phone_only.html.erb +0 -1
- data/test/rails/overrides/app/views/template_path/smart_phone_only_smart_phone.html.erb +0 -1
- data/test/rails/overrides/app/views/template_path/with_ipd.html.erb +0 -1
- data/test/rails/overrides/app/views/template_path/with_ipd_tablet_ipad.html.erb +0 -1
- data/test/rails/overrides/app/views/template_path/with_tblt.html.erb +0 -1
- data/test/rails/overrides/app/views/template_path/with_tblt_tablet.html.erb +0 -1
- data/test/rails/overrides/spec/fixtures/mobile_mailer/bounced-jp.eml +0 -72
- data/tools/e4u_conv.rb +0 -122
data/Gemfile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
group :development, :test do
|
4
|
-
gem 'mail', '~> 2.3.0'
|
5
4
|
gem 'jeweler'
|
6
|
-
gem 'rails', '~> 3.
|
7
|
-
gem 'rspec'
|
8
|
-
gem 'rspec-rails'
|
5
|
+
gem 'rails', '~> 3.2.0'
|
6
|
+
gem 'rspec'
|
7
|
+
gem 'rspec-rails'
|
9
8
|
gem 'webrat'
|
10
9
|
gem 'geokit'
|
11
10
|
gem 'sqlite3-ruby'
|
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= jpmobile: A Rails plugin for Japanese mobile-phones
|
2
2
|
|
3
3
|
== jpmobileとは
|
4
|
-
携帯電話特有の機能を Rails 3.
|
4
|
+
携帯電話特有の機能を Rails 3.2 や Rack middleware で利用するためのプラグイン。
|
5
5
|
以下の機能を備える。
|
6
6
|
|
7
7
|
* 携帯電話のキャリア判別
|
@@ -18,11 +18,13 @@
|
|
18
18
|
* メールの受信(experimental)
|
19
19
|
* 絵文字と漢字コードの変換
|
20
20
|
|
21
|
-
また Rails 3.
|
21
|
+
また Rails 3.2 に以下の機能を追加する
|
22
22
|
* ビューへの自動振分け
|
23
23
|
* 位置情報取得などのリンクヘルパーの追加
|
24
24
|
* セッションIDをフォーム/リンクに付与(Trans SID)
|
25
25
|
|
26
|
+
他のバージョンの Rails については {Versions : Jpmobile vs Rails}[https://github.com/jpmobile/jpmobile/wiki/Version-:-Jpmobile-vs-Rails] を参照。
|
27
|
+
|
26
28
|
== インストール
|
27
29
|
=== Rails pluginとしてインストールする場合
|
28
30
|
% rails plugin install git://github.com/jpmobile/jpmobile.git
|
@@ -150,19 +152,10 @@ jpmobileを読み込むとDoCoMo、Au、SoftBankの絵文字を透過的に扱
|
|
150
152
|
* Rails の場合は vendor/plugins に配置し、下記の設定を追加することで有効になる。
|
151
153
|
# Rack middleware を追加するメソッド
|
152
154
|
Rails.application.config.jpmobile.mobile_filter
|
153
|
-
or
|
154
|
-
Jpmobile.config.mobile_filter
|
155
155
|
|
156
156
|
* 下記の設定を追加することで、<form> タグの accept-charset が変更される。
|
157
157
|
# <form accept-charset="Shift_JIS" ...> などに変更する
|
158
158
|
Rails.application.config.jpmobile.form_accept_charset_conversion = true
|
159
|
-
or
|
160
|
-
Jpmobile.config.form_accept_charset_conversion = true
|
161
|
-
|
162
|
-
* Andriod/iPhone では Google 絵文字や Unicode 6.0 絵文字が使われています。下記の設定を追加すると、互換性をもたせるために3キャリアの絵文字に変換することができます。また表示の変換も可能です。
|
163
|
-
Rails.application.config.jpmobile.smart_phone_emoticon_compatibility = true
|
164
|
-
or
|
165
|
-
Jpmobile.config.smart_phone_emoticon_compatibility = true
|
166
159
|
|
167
160
|
携帯電話上では特に問題とならない。PCブラウザでテストする際に問題となるためのオプション。
|
168
161
|
|
@@ -246,7 +239,7 @@ Androidの場合はindex_smart_phone_android.html.erb、Windows Phoneの場合
|
|
246
239
|
end
|
247
240
|
|
248
241
|
trans_sid 機能を使う場合には cookie session store を使用することができません。
|
249
|
-
また Rails 3.
|
242
|
+
また Rails 3.2 では Cookie が使える場合にはそちらが優先されてしまうため、:always を指定した場合に問題になる場合があります。
|
250
243
|
trans_sid を使用する際には、例えば config/initializers/session_store.rb で
|
251
244
|
Rails.application.config.session_store :active_record_store
|
252
245
|
Rails.application.config.session_options = {:cookie_only => false}
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ begin
|
|
22
22
|
gem.files.exclude 'spec'
|
23
23
|
gem.files.exclude 'vendor'
|
24
24
|
|
25
|
-
gem.add_development_dependency('rails', '>=3.
|
25
|
+
gem.add_development_dependency('rails', '>=3.2.0')
|
26
26
|
gem.add_development_dependency('jeweler', '>=1.5.1')
|
27
27
|
gem.add_development_dependency('rspec', '>=2.6.0')
|
28
28
|
gem.add_development_dependency('rspec-rails', '>=2.6.0')
|
data/VERSION.yml
CHANGED
data/jpmobile.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jpmobile}
|
8
|
-
s.version = "
|
8
|
+
s.version = "3.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Yoji Shidara", "Shin-ichiro OGAWA"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-28}
|
13
13
|
s.description = %q{A Rails plugin for Japanese mobile-phones}
|
14
14
|
s.email = %q{dara@shidara.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -332,3 +332,4 @@ Gem::Specification.new do |s|
|
|
332
332
|
s.add_dependency(%q<rails>, [">= 3.0.3"])
|
333
333
|
end
|
334
334
|
end
|
335
|
+
|
data/lib/jpmobile.rb
CHANGED
@@ -22,23 +22,14 @@ module Jpmobile
|
|
22
22
|
autoload :Emobile, 'jpmobile/mobile/emobile'
|
23
23
|
autoload :Willcom, 'jpmobile/mobile/willcom'
|
24
24
|
autoload :Ddipocket, 'jpmobile/mobile/ddipocket'
|
25
|
-
|
26
25
|
autoload :SmartPhone, 'jpmobile/mobile/smart_phone'
|
27
26
|
autoload :Iphone, 'jpmobile/mobile/iphone'
|
28
27
|
autoload :Android, 'jpmobile/mobile/android'
|
29
28
|
autoload :WindowsPhone, 'jpmobile/mobile/windows_phone'
|
30
|
-
autoload :BlackBerry, 'jpmobile/mobile/black_berry'
|
31
|
-
|
32
|
-
autoload :Tablet, 'jpmobile/mobile/tablet'
|
33
|
-
autoload :AndroidTablet, 'jpmobile/mobile/android_tablet'
|
34
|
-
autoload :Ipad, 'jpmobile/mobile/ipad'
|
35
29
|
|
36
30
|
autoload :Display, 'jpmobile/mobile/display'
|
37
31
|
|
38
|
-
|
39
|
-
autoload :GoogleEmoticon, 'jpmobile/mobile/google_emoticon'
|
40
|
-
|
41
|
-
DEFAULT_CARRIERS = %w(Docomo Au Softbank Vodafone Emobile Willcom Ddipocket Ipad AndroidTablet Iphone Android WindowsPhone BlackBerry)
|
32
|
+
DEFAULT_CARRIERS = %w(Docomo Au Softbank Vodafone Emobile Willcom Ddipocket Iphone Android WindowsPhone)
|
42
33
|
|
43
34
|
def self.carriers
|
44
35
|
@carriers ||= DEFAULT_CARRIERS.dup
|
@@ -61,11 +52,6 @@ module Jpmobile
|
|
61
52
|
|
62
53
|
autoload :Mailer, 'jpmobile/mailer'
|
63
54
|
autoload :Resolver, 'jpmobile/resolver'
|
64
|
-
|
65
|
-
module_function
|
66
|
-
def config
|
67
|
-
::Jpmobile::Configuration.instance
|
68
|
-
end
|
69
55
|
end
|
70
56
|
|
71
57
|
if defined?(Rails)
|
data/lib/jpmobile/emoticon.rb
CHANGED
@@ -26,19 +26,9 @@ module Jpmobile
|
|
26
26
|
SJIS_REGEXP SOFTBANK_WEBCODE_REGEXP DOCOMO_SJIS_REGEXP AU_SJIS_REGEXP SOFTBANK_UNICODE_REGEXP
|
27
27
|
EMOTICON_UNICODES UTF8_REGEXP
|
28
28
|
CONVERSION_TABLE_TO_PC_EMAIL SOFTBANK_SJIS_REGEXP AU_EMAILJIS_REGEXP
|
29
|
-
UNICODE_EMOTICONS UNICODE_EMOTICON_REGEXP UNICODE_EMOTICON_TO_CARRIER_EMOTICON
|
30
|
-
GOOGLE_EMOTICONS GOOGLE_EMOTICON_REGEXP GOOGLE_EMOTICON_TO_CARRIER_EMOTICON
|
31
|
-
CONVERSION_TABLE_TO_UNICODE_EMOTICON CONVERSION_TABLE_TO_GOOGLE_EMOTICON
|
32
|
-
GETA_CODE GETA
|
33
29
|
).each do |const|
|
34
30
|
autoload const, 'jpmobile/emoticon/z_combine'
|
35
31
|
end
|
36
|
-
%w( GOOGLE_TO_DOCOMO_UNICODE GOOGLE_TO_AU_UNICODE GOOGLE_TO_SOFTBANK_UNICODE ).each do |const|
|
37
|
-
autoload const, 'jpmobile/emoticon/google'
|
38
|
-
end
|
39
|
-
%w( UNICODE_TO_DOCOMO_UNICODE UNICODE_TO_AU_UNICODE UNICODE_TO_SOFTBANK_UNICODE ).each do |const|
|
40
|
-
autoload const, 'jpmobile/emoticon/unicode'
|
41
|
-
end
|
42
32
|
|
43
33
|
# +str+ のなかでDoCoMo絵文字をUnicode数値文字参照に置換した文字列を返す。
|
44
34
|
def self.external_to_unicodecr_docomo(str)
|
@@ -90,52 +80,6 @@ module Jpmobile
|
|
90
80
|
external_to_unicodecr_softbank(str)
|
91
81
|
end
|
92
82
|
|
93
|
-
# Unicode 6.0絵文字の変換
|
94
|
-
def self.external_to_unicodecr_unicode60(str)
|
95
|
-
str.gsub(UNICODE_EMOTICON_REGEXP) do |match|
|
96
|
-
unicodes = match.unpack('U*')
|
97
|
-
unicodes = unicodes.first if unicodes.size == 1
|
98
|
-
|
99
|
-
if (emoticon = UNICODE_EMOTICON_TO_CARRIER_EMOTICON[unicodes]) == GETA_CODE
|
100
|
-
GETA
|
101
|
-
elsif emoticon
|
102
|
-
case emoticon
|
103
|
-
when GETA_CODE
|
104
|
-
GETA
|
105
|
-
when Integer
|
106
|
-
"&#x%04x;" % emoticon
|
107
|
-
when String
|
108
|
-
emoticon
|
109
|
-
end
|
110
|
-
else
|
111
|
-
# 変換できなければ〓に
|
112
|
-
GETA
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# Google絵文字の変換
|
118
|
-
def self.external_to_unicodecr_google(str)
|
119
|
-
str.gsub(GOOGLE_EMOTICON_REGEXP) do |match|
|
120
|
-
unicodes = match.unpack('U*')
|
121
|
-
unicodes = unicodes.first if unicodes.size == 1
|
122
|
-
|
123
|
-
if emoticon = GOOGLE_EMOTICON_TO_CARRIER_EMOTICON[unicodes]
|
124
|
-
case emoticon
|
125
|
-
when GETA_CODE
|
126
|
-
GETA
|
127
|
-
when Integer
|
128
|
-
"&#x%04x;" % emoticon
|
129
|
-
when String
|
130
|
-
emoticon
|
131
|
-
end
|
132
|
-
else
|
133
|
-
# 変換できなければ〓に
|
134
|
-
GETA
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
83
|
# +str+ のなかでUnicode数値文字参照で表記された絵文字を携帯側エンコーディングに置換する。
|
140
84
|
#
|
141
85
|
# キャリア間の変換に +conversion_table+ を使う。+conversion_table+ に+nil+を与えると、
|
@@ -146,7 +90,6 @@ module Jpmobile
|
|
146
90
|
def self.unicodecr_to_external(str, conversion_table=nil, to_sjis=true)
|
147
91
|
str.gsub(/&#x([0-9a-f]{4});/i) do |match|
|
148
92
|
unicode = $1.scanf("%x").first
|
149
|
-
|
150
93
|
if conversion_table
|
151
94
|
converted = conversion_table[unicode] # キャリア間変換
|
152
95
|
else
|
@@ -165,15 +108,9 @@ module Jpmobile
|
|
165
108
|
end
|
166
109
|
elsif webcode = SOFTBANK_UNICODE_TO_WEBCODE[converted-0x1000]
|
167
110
|
[converted-0x1000].pack('U')
|
168
|
-
elsif converted ==
|
111
|
+
elsif converted == GETA
|
169
112
|
# PCで〓を表示する場合
|
170
|
-
GETA
|
171
|
-
elsif UNICODE_EMOTICONS.include?(converted) or GOOGLE_EMOTICONS.include?(converted)
|
172
|
-
if unicode == GETA_CODE
|
173
|
-
GETA
|
174
|
-
else
|
175
|
-
[converted].pack('U*')
|
176
|
-
end
|
113
|
+
[GETA].pack("U")
|
177
114
|
else
|
178
115
|
# キャリア変換テーブルに指定されていたUnicodeに対応する
|
179
116
|
# 携帯側エンコーディングが見つからない(変換テーブルの不備の可能性あり)。
|
@@ -4,8 +4,7 @@ end
|
|
4
4
|
|
5
5
|
module Jpmobile
|
6
6
|
module Emoticon
|
7
|
-
|
8
|
-
GETA = [GETA_CODE].pack('U')
|
7
|
+
GETA = 0x3013
|
9
8
|
|
10
9
|
SJIS_TO_UNICODE = {}
|
11
10
|
SJIS_TO_UNICODE.update(DOCOMO_SJIS_TO_UNICODE)
|
@@ -33,20 +32,5 @@ module Jpmobile
|
|
33
32
|
|
34
33
|
SOFTBANK_SJIS_REGEXP = Regexp.union(*SOFTBANK_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)}).freeze
|
35
34
|
AU_EMAILJIS_REGEXP = Regexp.union(*AU_EMAILJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.jis_regexp(s)})
|
36
|
-
|
37
|
-
# for unicode/google emoticons
|
38
|
-
UNICODE_EMOTICONS = (UNICODE_TO_DOCOMO_UNICODE.keys|UNICODE_TO_AU_UNICODE.keys|UNICODE_TO_SOFTBANK_UNICODE.keys).uniq
|
39
|
-
GOOGLE_EMOTICONS = (GOOGLE_TO_DOCOMO_UNICODE.keys|GOOGLE_TO_AU_UNICODE.keys|GOOGLE_TO_SOFTBANK_UNICODE.keys).uniq
|
40
|
-
|
41
|
-
UNICODE_EMOTICON_REGEXP = Regexp.union(*UNICODE_EMOTICONS.map{|x| x.kind_of?(Array) ? x.pack('UU') : [x].pack('U')}).freeze
|
42
|
-
GOOGLE_EMOTICON_REGEXP = Regexp.union(*GOOGLE_EMOTICONS.map{|x| x.kind_of?(Array) ? x.pack('UU') : [x].pack('U')}).freeze
|
43
|
-
|
44
|
-
UNICODE_EMOTICON_TO_CARRIER_EMOTICON = UNICODE_TO_DOCOMO_UNICODE.merge(UNICODE_TO_AU_UNICODE.merge(UNICODE_TO_SOFTBANK_UNICODE))
|
45
|
-
GOOGLE_EMOTICON_TO_CARRIER_EMOTICON = GOOGLE_TO_SOFTBANK_UNICODE.merge(GOOGLE_TO_AU_UNICODE.merge(GOOGLE_TO_DOCOMO_UNICODE))
|
46
|
-
|
47
|
-
CONVERSION_TABLE_TO_UNICODE_EMOTICON = Jpmobile::Util.invert_table(UNICODE_TO_DOCOMO_UNICODE).merge(
|
48
|
-
Jpmobile::Util.invert_table(UNICODE_TO_AU_UNICODE).merge(Jpmobile::Util.invert_table(UNICODE_TO_SOFTBANK_UNICODE)))
|
49
|
-
CONVERSION_TABLE_TO_GOOGLE_EMOTICON = Jpmobile::Util.invert_table(GOOGLE_TO_SOFTBANK_UNICODE).merge(
|
50
|
-
Jpmobile::Util.invert_table(GOOGLE_TO_AU_UNICODE).merge(Jpmobile::Util.invert_table(GOOGLE_TO_DOCOMO_UNICODE)))
|
51
35
|
end
|
52
36
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
ActionView::LookupContext.register_detail(:mobile) {
|
2
|
+
ActionView::LookupContext.register_detail(:mobile) {[]}
|
data/lib/jpmobile/mail.rb
CHANGED
@@ -18,7 +18,7 @@ module Mail
|
|
18
18
|
|
19
19
|
# change encoding
|
20
20
|
def self.b_value_encode(str, encoding)
|
21
|
-
str = Jpmobile::Util.encode(str, encoding
|
21
|
+
str = Jpmobile::Util.encode(str, encoding)
|
22
22
|
[Ruby19.encode_base64(str), encoding]
|
23
23
|
end
|
24
24
|
end
|
@@ -48,10 +48,9 @@ module Mail
|
|
48
48
|
if @mobile = m
|
49
49
|
@charset = m.mail_charset(@charset)
|
50
50
|
|
51
|
-
if
|
52
|
-
|
53
|
-
|
54
|
-
self.body.mobile = m
|
51
|
+
if @body
|
52
|
+
@body.charset = @charset
|
53
|
+
@body.mobile = m
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
@@ -61,7 +60,7 @@ module Mail
|
|
61
60
|
header['subject'].mobile = @mobile if header['subject']
|
62
61
|
header['from'].mobile = @mobile if header['from']
|
63
62
|
header['to'].mobile = @mobile if header['to']
|
64
|
-
self.charset = @mobile.mail_charset
|
63
|
+
self.charset = @mobile.mail_charset(@charset)
|
65
64
|
|
66
65
|
ready_to_send!
|
67
66
|
|
@@ -83,8 +82,7 @@ module Mail
|
|
83
82
|
buffer << "\r\n"
|
84
83
|
buffer = @mobile.utf8_to_mail_encode(buffer)
|
85
84
|
buffer << body.encoded(content_transfer_encoding)
|
86
|
-
|
87
|
-
ascii_compatible!(buffer)
|
85
|
+
buffer
|
88
86
|
else
|
89
87
|
encoded_without_jpmobile
|
90
88
|
end
|
@@ -117,18 +115,17 @@ module Mail
|
|
117
115
|
if @mobile
|
118
116
|
@body.charset = @charset
|
119
117
|
@body.mobile = @mobile
|
120
|
-
@body.content_type_with_jpmobile = self.content_type
|
121
118
|
|
122
119
|
if has_content_transfer_encoding? and
|
123
|
-
["base64", "quoted-printable"].include?(
|
120
|
+
["base64", "quoted-printable"].include?(content_transfer_encoding) and
|
124
121
|
["text"].include?(@mobile_main_type)
|
125
122
|
@body.decode_transfer_encoding
|
126
123
|
end
|
127
124
|
|
128
125
|
if @body.multipart?
|
129
126
|
@body.parts.each do |p|
|
130
|
-
p.charset = @
|
131
|
-
p.mobile
|
127
|
+
p.charset = @charset
|
128
|
+
p.mobile = @mobile
|
132
129
|
end
|
133
130
|
end
|
134
131
|
end
|
@@ -263,9 +260,8 @@ module Mail
|
|
263
260
|
self.header[:subject].charset = subject_charset unless subject_charset.blank?
|
264
261
|
|
265
262
|
if @mobile
|
266
|
-
|
267
|
-
|
268
|
-
v = @mobile.to_mail_internal(subject_value, subject_converting_encoding)
|
263
|
+
v = @mobile.to_mail_internal(
|
264
|
+
Encodings.value_decode(self.header[:subject].value), subject_charset)
|
269
265
|
if @charset == subject_charset and @mobile.mail_charset != @charset
|
270
266
|
self.header[:subject].value = Jpmobile::Util.force_encode(v, @charset, Jpmobile::Util::UTF8)
|
271
267
|
else
|
@@ -274,23 +270,10 @@ module Mail
|
|
274
270
|
end
|
275
271
|
end
|
276
272
|
|
277
|
-
if @body_part_jpmobile and @mobile
|
278
|
-
if ["base64", "quoted-printable"].include?(self.content_transfer_encoding) and
|
279
|
-
self.content_type.match(/text/)
|
280
|
-
@body_part_jpmobile = Jpmobile::Util.decode(@body_part_jpmobile, self.content_transfer_encoding, @charset)
|
281
|
-
self.content_transfer_encoding = @mobile.class::MAIL_CONTENT_TRANSFER_ENCODING
|
282
|
-
end
|
283
|
-
unless Jpmobile::Util.check_charset(@body_part_jpmobile, @charset)
|
284
|
-
@body_part_jpmobile = Jpmobile::Util.correct_encoding(@body_part_jpmobile)
|
285
|
-
@charset = @body_part_jpmobile.encoding.to_s
|
286
|
-
end
|
273
|
+
if @body_part_jpmobile and @mobile
|
287
274
|
@body_part_jpmobile = @mobile.decode_transfer_encoding(@body_part_jpmobile, @charset)
|
288
275
|
end
|
289
276
|
end
|
290
|
-
|
291
|
-
def ascii_compatible!(str)
|
292
|
-
Jpmobile::Util.ascii_compatible!(str)
|
293
|
-
end
|
294
277
|
end
|
295
278
|
|
296
279
|
class Part
|
@@ -318,15 +301,10 @@ module Mail
|
|
318
301
|
|
319
302
|
alias_method :parse_message_without_jpmobile, :parse_message
|
320
303
|
alias_method :parse_message, :parse_message_with_jpmobile
|
321
|
-
|
322
|
-
private
|
323
|
-
def ascii_compatible!(str)
|
324
|
-
str
|
325
|
-
end
|
326
304
|
end
|
327
305
|
|
328
306
|
class Body
|
329
|
-
attr_accessor :mobile
|
307
|
+
attr_accessor :mobile
|
330
308
|
|
331
309
|
# convert encoding
|
332
310
|
def encoded_with_jpmobile(transfer_encoding = '8bit')
|
@@ -334,16 +312,10 @@ module Mail
|
|
334
312
|
if @mobile.to_mail_body_encoded?(@raw_source)
|
335
313
|
@raw_source
|
336
314
|
elsif Jpmobile::Util.ascii_8bit?(@raw_source)
|
337
|
-
|
338
|
-
|
339
|
-
else
|
340
|
-
enc = Mail::Encodings::get_encoding(get_best_encoding(transfer_encoding))
|
341
|
-
enc.encode(@raw_source)
|
342
|
-
end
|
343
|
-
Jpmobile::Util.force_encode(_raw_source, nil, @charset)
|
315
|
+
enc = Mail::Encodings::get_encoding(get_best_encoding(transfer_encoding))
|
316
|
+
Jpmobile::Util.force_encode(enc.encode(@raw_source), nil, @charset)
|
344
317
|
else
|
345
|
-
|
346
|
-
when /quoted-printable/
|
318
|
+
if transfer_encoding == 'quoted-printable'
|
347
319
|
# [str].pack("M").gsub(/\n/, "\r\n")
|
348
320
|
Jpmobile::Util.force_encode([@mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, @charset, Jpmobile::Util::UTF8))].pack("M").gsub(/\n/, "\r\n"), Jpmobile::Util::BINARY, @charset)
|
349
321
|
# @mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, @charset, Jpmobile::Util::UTF8))
|
@@ -368,25 +340,23 @@ module Mail
|
|
368
340
|
def mobile=(m)
|
369
341
|
@mobile = m
|
370
342
|
|
371
|
-
if ["base64", "quoted-printable"].include?(self.encoding) and
|
372
|
-
/text/.match(self.content_type_with_jpmobile)
|
373
|
-
self.decode_transfer_encoding
|
374
|
-
end
|
375
|
-
|
376
343
|
if self.multipart? and @mobile
|
377
344
|
self.parts.each do |part|
|
378
|
-
part.charset = @
|
345
|
+
part.charset = @charset
|
379
346
|
part.mobile = @mobile
|
380
|
-
part.body.charset =
|
347
|
+
part.body.charset = @charset
|
381
348
|
part.body.mobile = @mobile
|
382
349
|
end
|
383
350
|
end
|
384
351
|
end
|
385
352
|
|
386
353
|
def decode_transfer_encoding
|
387
|
-
_raw_source =
|
354
|
+
_raw_source = Encodings.get_encoding(encoding).decode(@raw_source)
|
355
|
+
unless Jpmobile::Util.extract_charset(_raw_source) == @charset
|
356
|
+
@charset = Jpmobile::Util.extract_charset(_raw_source)
|
357
|
+
end
|
358
|
+
_raw_source = Jpmobile::Util.set_encoding(_raw_source, @charset)
|
388
359
|
@raw_source = @mobile.decode_transfer_encoding(_raw_source, @charset)
|
389
|
-
self.encoding = 'text'
|
390
360
|
end
|
391
361
|
|
392
362
|
def preamble_with_jpmobile
|
@@ -487,15 +457,15 @@ module Mail
|
|
487
457
|
|
488
458
|
def mobile=(m)
|
489
459
|
if @mobile = m
|
490
|
-
self.charset = @mobile.mail_charset
|
491
|
-
self.value
|
460
|
+
self.charset = @mobile.mail_charset(@charset)
|
461
|
+
self.value = @jpmobile_raw_text
|
492
462
|
self.parse
|
493
463
|
end
|
494
464
|
end
|
495
465
|
|
496
466
|
def encoded_with_jpmobile
|
497
467
|
if @mobile
|
498
|
-
self.charset = @mobile.mail_charset
|
468
|
+
self.charset = @mobile.mail_charset(@charset)
|
499
469
|
end
|
500
470
|
|
501
471
|
encoded_without_jpmobile
|
@@ -516,15 +486,15 @@ module Mail
|
|
516
486
|
|
517
487
|
def mobile=(m)
|
518
488
|
if @mobile = m
|
519
|
-
self.charset = @mobile.mail_charset
|
520
|
-
self.value
|
489
|
+
self.charset = @mobile.mail_charset(@charset)
|
490
|
+
self.value = @jpmobile_raw_text
|
521
491
|
self.parse
|
522
492
|
end
|
523
493
|
end
|
524
494
|
|
525
495
|
def encoded_with_jpmobile
|
526
496
|
if @mobile
|
527
|
-
self.charset = @mobile.mail_charset
|
497
|
+
self.charset = @mobile.mail_charset(@charset)
|
528
498
|
end
|
529
499
|
|
530
500
|
encoded_without_jpmobile
|