jpmobile 1.0.0.pre.4 → 1.0.0.pre.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +4 -0
- data/Gemfile +3 -3
- data/VERSION.yml +2 -2
- data/jpmobile.gemspec +335 -0
- data/lib/jpmobile.rb +0 -1
- data/lib/jpmobile/email.rb +47 -21
- data/lib/jpmobile/mail.rb +33 -26
- data/lib/jpmobile/mailer.rb +2 -0
- data/lib/jpmobile/util.rb +3 -3
- data/spec/unit/email-fixtures/au-attached.eml +1551 -0
- data/spec/unit/email-fixtures/au-decomail.eml +44 -0
- data/spec/unit/email-fixtures/au-emoji.eml +19 -0
- data/spec/unit/email-fixtures/au-emoji2.eml +45 -0
- data/spec/unit/email-fixtures/au-emoji5.eml +24 -0
- data/spec/unit/email-fixtures/docomo-emoji.eml +19 -0
- data/spec/unit/email-fixtures/docomo-gmail-sjis.eml +45 -0
- data/spec/unit/email-fixtures/docomo-jis.eml +20 -0
- data/spec/unit/email-fixtures/pc-mail-multi.eml +77 -0
- data/spec/unit/email-fixtures/pc-mail-single.eml +29 -0
- data/spec/unit/email-fixtures/softbank-blank.eml +20 -0
- data/spec/unit/email-fixtures/softbank-emoji-utf8.eml +19 -0
- data/spec/unit/email-fixtures/softbank-emoji.eml +19 -0
- data/spec/unit/email-fixtures/softbank-gmail-sjis.eml +45 -0
- data/spec/unit/email-fixtures/softbank-gmail-utf8.eml +45 -0
- data/spec/unit/{detect_by_email_spec.rb → email_spec.rb} +25 -2
- data/spec/unit/emoticon_spec.rb +1 -1
- data/spec/unit/encoding_spec.rb +1 -1
- data/spec/unit/is_carrier_spec.rb +1 -1
- data/spec/unit/mail_spec.rb +1 -1
- data/spec/unit/receive_mail_spec.rb +26 -1
- data/spec/unit/util_spec.rb +1 -1
- data/spec/unit/valid_ip_spec.rb +1 -1
- data/test/rails/.gitignore +1 -0
- data/test/rails/overrides/.rspec +5 -0
- data/test/rails/overrides/Gemfile +33 -0
- data/test/rails/overrides/app/views/filter/index.html.erb +0 -0
- data/test/rails/overrides/app/views/hankaku_filter/index.html.erb +0 -0
- data/test/rails/overrides/app/views/hankaku_input_filter/index.html.erb +0 -0
- data/test/rails/overrides/app/views/hankaku_input_filter/index_xhtml.html.erb +1 -0
- data/test/rails/overrides/app/views/layouts/xhtml.html.erb +12 -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/mobile_mailer/multi_message.html.erb +11 -0
- data/test/rails/overrides/app/views/mobile_mailer/multi_message.text.erb +2 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection.html.erb +3 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile.html.erb +3 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_au.html.erb +3 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_docomo.html.erb +3 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_emobile.html.erb +3 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_softbank.html.erb +3 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_vodafone.html.erb +3 -0
- data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_willcom.html.erb +3 -0
- data/test/rails/overrides/app/views/normal_mailer/msg.text.erb +3 -0
- data/test/rails/overrides/app/views/template_path/_partial.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_mobile_docomo.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.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_mobile_docomo.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/partial.html.erb +2 -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/spec/fixtures/mobile_mailer/au-attached.eml +1551 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml +44 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji.eml +19 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji2.eml +45 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji5.eml +24 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-emoji.eml +19 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml +45 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-jis.eml +20 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/no-from.eml +78 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/non-jp.eml +45 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-blank.eml +20 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-emoji-utf8.eml +19 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-emoji.eml +19 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml +45 -0
- data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml +45 -0
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +1 -2
- data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +37 -1
- data/test/rails/overrides/spec/models/normal_mailer_spec.rb +1 -1
- data/test/rails/overrides/spec/rcov.opts +2 -0
- data/test/rails/overrides/spec/requests/docomo_guid_spec.rb +1 -2
- data/test/rails/overrides/spec/requests/docomo_spec.rb +1 -2
- data/test/rails/overrides/spec/requests/emobile_spec.rb +1 -2
- data/test/rails/overrides/spec/requests/filter_spec.rb +1 -1
- data/test/rails/overrides/spec/requests/helpers_spec.rb +1 -1
- data/test/rails/overrides/spec/requests/pc_spec.rb +1 -2
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +1 -2
- data/test/rails/overrides/spec/requests/template_path_spec.rb +1 -2
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +1 -2
- data/test/rails/overrides/spec/spec_helper.rb +1 -1
- metadata +229 -386
- data/test/rails/rails_root/app/controllers/application_controller.rb +0 -6
- data/test/rails/rails_root/app/controllers/docomo_guid_always_controller.rb +0 -3
- data/test/rails/rails_root/app/controllers/docomo_guid_base_controller.rb +0 -5
- data/test/rails/rails_root/app/controllers/docomo_guid_docomo_controller.rb +0 -3
- data/test/rails/rails_root/app/controllers/filter_controller.rb +0 -3
- data/test/rails/rails_root/app/controllers/filter_controller_base.rb +0 -25
- data/test/rails/rails_root/app/controllers/hankaku_filter_controller.rb +0 -3
- data/test/rails/rails_root/app/controllers/hankaku_input_filter_controller.rb +0 -7
- data/test/rails/rails_root/app/controllers/links_controller.rb +0 -28
- data/test/rails/rails_root/app/controllers/mobile_spec_controller.rb +0 -5
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +0 -17
- data/test/rails/rails_root/app/controllers/trans_sid_always_and_session_off_controller.rb +0 -4
- data/test/rails/rails_root/app/controllers/trans_sid_always_controller.rb +0 -3
- data/test/rails/rails_root/app/controllers/trans_sid_base_controller.rb +0 -40
- data/test/rails/rails_root/app/controllers/trans_sid_metal_controller.rb +0 -15
- data/test/rails/rails_root/app/controllers/trans_sid_mobile_controller.rb +0 -3
- data/test/rails/rails_root/app/controllers/trans_sid_none_controller.rb +0 -3
- data/test/rails/rails_root/app/helpers/application_helper.rb +0 -2
- data/test/rails/rails_root/app/models/mobile_mailer.rb +0 -19
- data/test/rails/rails_root/app/models/normal_mailer.rb +0 -9
- data/test/rails/rails_root/app/models/user.rb +0 -2
- data/test/rails/rails_root/autotest/discover.rb +0 -2
- data/test/rails/rails_root/config/application.rb +0 -42
- data/test/rails/rails_root/config/boot.rb +0 -6
- data/test/rails/rails_root/config/environment.rb +0 -5
- data/test/rails/rails_root/config/environments/development.rb +0 -26
- data/test/rails/rails_root/config/environments/production.rb +0 -49
- data/test/rails/rails_root/config/environments/test.rb +0 -35
- data/test/rails/rails_root/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails/rails_root/config/initializers/inflections.rb +0 -10
- data/test/rails/rails_root/config/initializers/jpmobile_generator.rb +0 -2
- data/test/rails/rails_root/config/initializers/mime_types.rb +0 -5
- data/test/rails/rails_root/config/initializers/secret_token.rb +0 -7
- data/test/rails/rails_root/config/initializers/session_store.rb +0 -2
- data/test/rails/rails_root/config/routes.rb +0 -7
- data/test/rails/rails_root/db/migrate/001_add_sessions_table.rb +0 -16
- data/test/rails/rails_root/db/migrate/20100824062306_create_users.rb +0 -13
- data/test/rails/rails_root/db/schema.rb +0 -31
- data/test/rails/rails_root/db/seeds.rb +0 -7
- data/test/rails/rails_root/spec/helpers/helpers_spec.rb +0 -15
- data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +0 -737
- data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +0 -34
- data/test/rails/rails_root/spec/requests/docomo_guid_spec.rb +0 -102
- data/test/rails/rails_root/spec/requests/docomo_spec.rb +0 -33
- data/test/rails/rails_root/spec/requests/emobile_spec.rb +0 -53
- data/test/rails/rails_root/spec/requests/filter_spec.rb +0 -221
- data/test/rails/rails_root/spec/requests/helpers_spec.rb +0 -187
- data/test/rails/rails_root/spec/requests/pc_spec.rb +0 -22
- data/test/rails/rails_root/spec/requests/softbank_emulator_spec.rb +0 -21
- data/test/rails/rails_root/spec/requests/template_path_spec.rb +0 -240
- data/test/rails/rails_root/spec/requests/trans_sid_spec.rb +0 -207
- data/test/rails/rails_root/spec/spec_helper.rb +0 -38
- data/test/rails/rails_root/test/performance/browsing_test.rb +0 -9
- data/test/rails/rails_root/test/test_helper.rb +0 -13
- data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile-ipaddresses.rb +0 -18
- data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb +0 -23
- data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/au.rb +0 -40
- data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/docomo.rb +0 -22
- data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/emobile.rb +0 -15
- data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/softbank.rb +0 -20
- data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/willcom.rb +0 -158
- data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile-terminfo.rb +0 -9
- data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile/mobile/terminfo.rb +0 -62
- data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile/mobile/terminfo/docomo.rb +0 -739
- data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/spec/spec_helper.rb +0 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/spec/terminfo_spec.rb +0 -54
- data/test/rails/rails_root/vendor/plugins/jpmobile/init.rb +0 -3
- data/test/rails/rails_root/vendor/plugins/jpmobile/install.rb +0 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +0 -59
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/datum_conv.rb +0 -72
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb +0 -43
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/email.rb +0 -33
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +0 -205
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/au.rb +0 -1931
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/conversion_table.rb +0 -3909
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/docomo.rb +0 -255
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/softbank.rb +0 -965
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/z_combine.rb +0 -36
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/encoding.rb +0 -29
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/filter.rb +0 -113
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/helpers.rb +0 -174
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +0 -18
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_dispatch.rb +0 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +0 -33
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/lookup_context.rb +0 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +0 -330
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +0 -41
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +0 -168
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/android.rb +0 -10
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +0 -128
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/ddipocket.rb +0 -12
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +0 -149
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/emobile.rb +0 -16
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/iphone.rb +0 -26
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/smart_phone.rb +0 -21
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +0 -91
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/vodafone.rb +0 -17
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/willcom.rb +0 -28
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/windows_phone.rb +0 -10
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +0 -40
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/position.rb +0 -68
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack.rb +0 -49
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/filter.rb +0 -50
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/mobile_carrier.rb +0 -33
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +0 -47
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +0 -50
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/request_with_mobile.rb +0 -45
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +0 -38
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/trans_sid.rb +0 -133
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +0 -370
- data/test/rails/rails_root/vendor/plugins/jpmobile/tmp/conversion-table.rb +0 -2588
- data/test/rails/rails_root/vendor/plugins/jpmobile/tmp/utf8_to_image.rb +0 -1407
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/emoji/genregexp.rb +0 -47
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_au_emoticon_table.rb +0 -34
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_docomo_emoticon_table.rb +0 -33
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_emoticon_conversion_table.rb +0 -107
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_softbank_emoticon_table.rb +0 -31
- data/test/rails/rails_root/vendor/plugins/jpmobile/tools/list_gps_unsupported_au.rb +0 -23
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses.rb +0 -18
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb +0 -23
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/au.rb +0 -40
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/docomo.rb +0 -22
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/emobile.rb +0 -15
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/softbank.rb +0 -20
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/willcom.rb +0 -158
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile-terminfo.rb +0 -9
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile/mobile/terminfo.rb +0 -62
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile/mobile/terminfo/docomo.rb +0 -739
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/spec/spec_helper.rb +0 -2
- data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/spec/terminfo_spec.rb +0 -54
@@ -1,36 +0,0 @@
|
|
1
|
-
unless Object.const_defined?(:Encoding)
|
2
|
-
$KCODE = 'u'
|
3
|
-
end
|
4
|
-
|
5
|
-
module Jpmobile
|
6
|
-
module Emoticon
|
7
|
-
GETA = 0x3013
|
8
|
-
|
9
|
-
SJIS_TO_UNICODE = {}
|
10
|
-
SJIS_TO_UNICODE.update(DOCOMO_SJIS_TO_UNICODE)
|
11
|
-
SJIS_TO_UNICODE.update(AU_SJIS_TO_UNICODE)
|
12
|
-
SJIS_TO_UNICODE.freeze
|
13
|
-
UNICODE_TO_SJIS = SJIS_TO_UNICODE.invert.freeze
|
14
|
-
|
15
|
-
# for au email
|
16
|
-
SJIS_TO_EMAIL_JIS = {0x81ac => 0x222E}
|
17
|
-
SJIS_TO_EMAIL_JIS.update(AU_SJIS_TO_EMAIL_JIS)
|
18
|
-
SJIS_TO_EMAIL_JIS.freeze
|
19
|
-
|
20
|
-
SJIS_REGEXP = Regexp.union(*SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
21
|
-
SOFTBANK_WEBCODE_REGEXP = Regexp.union(*([/(?!)/n]+SOFTBANK_WEBCODE_TO_UNICODE.keys.map{|x| "\x1b\x24#{x}\x0f"}))
|
22
|
-
|
23
|
-
DOCOMO_SJIS_REGEXP = Regexp.union(*DOCOMO_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
24
|
-
AU_SJIS_REGEXP = Regexp.union(*AU_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)})
|
25
|
-
SOFTBANK_UNICODE_REGEXP = Regexp.union(*SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|x| [x].pack('U')}).freeze
|
26
|
-
|
27
|
-
EMOTICON_UNICODES = UNICODE_TO_SJIS.keys|SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|k|k+0x1000}
|
28
|
-
UTF8_REGEXP = Regexp.union(*EMOTICON_UNICODES.map{|x| [x].pack('U')}).freeze
|
29
|
-
|
30
|
-
# for PC conversion "GETA"
|
31
|
-
CONVERSION_TABLE_TO_PC_EMAIL = Hash[*(CONVERSION_TABLE_TO_SOFTBANK.keys|CONVERSION_TABLE_TO_DOCOMO.keys|CONVERSION_TABLE_TO_AU.keys).map{|k| [k, GETA]}.flatten]
|
32
|
-
|
33
|
-
SOFTBANK_SJIS_REGEXP = Regexp.union(*SOFTBANK_SJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.sjis_regexp(s)}).freeze
|
34
|
-
AU_EMAILJIS_REGEXP = Regexp.union(*AU_EMAILJIS_TO_UNICODE.keys.map{|s| Jpmobile::Util.jis_regexp(s)})
|
35
|
-
end
|
36
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# params を UTF-8 にする拡張
|
3
|
-
module Jpmobile
|
4
|
-
module Encoding
|
5
|
-
def self.included(base)
|
6
|
-
base.class_eval do
|
7
|
-
alias_method :parameters_without_jpmobile, :parameters
|
8
|
-
|
9
|
-
def parameters
|
10
|
-
return @parameters if @jpmobile_params_converted
|
11
|
-
|
12
|
-
# load params
|
13
|
-
@parameters = parameters_without_jpmobile
|
14
|
-
# 変換
|
15
|
-
@parameters = Jpmobile::Util.deep_convert(@parameters) do |value|
|
16
|
-
value = Jpmobile::Util.utf8(value)
|
17
|
-
end
|
18
|
-
|
19
|
-
@jpmobile_params_converted = true
|
20
|
-
if @parameters.respond_to?(:with_indifferent_access)
|
21
|
-
@parameters = @parameters.with_indifferent_access
|
22
|
-
end
|
23
|
-
|
24
|
-
@parameters
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# = 半角変換フィルター
|
3
|
-
# thanks to masuidrive <masuidrive (at) masuidrive.jp>
|
4
|
-
|
5
|
-
class ActionController::Base #:nodoc:
|
6
|
-
def self.hankaku_filter(options={})
|
7
|
-
options = {:input => false}.update(options)
|
8
|
-
|
9
|
-
before_filter lambda {|controller| Jpmobile::HankakuFilter.before(controller, options)}
|
10
|
-
after_filter lambda {|controller| Jpmobile::HankakuFilter.after(controller, options)}
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.mobile_filter(options={})
|
14
|
-
STDERR.puts "Method mobile_filter is now deprecated. Use hankaku_filter instead for Hankaku-conversion."
|
15
|
-
|
16
|
-
self.hankaku_filter(options)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module Jpmobile
|
21
|
-
module HankakuFilter
|
22
|
-
module_function
|
23
|
-
|
24
|
-
# 入出力フィルタの適用条件
|
25
|
-
def apply_incoming?(controller)
|
26
|
-
controller.request.mobile?
|
27
|
-
end
|
28
|
-
def apply_outgoing?(controller)
|
29
|
-
controller.request.mobile? and
|
30
|
-
[nil, "text/html", "application/xhtml+xml"].include?(controller.response.content_type)
|
31
|
-
end
|
32
|
-
|
33
|
-
def before(controller, options = {})
|
34
|
-
if apply_incoming?(controller)
|
35
|
-
Util.deep_apply(controller.params) do |value|
|
36
|
-
value = to_internal(value, options)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
# 内部コードから外部コードに変換
|
41
|
-
def after(controller, options = {})
|
42
|
-
if apply_outgoing?(controller) and controller.response.body.is_a?(String)
|
43
|
-
controller.response.body = to_external(controller.response.body, options)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
@@internal = %w(ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ ヴ ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン ャ ュ ョ ァ ィ ゥ ェ ォ ッ ゛ ゜ ー 。 「 」 、 ・ ! ?).freeze
|
48
|
-
@@external = %w(ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ ヴ ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン ャ ュ ョ ァ ィ ゥ ェ ォ ッ ゙ ゚ ー 。 「 」 、 ・ ! ?).freeze
|
49
|
-
def to_internal(str, options = {})
|
50
|
-
filter(str, @@external, @@internal)
|
51
|
-
end
|
52
|
-
def to_external(str, options = {})
|
53
|
-
unless options[:input]
|
54
|
-
filter(str, @@internal, @@external)
|
55
|
-
else
|
56
|
-
encoding = (str =~ /^\s*<[^Hh>]*html/) and str.respond_to?(:encoding)
|
57
|
-
nokogiri_klass =
|
58
|
-
(str =~ /^\s*<[^Hh>]*html/) ? Nokogiri::HTML::Document : Nokogiri::HTML::DocumentFragment
|
59
|
-
doc = if encoding
|
60
|
-
nokogiri_klass.parse(str, nil, "UTF-8")
|
61
|
-
else
|
62
|
-
nokogiri_klass.parse(str)
|
63
|
-
end
|
64
|
-
|
65
|
-
doc = convert_text_content(doc)
|
66
|
-
|
67
|
-
doc.to_html
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def filter(str, from, to)
|
72
|
-
str = str.clone
|
73
|
-
|
74
|
-
# 一度UTF-8に変換
|
75
|
-
before_encoding = nil
|
76
|
-
if str.respond_to?(:force_encoding)
|
77
|
-
before_encoding = str.encoding
|
78
|
-
str.force_encoding("UTF-8")
|
79
|
-
end
|
80
|
-
|
81
|
-
from.each_with_index do |int, i|
|
82
|
-
str.gsub!(int, to[i])
|
83
|
-
end
|
84
|
-
|
85
|
-
# 元に戻す
|
86
|
-
if before_encoding
|
87
|
-
str.force_encoding(before_encoding)
|
88
|
-
end
|
89
|
-
|
90
|
-
str
|
91
|
-
end
|
92
|
-
|
93
|
-
# 再帰的に探す
|
94
|
-
def convert_text_content(document)
|
95
|
-
document.children.each do |element|
|
96
|
-
if element.kind_of?(Nokogiri::XML::Text)
|
97
|
-
unless element.parent.node_name == "textarea"
|
98
|
-
# textarea 以外のテキストなら content を変換
|
99
|
-
element.content = filter(element.content, @@internal, @@external)
|
100
|
-
end
|
101
|
-
elsif element.node_name == "input" and ["submit", "reset", "button"].include?(element["type"])
|
102
|
-
# テキスト以外でもボタンの value は変換
|
103
|
-
element["value"] = filter(element["value"], @@internal, @@external)
|
104
|
-
elsif element.children.any?
|
105
|
-
# 子要素があれば再帰的に変換
|
106
|
-
element = convert_text_content(element)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
document
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
@@ -1,174 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# =位置情報等を要求するヘルパー
|
3
|
-
module Jpmobile
|
4
|
-
# 携帯電話端末に位置情報を要求するための、特殊なリンクを出力するヘルパー群。
|
5
|
-
# 多くのキャリアでは特殊なFORMでも位置情報を要求できる。
|
6
|
-
module Helpers
|
7
|
-
# 位置情報(緯度経度がとれるもの。オープンiエリアをのぞく)要求するリンクを作成する。
|
8
|
-
# 位置情報を受け取るページを +url_for+ に渡す引数の形式で +options+ に指定する。
|
9
|
-
# :show_all => +true+ とするとキャリア判別を行わず全てキャリアのリンクを返す。
|
10
|
-
# 第1引数に文字列を与えるとその文字列をアンカーテキストにする。
|
11
|
-
# 第1引数がHashの場合はデフォルトのアンカーテキストを出力する。
|
12
|
-
def get_position_link_to(str=nil, options={})
|
13
|
-
if str.is_a?(Hash)
|
14
|
-
options = str
|
15
|
-
str = nil
|
16
|
-
end
|
17
|
-
show_all = nil
|
18
|
-
if options.is_a?(Hash)
|
19
|
-
options = options.symbolize_keys
|
20
|
-
show_all = options.delete(:show_all)
|
21
|
-
end
|
22
|
-
|
23
|
-
# TODO: コード汚い
|
24
|
-
s = []
|
25
|
-
if show_all || request.mobile.instance_of?(Mobile::Docomo)
|
26
|
-
s << docomo_foma_gps_link_to(str||"DoCoMo FOMA(GPS)", options)
|
27
|
-
end
|
28
|
-
if show_all || request.mobile.instance_of?(Mobile::Au)
|
29
|
-
if show_all || request.mobile.supports_gps?
|
30
|
-
s << au_gps_link_to(str||"au(GPS)", options)
|
31
|
-
end
|
32
|
-
if show_all || (!(request.mobile.supports_gps?) && request.mobile.supports_location?)
|
33
|
-
s << au_location_link_to(str||"au(antenna)", options)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
if show_all || request.mobile.instance_of?(Mobile::Vodafone) || request.mobile.instance_of?(Mobile::Softbank)
|
37
|
-
s << softbank_location_link_to(str||"Softbank 3G(GPS)", options)
|
38
|
-
end
|
39
|
-
if show_all || request.mobile.instance_of?(Mobile::Willcom)
|
40
|
-
s << willcom_location_link_to(str||"Willcom", options)
|
41
|
-
end
|
42
|
-
return s.join("<br>\n").html_safe
|
43
|
-
end
|
44
|
-
|
45
|
-
# DoCoMo FOMAでGPS位置情報を取得するためのリンクを返す。
|
46
|
-
def docomo_foma_gps_link_to(str, options={})
|
47
|
-
url = options
|
48
|
-
if options.is_a?(Hash)
|
49
|
-
options = options.symbolize_keys
|
50
|
-
options[:only_path] = false
|
51
|
-
url = url_for(options)
|
52
|
-
end
|
53
|
-
return %{<a href="#{url}" lcs>#{str}</a>}.html_safe
|
54
|
-
end
|
55
|
-
|
56
|
-
# DoCoMoでオープンiエリアを取得するためのURLを返す。
|
57
|
-
def docomo_openiarea_url_for(options={})
|
58
|
-
url = options
|
59
|
-
if options.is_a?(Hash)
|
60
|
-
options = options.symbolize_keys
|
61
|
-
options[:only_path] = false
|
62
|
-
posinfo = options.delete(:posinfo) || "1" # 基地局情報を元に測位した緯度経度情報を要求
|
63
|
-
url = url_for(options)
|
64
|
-
else
|
65
|
-
posinfo = "1"
|
66
|
-
end
|
67
|
-
return "http://w1m.docomo.ne.jp/cp/iarea?ecode=OPENAREACODE&msn=OPENAREAKEY&posinfo=#{posinfo}&nl=#{CGI.escape(url)}"
|
68
|
-
end
|
69
|
-
|
70
|
-
# DoCoMoでオープンiエリアを取得するためのリンクを返す。
|
71
|
-
def docomo_openiarea_link_to(str, options={})
|
72
|
-
link_to_url(str, docomo_openiarea_url_for(options))
|
73
|
-
end
|
74
|
-
|
75
|
-
# DoCoMoで端末製造番号等を取得するためのリンクを返す。
|
76
|
-
def docomo_utn_link_to(str, options={})
|
77
|
-
url = options
|
78
|
-
if options.is_a?(Hash)
|
79
|
-
options = options.symbolize_keys
|
80
|
-
options[:only_path] = false
|
81
|
-
url = url_for(options)
|
82
|
-
end
|
83
|
-
return %{<a href="#{url}" utn>#{str}</a>}.html_safe
|
84
|
-
end
|
85
|
-
|
86
|
-
# DoCoMoでiモードIDを取得するためのリンクを返す。
|
87
|
-
def docomo_guid_link_to(str, options={})
|
88
|
-
url = options
|
89
|
-
if options.is_a?(Hash)
|
90
|
-
options = options.symbolize_keys
|
91
|
-
options[:guid] = "ON"
|
92
|
-
url = url_for(options)
|
93
|
-
end
|
94
|
-
return link_to_url(str, url)
|
95
|
-
end
|
96
|
-
|
97
|
-
# au GPS位置情報を取得するためのURLを返す。
|
98
|
-
def au_gps_url_for(options={})
|
99
|
-
url = options
|
100
|
-
datum = 0 # 0:wgs84, 1:tokyo
|
101
|
-
unit = 0 # 0:dms, 1:deg
|
102
|
-
if options.is_a?(Hash)
|
103
|
-
options = options.symbolize_keys
|
104
|
-
options[:only_path] = false
|
105
|
-
datum = (options.delete(:datum) || 0 ).to_i # 0:wgs84, 1:tokyo
|
106
|
-
unit = (options.delete(:unit) || 0 ).to_i # 0:dms, 1:deg
|
107
|
-
url = url_for(options)
|
108
|
-
end
|
109
|
-
return "device:gpsone?url=#{CGI.escape(url)}&ver=1&datum=#{datum}&unit=#{unit}&acry=0&number=0"
|
110
|
-
end
|
111
|
-
|
112
|
-
# au GPS位置情報を取得するためのリンクを返す。
|
113
|
-
def au_gps_link_to(str, options={})
|
114
|
-
link_to_url(str, au_gps_url_for(options))
|
115
|
-
end
|
116
|
-
|
117
|
-
# au 簡易位置情報を取得するためのURLを返す。
|
118
|
-
def au_location_url_for(options={})
|
119
|
-
url = options
|
120
|
-
if options.is_a?(Hash)
|
121
|
-
options = options.symbolize_keys
|
122
|
-
options[:only_path] = false
|
123
|
-
url = url_for(options)
|
124
|
-
end
|
125
|
-
return "device:location?url=#{CGI.escape(url)}"
|
126
|
-
end
|
127
|
-
|
128
|
-
# au 簡易位置情報を取得するためのリンクを返す。
|
129
|
-
def au_location_link_to(str, options={})
|
130
|
-
link_to_url(str, au_location_url_for(options))
|
131
|
-
end
|
132
|
-
|
133
|
-
# Softbank(含むVodafone 3G)で位置情報を取得するためのURLを返す。
|
134
|
-
def softbank_location_url_for(options={})
|
135
|
-
url = options
|
136
|
-
mode = "auto"
|
137
|
-
if options.is_a?(Hash)
|
138
|
-
options = options.symbolize_keys
|
139
|
-
mode = options.delete(:mode) || "auto"
|
140
|
-
options[:only_path] = false
|
141
|
-
url = url_for(options)
|
142
|
-
end
|
143
|
-
url.sub!(/\?/, '&')
|
144
|
-
return "location:#{mode}?url=#{url}"
|
145
|
-
end
|
146
|
-
|
147
|
-
# Softbank(含むVodafone 3G)で位置情報を取得するためのリンクを返す。
|
148
|
-
def softbank_location_link_to(str,options={})
|
149
|
-
link_to_url(str,softbank_location_url_for(options))
|
150
|
-
end
|
151
|
-
|
152
|
-
# Willcom 基地局位置情報を取得するためのURLを返す。
|
153
|
-
def willcom_location_url_for(options={})
|
154
|
-
url = options
|
155
|
-
if options.is_a?(Hash)
|
156
|
-
options = options.symbolize_keys
|
157
|
-
options[:only_path] = false
|
158
|
-
url = url_for(options)
|
159
|
-
end
|
160
|
-
return "http://location.request/dummy.cgi?my=#{url}&pos=$location"
|
161
|
-
end
|
162
|
-
|
163
|
-
# Willcom 基地局位置情報を取得するためのリンクを返す。
|
164
|
-
def willcom_location_link_to(str,options={})
|
165
|
-
link_to_url(str, willcom_location_url_for(options))
|
166
|
-
end
|
167
|
-
|
168
|
-
private
|
169
|
-
# 外部へのリンク
|
170
|
-
def link_to_url(str, url)
|
171
|
-
%{<a href="#{html_escape(url)}">#{html_escape(str)}</a>}.html_safe
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'jpmobile/lookup_context'
|
3
|
-
|
4
|
-
module ActionController
|
5
|
-
class Base
|
6
|
-
include Jpmobile::Helpers
|
7
|
-
before_filter :gettext_force_ja_for_mobile
|
8
|
-
# gettextが組み込まれている場合、携帯電話からのアクセスをjaロケールに強制する。
|
9
|
-
def gettext_force_ja_for_mobile
|
10
|
-
if Object.const_defined?(:GetText) and request.mobile?
|
11
|
-
begin
|
12
|
-
::GetText.locale = 'ja'
|
13
|
-
rescue NameError
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#:stopdoc:
|
3
|
-
# helperを追加
|
4
|
-
ActionView::Base.class_eval { include Jpmobile::Helpers }
|
5
|
-
#:startdoc:
|
6
|
-
|
7
|
-
# :stopdoc:
|
8
|
-
# accept-charset に charset を変更できるようにする
|
9
|
-
# ActionView で trans_sid を有効にする
|
10
|
-
module ActionView
|
11
|
-
module Helpers
|
12
|
-
module FormTagHelper
|
13
|
-
private
|
14
|
-
def html_options_for_form(url_for_options, options, *parameters_for_url)
|
15
|
-
accept_charset = (Rails.application.config.jpmobile.form_accept_charset_conversion && request && request.mobile && request.mobile.default_charset) || "UTF-8"
|
16
|
-
|
17
|
-
options.stringify_keys.tap do |html_options|
|
18
|
-
html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart")
|
19
|
-
# The following URL is unescaped, this is just a hash of options, and it is the
|
20
|
-
# responsability of the caller to escape all the values.
|
21
|
-
html_options["action"] = url_for(url_for_options, *parameters_for_url)
|
22
|
-
html_options["accept-charset"] = accept_charset
|
23
|
-
html_options["data-remote"] = true if html_options.delete("remote")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class Base
|
30
|
-
delegate :default_url_options, :to => :controller unless respond_to?(:default_url_options)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
#:startdoc:
|
@@ -1,330 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'mail'
|
3
|
-
|
4
|
-
module Jpmobile
|
5
|
-
module Mail
|
6
|
-
module_function
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module Mail
|
11
|
-
# encoding patch
|
12
|
-
if self.const_defined?(:Ruby19)
|
13
|
-
Ruby19.class_eval do
|
14
|
-
def self.b_value_decode(str)
|
15
|
-
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
|
16
|
-
if match
|
17
|
-
encoding = match[1]
|
18
|
-
str = self.decode_base64(match[2])
|
19
|
-
str.force_encoding(fix_encoding(encoding))
|
20
|
-
end
|
21
|
-
# if str contains some emoticon, the following line raises Encoding error
|
22
|
-
str.encode("utf-8", :invalid => :replace, :replace => "") rescue Jpmobile::Util.ascii_8bit(str)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
elsif self.const_defined?(:Ruby18)
|
26
|
-
Ruby18.class_eval do
|
27
|
-
def self.b_value_decode(str)
|
28
|
-
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
|
29
|
-
if match
|
30
|
-
encoding = match[1]
|
31
|
-
str = Ruby18.decode_base64(match[2])
|
32
|
-
end
|
33
|
-
str
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class Message
|
39
|
-
attr_accessor :mobile
|
40
|
-
|
41
|
-
def mobile=(m)
|
42
|
-
@mobile = m
|
43
|
-
@charset = m.mail_charset(@charset)
|
44
|
-
|
45
|
-
if @body
|
46
|
-
@body.charset = @charset
|
47
|
-
@body.mobile = m
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def encoded_with_jpmobile
|
52
|
-
if @mobile
|
53
|
-
header['subject'].mobile = @mobile if header['subject']
|
54
|
-
self.charset = @mobile.mail_charset(@charset)
|
55
|
-
|
56
|
-
ready_to_send!
|
57
|
-
|
58
|
-
self.body.charset = @charset
|
59
|
-
self.body.mobile = @mobile
|
60
|
-
self.header['Content-Transfer-Encoding'] = '8bit'
|
61
|
-
|
62
|
-
buffer = header.encoded
|
63
|
-
buffer << "\r\n"
|
64
|
-
buffer = @mobile.utf8_to_mail_encode(buffer)
|
65
|
-
buffer << body.encoded(content_transfer_encoding)
|
66
|
-
buffer
|
67
|
-
else
|
68
|
-
encoded_without_jpmobile
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def parse_message_with_jpmobile
|
73
|
-
header_part, body_part = raw_source.split(/#{CRLF}#{WSP}*#{CRLF}/m, 2)
|
74
|
-
|
75
|
-
self.header = header_part
|
76
|
-
|
77
|
-
@body_part_jpmobile = body_part
|
78
|
-
convert_encoding_jpmobile
|
79
|
-
body_part = @body_part_jpmobile
|
80
|
-
|
81
|
-
self.body = body_part
|
82
|
-
end
|
83
|
-
|
84
|
-
def init_with_string(string)
|
85
|
-
# convert to ASCII-8BIT for ascii incompatible encodings
|
86
|
-
s = Jpmobile::Util.ascii_8bit(string)
|
87
|
-
self.raw_source = s
|
88
|
-
set_envelope_header
|
89
|
-
parse_message
|
90
|
-
@separate_parts = multipart?
|
91
|
-
end
|
92
|
-
|
93
|
-
def process_body_raw_with_jpmobile
|
94
|
-
process_body_raw_without_jpmobile
|
95
|
-
|
96
|
-
@body.charset = @charset
|
97
|
-
@body.mobile = @mobile
|
98
|
-
|
99
|
-
if has_content_transfer_encoding? and
|
100
|
-
["base64", "quoted-printable"].include?(content_transfer_encoding) and
|
101
|
-
["text", nil].include?(@mobile_main_type)
|
102
|
-
@body.decode_transfer_encoding
|
103
|
-
end
|
104
|
-
|
105
|
-
if @body.multipart?
|
106
|
-
@body.parts.each do |p|
|
107
|
-
p.charset = @charset
|
108
|
-
p.mobile = @mobile
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def body_lazy_with_jpmobile(value, index)
|
114
|
-
body_lazy_without_jpmobile(value, index)
|
115
|
-
end
|
116
|
-
|
117
|
-
alias_method :encoded_without_jpmobile, :encoded
|
118
|
-
alias_method :encoded, :encoded_with_jpmobile
|
119
|
-
|
120
|
-
alias_method :parse_message_without_jpmobile, :parse_message
|
121
|
-
alias_method :parse_message, :parse_message_with_jpmobile
|
122
|
-
|
123
|
-
alias_method :process_body_raw_without_jpmobile, :process_body_raw
|
124
|
-
alias_method :process_body_raw, :process_body_raw_with_jpmobile
|
125
|
-
|
126
|
-
alias_method :body_lazy_without_jpmobile, :body_lazy
|
127
|
-
alias_method :body_lazy, :body_lazy_with_jpmobile
|
128
|
-
|
129
|
-
private
|
130
|
-
def convert_encoding_jpmobile
|
131
|
-
# decide mobile carrier
|
132
|
-
if self.header['From']
|
133
|
-
mobile_class = Jpmobile::Email.detect_from_mail_header(self.header['From'].value)
|
134
|
-
@mobile ||= (mobile_class || Jpmobile::Mobile::AbstractMobile ).new(nil, nil)
|
135
|
-
end
|
136
|
-
|
137
|
-
# override charset
|
138
|
-
if self.header['Content-Type']
|
139
|
-
@charset = Jpmobile::Util.extract_charset(self.header['Content-Type'].value)
|
140
|
-
self.header['Content-Type'].parameters[:charset] = @charset
|
141
|
-
@mobile_main_type = self.header['Content-Type'].main_type
|
142
|
-
end
|
143
|
-
|
144
|
-
# convert header(s)
|
145
|
-
if self.header['Subject']
|
146
|
-
subject_charset = Jpmobile::Util.extract_charset(self.header['Subject'].value)
|
147
|
-
|
148
|
-
# override subject encoding if @charset is blank
|
149
|
-
@charset = subject_charset if !subject_charset.blank? and @charset.blank?
|
150
|
-
|
151
|
-
self.header['Subject'].charset = subject_charset
|
152
|
-
|
153
|
-
if @mobile
|
154
|
-
v = @mobile.to_mail_internal(
|
155
|
-
Encodings.value_decode(self.header['Subject'].value), subject_charset)
|
156
|
-
self.header['Subject'].value = Jpmobile::Util.force_encode(v, @mobile.mail_charset(@charset), Jpmobile::Util::UTF8)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
if @body_part_jpmobile and @mobile
|
161
|
-
@body_part_jpmobile = @mobile.decode_transfer_encoding(@body_part_jpmobile, @charset)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
class Part
|
167
|
-
def init_with_string(string)
|
168
|
-
self.raw_source = string
|
169
|
-
set_envelope_header
|
170
|
-
parse_message
|
171
|
-
@separate_parts = multipart?
|
172
|
-
end
|
173
|
-
|
174
|
-
def parse_message_with_jpmobile
|
175
|
-
header_part, body_part = raw_source.split(/#{CRLF}#{WSP}*#{CRLF}/m, 2)
|
176
|
-
|
177
|
-
if header_part =~ HEADER_LINE
|
178
|
-
self.header = header_part
|
179
|
-
else
|
180
|
-
self.header = "Content-Type: text/plain\r\n"
|
181
|
-
end
|
182
|
-
|
183
|
-
@body_part_jpmobile = body_part
|
184
|
-
convert_encoding_jpmobile
|
185
|
-
body_part = @body_part_jpmobile
|
186
|
-
|
187
|
-
self.body = body_part
|
188
|
-
end
|
189
|
-
|
190
|
-
alias_method :parse_message_without_jpmobile, :parse_message
|
191
|
-
alias_method :parse_message, :parse_message_with_jpmobile
|
192
|
-
end
|
193
|
-
|
194
|
-
class Body
|
195
|
-
attr_accessor :mobile
|
196
|
-
|
197
|
-
# convert encoding
|
198
|
-
def encoded_with_jpmobile(transfer_encoding = '8bit')
|
199
|
-
if @mobile and !multipart?
|
200
|
-
if @mobile.to_mail_body_encoded?(@raw_source)
|
201
|
-
@raw_source
|
202
|
-
else
|
203
|
-
@mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, @charset, Jpmobile::Util::UTF8))
|
204
|
-
end
|
205
|
-
else
|
206
|
-
encoded_without_jpmobile(transfer_encoding)
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def decoded_with_jpmobile
|
211
|
-
decoded_without_jpmobile
|
212
|
-
end
|
213
|
-
|
214
|
-
# fix charset
|
215
|
-
def set_charset_with_jpmobile
|
216
|
-
@charset ||= only_us_ascii? ? 'US-ASCII' : nil
|
217
|
-
end
|
218
|
-
|
219
|
-
def mobile=(m)
|
220
|
-
@mobile = m
|
221
|
-
|
222
|
-
if self.multipart?
|
223
|
-
self.parts.each do |part|
|
224
|
-
part.charset = @charset
|
225
|
-
part.mobile = @mobile
|
226
|
-
part.body.charset = @charset
|
227
|
-
part.body.mobile = @mobile
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
def decode_transfer_encoding
|
233
|
-
_raw_source = Encodings.get_encoding(encoding).decode(@raw_source)
|
234
|
-
_raw_source = Jpmobile::Util.set_encoding(_raw_source, @charset)
|
235
|
-
|
236
|
-
@raw_source = @mobile.decode_transfer_encoding(_raw_source, @charset)
|
237
|
-
end
|
238
|
-
|
239
|
-
def preamble_with_jpmobile
|
240
|
-
if @mobile
|
241
|
-
Jpmobile::Util.encode(@preamble, @charset)
|
242
|
-
else
|
243
|
-
preamble_without_jpmobile
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
def epilogue_with_jpmobile
|
248
|
-
if @mobile
|
249
|
-
Jpmobile::Util.encode(@epilogue, @charset)
|
250
|
-
else
|
251
|
-
epilogue_without_jpmobile
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
def crlf_boundary_with_jpmobile
|
256
|
-
if @mobile
|
257
|
-
Jpmobile::Util.encode(crlf_boundary_without_jpmobile, @charset)
|
258
|
-
else
|
259
|
-
epilogue_without_jpmobile
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
def end_boundary_with_jpmobile
|
264
|
-
if @mobile
|
265
|
-
Jpmobile::Util.encode(end_boundary_without_jpmobile, @charset)
|
266
|
-
else
|
267
|
-
epilogue_without_jpmobile
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
alias_method :encoded_without_jpmobile, :encoded
|
272
|
-
alias_method :encoded, :encoded_with_jpmobile
|
273
|
-
|
274
|
-
alias_method :decoded_without_jpmobile, :decoded
|
275
|
-
alias_method :decoded, :decoded_with_jpmobile
|
276
|
-
|
277
|
-
alias_method :set_charset_without_jpmobile, :set_charset
|
278
|
-
alias_method :set_charset, :set_charset_with_jpmobile
|
279
|
-
|
280
|
-
alias_method :preamble_without_jpmobile, :preamble
|
281
|
-
alias_method :preamble, :preamble_with_jpmobile
|
282
|
-
|
283
|
-
alias_method :crlf_boundary_without_jpmobile, :crlf_boundary
|
284
|
-
alias_method :crlf_boundary, :crlf_boundary_with_jpmobile
|
285
|
-
|
286
|
-
alias_method :end_boundary_without_jpmobile, :end_boundary
|
287
|
-
alias_method :end_boundary, :end_boundary_with_jpmobile
|
288
|
-
|
289
|
-
alias_method :epilogue_without_jpmobile, :epilogue
|
290
|
-
alias_method :epilogue, :epilogue_with_jpmobile
|
291
|
-
end
|
292
|
-
|
293
|
-
class UnstructuredField
|
294
|
-
attr_accessor :mobile
|
295
|
-
end
|
296
|
-
|
297
|
-
# for subject
|
298
|
-
class SubjectField < UnstructuredField
|
299
|
-
# FIXME: not folding subject -> folding
|
300
|
-
def encoded_with_jpmobile
|
301
|
-
if @mobile
|
302
|
-
if @mobile.to_mail_subject_encoded?(value)
|
303
|
-
"#{name}: #{value}\r\n"
|
304
|
-
else
|
305
|
-
# convert encoding
|
306
|
-
"#{name}: " + @mobile.to_mail_subject(value) + "\r\n"
|
307
|
-
end
|
308
|
-
else
|
309
|
-
encoded_without_jpmobile
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
alias_method :encoded_without_jpmobile, :encoded
|
314
|
-
alias_method :encoded, :encoded_with_jpmobile
|
315
|
-
end
|
316
|
-
|
317
|
-
class Sendmail
|
318
|
-
def Sendmail.call(path, arguments, destinations, mail)
|
319
|
-
encoded_mail = mail.encoded
|
320
|
-
if Jpmobile::Util.jis?(encoded_mail)
|
321
|
-
encoded_mail = Jpmobile::Util.ascii_8bit(encoded_mail)
|
322
|
-
end
|
323
|
-
|
324
|
-
IO.popen("#{path} #{arguments} #{destinations}", "w+") do |io|
|
325
|
-
io.puts encoded_mail.gsub(/\r\r\n/, "\n").to_lf
|
326
|
-
io.flush
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|