Class: Jpmobile::Mobile::Softbank

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

Overview

Softbank携帯電話

Vodafoneのスーパクラス。

Direct Known Subclasses

Vodafone

Constant Summary

USER_AGENT_REGEXP =

対応するuser-agentの正規表現

/^(?:SoftBank|Semulator)/
MAIL_ADDRESS_REGEXP =

対応するメールアドレスの正規表現 ディズニーモバイル対応

/.+@(?:softbank\.ne\.jp|disney\.ne\.jp)/
MAIL_CHARSET =

メールのデフォルトのcharset

"Shift_JIS"
MAIL_CONTENT_TRANSFER_ENCODING =

テキスト部分の content-transfer-encoding

'8bit'

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?, #default_charset, #display, #ident, #initialize, ip_address_class, #mail_charset, #mail_variants, #smart_phone?, #tablet?, #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

#decoratable?Boolean



85
86
87
# File 'lib/jpmobile/mobile/softbank.rb', line 85

def decoratable?
  true
end

#positionObject

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



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jpmobile/mobile/softbank.rb', line 31

def position
  return @__position if defined? @__position
  if params["pos"] =~ /^([NS])(\d+)\.(\d+)\.(\d+\.\d+)([WE])(\d+)\.(\d+)\.(\d+\.\d+)$/
    raise "Unsupported datum" if params["geo"] != "wgs84"
    l = Jpmobile::Position.new
    l.lat = ($1=="N" ? 1 : -1) * Jpmobile::Position.dms2deg($2,$3,$4)
    l.lon = ($5=="E" ? 1 : -1) * Jpmobile::Position.dms2deg($6,$7,$8)
    l.options = params.reject {|x,v| !["pos","geo","x-acr"].include?(x) }
    return @__position = l
  else
    return @__position = nil
  end
end


88
89
90
# File 'lib/jpmobile/mobile/softbank.rb', line 88

def require_related_part?
  true
end

#serial_numberObject Also known as: ident_device

製造番号を返す。無ければ nil を返す。



18
19
20
21
# File 'lib/jpmobile/mobile/softbank.rb', line 18

def serial_number
  @request.env['HTTP_USER_AGENT'] =~ /SN(.+?) /
  return $1
end

#supports_cookie?Boolean

cookieに対応しているか?



46
47
48
# File 'lib/jpmobile/mobile/softbank.rb', line 46

def supports_cookie?
  true
end

#to_external(str, content_type, charset) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/jpmobile/mobile/softbank.rb', line 57

def to_external(str, content_type, charset)
  # UTF-8を数値参照に
  str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
  # 数値参照を絵文字コードに変換
  str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, false)

  [str, charset]
end

#to_internal(str) ⇒ Object

文字コード変換



51
52
53
54
55
56
# File 'lib/jpmobile/mobile/softbank.rb', line 51

def to_internal(str)
  # 絵文字を数値参照に変換
  str = Jpmobile::Emoticon.external_to_unicodecr_softbank(Jpmobile::Util.utf8(str))
  # 数値参照を UTF-8 に変換
  Jpmobile::Emoticon::unicodecr_to_utf8(str)
end

#to_mail_body(str) ⇒ Object

メール送信用



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

def to_mail_body(str)
  to_mail_encoding(str)
end

#to_mail_body_encoded?(str) ⇒ Boolean



82
83
84
# File 'lib/jpmobile/mobile/softbank.rb', line 82

def to_mail_body_encoded?(str)
  Jpmobile::Util.shift_jis?(str)
end

#to_mail_internal(str, charset) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/jpmobile/mobile/softbank.rb', line 70

def to_mail_internal(str, charset)
  # 絵文字を数値参照に変換
  if Jpmobile::Util.utf8?(str) or charset == "UTF-8"
    # UTF-8
    str = Jpmobile::Emoticon.external_to_unicodecr_softbank(Jpmobile::Util.utf8(str))
  elsif Jpmobile::Util.shift_jis?(str) or Jpmobile::Util.ascii_8bit?(str) or charset == mail_charset
    # Shift_JIS
    str = Jpmobile::Emoticon.external_to_unicodecr_softbank_sjis(Jpmobile::Util.sjis(str))
  end

  str
end

#x_jphone_uidObject Also known as: ident_subscriber

UIDを返す。



25
26
27
# File 'lib/jpmobile/mobile/softbank.rb', line 25

def x_jphone_uid
  @request.env["HTTP_X_JPHONE_UID"]
end