jpmobile 0.0.8 → 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -3
- data/{spec/spec.opts → .rspec} +1 -2
- data/README.rdoc +122 -128
- data/Rakefile +23 -101
- data/VERSION.yml +4 -3
- data/jpmobile.gemspec +130 -182
- data/lib/jpmobile.rb +37 -24
- data/lib/jpmobile/docomo_guid.rb +2 -1
- data/lib/jpmobile/email.rb +3 -4
- data/lib/jpmobile/emoticon.rb +2 -6
- data/lib/jpmobile/encoding.rb +29 -0
- data/lib/jpmobile/filter.rb +42 -134
- data/lib/jpmobile/helpers.rb +5 -18
- data/lib/jpmobile/hook_action_controller.rb +24 -16
- data/lib/jpmobile/hook_action_view.rb +28 -89
- data/lib/jpmobile/mobile/abstract_mobile.rb +21 -4
- data/lib/jpmobile/mobile/android.rb +10 -0
- data/lib/jpmobile/mobile/au.rb +28 -3
- data/lib/jpmobile/mobile/ddipocket.rb +12 -0
- data/lib/jpmobile/mobile/display.rb +29 -26
- data/lib/jpmobile/mobile/docomo.rb +38 -12
- data/lib/jpmobile/mobile/iphone.rb +26 -0
- data/lib/jpmobile/mobile/smart_phone.rb +21 -0
- data/lib/jpmobile/mobile/softbank.rb +16 -41
- data/lib/jpmobile/mobile/vodafone.rb +17 -0
- data/lib/jpmobile/mobile/willcom.rb +1 -10
- data/lib/jpmobile/mobile/windows_phone.rb +10 -0
- data/lib/jpmobile/position.rb +4 -3
- data/lib/jpmobile/rack.rb +43 -0
- data/lib/jpmobile/rack/filter.rb +51 -0
- data/lib/jpmobile/rack/mobile_carrier.rb +33 -0
- data/lib/jpmobile/rack/params_filter.rb +47 -0
- data/lib/jpmobile/rails.rb +22 -0
- data/lib/jpmobile/request_with_mobile.rb +8 -12
- data/lib/jpmobile/trans_sid.rb +44 -26
- data/lib/jpmobile/util.rb +68 -0
- data/{tasks → lib/tasks}/jpmobile_tasks.rake +32 -13
- data/spec/rack/jpmobile/android_spec.rb +20 -0
- data/spec/rack/jpmobile/au_spec.rb +206 -0
- data/spec/rack/jpmobile/docomo_spec.rb +237 -0
- data/spec/rack/jpmobile/emoticon_spec.rb +215 -0
- data/spec/rack/jpmobile/filter_spec.rb +181 -0
- data/spec/rack/jpmobile/iphone_spec.rb +32 -0
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +39 -0
- data/spec/rack/jpmobile/params_filter_spec.rb +193 -0
- data/spec/rack/jpmobile/softbank_spec.rb +123 -0
- data/spec/rack/jpmobile/willcom_spec.rb +67 -0
- data/spec/rack/jpmobile/windows_phone.rb +20 -0
- data/spec/rack_helper.rb +86 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/unit/detect_by_email_spec.rb +21 -27
- data/spec/unit/is_carrier_spec.rb +56 -84
- data/spec/unit/spec_helper.rb +1 -2
- data/spec/unit/util_spec.rb +2 -2
- data/spec/unit/valid_ip_spec.rb +43 -52
- data/test/legacy/autoload_test.rb +1 -3
- data/test/legacy/emoticon_test.rb +5 -6
- data/test/legacy/helper.rb +0 -71
- data/test/rails/overrides/.rspec +5 -0
- data/test/rails/overrides/Gemfile +32 -0
- data/test/rails/overrides/app/controllers/docomo_guid_always_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +5 -0
- data/test/rails/overrides/app/controllers/docomo_guid_docomo_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/filter_controller.rb +0 -34
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +19 -0
- data/test/rails/overrides/app/controllers/hankaku_filter_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/links_controller.rb +28 -0
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_always_and_session_off_controller.rb +4 -0
- data/test/rails/overrides/app/controllers/trans_sid_always_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -0
- data/test/rails/overrides/app/controllers/trans_sid_mobile_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_none_controller.rb +3 -0
- data/test/rails/overrides/app/views/links/au_gps.html.erb +1 -0
- data/test/rails/overrides/app/views/links/au_location.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_foma_gps.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_openiarea.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_utn.html.erb +1 -0
- data/test/rails/overrides/app/views/links/link.html.erb +1 -0
- data/test/rails/overrides/app/views/links/show_all.html.erb +1 -0
- data/test/rails/overrides/app/views/links/softbank_location.html.erb +1 -0
- data/test/rails/overrides/app/views/links/willcom_location.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_smart_phone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_smart_phone_iphone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_smart_phone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_smart_phone_iphone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/show_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/show_mobile_docomo.html.erb +1 -0
- data/test/rails/overrides/autotest/discover.rb +2 -0
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +1 -0
- data/test/rails/overrides/config/routes.rb +58 -0
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +16 -0
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +2 -2
- data/test/rails/overrides/spec/{controllers → requests}/docomo_guid_spec.rb +37 -14
- data/test/rails/overrides/spec/{controllers → requests}/docomo_spec.rb +11 -8
- data/test/rails/overrides/spec/{controllers → requests}/emobile_spec.rb +24 -8
- data/test/rails/overrides/spec/requests/filter_spec.rb +171 -0
- data/test/rails/overrides/spec/requests/helpers_spec.rb +187 -0
- data/test/rails/overrides/spec/requests/pc_spec.rb +22 -0
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +21 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +234 -0
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +142 -0
- data/test/rails/overrides/spec/spec_helper.rb +17 -48
- data/test/sinatra/guestbook.rb +40 -0
- data/test/sinatra/test/filter_test.rb +39 -0
- metadata +185 -312
- data/lib/jpmobile/hook_request.rb +0 -5
- data/lib/jpmobile/rack/auth.rb +0 -55
- data/lib/jpmobile/rack/combined_logger.rb +0 -54
- data/lib/jpmobile/rack/request.rb +0 -7
- data/lib/jpmobile/rack/trans_sid.rb +0 -14
- data/lib/jpmobile/version.rb +0 -9
- data/spec/unit/detect_by_ua_spec.rb +0 -40
- data/test/legacy/au_test.rb +0 -173
- data/test/legacy/docomo_test.rb +0 -187
- data/test/legacy/emoticon_functional_test.rb +0 -195
- data/test/legacy/filter_test.rb +0 -34
- data/test/legacy/helpers_test.rb +0 -217
- data/test/legacy/softbank_test.rb +0 -183
- data/test/legacy/willcom_test.rb +0 -56
- data/test/rails/2.3.2/spec/controllers/trans_sid_spec.rb +0 -99
- data/test/rails/overrides/app/controllers/docomo_guid_controller.rb +0 -13
- data/test/rails/overrides/app/controllers/trans_sid_controller.rb +0 -28
- data/test/rails/overrides/lib/tasks/rspec.rake +0 -165
- data/test/rails/overrides/spec/controllers/filter_spec.rb +0 -159
- data/test/rails/overrides/spec/controllers/pc_spec.rb +0 -13
- data/test/rails/overrides/spec/controllers/softbank_emulator_spec.rb +0 -42
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +0 -117
- data/test/rails/overrides/spec/controllers/trans_sid_spec.rb +0 -117
- data/test/rails/overrides/spec/rspec.rake +0 -165
- data/test/rails/overrides/spec/spec.opts +0 -4
@@ -1,9 +1,11 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'ipaddr'
|
2
3
|
|
3
4
|
module Jpmobile::Mobile
|
4
5
|
# 携帯電話の抽象クラス。
|
5
6
|
class AbstractMobile
|
6
|
-
def initialize(request)
|
7
|
+
def initialize(env, request)
|
8
|
+
@env = env
|
7
9
|
@request = request
|
8
10
|
end
|
9
11
|
|
@@ -37,7 +39,7 @@ module Jpmobile::Mobile
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def valid_ip?
|
40
|
-
@__valid_ip ||= self.class.valid_ip? @request.
|
42
|
+
@__valid_ip ||= self.class.valid_ip? @request.ip
|
41
43
|
end
|
42
44
|
|
43
45
|
# 画面情報を +Display+ クラスのインスタンスで返す。
|
@@ -50,10 +52,25 @@ module Jpmobile::Mobile
|
|
50
52
|
return false
|
51
53
|
end
|
52
54
|
|
55
|
+
# smartphone かどうか
|
56
|
+
def smart_phone?
|
57
|
+
false
|
58
|
+
end
|
59
|
+
|
60
|
+
# エンコーディング変換用
|
61
|
+
def to_internal(str)
|
62
|
+
str
|
63
|
+
end
|
64
|
+
def to_external(str, content_type, charset)
|
65
|
+
[str, charset]
|
66
|
+
end
|
67
|
+
def default_charset
|
68
|
+
"UTF-8"
|
69
|
+
end
|
53
70
|
# リクエストがこのクラスに属するか調べる
|
54
71
|
# メソッド名に関して非常に不安
|
55
|
-
def self.
|
56
|
-
self::USER_AGENT_REGEXP &&
|
72
|
+
def self.check_carrier(env)
|
73
|
+
self::USER_AGENT_REGEXP && env['HTTP_USER_AGENT'] =~ self::USER_AGENT_REGEXP
|
57
74
|
end
|
58
75
|
|
59
76
|
#XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義しているから動くのです
|
data/lib/jpmobile/mobile/au.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# =au携帯電話
|
3
3
|
|
4
|
-
require 'ipaddr'
|
5
|
-
|
6
4
|
module Jpmobile::Mobile
|
7
5
|
# ==au携帯電話
|
8
6
|
# CDMA 1X, CDMA 1X WINを含む。
|
@@ -68,7 +66,7 @@ module Jpmobile::Mobile
|
|
68
66
|
a = r.split(/,/)
|
69
67
|
cols = 2 ** a[0].to_i
|
70
68
|
end
|
71
|
-
@__display = Jpmobile::Display.new(p_w, p_h, nil, nil, col_p, cols)
|
69
|
+
@__display = Jpmobile::Mobile::Display.new(p_w, p_h, nil, nil, col_p, cols)
|
72
70
|
end
|
73
71
|
|
74
72
|
# デバイスIDを返す
|
@@ -99,5 +97,32 @@ module Jpmobile::Mobile
|
|
99
97
|
true
|
100
98
|
end
|
101
99
|
end
|
100
|
+
|
101
|
+
# 文字コード変換
|
102
|
+
def to_internal(str)
|
103
|
+
# 絵文字を数値参照に変換
|
104
|
+
str = Jpmobile::Emoticon.external_to_unicodecr_au(Jpmobile::Util.sjis(str))
|
105
|
+
# 文字コードを UTF-8 に変換
|
106
|
+
str = Jpmobile::Util.sjis_to_utf8(str)
|
107
|
+
# 数値参照を UTF-8 に変換
|
108
|
+
Jpmobile::Emoticon::unicodecr_to_utf8(str)
|
109
|
+
# 半角->全角変換
|
110
|
+
end
|
111
|
+
def to_external(str, content_type, charset)
|
112
|
+
# UTF-8を数値参照に
|
113
|
+
str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
|
114
|
+
# 文字コードを Shift_JIS に変換
|
115
|
+
if [nil, "text/html", "application/xhtml+xml"].include?(content_type)
|
116
|
+
str = Jpmobile::Util.utf8_to_sjis(str)
|
117
|
+
charset = default_charset unless str.empty?
|
118
|
+
end
|
119
|
+
# 数値参照を絵文字コードに変換
|
120
|
+
str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_AU, true)
|
121
|
+
|
122
|
+
[str, charset]
|
123
|
+
end
|
124
|
+
def default_charset
|
125
|
+
"Shift_JIS"
|
126
|
+
end
|
102
127
|
end
|
103
128
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# =DDI-POCKET
|
3
|
+
module Jpmobile::Mobile
|
4
|
+
# ==DDI-POCKET
|
5
|
+
# スーパクラスはWillcom。
|
6
|
+
class Ddipocket < Willcom
|
7
|
+
# 対応するUser-Agentの正規表現
|
8
|
+
USER_AGENT_REGEXP = /^Mozilla\/3.0\(DDIPOCKET/
|
9
|
+
|
10
|
+
MAIL_ADDRESS_REGEXP = nil # DdipocketはEmail判定だとWillcomと判定させたい
|
11
|
+
end
|
12
|
+
end
|
@@ -1,33 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# = 端末のディスプレイに関する情報
|
2
3
|
# request.mobile.display
|
3
4
|
# で取得できる。
|
4
5
|
module Jpmobile
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
module Mobile
|
7
|
+
# ディスプレイ情報
|
8
|
+
class Display
|
9
|
+
def initialize(physical_width=nil, physical_height=nil, browser_width=nil, browser_height=nil, color_p=nil, colors=nil) # :nodoc:
|
10
|
+
@physical_width = physical_width
|
11
|
+
@physical_height = physical_height
|
12
|
+
@browser_width = browser_width
|
13
|
+
@browser_height = browser_height
|
14
|
+
@colors = colors
|
15
|
+
@color_p = color_p
|
16
|
+
end
|
17
|
+
|
18
|
+
# 画面がカラーならば +true+、白黒ならば +false+ を返す。不明の場合は +nil+。
|
19
|
+
def color?; @color_p; end
|
20
|
+
# 画面の色数を返す。不明の場合は +nil+。
|
21
|
+
def colors; @colors; end
|
22
|
+
# ディスプレイの画面幅を返す。不明の場合は +nil+。
|
23
|
+
def physical_width; @physical_width; end
|
24
|
+
# ディスプレイの画面高さを返す。不明の場合は +nil+。
|
25
|
+
def physical_height; @physical_height; end
|
26
|
+
# ブラウザの画面幅を返す。不明の場合は +nil+。
|
27
|
+
def browser_width; @browser_width; end
|
28
|
+
# ブラウザの画面高さを返す。不明の場合は +nil+。
|
29
|
+
def browser_height; @browser_height; end
|
30
|
+
# 画面の幅を返す。ブラウザ画面の幅がわかる場合はそれを優先する。不明の場合は +nil+。
|
31
|
+
def width; browser_width || physical_width; end
|
32
|
+
# 画面の高さを返す。ブラウザ画面の高さがわかる場合はそれを優先する。不明の場合は +nil+。
|
33
|
+
def height; browser_height || physical_height; end
|
14
34
|
end
|
15
|
-
|
16
|
-
# 画面がカラーならば +true+、白黒ならば +false+ を返す。不明の場合は +nil+。
|
17
|
-
def color?; @color_p; end
|
18
|
-
# 画面の色数を返す。不明の場合は +nil+。
|
19
|
-
def colors; @colors; end
|
20
|
-
# ディスプレイの画面幅を返す。不明の場合は +nil+。
|
21
|
-
def physical_width; @physical_width; end
|
22
|
-
# ディスプレイの画面高さを返す。不明の場合は +nil+。
|
23
|
-
def physical_height; @physical_height; end
|
24
|
-
# ブラウザの画面幅を返す。不明の場合は +nil+。
|
25
|
-
def browser_width; @browser_width; end
|
26
|
-
# ブラウザの画面高さを返す。不明の場合は +nil+。
|
27
|
-
def browser_height; @browser_height; end
|
28
|
-
# 画面の幅を返す。ブラウザ画面の幅がわかる場合はそれを優先する。不明の場合は +nil+。
|
29
|
-
def width; browser_width || physical_width; end
|
30
|
-
# 画面の高さを返す。ブラウザ画面の高さがわかる場合はそれを優先する。不明の場合は +nil+。
|
31
|
-
def height; browser_height || physical_height; end
|
32
35
|
end
|
33
36
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# =DoCoMo携帯電話
|
2
3
|
|
3
4
|
module Jpmobile::Mobile
|
@@ -38,7 +39,7 @@ module Jpmobile::Mobile
|
|
38
39
|
|
39
40
|
# 端末製造番号があれば返す。無ければ +nil+ を返す。
|
40
41
|
def serial_number
|
41
|
-
case @
|
42
|
+
case @env["HTTP_USER_AGENT"]
|
42
43
|
when /ser([0-9a-zA-Z]{11})$/ # mova
|
43
44
|
return $1
|
44
45
|
when /ser([0-9a-zA-Z]{15});/ # FOMA
|
@@ -51,13 +52,13 @@ module Jpmobile::Mobile
|
|
51
52
|
|
52
53
|
# FOMAカード製造番号があれば返す。無ければ +nil+ を返す。
|
53
54
|
def icc
|
54
|
-
@
|
55
|
+
@env['HTTP_USER_AGENT'] =~ /icc([0-9a-zA-Z]{20})\)/
|
55
56
|
return $1
|
56
57
|
end
|
57
58
|
|
58
59
|
# iモードIDを返す。
|
59
60
|
def guid
|
60
|
-
@
|
61
|
+
@env['HTTP_X_DCMGUID']
|
61
62
|
end
|
62
63
|
|
63
64
|
# iモードID, FOMAカード製造番号の順で調べ、あるものを返す。なければ +nil+ を返す。
|
@@ -67,11 +68,11 @@ module Jpmobile::Mobile
|
|
67
68
|
|
68
69
|
# 画面情報を +Display+ クラスのインスタンスで返す。
|
69
70
|
def display
|
70
|
-
@__display ||= Jpmobile::Display.new(nil,nil,
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
@__display ||= Jpmobile::Mobile::Display.new(nil,nil,
|
72
|
+
display_info[:browser_width],
|
73
|
+
display_info[:browser_height],
|
74
|
+
display_info[:color_p],
|
75
|
+
display_info[:colors])
|
75
76
|
end
|
76
77
|
|
77
78
|
# cookieに対応しているか?
|
@@ -79,6 +80,32 @@ module Jpmobile::Mobile
|
|
79
80
|
imode_browser_version != '1.0'
|
80
81
|
end
|
81
82
|
|
83
|
+
# 文字コード変換
|
84
|
+
def to_internal(str)
|
85
|
+
# 絵文字を数値参照に変換
|
86
|
+
str = Jpmobile::Emoticon.external_to_unicodecr_docomo(Jpmobile::Util.sjis(str))
|
87
|
+
# 文字コードを UTF-8 に変換
|
88
|
+
str = Jpmobile::Util.sjis_to_utf8(str)
|
89
|
+
# 数値参照を UTF-8 に変換
|
90
|
+
Jpmobile::Emoticon.unicodecr_to_utf8(str)
|
91
|
+
end
|
92
|
+
def to_external(str, content_type, charset)
|
93
|
+
# UTF-8を数値参照に
|
94
|
+
str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
|
95
|
+
# 文字コードを Shift_JIS に変換
|
96
|
+
if [nil, "text/html", "application/xhtml+xml"].include?(content_type)
|
97
|
+
str = Jpmobile::Util.utf8_to_sjis(str)
|
98
|
+
charset = default_charset unless str.empty?
|
99
|
+
end
|
100
|
+
# 数値参照を絵文字コードに変換
|
101
|
+
str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)
|
102
|
+
|
103
|
+
[str, charset]
|
104
|
+
end
|
105
|
+
def default_charset
|
106
|
+
"Shift_JIS"
|
107
|
+
end
|
108
|
+
|
82
109
|
# i-mode ブラウザのバージョンを返す。
|
83
110
|
# http://labs.unoh.net/2009/07/i_20.html
|
84
111
|
def imode_browser_version
|
@@ -90,7 +117,7 @@ module Jpmobile::Mobile
|
|
90
117
|
@request.env['HTTP_USER_AGENT'] =~ / (\w+)\(c(\d+);/
|
91
118
|
model = $1
|
92
119
|
cache_size = $2.to_i
|
93
|
-
|
120
|
+
|
94
121
|
ver = cache_size >= 500 ? (%w(P03B P05B L01B).member?(model) ? '2.0LE' : '2.0') : '1.0'
|
95
122
|
else
|
96
123
|
# DoCoMo/3.0以降等は、とりあえず非v1.0扱い
|
@@ -100,13 +127,12 @@ module Jpmobile::Mobile
|
|
100
127
|
ver
|
101
128
|
end
|
102
129
|
|
103
|
-
|
104
130
|
private
|
105
131
|
# モデル名を返す。
|
106
132
|
def model_name
|
107
|
-
if @
|
133
|
+
if @env["HTTP_USER_AGENT"] =~ /^DoCoMo\/2.0 (.+)\(/
|
108
134
|
return $1
|
109
|
-
elsif @
|
135
|
+
elsif @env["HTTP_USER_AGENT"] =~ /^DoCoMo\/1.0\/(.+?)\//
|
110
136
|
return $1
|
111
137
|
end
|
112
138
|
return nil
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# =iPhone
|
3
|
+
|
4
|
+
module Jpmobile::Mobile
|
5
|
+
# ==iPhone
|
6
|
+
class Iphone < SmartPhone
|
7
|
+
# 対応するUser-Agentの正規表現
|
8
|
+
USER_AGENT_REGEXP = /iPhone/
|
9
|
+
|
10
|
+
# 文字コード変換
|
11
|
+
def to_internal(str)
|
12
|
+
# 絵文字を数値参照に変換
|
13
|
+
str = Jpmobile::Emoticon.external_to_unicodecr_softbank(Jpmobile::Util.utf8(str))
|
14
|
+
# 数値参照を UTF-8 に変換
|
15
|
+
Jpmobile::Emoticon.unicodecr_to_utf8(str)
|
16
|
+
end
|
17
|
+
def to_external(str, content_type, charset)
|
18
|
+
# UTF-8を数値参照に
|
19
|
+
str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
|
20
|
+
# 数値参照を絵文字コードに変換
|
21
|
+
str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, false)
|
22
|
+
|
23
|
+
[str, charset]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# =スマートフォンの親クラス
|
3
|
+
|
4
|
+
module Jpmobile::Mobile
|
5
|
+
class SmartPhone < AbstractMobile
|
6
|
+
# 無効化
|
7
|
+
def valid_ip?
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
11
|
+
# cookie は有効と見なす
|
12
|
+
def supports_cookie?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
# smartphone なので true
|
17
|
+
def smart_phone?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,11 +1,9 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# =SoftBank携帯電話
|
2
|
-
#
|
3
|
-
|
4
|
-
require 'nkf'
|
5
|
-
|
3
|
+
# Vodafoneを含む
|
6
4
|
module Jpmobile::Mobile
|
7
5
|
# ==Softbank携帯電話
|
8
|
-
# Vodafone
|
6
|
+
# Vodafoneのスーパクラス。
|
9
7
|
class Softbank < AbstractMobile
|
10
8
|
autoload :IP_ADDRESSES, 'jpmobile/mobile/z_ip_addresses_softbank'
|
11
9
|
|
@@ -60,51 +58,28 @@ module Jpmobile::Mobile
|
|
60
58
|
cols = $1.to_i
|
61
59
|
end
|
62
60
|
end
|
63
|
-
@__display = Jpmobile::Display.new(p_w, p_h, nil, nil, col_p, cols)
|
61
|
+
@__display = Jpmobile::Mobile::Display.new(p_w, p_h, nil, nil, col_p, cols)
|
64
62
|
end
|
65
63
|
|
66
64
|
# cookieに対応しているか?
|
67
65
|
def supports_cookie?
|
68
66
|
true
|
69
67
|
end
|
70
|
-
end
|
71
|
-
# ==Vodafone 3G携帯電話(J-PHONE, SoftBank含まず)
|
72
|
-
# スーパクラスはSoftbank。
|
73
|
-
class Vodafone < Softbank
|
74
|
-
# 対応するUser-Agentの正規表現
|
75
|
-
USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/
|
76
|
-
# 対応するメールアドレスの正規表現
|
77
|
-
MAIL_ADDRESS_REGEXP = /^.+@[dhtcrknsq]\.vodafone\.ne\.jp$/
|
78
68
|
|
79
|
-
#
|
80
|
-
def
|
81
|
-
|
69
|
+
# 文字コード変換
|
70
|
+
def to_internal(str)
|
71
|
+
# 絵文字を数値参照に変換
|
72
|
+
str = Jpmobile::Emoticon.external_to_unicodecr_softbank(Jpmobile::Util.utf8(str))
|
73
|
+
# 数値参照を UTF-8 に変換
|
74
|
+
Jpmobile::Emoticon::unicodecr_to_utf8(str)
|
82
75
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
USER_AGENT_REGEXP = /^(J-PHONE|J-EMULATOR)/
|
89
|
-
# 対応するメールアドレスの正規表現
|
90
|
-
MAIL_ADDRESS_REGEXP = /^.+@jp-[dhtcrknsq]\.ne\.jp$/
|
76
|
+
def to_external(str, content_type, charset)
|
77
|
+
# UTF-8を数値参照に
|
78
|
+
str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
|
79
|
+
# 数値参照を絵文字コードに変換
|
80
|
+
str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, false)
|
91
81
|
|
92
|
-
|
93
|
-
def position
|
94
|
-
str = @request.env["HTTP_X_JPHONE_GEOCODE"]
|
95
|
-
return nil if str.nil? || str == "0000000%1A0000000%1A%88%CA%92%75%8F%EE%95%F1%82%C8%82%B5"
|
96
|
-
raise "unsuppoted format" unless str =~ /^(\d\d)(\d\d)(\d\d)%1A(\d\d\d)(\d\d)(\d\d)%1A(.+)$/
|
97
|
-
pos = Jpmobile::Position.new
|
98
|
-
pos.lat = Jpmobile::Position.dms2deg($1,$2,$3)
|
99
|
-
pos.lon = Jpmobile::Position.dms2deg($4,$5,$6)
|
100
|
-
pos.options = {"address"=>NKF.nkf("-m0 -Sw", CGI.unescape($7))}
|
101
|
-
pos.tokyo2wgs84!
|
102
|
-
return pos
|
103
|
-
end
|
104
|
-
|
105
|
-
# cookieに対応しているか?
|
106
|
-
def supports_cookie?
|
107
|
-
false
|
82
|
+
[str, charset]
|
108
83
|
end
|
109
84
|
end
|
110
85
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Vodafone
|
3
|
+
module Jpmobile::Mobile
|
4
|
+
# ==Vodafone 3G携帯電話(SoftBank含まず)
|
5
|
+
# スーパクラスはSoftbank。
|
6
|
+
class Vodafone < Softbank
|
7
|
+
# 対応するUser-Agentの正規表現
|
8
|
+
USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/
|
9
|
+
# 対応するメールアドレスの正規表現
|
10
|
+
MAIL_ADDRESS_REGEXP = /^.+@[dhtcrknsq]\.vodafone\.ne\.jp$/
|
11
|
+
|
12
|
+
# cookieに対応しているか?
|
13
|
+
def supports_cookie?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# =Willcom携帯電話
|
2
|
-
# DDI-POCKETを含む。
|
3
|
-
|
4
3
|
module Jpmobile::Mobile
|
5
4
|
# ==Willcom携帯電話
|
6
5
|
# Ddipocketのスーパクラス。
|
@@ -28,12 +27,4 @@ module Jpmobile::Mobile
|
|
28
27
|
true
|
29
28
|
end
|
30
29
|
end
|
31
|
-
# ==DDI-POCKET
|
32
|
-
# スーパクラスはWillcom。
|
33
|
-
class Ddipocket < Willcom
|
34
|
-
# 対応するUser-Agentの正規表現
|
35
|
-
USER_AGENT_REGEXP = /^Mozilla\/3.0\(DDIPOCKET/
|
36
|
-
|
37
|
-
MAIL_ADDRESS_REGEXP = nil # DdipocketはEmail判定だとWillcomと判定させたい
|
38
|
-
end
|
39
30
|
end
|