jpmobile 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/{test/rails/rails_root/vendor/plugins/jpmobile/MIT-LICENSE → MIT-LICENSE} +0 -0
- data/README.rdoc +16 -6
- data/Rakefile +14 -0
- data/VERSION.yml +4 -0
- data/init.rb +3 -0
- data/install.rb +1 -0
- data/jpmobile.gemspec +299 -0
- data/lib/jpmobile.rb +0 -2
- data/lib/jpmobile/emoticon.rb +16 -2
- data/lib/jpmobile/emoticon/z_combine.rb +17 -4
- data/lib/jpmobile/filter.rb +2 -3
- data/lib/jpmobile/mobile/abstract_mobile.rb +6 -0
- data/lib/jpmobile/mobile/docomo.rb +24 -1
- data/lib/jpmobile/mobile/z_ip_addresses_au.rb +3 -2
- data/lib/jpmobile/mobile/z_ip_addresses_docomo.rb +4 -1
- data/lib/jpmobile/request_with_mobile.rb +4 -1
- data/{test/rails/rails_root/vendor/plugins/jpmobile/spec → spec}/spec.opts +0 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/unit/detect_by_email_spec.rb +31 -0
- data/{test/rails/rails_root/vendor/plugins/jpmobile/spec → spec}/unit/detect_by_ua_spec.rb +11 -13
- data/spec/unit/is_carrier_spec.rb +93 -0
- data/spec/unit/spec_helper.rb +5 -0
- data/spec/unit/util_spec.rb +30 -0
- data/spec/unit/valid_ip_spec.rb +60 -0
- data/{test/rails/rails_root/vendor/plugins/jpmobile/tasks → tasks}/jpmobile_tasks.rake +3 -3
- data/test/legacy/autoload_test.rb +2 -1
- data/test/legacy/docomo_test.rb +39 -0
- data/test/legacy/emoticon_functional_test.rb +21 -19
- data/test/legacy/emoticon_test.rb +12 -12
- data/test/legacy/filter_test.rb +10 -8
- data/test/legacy/helper.rb +32 -3
- data/test/legacy/softbank_test.rb +2 -0
- data/test/rails/.gitignore +1 -0
- data/test/rails/overrides/app/controllers/filter_controller.rb +10 -0
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +2 -0
- data/test/rails/overrides/spec/controllers/docomo_spec.rb +2 -0
- data/test/rails/overrides/spec/controllers/emobile_spec.rb +2 -0
- data/test/rails/overrides/spec/controllers/filter_spec.rb +8 -7
- data/test/rails/overrides/spec/controllers/pc_spec.rb +2 -0
- data/test/rails/overrides/spec/controllers/softbank_emulator_spec.rb +2 -0
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +2 -0
- data/test/rails/overrides/spec/controllers/trans_sid_spec.rb +1 -0
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +2 -0
- data/test/rails/overrides/spec/spec_helper.rb +15 -0
- data/test/rails/rails_root/app/controllers/filter_controller.rb +0 -23
- data/test/rails/rails_root/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +3 -0
- data/test/rails/rails_root/app/helpers/application_helper.rb +0 -1
- data/test/rails/rails_root/config/boot.rb +13 -110
- data/test/rails/rails_root/config/environment.rb +4 -41
- data/test/rails/rails_root/config/environments/development.rb +22 -13
- data/test/rails/rails_root/config/environments/production.rb +41 -20
- data/test/rails/rails_root/config/environments/test.rb +35 -28
- data/test/rails/rails_root/config/initializers/backtrace_silencers.rb +2 -2
- data/test/rails/rails_root/config/initializers/inflections.rb +1 -1
- data/test/rails/rails_root/config/initializers/session_store.rb +2 -15
- data/test/rails/rails_root/config/routes.rb +6 -42
- data/test/rails/rails_root/db/schema.rb +24 -7
- data/test/rails/rails_root/db/seeds.rb +2 -2
- data/test/rails/rails_root/spec/helpers/helpers_spec.rb +4 -2
- data/test/rails/rails_root/spec/spec_helper.rb +19 -35
- data/test/rails/rails_root/test/performance/browsing_test.rb +2 -2
- data/test/rails/rails_root/test/test_helper.rb +2 -27
- data/test/rails/rails_root/vendor/plugins/jpmobile/init.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +39 -25
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb +2 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/email.rb +3 -4
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +24 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/conversion_table.rb +10 -9
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/z_combine.rb +17 -4
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/filter.rb +43 -136
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/helpers.rb +5 -18
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +24 -16
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +42 -85
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +25 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +28 -3
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/display.rb +29 -26
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +60 -11
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +16 -41
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/willcom.rb +1 -10
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_au.rb +3 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_docomo.rb +4 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/position.rb +4 -3
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/request_with_mobile.rb +14 -13
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/trans_sid.rb +52 -35
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +68 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/spec_helper.rb +3 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/detect_by_email_spec.rb +21 -27
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/is_carrier_spec.rb +56 -84
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/spec_helper.rb +1 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/util_spec.rb +8 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/spec/unit/valid_ip_spec.rb +43 -52
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/disabled_update_display_info_docomo.rb +0 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/update_ip_addresses_au.rb +0 -0
- data/tools/emoji/genregexp.rb +47 -0
- metadata +348 -253
- data/test/rails/rails_root/README +0 -243
- data/test/rails/rails_root/Rakefile +0 -10
- data/test/rails/rails_root/app/controllers/docomo_guid_controller.rb +0 -13
- data/test/rails/rails_root/app/controllers/trans_sid_controller.rb +0 -28
- data/test/rails/rails_root/app/views/filter/index.html.erb +0 -0
- data/test/rails/rails_root/app/views/hankaku_filter/index.html.erb +0 -0
- data/test/rails/rails_root/app/views/template_path/_partial.html.erb +0 -1
- data/test/rails/rails_root/app/views/template_path/_partial_mobile.html.erb +0 -1
- data/test/rails/rails_root/app/views/template_path/_partial_mobile_docomo.html.erb +0 -1
- data/test/rails/rails_root/app/views/template_path/index.html.erb +0 -1
- data/test/rails/rails_root/app/views/template_path/index_mobile.html.erb +0 -1
- data/test/rails/rails_root/app/views/template_path/index_mobile_docomo.html.erb +0 -1
- data/test/rails/rails_root/app/views/template_path/partial.html.erb +0 -2
- data/test/rails/rails_root/config/database.yml +0 -22
- data/test/rails/rails_root/config/initializers/new_rails_defaults.rb +0 -21
- data/test/rails/rails_root/config/locales/en.yml +0 -5
- data/test/rails/rails_root/db/development.sqlite3 +0 -0
- data/test/rails/rails_root/db/test.sqlite3 +0 -0
- data/test/rails/rails_root/doc/README_FOR_APP +0 -2
- data/test/rails/rails_root/lib/tasks/rspec.rake +0 -165
- data/test/rails/rails_root/log/development.log +0 -38
- data/test/rails/rails_root/log/production.log +0 -0
- data/test/rails/rails_root/log/server.log +0 -0
- data/test/rails/rails_root/log/test.log +0 -451
- data/test/rails/rails_root/public/404.html +0 -30
- data/test/rails/rails_root/public/422.html +0 -30
- data/test/rails/rails_root/public/500.html +0 -30
- data/test/rails/rails_root/public/favicon.ico +0 -0
- data/test/rails/rails_root/public/images/rails.png +0 -0
- data/test/rails/rails_root/public/index.html +0 -275
- data/test/rails/rails_root/public/javascripts/application.js +0 -2
- data/test/rails/rails_root/public/javascripts/controls.js +0 -963
- data/test/rails/rails_root/public/javascripts/dragdrop.js +0 -973
- data/test/rails/rails_root/public/javascripts/effects.js +0 -1128
- data/test/rails/rails_root/public/javascripts/prototype.js +0 -4320
- data/test/rails/rails_root/public/robots.txt +0 -5
- data/test/rails/rails_root/script/about +0 -4
- data/test/rails/rails_root/script/console +0 -3
- data/test/rails/rails_root/script/dbconsole +0 -3
- data/test/rails/rails_root/script/destroy +0 -3
- data/test/rails/rails_root/script/generate +0 -3
- data/test/rails/rails_root/script/performance/benchmarker +0 -3
- data/test/rails/rails_root/script/performance/profiler +0 -3
- data/test/rails/rails_root/script/plugin +0 -3
- data/test/rails/rails_root/script/runner +0 -3
- data/test/rails/rails_root/script/server +0 -3
- data/test/rails/rails_root/spec/controllers/docomo_guid_spec.rb +0 -77
- data/test/rails/rails_root/spec/controllers/docomo_spec.rb +0 -28
- data/test/rails/rails_root/spec/controllers/emobile_spec.rb +0 -35
- data/test/rails/rails_root/spec/controllers/filter_spec.rb +0 -157
- data/test/rails/rails_root/spec/controllers/pc_spec.rb +0 -11
- data/test/rails/rails_root/spec/controllers/softbank_emulator_spec.rb +0 -40
- data/test/rails/rails_root/spec/controllers/template_path_spec.rb +0 -115
- data/test/rails/rails_root/spec/controllers/trans_sid_spec.rb +0 -99
- data/test/rails/rails_root/spec/rcov.opts +0 -2
- data/test/rails/rails_root/spec/rspec.rake +0 -165
- data/test/rails/rails_root/spec/spec.opts +0 -4
- data/test/rails/rails_root/vendor/plugins/jpmobile/CHANGELOG +0 -7
- data/test/rails/rails_root/vendor/plugins/jpmobile/README.rdoc +0 -239
- data/test/rails/rails_root/vendor/plugins/jpmobile/Rakefile +0 -116
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_request.rb +0 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/auth.rb +0 -55
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/combined_logger.rb +0 -54
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/request.rb +0 -7
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/trans_sid.rb +0 -14
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/version.rb +0 -9
@@ -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,6 +52,27 @@ 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
|
70
|
+
# リクエストがこのクラスに属するか調べる
|
71
|
+
# メソッド名に関して非常に不安
|
72
|
+
def self.check_carrier(env)
|
73
|
+
self::USER_AGENT_REGEXP && env['HTTP_USER_AGENT'] =~ self::USER_AGENT_REGEXP
|
74
|
+
end
|
75
|
+
|
53
76
|
#XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義しているから動くのです
|
54
77
|
Jpmobile::Mobile.carriers.each do |carrier|
|
55
78
|
carrier_class = Jpmobile::Mobile.const_get(carrier)
|
@@ -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
|
@@ -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,23 +68,71 @@ 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に対応しているか?
|
78
79
|
def supports_cookie?
|
79
|
-
|
80
|
+
imode_browser_version != '1.0'
|
80
81
|
end
|
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
|
+
|
109
|
+
# i-mode ブラウザのバージョンを返す。
|
110
|
+
# http://labs.unoh.net/2009/07/i_20.html
|
111
|
+
def imode_browser_version
|
112
|
+
ver = '1.0'
|
113
|
+
case @request.env['HTTP_USER_AGENT']
|
114
|
+
when %r{^DoCoMo/1.0/}
|
115
|
+
# 必ずv1.0
|
116
|
+
when %r{^DoCoMo/2.0 }
|
117
|
+
@request.env['HTTP_USER_AGENT'] =~ / (\w+)\(c(\d+);/
|
118
|
+
model = $1
|
119
|
+
cache_size = $2.to_i
|
120
|
+
|
121
|
+
ver = cache_size >= 500 ? (%w(P03B P05B L01B).member?(model) ? '2.0LE' : '2.0') : '1.0'
|
122
|
+
else
|
123
|
+
# DoCoMo/3.0以降等は、とりあえず非v1.0扱い
|
124
|
+
ver = '2.0'
|
125
|
+
end
|
126
|
+
|
127
|
+
ver
|
128
|
+
end
|
129
|
+
|
81
130
|
private
|
82
131
|
# モデル名を返す。
|
83
132
|
def model_name
|
84
|
-
if @
|
133
|
+
if @env["HTTP_USER_AGENT"] =~ /^DoCoMo\/2.0 (.+)\(/
|
85
134
|
return $1
|
86
|
-
elsif @
|
135
|
+
elsif @env["HTTP_USER_AGENT"] =~ /^DoCoMo\/1.0\/(.+?)\//
|
87
136
|
return $1
|
88
137
|
end
|
89
138
|
return nil
|
@@ -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
|
@@ -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
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Jpmobile::Mobile::Au::IP_ADDRESSES =
|
1
|
+
Jpmobile::Mobile::Au::IP_ADDRESSES =
|
2
2
|
["210.230.128.224/28",
|
3
3
|
"121.111.227.160/27",
|
4
4
|
"61.117.1.0/28",
|
@@ -23,4 +23,5 @@ Jpmobile::Mobile::Au::IP_ADDRESSES =
|
|
23
23
|
"111.86.142.0/26",
|
24
24
|
"111.86.141.64/26",
|
25
25
|
"111.86.141.128/26",
|
26
|
-
"111.86.141.192/26"
|
26
|
+
"111.86.141.192/26",
|
27
|
+
"118.159.133.192/26"].map {|ip| IPAddr.new(ip) }
|
data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/z_ip_addresses_docomo.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# = IPアドレス帯域テーブル(手動更新分)
|
2
3
|
# == DoCoMo
|
3
4
|
# http://www.nttdocomo.co.jp/service/imode/make/content/ip/index.html
|
@@ -8,5 +9,7 @@ Jpmobile::Mobile::Docomo::IP_ADDRESSES = %w(
|
|
8
9
|
210.153.86.0/24
|
9
10
|
124.146.174.0/24
|
10
11
|
124.146.175.0/24
|
12
|
+
202.229.176.0/24
|
13
|
+
202.229.177.0/24
|
14
|
+
202.229.178.0/24
|
11
15
|
).map {|ip| IPAddr.new(ip) }
|
12
|
-
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#= 位置情報
|
2
3
|
|
3
|
-
#
|
4
|
+
# Rack 化にあわせて gem を見るように
|
4
5
|
begin
|
5
|
-
require
|
6
|
-
rescue
|
6
|
+
require 'geokit'
|
7
|
+
rescue LoadError
|
7
8
|
end
|
8
9
|
|
9
10
|
module Jpmobile
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
1
3
|
# jpmobile の各機能を提供するモジュール
|
2
|
-
# env
|
3
|
-
# 今のところはRack::RequestとActionController::AbstractRequestに対応しているはず。
|
4
|
+
# envメソッドが実装されている必要がある。
|
4
5
|
|
5
6
|
module Jpmobile
|
6
7
|
module RequestWithMobile
|
@@ -11,8 +12,10 @@ module Jpmobile
|
|
11
12
|
|
12
13
|
# for reverse proxy.
|
13
14
|
def remote_addr
|
14
|
-
if respond_to?
|
15
|
-
return __send__(:remote_ip)
|
15
|
+
if respond_to?(:remote_ip)
|
16
|
+
return __send__(:remote_ip) # for Rails
|
17
|
+
elsif respond_to?(:ip)
|
18
|
+
return __send__(:ip) # for Rack
|
16
19
|
else
|
17
20
|
return ( env["HTTP_X_FORWARDED_FOR"] ? env["HTTP_X_FORWARDED_FOR"].split(',').pop : env["REMOTE_ADDR"] )
|
18
21
|
end
|
@@ -25,20 +28,18 @@ module Jpmobile
|
|
25
28
|
|
26
29
|
# 携帯電話からであれば +true+を、そうでなければ +false+ を返す。
|
27
30
|
def mobile?
|
28
|
-
mobile
|
31
|
+
mobile and not mobile.smart_phone?
|
32
|
+
end
|
33
|
+
|
34
|
+
# viewの切り替えをするかどうか
|
35
|
+
def smart_phone?
|
36
|
+
mobile and mobile.smart_phone?
|
29
37
|
end
|
30
38
|
|
31
39
|
# 携帯電話の機種に応じて Mobile::xxx を返す。
|
32
40
|
# 携帯電話でない場合はnilを返す。
|
33
41
|
def mobile
|
34
|
-
|
35
|
-
|
36
|
-
Jpmobile::Mobile.carriers.each do |const|
|
37
|
-
c = Jpmobile::Mobile.const_get(const)
|
38
|
-
return @__mobile = c.new(self) if c::USER_AGENT_REGEXP && user_agent =~ c::USER_AGENT_REGEXP
|
39
|
-
end
|
40
|
-
nil
|
42
|
+
env['rack.jpmobile']
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
44
|
-
|