Class: Jpmobile::Mobile::Au

Inherits:
AbstractMobile show all
Defined in:
lib/jpmobile/mobile/au.rb

Overview

au携帯電話

CDMA 1X, CDMA 1X WINを含む。

Constant Summary

USER_AGENT_REGEXP =

対応するUser-Agentの正規表現 User-Agent文字列中に “UP.Browser” を含むVodafoneの端末があるので注意が必要

/^(?:KDDI|UP.Browser\/.+?)-(.+?) /
MAIL_ADDRESS_REGEXP =

対応するメールアドレスの正規表現

/.+@ezweb\.ne\.jp/
LOCATION_UNSUPPORTED_DEVICE_ID =

簡易位置情報取得に対応していないデバイスID www.au.kddi.com/ezfactory/tec/spec/eznavi.html

["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"]
GPS_UNSUPPORTED_DEVICE_ID =

GPS取得に対応していないデバイスID

["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"]

Constants inherited from AbstractMobile

Jpmobile::Mobile::AbstractMobile::MAIL_CHARSET, Jpmobile::Mobile::AbstractMobile::MAIL_CONTENT_TRANSFER_ENCODING

Instance Method Summary (collapse)

Methods inherited from AbstractMobile

add_user_agent_regexp, #apply_filter?, #apply_params_filter?, carrier, check_carrier, #content_transfer_encoding, #decode_transfer_encoding, #decorated=, #decorated?, #display, #ident, #ident_device, #initialize, ip_address_class, #mail_charset, #mail_variants, #require_related_part?, #smart_phone?, #tablet?, #to_mail_body_encoded?, #to_mail_subject, #to_mail_subject_encoded?, user_agent_regexp, #utf8_to_mail_encode, #valid_ip?, valid_ip?, #variants

Constructor Details

This class inherits a constructor from Jpmobile::Mobile::AbstractMobile

Instance Method Details

- (Boolean) decoratable?



121
122
123
# File 'lib/jpmobile/mobile/au.rb', line 121

def decoratable?
  true
end

- (Object) default_charset



103
104
105
# File 'lib/jpmobile/mobile/au.rb', line 103

def default_charset
  "Shift_JIS"
end

- (Object) device_id

デバイスIDを返す



53
54
55
56
57
58
59
# File 'lib/jpmobile/mobile/au.rb', line 53

def device_id
  if @request.env['HTTP_USER_AGENT'] =~ USER_AGENT_REGEXP
    return $1
  else
    nil
  end
end

- (Object) position

位置情報があれば Position のインスタンスを返す。無ければ nil を返す。



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jpmobile/mobile/au.rb', line 26

def position
  return @__posotion if defined? @__posotion
  return @__posotion = nil if ( params["lat"].nil? || params['lat'] == '' || params["lon"].nil? || params["lon"] == '' )
  l = Jpmobile::Position.new
  l.options = params.reject {|x,v| !["ver", "datum", "unit", "lat", "lon", "alt", "time", "smaj", "smin", "vert", "majaa", "fm"].include?(x) }
  case params["unit"]
  when "1"
    l.lat = params["lat"].to_f
    l.lon = params["lon"].to_f
  when "0", "dms"
    raise "Invalid dms form" unless params["lat"] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/
    l.lat = Jpmobile::Position.dms2deg($1,$2,$3)
    raise "Invalid dms form" unless params["lon"] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/
    l.lon = Jpmobile::Position.dms2deg($1,$2,$3)
  else
    return @__posotion = nil
  end
  if params["datum"] == "1"
    # ただし、params["datum"]=="tokyo"のとき(簡易位置情報)のときは、
    # 実際にはWGS84系のデータが渡ってくる
    # http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
    l.tokyo2wgs84!
  end
  return @__posotion = l
end

- (Object) subno Also known as: ident_subscriber

EZ番号(サブスクライバID)があれば返す。無ければ nil を返す。



20
21
22
# File 'lib/jpmobile/mobile/au.rb', line 20

def subno
  @request.env["HTTP_X_UP_SUBNO"]
end

- (Boolean) supports_cookie?

cookieに対応しているか?



72
73
74
75
76
77
78
79
# File 'lib/jpmobile/mobile/au.rb', line 72

def supports_cookie?
  protocol = @request.respond_to?(:scheme) ? @request.scheme : @request.protocol rescue "none"
  if protocol =~ /\Ahttps/
    false
  else
    true
  end
end

- (Boolean) supports_gps?

GPS位置情報取得に対応している場合は true を返す。



67
68
69
# File 'lib/jpmobile/mobile/au.rb', line 67

def supports_gps?
  ! GPS_UNSUPPORTED_DEVICE_ID.include?(device_id)
end

- (Boolean) supports_location?

簡易位置情報取得に対応している場合は true を返す。



62
63
64
# File 'lib/jpmobile/mobile/au.rb', line 62

def supports_location?
  ! LOCATION_UNSUPPORTED_DEVICE_ID.include?(device_id)
end

- (Object) to_external(str, content_type, charset)



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/jpmobile/mobile/au.rb', line 90

def to_external(str, content_type, charset)
  # UTF-8を数値参照に
  str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
  # 文字コードを Shift_JIS に変換
  if [nil, "text/html", "application/xhtml+xml"].include?(content_type)
    str = Jpmobile::Util.utf8_to_sjis(str)
    charset = default_charset unless str.empty?
  end
  # 数値参照を絵文字コードに変換
  str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_AU, true)

  [str, charset]
end

- (Object) to_internal(str)

文字コード変換



82
83
84
85
86
87
88
89
# File 'lib/jpmobile/mobile/au.rb', line 82

def to_internal(str)
  # 絵文字を数値参照に変換
  str = Jpmobile::Emoticon.external_to_unicodecr_au(Jpmobile::Util.sjis(str))
  # 文字コードを UTF-8 に変換
  str = Jpmobile::Util.sjis_to_utf8(str)
  # 数値参照を UTF-8 に変換
  Jpmobile::Emoticon::unicodecr_to_utf8(str)
end

- (Object) to_mail_body(str)

メール送信用



108
109
110
# File 'lib/jpmobile/mobile/au.rb', line 108

def to_mail_body(str)
  to_mail_encoding(str)
end

- (Object) to_mail_internal(str, charset)



112
113
114
115
116
117
118
119
# File 'lib/jpmobile/mobile/au.rb', line 112

def to_mail_internal(str, charset)
  if Jpmobile::Util.jis?(str) or Jpmobile::Util.ascii_8bit?(str) or charset == mail_charset
    # 絵文字を数値参照に変換
    str = Jpmobile::Emoticon.external_to_unicodecr_au_mail(Jpmobile::Util.jis(str))
    str = Jpmobile::Util.jis_to_utf8(Jpmobile::Util.jis_win(str))
  end
  str
end