rhodes 3.0.0 → 3.0.1.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/CHANGELOG +4 -0
  2. data/Rakefile +9 -2
  3. data/doc/application.txt +1 -1
  4. data/doc/build.txt +49 -70
  5. data/doc/device-caps.txt +22 -97
  6. data/doc/extensions.txt +1 -1
  7. data/doc/nfc.txt +542 -0
  8. data/doc/rhom.txt +7 -5
  9. data/doc/simulator.txt +116 -0
  10. data/doc/ui.txt +1 -1
  11. data/lib/build/jake.rb +5 -5
  12. data/lib/extensions/debugger/debugger.rb +63 -35
  13. data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +8 -6
  14. data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +1070 -249
  15. data/lib/extensions/nfc/ext/nfc/platform/android/res/xml/filter_nfc.xml +1 -5
  16. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +894 -72
  17. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java +82 -18
  18. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessage.java +65 -0
  19. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcRecord.java +88 -24
  20. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java +3 -0
  21. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +204 -3
  22. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +1047 -5
  23. data/lib/extensions/nfc/nfc.rb +635 -91
  24. data/lib/extensions/rhoxml/rexml/encodings/CP-1252.rb +103 -0
  25. data/lib/extensions/rhoxml/rexml/encodings/ISO-8859-1.rb +7 -0
  26. data/lib/framework/dateME.rb +26 -0
  27. data/lib/framework/rho/render.rb +21 -9
  28. data/lib/framework/rho/rho.rb +12 -0
  29. data/lib/framework/rho/rhoevent_bb.rb +3 -0
  30. data/lib/framework/rho/rhoevent_c.rb +3 -0
  31. data/lib/framework/rhodes.rb +1 -1
  32. data/lib/framework/rhom/rhom_db_adapter.rb +9 -9
  33. data/lib/framework/rhosystem.rb +17 -0
  34. data/lib/framework/stringio.rb +18 -0
  35. data/lib/framework/version.rb +1 -1
  36. data/lib/rhodes.rb +1 -1
  37. data/platform/android/Rhodes/AndroidManifest.xml +2 -2
  38. data/platform/android/Rhodes/res/xml/filter_nfc.xml +1 -5
  39. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +0 -2
  40. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +10 -6
  41. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +29 -18
  42. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +67 -12
  43. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivityListener.java +14 -0
  44. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +102 -28
  45. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +35 -66
  46. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +5 -5
  47. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +69 -41
  48. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +7 -5
  49. data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +68 -35
  50. data/platform/android/build/RhodesSRC_build.files +1 -0
  51. data/platform/android/build/android.rake +2 -2
  52. data/platform/bb/RubyVM/src/com/rho/RhoConf.java +1 -0
  53. data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +18 -6
  54. data/platform/bb/build/bb.rake +1 -1
  55. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +5 -4
  56. data/platform/iphone/Classes/SimpleMainView.m +1 -1
  57. data/platform/iphone/Info.plist +1 -1
  58. data/platform/shared/common/RhodesApp.cpp +9 -3
  59. data/platform/shared/curl/lib/rhossl.c +5 -2
  60. data/platform/shared/db/DBAdapter.cpp +9 -0
  61. data/platform/shared/net/CURLNetRequest.cpp +8 -3
  62. data/platform/shared/net/iphone/sslimpl.cpp +3 -2
  63. data/platform/shared/net/ssl.cpp +8 -0
  64. data/platform/shared/ruby/ext/rho/rhoruby.c +10 -0
  65. data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
  66. data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +3 -4
  67. data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
  68. data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
  69. data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
  70. data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
  71. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  72. data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
  73. data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
  74. data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
  75. data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
  76. data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
  77. data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
  78. data/platform/win32/RhoSimulator/libeay32.dll +0 -0
  79. data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
  80. data/platform/wm/build/wm.rake +27 -3
  81. data/platform/wm/rhodes/Rhodes.cpp +4 -0
  82. data/platform/wm/rhodes/emulator/MainWindowCallback.h +1 -0
  83. data/platform/wm/rhodes/emulator/MainWindowProxy.cpp +3 -1
  84. data/platform/wm/rhodes/emulator/MainWindowQt.cpp +23 -12
  85. data/platform/wm/rhodes/emulator/MainWindowQt.h +5 -1
  86. data/platform/wm/rhodes/emulator/QtMainWindow.cpp +39 -6
  87. data/platform/wm/rhodes/emulator/QtMainWindow.h +1 -1
  88. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +5 -0
  89. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.Libraries.dll +0 -0
  90. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.dll +0 -0
  91. data/platform/wp7/IronRuby/bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
  92. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.Core.dll +0 -0
  93. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.dll +0 -0
  94. data/platform/wp7/RhoAppRunner/Program.cs +2 -2
  95. data/platform/wp7/RhoRubyLib/RhoRuby.cs +8 -0
  96. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +29 -7
  97. data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +5 -2
  98. data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +12 -0
  99. data/platform/wp7/RhoRubyLib/net/HttpServer.cs +2 -0
  100. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +1 -1
  101. data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +52 -7
  102. data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +85 -18
  103. data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +38 -3
  104. data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +27 -2
  105. data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +111 -15
  106. data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +330 -55
  107. data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +61 -4
  108. data/platform/wp7/build/wp.rake +89 -72
  109. data/platform/wp7/rhodes/App.xaml.cs +1 -1
  110. data/rakefile.rb +9 -2
  111. data/rhodes.gemspec +1 -3
  112. data/spec/phone_spec/app/spec/asynchttp_spec.rb +7 -9
  113. data/spec/phone_spec/app/spec/uri_spec.rb +75 -0
  114. data/spec/phone_spec/app/spec_runner.rb +4 -0
  115. metadata +21 -15
  116. data/Manifest.txt +0 -6403
  117. data/platform/win32/RhoSimulator/codecs/qcncodecs4.dll +0 -0
  118. data/platform/win32/RhoSimulator/codecs/qjpcodecs4.dll +0 -0
  119. data/platform/win32/RhoSimulator/codecs/qkrcodecs4.dll +0 -0
  120. data/platform/win32/RhoSimulator/codecs/qtwcodecs4.dll +0 -0
  121. data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
@@ -0,0 +1,103 @@
1
+ #
2
+ # This class was contributed by Mikko Tiihonen mikko DOT tiihonen AT hut DOT fi
3
+ #
4
+ module REXML
5
+ module Encoding
6
+ register( "CP-1252" ) do |o|
7
+ class << o
8
+ alias encode encode_cp1252
9
+ alias decode decode_cp1252
10
+ end
11
+ end
12
+
13
+ # Convert from UTF-8
14
+ def encode_cp1252(content)
15
+ array_utf8 = content.unpack('U*')
16
+ array_enc = []
17
+ array_utf8.each do |num|
18
+ case num
19
+ # shortcut first bunch basic characters
20
+ when 0..0xFF; array_enc << num
21
+ # characters added compared to iso-8859-1
22
+ when 0x20AC; array_enc << 0x80 # 0xe2 0x82 0xac
23
+ when 0x201A; array_enc << 0x82 # 0xe2 0x82 0x9a
24
+ when 0x0192; array_enc << 0x83 # 0xc6 0x92
25
+ when 0x201E; array_enc << 0x84 # 0xe2 0x82 0x9e
26
+ when 0x2026; array_enc << 0x85 # 0xe2 0x80 0xa6
27
+ when 0x2020; array_enc << 0x86 # 0xe2 0x80 0xa0
28
+ when 0x2021; array_enc << 0x87 # 0xe2 0x80 0xa1
29
+ when 0x02C6; array_enc << 0x88 # 0xcb 0x86
30
+ when 0x2030; array_enc << 0x89 # 0xe2 0x80 0xb0
31
+ when 0x0160; array_enc << 0x8A # 0xc5 0xa0
32
+ when 0x2039; array_enc << 0x8B # 0xe2 0x80 0xb9
33
+ when 0x0152; array_enc << 0x8C # 0xc5 0x92
34
+ when 0x017D; array_enc << 0x8E # 0xc5 0xbd
35
+ when 0x2018; array_enc << 0x91 # 0xe2 0x80 0x98
36
+ when 0x2019; array_enc << 0x92 # 0xe2 0x80 0x99
37
+ when 0x201C; array_enc << 0x93 # 0xe2 0x80 0x9c
38
+ when 0x201D; array_enc << 0x94 # 0xe2 0x80 0x9d
39
+ when 0x2022; array_enc << 0x95 # 0xe2 0x80 0xa2
40
+ when 0x2013; array_enc << 0x96 # 0xe2 0x80 0x93
41
+ when 0x2014; array_enc << 0x97 # 0xe2 0x80 0x94
42
+ when 0x02DC; array_enc << 0x98 # 0xcb 0x9c
43
+ when 0x2122; array_enc << 0x99 # 0xe2 0x84 0xa2
44
+ when 0x0161; array_enc << 0x9A # 0xc5 0xa1
45
+ when 0x203A; array_enc << 0x9B # 0xe2 0x80 0xba
46
+ when 0x0152; array_enc << 0x9C # 0xc5 0x93
47
+ when 0x017E; array_enc << 0x9E # 0xc5 0xbe
48
+ when 0x0178; array_enc << 0x9F # 0xc5 0xb8
49
+ else
50
+ # all remaining basic characters can be used directly
51
+ if num <= 0xFF
52
+ array_enc << num
53
+ else
54
+ # Numeric entity (&#nnnn;); shard by Stefan Scholl
55
+ array_enc.concat "&\##{num};".unpack('C*')
56
+ end
57
+ end
58
+ end
59
+ array_enc.pack('C*')
60
+ end
61
+
62
+ # Convert to UTF-8
63
+ def decode_cp1252(str)
64
+ array_latin9 = str.unpack('C*')
65
+ array_enc = []
66
+ array_latin9.each do |num|
67
+ case num
68
+ # characters that added compared to iso-8859-1
69
+ when 0x80; array_enc << 0x20AC # 0xe2 0x82 0xac
70
+ when 0x82; array_enc << 0x201A # 0xe2 0x82 0x9a
71
+ when 0x83; array_enc << 0x0192 # 0xc6 0x92
72
+ when 0x84; array_enc << 0x201E # 0xe2 0x82 0x9e
73
+ when 0x85; array_enc << 0x2026 # 0xe2 0x80 0xa6
74
+ when 0x86; array_enc << 0x2020 # 0xe2 0x80 0xa0
75
+ when 0x87; array_enc << 0x2021 # 0xe2 0x80 0xa1
76
+ when 0x88; array_enc << 0x02C6 # 0xcb 0x86
77
+ when 0x89; array_enc << 0x2030 # 0xe2 0x80 0xb0
78
+ when 0x8A; array_enc << 0x0160 # 0xc5 0xa0
79
+ when 0x8B; array_enc << 0x2039 # 0xe2 0x80 0xb9
80
+ when 0x8C; array_enc << 0x0152 # 0xc5 0x92
81
+ when 0x8E; array_enc << 0x017D # 0xc5 0xbd
82
+ when 0x91; array_enc << 0x2018 # 0xe2 0x80 0x98
83
+ when 0x92; array_enc << 0x2019 # 0xe2 0x80 0x99
84
+ when 0x93; array_enc << 0x201C # 0xe2 0x80 0x9c
85
+ when 0x94; array_enc << 0x201D # 0xe2 0x80 0x9d
86
+ when 0x95; array_enc << 0x2022 # 0xe2 0x80 0xa2
87
+ when 0x96; array_enc << 0x2013 # 0xe2 0x80 0x93
88
+ when 0x97; array_enc << 0x2014 # 0xe2 0x80 0x94
89
+ when 0x98; array_enc << 0x02DC # 0xcb 0x9c
90
+ when 0x99; array_enc << 0x2122 # 0xe2 0x84 0xa2
91
+ when 0x9A; array_enc << 0x0161 # 0xc5 0xa1
92
+ when 0x9B; array_enc << 0x203A # 0xe2 0x80 0xba
93
+ when 0x9C; array_enc << 0x0152 # 0xc5 0x93
94
+ when 0x9E; array_enc << 0x017E # 0xc5 0xbe
95
+ when 0x9F; array_enc << 0x0178 # 0xc5 0xb8
96
+ else
97
+ array_enc << num
98
+ end
99
+ end
100
+ array_enc.pack('U*')
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,7 @@
1
+ require 'rexml/encodings/US-ASCII'
2
+
3
+ module REXML
4
+ module Encoding
5
+ register("ISO-8859-1", &encoding_method("US-ASCII"))
6
+ end
7
+ end
@@ -2,6 +2,9 @@ require 'date/format'
2
2
 
3
3
  class Time
4
4
 
5
+ def getlocal() localtime end
6
+ def to_time() getlocal end
7
+
5
8
  def __makeTwoDigit(num)
6
9
  str = num.to_s
7
10
  if str.length < 2
@@ -101,7 +104,27 @@ class Date
101
104
  ((@m_date-x._get_date()).to_i)/(60*60*24)
102
105
  end
103
106
 
107
+ def + (x)
108
+ Date.new( @m_date + x*(60*60*24) )
109
+ end
110
+
111
+ # Get the week day of this date. Sunday is day-of-week 0;
112
+ # Saturday is day-of-week 6.
104
113
  def wday() @m_date.wday end
114
+
115
+ # Get the commercial day of the week of this date. Monday is
116
+ # commercial day-of-week 1; Sunday is commercial day-of-week 7.
117
+ def cwday()
118
+ _wday = @m_date.wday
119
+ return 7 if _wday == 0
120
+
121
+ return _wday
122
+ end
123
+
124
+ # Get the commercial week of the year of this date.
125
+ # TODO: cweek()
126
+ #def cweek() 0 end
127
+
105
128
  def mon() @m_date.mon end
106
129
  def year() @m_date.year end
107
130
  def mday() @m_date.mday end
@@ -121,6 +144,9 @@ class Date
121
144
  end
122
145
 
123
146
  private_class_method :now
147
+
148
+ def to_time() Time.local(year(), mon(), mday()) end
149
+ def to_date() self end
124
150
 
125
151
  end
126
152
 
@@ -26,16 +26,28 @@ module Rho
26
26
  end
27
27
 
28
28
  def self.renderfile(filename, req = {}, res = {})
29
- res = ""
29
+ begin
30
+ res = ""
30
31
 
31
- if filename.end_with?(RHO_ERB_EXT)
32
- res = (RhoController.new).inst_render_index(filename, req, res)
33
- else
34
- res = IO.read(filename)
35
- end
36
- RhoController.start_objectnotify()
37
- RhoController.start_geoview_notification()
38
- res
32
+ if filename.end_with?(RHO_ERB_EXT)
33
+ res = (RhoController.new).inst_render_index(filename, req, res)
34
+ else
35
+ res = IO.read(filename)
36
+ end
37
+ RhoController.start_objectnotify()
38
+ RhoController.start_geoview_notification()
39
+ res
40
+ rescue Exception => exception
41
+ if defined? RHO_WP7
42
+ #For some reason rho_serve get another exception, so report original one here
43
+ if exception
44
+ trace_msg = exception.backtrace.join("\n")
45
+ puts "renderfile error: #{exception}\n #{trace_msg}"
46
+ end
47
+ end
48
+
49
+ raise
50
+ end
39
51
  end
40
52
 
41
53
  def inst_render_index(filename, req, res)
@@ -16,6 +16,18 @@ module Rho
16
16
  System::get_property('platform') == 'APPLE' || System::get_property('platform') == 'ANDROID' || is_bb6
17
17
  end
18
18
 
19
+ def self.close_database(arg_partition=nil)
20
+ if arg_partition
21
+ puts "Close database for partition: #{arg_partition}"
22
+ ::Rho::RHO.get_db_partitions()[arg_partition].close
23
+ else
24
+ ::Rho::RHO.get_db_partitions().each do |partition, db|
25
+ puts "Close database for partition: #{partition}"
26
+ db.close
27
+ end
28
+ end
29
+ end
30
+
19
31
  class RHO
20
32
  APPLICATIONS = {}
21
33
  APPNAME = 'app'
@@ -11,6 +11,9 @@ module Rho
11
11
  elsif args.first == :all
12
12
 
13
13
  if args.length > 1
14
+ args[1][:start_date] = args[1][:start_date].to_time unless args[1][:start_date].nil?
15
+ args[1][:end_date] = args[1][:end_date].to_time unless args[1][:end_date].nil?
16
+
14
17
  records = Calendar::findCalendarEvents(pb, args[1])
15
18
  else
16
19
  records = Calendar::getallCalendarEvents(pb)
@@ -12,6 +12,9 @@ module Rho
12
12
  end
13
13
  end
14
14
 
15
+ params['start_date'] = params['start_date'].to_time unless params['start_date'].nil?
16
+ params['end_date'] = params['end_date'].to_time unless params['end_date'].nil?
17
+
15
18
  params['start_date'] = MIN_TIME if params['start_date'].nil? or params['start_date'] < MIN_TIME
16
19
  params['end_date'] = MAX_TIME if params['end_date'].nil? or params['end_date'] > MAX_TIME
17
20
 
@@ -1,6 +1,6 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
  end
5
5
  unless defined? Rhodes::DBVERSION
6
6
  DBVERSION = '2.2.0'
@@ -32,15 +32,15 @@ class RhomDbAdapter
32
32
  end
33
33
 
34
34
  # closes the database if and only if it is open
35
- #def close
36
- # if @database
37
- # @database.close
38
- # @database = nil
39
- # else
40
- # return false
41
- # end
42
- # return true
43
- #end
35
+ def close
36
+ if @database
37
+ @database.close
38
+ @database = nil
39
+ else
40
+ return false
41
+ end
42
+ return true
43
+ end
44
44
 
45
45
  def is_ui_waitfordb
46
46
  @database.is_ui_waitfordb
@@ -35,6 +35,23 @@ module Alert
35
35
  end
36
36
  end
37
37
 
38
+ module NavBar
39
+ def self.create( arg )
40
+ #TODO: create
41
+ end
42
+
43
+ def self.remove( )
44
+ #TODO: remove
45
+ end
46
+
47
+ def self.started( )
48
+ #TODO: started
49
+
50
+ false
51
+ end
52
+
53
+ end
54
+
38
55
  module Rho
39
56
 
40
57
  class RhoConf
@@ -0,0 +1,18 @@
1
+ # ****************************************************************************
2
+ #
3
+ # Copyright (c) Microsoft Corporation.
4
+ #
5
+ # This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6
+ # copy of the license can be found in the License.html file at the root of this distribution. If
7
+ # you cannot locate the Apache License, Version 2.0, please send an email to
8
+ # ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9
+ # by the terms of the Apache License, Version 2.0.
10
+ #
11
+ # You must not remove this notice, or any other, from this software.
12
+ #
13
+ #
14
+ # ****************************************************************************
15
+
16
+ if defined?( RHO_WP7 )
17
+ load_assembly 'IronRuby.Libraries', 'IronRuby.StandardLibrary.StringIO'
18
+ end
@@ -1,6 +1,6 @@
1
1
  module RhodesFramework
2
2
  unless defined? RhodesFramework::VERSION
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
  end
5
5
  unless defined? RhodesFramework::DBVERSION
6
6
  DBVERSION = '2.2.2'
data/lib/rhodes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
  end
5
5
  unless defined? Rhodes::DBVERSION
6
6
  DBVERSION = '2.2.0'
@@ -2,8 +2,8 @@
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  package="com.rhomobile.rhodes"
4
4
  android:installLocation="auto"
5
- android:versionCode="32"
6
- android:versionName="3.0.0">
5
+ android:versionCode="33"
6
+ android:versionName="3.0.1">
7
7
 
8
8
  <uses-sdk android:minSdkVersion="4" />
9
9
 
@@ -4,10 +4,6 @@
4
4
  <tech>android.nfc.tech.MifareClassic</tech>
5
5
  </tech-list>
6
6
  <tech-list>
7
- <tech>android.nfc.tech.MifareUltralight</tech>
8
- </tech-list>
9
- <tech-list>
10
- <tech>android.nfc.tech.MifareClassic</tech>
11
- <tech>android.nfc.tech.MifareUltralight</tech>
7
+ <tech>android.nfc.tech.Ndef</tech>
12
8
  </tech-list>
13
9
  </resources>
@@ -1,9 +1,7 @@
1
1
  package com.rhomobile.rhodes;
2
2
 
3
3
  import android.app.Activity;
4
- import android.app.Application;
5
4
  import android.content.ComponentName;
6
- //import android.content.Context;
7
5
  import android.content.Context;
8
6
  import android.content.Intent;
9
7
  import android.content.ServiceConnection;
@@ -51,12 +51,16 @@ public class PushReceiver extends BroadcastReceiver {
51
51
  private void handleMessage(Context context, Intent intent) {
52
52
  Bundle extras = intent.getExtras();
53
53
 
54
- if (DEBUG) {
55
- Log.d(TAG, "Message: " + extras.toString());
56
- for (String key: extras.keySet()) {
57
- Log.d(TAG, key + ": " + extras.get(key).toString());
58
- }
59
- }
54
+ if (DEBUG) {
55
+ if (extras != null) {
56
+ Log.d(TAG, "Message: " + extras.toString());
57
+ for (String key: extras.keySet()) {
58
+ Log.d(TAG, key + ": " + extras.get(key).toString());
59
+ }
60
+ } else {
61
+ Log.d(TAG, "Message: <empty>");
62
+ }
63
+ }
60
64
 
61
65
  Intent serviceIntent = new Intent(context, RhodesService.class);
62
66
  serviceIntent.putExtra(RhodesService.INTENT_SOURCE, INTENT_SOURCE);
@@ -10,9 +10,8 @@ import javax.crypto.spec.IvParameterSpec;
10
10
  import javax.crypto.spec.SecretKeySpec;
11
11
  import java.nio.ByteBuffer;
12
12
 
13
- //import android.util.Base64;
13
+ import android.content.Context;
14
14
  import android.content.SharedPreferences;
15
- import android.app.Activity;
16
15
  import com.rhomobile.rhodes.Logger;
17
16
 
18
17
  public class RhoCryptImpl
@@ -24,10 +23,10 @@ public class RhoCryptImpl
24
23
  final String m_strPrefName = "rho_internal_data";
25
24
  Cipher m_encryptCipher, m_decryptCipher;
26
25
  final int m_nKeyLenBit = 128; // 192 and 256 bits may not be available
27
-
28
- private void readKeyFromStorage()
29
- {
30
- SharedPreferences settings = RhodesActivity.getInstance().getSharedPreferences( m_strPrefName, Activity.MODE_PRIVATE);
26
+
27
+ private void readKeyFromStorage()
28
+ {
29
+ SharedPreferences settings = RhodesService.getInstance().getSharedPreferences( m_strPrefName, Context.MODE_PRIVATE);
31
30
  String strOldKey = settings.getString(m_strDBPartition, "");
32
31
  if ( strOldKey != null && strOldKey.length() > 0 )
33
32
  {
@@ -46,7 +45,7 @@ public class RhoCryptImpl
46
45
 
47
46
  private void writeKeyToStorage()
48
47
  {
49
- SharedPreferences settings = RhodesActivity.getInstance().getSharedPreferences(m_strPrefName, Activity.MODE_PRIVATE);
48
+ SharedPreferences settings = RhodesService.getInstance().getSharedPreferences(m_strPrefName, Context.MODE_PRIVATE);
50
49
  SharedPreferences.Editor editor = settings.edit();
51
50
  String strKey = Base64.encodeToString(m_dbKeyData, false);//, Base64.DEFAULT);
52
51
  editor.putString(m_strDBPartition, strKey );
@@ -70,8 +69,10 @@ public class RhoCryptImpl
70
69
 
71
70
  private void initContext(String szPartition)throws Exception
72
71
  {
73
- if ( m_dbKeyData != null )
72
+ if ( m_dbKeyData != null ) {
73
+ Logger.T(TAG, "RhoCrypt context already initialized, partition: " + szPartition);
74
74
  return;
75
+ }
75
76
 
76
77
  initKey(szPartition);
77
78
 
@@ -89,6 +90,8 @@ public class RhoCryptImpl
89
90
  m_decryptCipher = Cipher.getInstance("AES/CBC/NoPadding");
90
91
  m_decryptCipher.init(Cipher.DECRYPT_MODE, skeySpec, paramSpec);
91
92
 
93
+ Logger.T(TAG, "RhoCrypt context initialized for partition: " + szPartition);
94
+
92
95
  }
93
96
 
94
97
  private static void reportFail(String name, Exception e)
@@ -103,8 +106,12 @@ public class RhoCryptImpl
103
106
  initContext(szPartition);
104
107
 
105
108
  dataOut.rewind();
106
- m_encryptCipher.doFinal(dataIn, dataOut);
107
-
109
+
110
+ if (m_encryptCipher == null)
111
+ throw new NullPointerException("m_encryptCipher == null");
112
+
113
+ m_encryptCipher.doFinal(dataIn, dataOut);
114
+
108
115
  return true;
109
116
  }catch(Exception exc)
110
117
  {
@@ -115,17 +122,21 @@ public class RhoCryptImpl
115
122
 
116
123
  public boolean db_decrypt( String szPartition, ByteBuffer dataIn, ByteBuffer dataOut )
117
124
  {
118
- try
119
- {
120
- initContext(szPartition);
121
-
125
+ try
126
+ {
127
+ initContext(szPartition);
128
+
122
129
  dataOut.rewind();
123
- m_decryptCipher.doFinal(dataIn, dataOut);
124
-
125
- return true;
130
+
131
+ if (m_decryptCipher == null)
132
+ throw new NullPointerException("m_decryptCipher == null");
133
+
134
+ m_decryptCipher.doFinal(dataIn, dataOut);
135
+
136
+ return true;
126
137
  }catch(Exception exc)
127
138
  {
128
- reportFail("db_encrypt", exc);
139
+ reportFail("db_decrypt", exc);
129
140
  return false;
130
141
  }
131
142
  }