jpmobile 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -3
- data/.rubocop.yml +123 -0
- data/CONTRIBUTING.md +16 -14
- data/Gemfile +6 -0
- data/Gemfile.lock +198 -0
- data/README.md +409 -0
- data/Rakefile +9 -9
- data/circle.yml +14 -0
- data/jpmobile.gemspec +9 -10
- data/lib/jpmobile.rb +6 -5
- data/lib/jpmobile/datum_conv.rb +35 -35
- data/lib/jpmobile/docomo_guid.rb +7 -8
- data/lib/jpmobile/email.rb +12 -12
- data/lib/jpmobile/emoticon.rb +85 -76
- data/lib/jpmobile/emoticon/au.rb +1284 -1284
- data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
- data/lib/jpmobile/emoticon/docomo.rb +252 -252
- data/lib/jpmobile/emoticon/google.rb +9 -9
- data/lib/jpmobile/emoticon/softbank.rb +471 -471
- data/lib/jpmobile/emoticon/unicode.rb +9 -9
- data/lib/jpmobile/emoticon/z_combine.rb +20 -23
- data/lib/jpmobile/encoding.rb +1 -1
- data/lib/jpmobile/fallback_view_selector.rb +2 -3
- data/lib/jpmobile/filter.rb +44 -47
- data/lib/jpmobile/helpers.rb +38 -38
- data/lib/jpmobile/hook_action_view.rb +7 -7
- data/lib/jpmobile/hook_test_request.rb +0 -1
- data/lib/jpmobile/lookup_context.rb +1 -2
- data/lib/jpmobile/mail.rb +156 -134
- data/lib/jpmobile/mailer.rb +4 -4
- data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
- data/lib/jpmobile/mobile/android.rb +0 -1
- data/lib/jpmobile/mobile/android_tablet.rb +0 -1
- data/lib/jpmobile/mobile/au.rb +40 -28
- data/lib/jpmobile/mobile/black_berry.rb +0 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -2
- data/lib/jpmobile/mobile/docomo.rb +47 -36
- data/lib/jpmobile/mobile/emobile.rb +1 -2
- data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
- data/lib/jpmobile/mobile/ipad.rb +0 -1
- data/lib/jpmobile/mobile/iphone.rb +0 -1
- data/lib/jpmobile/mobile/smart_phone.rb +0 -1
- data/lib/jpmobile/mobile/softbank.rb +24 -20
- data/lib/jpmobile/mobile/tablet.rb +0 -1
- data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
- data/lib/jpmobile/mobile/vodafone.rb +0 -1
- data/lib/jpmobile/mobile/willcom.rb +7 -7
- data/lib/jpmobile/mobile/windows_phone.rb +0 -1
- data/lib/jpmobile/path_set.rb +1 -1
- data/lib/jpmobile/position.rb +30 -14
- data/lib/jpmobile/rack/filter.rb +4 -4
- data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
- data/lib/jpmobile/rack/params_filter.rb +7 -6
- data/lib/jpmobile/rails.rb +3 -4
- data/lib/jpmobile/request_with_mobile.rb +9 -6
- data/lib/jpmobile/resolver.rb +23 -17
- data/lib/jpmobile/session/active_record_store.rb +7 -9
- data/lib/jpmobile/session/mem_cache_store.rb +7 -9
- data/lib/jpmobile/sinatra.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +15 -20
- data/lib/jpmobile/util.rb +61 -77
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +35 -28
- data/spec/rack/jpmobile/android_spec.rb +5 -5
- data/spec/rack/jpmobile/au_spec.rb +74 -59
- data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
- data/spec/rack/jpmobile/docomo_spec.rb +77 -64
- data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
- data/spec/rack/jpmobile/filter_spec.rb +149 -128
- data/spec/rack/jpmobile/iphone_spec.rb +9 -8
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
- data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
- data/spec/rack/jpmobile/softbank_spec.rb +49 -42
- data/spec/rack/jpmobile/willcom_spec.rb +22 -18
- data/spec/rack/jpmobile/windows_phone.rb +5 -5
- data/spec/rack_helper.rb +9 -8
- data/spec/spec_helper.rb +5 -6
- data/spec/unit/decorated_mail_spec.rb +8 -9
- data/spec/unit/email_spec.rb +44 -44
- data/spec/unit/emoticon_spec.rb +57 -58
- data/spec/unit/encoding_spec.rb +35 -36
- data/spec/unit/is_carrier_spec.rb +49 -49
- data/spec/unit/mail_spec.rb +153 -143
- data/spec/unit/mobile/iphone_spec.rb +6 -7
- data/spec/unit/receive_mail_spec.rb +172 -173
- data/spec/unit/spec_helper.rb +6 -6
- data/spec/unit/util_spec.rb +125 -46
- data/spec/unit/valid_ip_spec.rb +35 -35
- data/spec/unit/variants_spec.rb +18 -19
- data/test/rails/overrides/Gemfile +54 -0
- data/test/rails/overrides/Gemfile.jpmobile +1 -2
- data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
- data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
- data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
- data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
- data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
- data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
- data/test/rails/overrides/autotest/discover.rb +2 -2
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
- data/test/rails/overrides/config/routes.rb +95 -2
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
- data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
- data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
- data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
- data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
- data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
- data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
- data/test/rails/overrides/spec/rails_helper.rb +1 -1
- data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
- data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
- data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
- data/test/sinatra/test/filter_test.rb +10 -11
- data/tools/e4u_conv.rb +0 -1
- metadata +18 -14
- data/README +0 -0
- data/README.rdoc +0 -308
data/lib/jpmobile/mailer.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require 'jpmobile/mail'
|
3
2
|
require 'jpmobile/lookup_context'
|
4
3
|
|
@@ -8,9 +7,9 @@ module Jpmobile
|
|
8
7
|
module Mailer
|
9
8
|
class Base < ActionMailer::Base
|
10
9
|
self._view_paths = self._view_paths.dup
|
11
|
-
self.view_paths.unshift(Jpmobile::Resolver.new(File.join(::Rails.root,
|
10
|
+
self.view_paths.unshift(Jpmobile::Resolver.new(File.join(::Rails.root, 'app/views')))
|
12
11
|
|
13
|
-
def mail(headers={}, &block)
|
12
|
+
def mail(headers = {}, &block)
|
14
13
|
tos = headers[:to] || self.default_params[:to]
|
15
14
|
tos = tos.split(/,/)
|
16
15
|
|
@@ -27,7 +26,7 @@ module Jpmobile
|
|
27
26
|
|
28
27
|
m = super(headers, &block)
|
29
28
|
|
30
|
-
m.mobile
|
29
|
+
m.mobile = @mobile
|
31
30
|
|
32
31
|
# for decorated-mail manipulation
|
33
32
|
m.rearrange! if @mobile.decorated?
|
@@ -37,6 +36,7 @@ module Jpmobile
|
|
37
36
|
|
38
37
|
class << self
|
39
38
|
protected
|
39
|
+
|
40
40
|
def set_payload_for_mail(payload, mail) #:nodoc:
|
41
41
|
super
|
42
42
|
|
@@ -1,11 +1,10 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
require 'ipaddr'
|
3
2
|
|
4
3
|
module Jpmobile::Mobile
|
5
4
|
# 携帯電話の抽象クラス。
|
6
5
|
class AbstractMobile
|
7
6
|
# メールのデフォルトのcharset
|
8
|
-
MAIL_CHARSET =
|
7
|
+
MAIL_CHARSET = 'ISO-2022-JP'.freeze
|
9
8
|
|
10
9
|
def initialize(env, request)
|
11
10
|
@env = env
|
@@ -20,17 +19,27 @@ module Jpmobile::Mobile
|
|
20
19
|
# 対応するメールアドレスの正規表現
|
21
20
|
MAIL_ADDRESS_REGEXP = nil
|
22
21
|
# テキスト部分の content-transfer-encoding
|
23
|
-
MAIL_CONTENT_TRANSFER_ENCODING = '7bit'
|
22
|
+
MAIL_CONTENT_TRANSFER_ENCODING = '7bit'.freeze
|
24
23
|
|
25
24
|
# 緯度経度があれば Position のインスタンスを返す。
|
26
|
-
def position
|
25
|
+
def position
|
26
|
+
nil
|
27
|
+
end
|
27
28
|
|
28
29
|
# 契約者又は端末を識別する文字列があれば返す。
|
29
|
-
def ident
|
30
|
+
def ident
|
31
|
+
ident_subscriber || ident_device
|
32
|
+
end
|
33
|
+
|
30
34
|
# 契約者を識別する文字列があれば返す。
|
31
|
-
def ident_subscriber
|
35
|
+
def ident_subscriber
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
32
39
|
# 端末を識別する文字列があれば返す。
|
33
|
-
def ident_device
|
40
|
+
def ident_device
|
41
|
+
nil
|
42
|
+
end
|
34
43
|
|
35
44
|
def valid_ip?
|
36
45
|
@__valid_ip ||= self.class.valid_ip? @request.ip
|
@@ -40,12 +49,12 @@ module Jpmobile::Mobile
|
|
40
49
|
def display
|
41
50
|
@__displlay ||= Jpmobile::Mobile::Terminfo.new(self, @env)
|
42
51
|
rescue LoadError
|
43
|
-
puts
|
52
|
+
puts 'display method require jpmobile-terminfo plugin.'
|
44
53
|
end
|
45
54
|
|
46
55
|
# クッキーをサポートしているか。
|
47
56
|
def supports_cookie?
|
48
|
-
|
57
|
+
false
|
49
58
|
end
|
50
59
|
|
51
60
|
# smartphone かどうか
|
@@ -72,78 +81,86 @@ module Jpmobile::Mobile
|
|
72
81
|
def to_internal(str)
|
73
82
|
str
|
74
83
|
end
|
84
|
+
|
75
85
|
def to_external(str, content_type, charset)
|
76
86
|
[str, charset]
|
77
87
|
end
|
88
|
+
|
78
89
|
def default_charset
|
79
|
-
|
90
|
+
'UTF-8'
|
80
91
|
end
|
81
92
|
|
82
93
|
# for view selector
|
83
94
|
def variants
|
84
95
|
return @_variants if @_variants
|
85
96
|
|
86
|
-
@_variants = self.class.ancestors.select {|c| c.to_s =~ /^Jpmobile/ && c.to_s !~ /Emoticon/}.map do |klass|
|
97
|
+
@_variants = self.class.ancestors.select { |c| c.to_s =~ /^Jpmobile/ && c.to_s !~ /Emoticon/ }.map do |klass|
|
87
98
|
klass = klass.to_s.
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
klass =~ /abstract/ ?
|
99
|
+
gsub(/Jpmobile::/, '').
|
100
|
+
gsub(/AbstractMobile::/, '').
|
101
|
+
gsub(/Mobile::SmartPhone/, 'smart_phone').
|
102
|
+
gsub(/Mobile::Tablet/, 'tablet').
|
103
|
+
gsub(/::/, '_').
|
104
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
105
|
+
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
106
|
+
downcase
|
107
|
+
(klass =~ /abstract/) ? 'mobile' : klass
|
97
108
|
end
|
98
109
|
|
99
110
|
if @_variants.include?('tablet')
|
100
|
-
@_variants = @_variants.reject{|v| v ==
|
101
|
-
elsif @_variants.include?(
|
102
|
-
@_variants = @_variants.reject{|v| v ==
|
111
|
+
@_variants = @_variants.reject { |v| v == 'mobile' }.map { |v| v.gsub(/mobile_/, 'tablet_') }
|
112
|
+
elsif @_variants.include?('smart_phone')
|
113
|
+
@_variants = @_variants.reject { |v| v == 'mobile' }.map { |v| v.gsub(/mobile_/, 'smart_phone_') }
|
103
114
|
end
|
104
115
|
|
105
116
|
@_variants || []
|
106
117
|
end
|
118
|
+
|
107
119
|
def mail_variants
|
108
120
|
return @_mail_variants if @_mail_variants
|
109
121
|
|
110
|
-
@_mail_variants = variants == ['mobile'] ? [] : variants
|
122
|
+
@_mail_variants = (variants == ['mobile']) ? [] : variants
|
111
123
|
end
|
112
124
|
|
113
125
|
# メール送信用
|
114
126
|
def to_mail_subject(str)
|
115
127
|
Jpmobile::Util.fold_text(Jpmobile::Emoticon.unicodecr_to_utf8(str)).
|
116
|
-
map{|text| "=?#{mail_charset}?B?" + [to_mail_encoding(text)].pack('m').
|
128
|
+
map { |text| "=?#{mail_charset}?B?" + [to_mail_encoding(text)].pack('m').delete("\n") + '?=' }.
|
117
129
|
join("\n\s")
|
118
130
|
end
|
131
|
+
|
119
132
|
def to_mail_body(str)
|
120
133
|
to_mail_encoding(str)
|
121
134
|
end
|
135
|
+
|
122
136
|
def mail_charset(charset = nil)
|
123
137
|
# (charset.nil? or charset == "") ? self.class::MAIL_CHARSET : charset
|
124
138
|
# self.class::MAIL_CHARSET
|
125
|
-
charset.nil? || charset == '' || charset =~ /US-ASCII/i ? self.class::MAIL_CHARSET : charset
|
139
|
+
(charset.nil? || charset == '' || charset =~ /US-ASCII/i) ? self.class::MAIL_CHARSET : charset
|
126
140
|
end
|
141
|
+
|
127
142
|
def content_transfer_encoding(headers)
|
128
143
|
transfer_encoding = headers['Content-Transfer-Encoding']
|
129
144
|
case headers['Content-Type'].to_s
|
130
|
-
when /
|
131
|
-
transfer_encoding.to_s == MAIL_CONTENT_TRANSFER_ENCODING ? transfer_encoding : MAIL_CONTENT_TRANSFER_ENCODING
|
132
|
-
when /
|
145
|
+
when %r{text/plain}
|
146
|
+
(transfer_encoding.to_s == MAIL_CONTENT_TRANSFER_ENCODING) ? transfer_encoding : MAIL_CONTENT_TRANSFER_ENCODING
|
147
|
+
when %r{text/html}
|
133
148
|
if self.decorated?
|
134
149
|
'quoted-printable'
|
135
150
|
else
|
136
|
-
transfer_encoding.to_s == MAIL_CONTENT_TRANSFER_ENCODING ? transfer_encoding : MAIL_CONTENT_TRANSFER_ENCODING
|
151
|
+
(transfer_encoding.to_s == MAIL_CONTENT_TRANSFER_ENCODING) ? transfer_encoding : MAIL_CONTENT_TRANSFER_ENCODING
|
137
152
|
end
|
138
153
|
else
|
139
154
|
transfer_encoding
|
140
155
|
end
|
141
156
|
end
|
157
|
+
|
142
158
|
def to_mail_encoding(str)
|
143
159
|
str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
|
144
160
|
str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_PC_EMAIL, false)
|
145
161
|
Jpmobile::Util.encode(str, mail_charset)
|
146
162
|
end
|
163
|
+
|
147
164
|
def utf8_to_mail_encode(str)
|
148
165
|
case mail_charset
|
149
166
|
when /ISO-2022-JP/i
|
@@ -154,29 +171,35 @@ module Jpmobile::Mobile
|
|
154
171
|
str
|
155
172
|
end
|
156
173
|
end
|
174
|
+
|
157
175
|
def to_mail_internal(str, charset)
|
158
176
|
str
|
159
177
|
end
|
178
|
+
|
160
179
|
def to_mail_subject_encoded?(str)
|
161
180
|
str.match(/\=\?#{mail_charset}\?B.+\?\=/i)
|
162
181
|
end
|
182
|
+
|
163
183
|
def to_mail_body_encoded?(str)
|
164
184
|
Jpmobile::Util.jis?(str)
|
165
185
|
end
|
186
|
+
|
166
187
|
def decode_transfer_encoding(body, charset)
|
167
188
|
body = Jpmobile::Util.set_encoding(body, charset)
|
168
189
|
body = to_mail_internal(body, nil)
|
169
190
|
Jpmobile::Util.force_encode(body, charset, Jpmobile::Util::UTF8)
|
170
191
|
end
|
192
|
+
|
171
193
|
def decoratable?
|
172
194
|
false
|
173
195
|
end
|
196
|
+
|
174
197
|
def require_related_part?
|
175
198
|
false
|
176
199
|
end
|
177
|
-
|
178
|
-
|
179
|
-
|
200
|
+
|
201
|
+
attr_writer :decorated
|
202
|
+
|
180
203
|
def decorated?
|
181
204
|
@decorated
|
182
205
|
end
|
@@ -185,7 +208,7 @@ module Jpmobile::Mobile
|
|
185
208
|
# 当該キャリアのIPアドレス帯域からのアクセスであれば +true+ を返す。
|
186
209
|
# そうでなければ +false+ を返す。
|
187
210
|
# IP空間が定義されていない場合は +nil+ を返す。
|
188
|
-
def valid_ip?
|
211
|
+
def valid_ip?(remote_addr)
|
189
212
|
@ip_list ||= ip_address_class
|
190
213
|
return false unless @ip_list
|
191
214
|
|
@@ -220,11 +243,13 @@ module Jpmobile::Mobile
|
|
220
243
|
|
221
244
|
#
|
222
245
|
def ip_address_class
|
223
|
-
|
246
|
+
Object.const_get("::Jpmobile::Mobile::IpAddresses::#{self.to_s.split(/::/).last}").new
|
247
|
+
rescue
|
248
|
+
nil
|
224
249
|
end
|
225
250
|
end
|
226
251
|
|
227
|
-
#XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義しているから動くのです
|
252
|
+
# XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義しているから動くのです
|
228
253
|
Jpmobile::Mobile.carriers.each do |carrier|
|
229
254
|
carrier_class = Jpmobile::Mobile.const_get(carrier)
|
230
255
|
next if carrier_class == self
|
@@ -235,6 +260,7 @@ module Jpmobile::Mobile
|
|
235
260
|
end
|
236
261
|
|
237
262
|
private
|
263
|
+
|
238
264
|
# リクエストのパラメータ。
|
239
265
|
def params
|
240
266
|
if @request.respond_to? :parameters
|
data/lib/jpmobile/mobile/au.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# =au携帯電話
|
3
2
|
|
4
3
|
module Jpmobile::Mobile
|
@@ -7,52 +6,52 @@ module Jpmobile::Mobile
|
|
7
6
|
class Au < AbstractMobile
|
8
7
|
# 対応するUser-Agentの正規表現
|
9
8
|
# User-Agent文字列中に "UP.Browser" を含むVodafoneの端末があるので注意が必要
|
10
|
-
USER_AGENT_REGEXP =
|
9
|
+
USER_AGENT_REGEXP = %r{^(?:KDDI|UP.Browser/.+?)-(.+?) }
|
11
10
|
# 対応するメールアドレスの正規表現
|
12
11
|
MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp/
|
13
12
|
# 簡易位置情報取得に対応していないデバイスID
|
14
13
|
# http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
|
15
|
-
LOCATION_UNSUPPORTED_DEVICE_ID = [
|
14
|
+
LOCATION_UNSUPPORTED_DEVICE_ID = %w[PT21 TS25 KCTE TST9 KCU1 SYT5 KCTD TST8 TST7 KCTC SYT4 KCTB KCTA TST6 KCT9 TST5 TST4 KCT8 SYT3 KCT7 MIT1 MAT3 KCT6 TST3 KCT5 KCT4 SYT2 MAT1 MAT2 TST2 KCT3 KCT2 KCT1 TST1 SYT1].freeze
|
16
15
|
# GPS取得に対応していないデバイスID
|
17
|
-
GPS_UNSUPPORTED_DEVICE_ID = [
|
16
|
+
GPS_UNSUPPORTED_DEVICE_ID = %w[PT21 KC26 SN28 SN26 KC23 SA28 TS25 SA25 SA24 SN23 ST14 KC15 SN22 KC14 ST13 SN17 SY15 CA14 HI14 TS14 KC13 SN15 SN16 SY14 ST12 TS13 CA13 MA13 HI13 SN13 SY13 SN12 SN14 ST11 DN11 SY12 KCTE TST9 KCU1 SYT5 KCTD TST8 TST7 KCTC SYT4 KCTB KCTA TST6 KCT9 TST5 TST4 KCT8 SYT3 KCT7 MIT1 MAT3 KCT6 TST3 KCT5 KCT4 SYT2 MAT1 MAT2 TST2 KCT3 KCT2 KCT1 TST1 SYT1].freeze
|
18
17
|
|
19
18
|
# EZ番号(サブスクライバID)があれば返す。無ければ +nil+ を返す。
|
20
19
|
def subno
|
21
|
-
@request.env[
|
20
|
+
@request.env['HTTP_X_UP_SUBNO']
|
22
21
|
end
|
23
|
-
|
22
|
+
alias_method :ident_subscriber, :subno
|
24
23
|
|
25
24
|
# 位置情報があれば Position のインスタンスを返す。無ければ +nil+ を返す。
|
26
25
|
def position
|
27
26
|
return @__posotion if defined? @__posotion
|
28
|
-
return @__posotion = nil if
|
27
|
+
return @__posotion = nil if params['lat'].nil? || params['lat'] == '' || params['lon'].nil? || params['lon'] == ''
|
29
28
|
l = Jpmobile::Position.new
|
30
|
-
l.options = params.
|
31
|
-
case params[
|
32
|
-
when
|
33
|
-
l.lat = params[
|
34
|
-
l.lon = params[
|
35
|
-
when
|
36
|
-
raise
|
37
|
-
l.lat = Jpmobile::Position.dms2deg(
|
38
|
-
raise
|
39
|
-
l.lon = Jpmobile::Position.dms2deg(
|
29
|
+
l.options = params.select { |x, _| %w[ver datum unit lat lon alt time smaj smin vert majaa fm].include?(x) }
|
30
|
+
case params['unit']
|
31
|
+
when '1'
|
32
|
+
l.lat = params['lat'].to_f
|
33
|
+
l.lon = params['lon'].to_f
|
34
|
+
when '0', 'dms'
|
35
|
+
raise 'Invalid dms form' unless params['lat'] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/
|
36
|
+
l.lat = Jpmobile::Position.dms2deg(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3))
|
37
|
+
raise 'Invalid dms form' unless params['lon'] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/
|
38
|
+
l.lon = Jpmobile::Position.dms2deg(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3))
|
40
39
|
else
|
41
40
|
return @__posotion = nil
|
42
41
|
end
|
43
|
-
if params[
|
42
|
+
if params['datum'] == '1'
|
44
43
|
# ただし、params["datum"]=="tokyo"のとき(簡易位置情報)のときは、
|
45
44
|
# 実際にはWGS84系のデータが渡ってくる
|
46
45
|
# http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
|
47
46
|
l.tokyo2wgs84!
|
48
47
|
end
|
49
|
-
|
48
|
+
@__posotion = l
|
50
49
|
end
|
51
50
|
|
52
51
|
# デバイスIDを返す
|
53
52
|
def device_id
|
54
53
|
if @request.env['HTTP_USER_AGENT'] =~ USER_AGENT_REGEXP
|
55
|
-
|
54
|
+
Regexp.last_match(1)
|
56
55
|
else
|
57
56
|
nil
|
58
57
|
end
|
@@ -60,18 +59,28 @@ module Jpmobile::Mobile
|
|
60
59
|
|
61
60
|
# 簡易位置情報取得に対応している場合は +true+ を返す。
|
62
61
|
def supports_location?
|
63
|
-
!
|
62
|
+
!LOCATION_UNSUPPORTED_DEVICE_ID.include?(device_id)
|
64
63
|
end
|
65
64
|
|
66
65
|
# GPS位置情報取得に対応している場合は +true+ を返す。
|
67
66
|
def supports_gps?
|
68
|
-
!
|
67
|
+
!GPS_UNSUPPORTED_DEVICE_ID.include?(device_id)
|
69
68
|
end
|
70
69
|
|
71
70
|
# cookieに対応しているか?
|
72
71
|
def supports_cookie?
|
73
|
-
protocol =
|
74
|
-
|
72
|
+
protocol =
|
73
|
+
begin
|
74
|
+
if @request.respond_to?(:scheme)
|
75
|
+
@request.scheme
|
76
|
+
else
|
77
|
+
@request.protocol
|
78
|
+
end
|
79
|
+
rescue
|
80
|
+
'none'
|
81
|
+
end
|
82
|
+
|
83
|
+
if protocol.start_with?('https')
|
75
84
|
false
|
76
85
|
else
|
77
86
|
true
|
@@ -85,13 +94,14 @@ module Jpmobile::Mobile
|
|
85
94
|
# 文字コードを UTF-8 に変換
|
86
95
|
str = Jpmobile::Util.sjis_to_utf8(str)
|
87
96
|
# 数値参照を UTF-8 に変換
|
88
|
-
Jpmobile::Emoticon
|
97
|
+
Jpmobile::Emoticon.unicodecr_to_utf8(str)
|
89
98
|
end
|
99
|
+
|
90
100
|
def to_external(str, content_type, charset)
|
91
101
|
# UTF-8を数値参照に
|
92
102
|
str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
|
93
103
|
# 文字コードを Shift_JIS に変換
|
94
|
-
if [nil,
|
104
|
+
if [nil, 'text/html', 'application/xhtml+xml'].include?(content_type)
|
95
105
|
str = Jpmobile::Util.utf8_to_sjis(str)
|
96
106
|
charset = default_charset unless str.empty?
|
97
107
|
end
|
@@ -100,8 +110,9 @@ module Jpmobile::Mobile
|
|
100
110
|
|
101
111
|
[str, charset]
|
102
112
|
end
|
113
|
+
|
103
114
|
def default_charset
|
104
|
-
|
115
|
+
'Shift_JIS'
|
105
116
|
end
|
106
117
|
|
107
118
|
# メール送信用
|
@@ -110,7 +121,7 @@ module Jpmobile::Mobile
|
|
110
121
|
end
|
111
122
|
|
112
123
|
def to_mail_internal(str, charset)
|
113
|
-
if Jpmobile::Util.jis?(str)
|
124
|
+
if Jpmobile::Util.jis?(str) || Jpmobile::Util.ascii_8bit?(str) || (charset == mail_charset)
|
114
125
|
# 絵文字を数値参照に変換
|
115
126
|
str = Jpmobile::Emoticon.external_to_unicodecr_au_mail(Jpmobile::Util.jis(str))
|
116
127
|
str = Jpmobile::Util.jis_to_utf8(Jpmobile::Util.jis_win(str))
|
@@ -123,6 +134,7 @@ module Jpmobile::Mobile
|
|
123
134
|
end
|
124
135
|
|
125
136
|
private
|
137
|
+
|
126
138
|
def to_mail_encoding(str)
|
127
139
|
str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
|
128
140
|
str = Jpmobile::Util.utf8_to_jis(str)
|
@@ -1,11 +1,10 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# =DDI-POCKET
|
3
2
|
module Jpmobile::Mobile
|
4
3
|
# ==DDI-POCKET
|
5
4
|
# スーパクラスはWillcom。
|
6
5
|
class Ddipocket < Willcom
|
7
6
|
# 対応するUser-Agentの正規表現
|
8
|
-
USER_AGENT_REGEXP =
|
7
|
+
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(DDIPOCKET}
|
9
8
|
|
10
9
|
MAIL_ADDRESS_REGEXP = nil # DdipocketはEmail判定だとWillcomと判定させたい
|
11
10
|
end
|