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
data/doc/rhom.txt CHANGED
@@ -224,10 +224,12 @@ Below is a full list of options available to fixed schema models:
224
224
  property :mycustomproperty, 'hello'
225
225
  end
226
226
 
227
- ### Fixed Schema Data Migrations
228
- When the application starts the first time after an update, the database will be (re)created if the `app_db_version` in `rhoconfig.txt` is different from what existed before. If the database is recreated, the existing database is removed along with all data.
227
+ ## Data Migrations
228
+ To clean all client data at startup - change `app_db_version` in `rhoconfig.txt`.
229
+ This scenario will work for Property Bag and Fixed Schema models
229
230
 
230
- For this scenario, Rhom provides an application hook to migrate the data manually, overriding the default behavior which deletes the data. You can also use this hook to run business logic related to updating the database. For example, your application may want to display a customized alert notifying the user that a migration is in progress and it may take a few moments.
231
+ ### Fixed Schema Data Migrations
232
+ Rhom provides an application hook to migrate the data manually, overriding the default behavior which deletes the data. You can also use this hook to run business logic related to updating the database. For example, your application may want to display a customized alert notifying the user that a migration is in progress and it may take a few moments.
231
233
 
232
234
  To use this hook, first we need to track the `:schema_version` in our model:
233
235
 
@@ -597,11 +599,11 @@ Returns 1 if last sync was successful, 0 if it failed.
597
599
  @source.last_sync_success
598
600
  #=> 1
599
601
 
600
- ### `distinct_object`
602
+ ### `distinct_objects`
601
603
  Number of records for this source.
602
604
 
603
605
  :::ruby
604
- @source.distinct_object
606
+ @source.distinct_objects
605
607
  #=> 837
606
608
 
607
609
  ## Resetting the Database
data/doc/simulator.txt ADDED
@@ -0,0 +1,116 @@
1
+ # Using RhoSimulator
2
+
3
+ RhoSimulator allows to [run](#run-application-in-rhosimulator) Rhodes applications without lengthy build process and to [debug](#debugging-with-rhostudio) them in [RhoStudio](../rhostudio.tutorial). Currently RhoSimulator works on <b>Windows</b> only.
4
+
5
+ ## Install RhoSimulator
6
+
7
+ If you have [Rhodes gem](install#rhodes-gem), then RhoSimulator is installed already.
8
+
9
+ If you would like to run RhoSimulator without Rhodes gem, [download it](http://rhosimulator.s3.amazonaws.com/RhoSimulator.zip), unzip and specify path to `rhosimulator.exe` at `rhodes/rhobuild.yml`:
10
+
11
+ env:
12
+ paths:
13
+ rhosimulator: <RhoSimulator folder>
14
+
15
+ Alternatively you may [build](#build-rhosimulator) your own customized version of RhoSimulator as described [below](#build-rhosimulator).
16
+
17
+ ## Run application in RhoSimulator
18
+
19
+ To run application in RhoSimulator just run in rhodes or application folder:
20
+
21
+ rake run:win32:rhosimulator
22
+
23
+ If you modified Rhodes application sources, just press 'Refresh' in RhoSimulator to reload application, i.e. generally no RhoSimulator restart is required.
24
+ The restart of RhoSimulator is required only if a model was added/modified or some code was added to the AppApplication class.
25
+
26
+ ## Debugging with RhoStudio
27
+
28
+ ### Prerequisites
29
+
30
+ * Install [RhoStudio](../rhostudio.tutorial)
31
+ * Install [RhoSimulator](#install-rhosimulator)
32
+ * Ensure your application is configured properly and successfully [runs in RhoSimulator](#run-application-in-rhosimulator) (from command line as described above)
33
+
34
+ ### Starting debug session in RhoStudio
35
+
36
+ * Select Run » Debug Configurations... from top menu
37
+ * Find 'Rhodes Application' section on the left and add new (or modify existing) configuration
38
+ * On 'Common setting' tab select a project by clicking 'Browse...' button next to 'Project name:'
39
+ * Select 'Rho simulator' as the platform
40
+ * Click 'Apply' and then 'Debug'
41
+
42
+ ### Debug capabilities
43
+
44
+ In present version of RhoStudio you may:
45
+
46
+ * Set breakpoints in Ruby code (.rb files)
47
+ * Watch variable values (global, local, class and instance) - currently auto-watch list is displayed in Expressions window
48
+ * View application log in Console window
49
+
50
+ ## Build RhoSimulator
51
+
52
+ If you use custom native extensions, then running and debugging your applications in RhoSimulator requires a custom build.
53
+ Follow these instructions to build your own customized version of RhoSimulator.
54
+
55
+ ### Preliminary steps
56
+
57
+ * Currently only <b>Visual Studio 2005 Service Pack 1</b> is supported
58
+ * Follow [Build for Windows - Prerequisites](build#build-for-windows), but do not install the Rhodes gem since you're going to use Rhodes SDK source.
59
+ * Get the `rhodes` source (if haven't done it already) as described [here](build#setup-rhodes-source-code). Don't forget to add the `bin` folder to your path, run `rhodes-setup` and update Rhodes SDK path in `build.yml` at your application root folder.
60
+ * First build the Qt libraries for VS 2005:
61
+ * Download the Qt source:
62
+ * Go to [http://qt.nokia.com/downloads](http://qt.nokia.com/downloads)
63
+ * Choose the open source LGPL version
64
+ * Under the Framework Only section choose Qt libraries for Windows (VS 2008)
65
+ * Cancel automatically started download, and download the [source code](http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.zip)
66
+ * Extract the downloaded archive, e.g. into `C:\Qt\4.7.3-msvc2005`
67
+ * Prepare to build the OpenSSL library:
68
+ * Download [v0.9 source code](http://www.openssl.org/source/openssl-0.9.8r.tar.gz) from [www.openssl.org](http://www.openssl.org/) and extract the downloaded archive, e.g. into `C:\Qt\openssl-0.9.8r`
69
+ * Install Perl interpreter (if it's not installed yet), e.g. [ActiveState Perl](http://www.activestate.com/activeperl)
70
+ * Open Control Panel » System » Advanced system settings » Environment Variables and then:
71
+ * Create new system variable `QTDIR` = `C:\Qt\4.7.3-msvc2005`
72
+ * Add to the `PATH` variable: `C:\Qt\4.7.3-msvc2005\bin;C:\Qt\openssl-0.9.8r\bin` (it doesn't matter that `C:\Qt\openssl-0.9.8r\bin` folder does not exist yet)
73
+ * Either close all command prompts and Visual Studio instances, or reboot the computer so the new settings take effect.
74
+ * Open Visual Studio 2005 Command Prompt. This is accomplished using Start » All Programs » Microsoft Visual Studio 2005 » Visual Studio Tools » Visual Studio 2005 Command Prompt. Run in Visual Studio 2005 Command Prompt:
75
+
76
+ > vcvarsall.bat x86
77
+ > C:
78
+
79
+ * To build OpenSSL library run in the same command prompt:
80
+
81
+ > cd \Qt\openssl-0.9.8r
82
+ > perl Configure VC-WIN32 --prefix=C:/Qt/openssl-0.9.8r
83
+ > ms\do_masm
84
+ > nmake -f ms\ntdll.mak
85
+ > nmake -f ms\ntdll.mak install
86
+ > nmake -f ms\ntdll.mak clean
87
+
88
+ * To build Qt library run in the same command prompt:
89
+
90
+ > cd \Qt\4.7.3-msvc2005
91
+ > configure -opensource -platform win32-msvc2005
92
+ -nomake examples -nomake demos -nomake docs
93
+ -qt-libpng -qt-libjpeg -qt-libtiff -qt-gif -qt-libmng
94
+ -openssl-linked -I C:/Qt/openssl-0.9.8r/include
95
+ -L C:/Qt/openssl-0.9.8r/lib
96
+ > nmake
97
+ > nmake clean
98
+
99
+ Be aware that it will take a while to build the Qt libraries from sources (maybe few hours or so). Particularly the `configure` command may run for a few minutes, and the `nmake` command may run for a few hours.
100
+ * After the build process is completed exit Visual Studio 2005 Command Prompt
101
+
102
+ ### Build with rake command:
103
+
104
+ rake build:win32:rhosimulator
105
+
106
+ To run Rhodes applications in custom built RhoSimulator, please ensure that no `env:` » `paths:` » `rhosimulator:` line is present at your `rhobuild.yml` (if present, remove that line).
107
+
108
+ ### Build in Visual Studio 2005:
109
+
110
+ * Open the solution:
111
+ `C:\Rhomobile\rhodes\platform\wm\rhodes\rhodes.vcproj`
112
+ * Build solution for the configuration `EmulatorRelease|Win32`
113
+ * Specify the path to custom built RhoSimulator at `rhobuild.yml`:
114
+ env:
115
+ paths:
116
+ rhosimulator: platform/wm/bin/Win32/rhodes/EmulatorRelease
data/doc/ui.txt CHANGED
@@ -540,7 +540,7 @@ Each tabbar item defined in the above sample defines following tab elements:
540
540
  * :reload => true - Optional argument which tells rhodes to reload the tab's :action, defaults to false
541
541
  * :selected_color => 0xFFFF00 - Optional parameter for change selected color of this tabs (if you use it on Android - you should defined it for all tabs! and also define :background_color for TabBar!)
542
542
  * :disabled => true - Optional parameter for disable this tab
543
- * :web_bkg_color = > int hex value (like HTML color) - background color for tab (use when your app bkg is not white for remove blink during switch tabs)
543
+ * :web_bkg_color = > int hex value (0x7F7F7F for example) - background color for tab (use when your app bkg is not white for remove blink during switch tabs)
544
544
  * :use_current_view_for_tab => true - Optional argument which tells rhodes to smooth transfer WebView from current view into this Tab and make this Tab active. Defaults to false. Only one Tab can have this parameter!
545
545
 
546
546
 
data/lib/build/jake.rb CHANGED
@@ -38,7 +38,7 @@ class Jake
38
38
 
39
39
  def self.get_absolute(path)
40
40
  return File.expand_path(path) if File.exists?(path)
41
- currentdir = pwd
41
+ currentdir = Dir.pwd()
42
42
 
43
43
  path = currentdir + "/" + path
44
44
 
@@ -210,13 +210,13 @@ class Jake
210
210
 
211
211
  wd = options[:directory]
212
212
  if not wd.nil?
213
- currentdir = pwd()
213
+ currentdir = Dir.pwd()
214
214
  chdir wd
215
215
  end
216
216
 
217
217
  cmdstr = argv.map { |x| x =~ / |\|/ ? '"' + x + '"' : x }.join(' ')
218
218
 
219
- puts "PWD: " + pwd
219
+ puts "PWD: " + Dir.pwd()
220
220
  puts "CMD: " + cmdstr
221
221
  $stdout.flush
222
222
 
@@ -278,7 +278,7 @@ class Jake
278
278
 
279
279
  p = Pathname.new(src)
280
280
  src = p.realpath
281
- currentdir = pwd()
281
+ currentdir = Dir.pwd()
282
282
  src = src.to_s.gsub(/"/,"")
283
283
 
284
284
  args = Array.new
@@ -344,7 +344,7 @@ class Jake
344
344
  javabin = $config["env"]["paths"]["java"]
345
345
  cmd = jdehome + "/bin/rapc.exe"
346
346
 
347
- currentdir = pwd()
347
+ currentdir = Dir.pwd()
348
348
 
349
349
 
350
350
  chdir destdir
@@ -1,6 +1,9 @@
1
1
  require 'uri'
2
2
  require 'timeout'
3
3
 
4
+ DEBUGGER_STEP_TYPE = ['STEP','STOVER','STRET','SUSP']
5
+ DEBUGGER_STEP_COMMENT = ['Stepped into','Stepped over','Stepped return','Suspended']
6
+
4
7
  def debug_read_cmd(io,wait)
5
8
  begin
6
9
  if wait
@@ -59,7 +62,14 @@ def get_variables(scope)
59
62
  vars = eval(prefix + cmd, $_binding)
60
63
  $_s.write("VSTART:#{vartype}\n")
61
64
  vars.each do |v|
62
- $_s.write("V:#{vartype}:#{v}:#{eval(v,$_binding).inspect}\n")
65
+ if v !~ /^\$(=|KCODE)$/
66
+ begin
67
+ result = eval(v,$_binding).inspect
68
+ rescue Exception => exc
69
+ result = "#{$!}".inspect
70
+ end
71
+ $_s.write("V:#{vartype}:#{v}:#{result}\n")
72
+ end
63
73
  end
64
74
  $_s.write("VEND:#{vartype}\n")
65
75
  rescue
@@ -67,7 +77,7 @@ def get_variables(scope)
67
77
  end
68
78
 
69
79
  def log_command(cmd)
70
- puts "[Debugger] Received command: #{cmd}"
80
+ # puts "[Debugger] Received command: #{cmd}"
71
81
  end
72
82
 
73
83
  def debug_handle_cmd(inline)
@@ -108,35 +118,44 @@ def debug_handle_cmd(inline)
108
118
  processed = true
109
119
  elsif inline and (cmd =~ /^STEPOVER/)
110
120
  log_command(cmd)
111
- $_step = true
121
+ $_step = 2
112
122
  $_step_level = $_call_stack
123
+ $_resumed = true
113
124
  wait = false
114
125
  puts "[Debugger] Step over"
115
126
  processed = true
116
127
  elsif inline and (cmd =~ /^STEPRET/)
117
128
  log_command(cmd)
118
- $_step = true
119
- $_step_level = $_call_stack-1
129
+ if $_call_stack < 1
130
+ $_step = 0
131
+ comment = ' (continue)'
132
+ else
133
+ $_step = 3
134
+ $_step_level = $_call_stack-1;
135
+ comment = ''
136
+ end
137
+ $_resumed = true
120
138
  wait = false
121
- puts "[Debugger] Step return"
139
+ puts "[Debugger] Step return" + comment
122
140
  processed = true
123
141
  elsif inline and (cmd =~ /^STEP/)
124
142
  log_command(cmd)
125
- $_step = true
143
+ $_step = 1
126
144
  $_step_level = -1
145
+ $_resumed = true
127
146
  wait = false
128
147
  puts "[Debugger] Step into"
129
148
  processed = true
130
149
  elsif inline and (cmd =~ /^CONT/)
131
150
  log_command(cmd)
132
151
  wait = false
133
- $_step = false
152
+ $_step = 0
134
153
  $_resumed = true
135
154
  puts "[Debugger] Resuming"
136
155
  processed = true
137
156
  elsif cmd =~ /^SUSP/
138
157
  log_command(cmd)
139
- $_step = true
158
+ $_step = 4
140
159
  $_step_level = -1
141
160
  wait = true
142
161
  puts "[Debugger] Suspend"
@@ -172,36 +191,44 @@ $_tracefunc = lambda{|event, file, line, id, bind, classname|
172
191
  $_binding = bind;
173
192
  $_classname = classname;
174
193
  $_methodname = id;
175
- if event =~ /^line/
176
-
177
- unhandled = true
178
- step_stop = $_step and (($_step_level < 0) or ($_call_stack <= $_step_level))
179
- if (step_stop or ($_breakpoints_enabled and (not $_breakpoint.empty?)))
180
- filename = file.sub(/^(.*?[\\\/]|)app[\\\/](.*)$/,'\\2')
181
- ln = line.to_i.to_s
182
- if (step_stop or ($_breakpoints_enabled and ($_breakpoint.has_key?(filename + ':' + ln))))
183
- fn = filename.gsub(/:/, '|')
184
- cl = classname.to_s.gsub(/:/,'#')
185
- $_s.write((step_stop ? "STEP" : "BP") + ":#{fn}:#{ln}:#{cl}:#{id}\n")
186
- puts "[Debugger] " + (step_stop ? "Stop" : "Breakpoint") + " in #{fn} at #{ln}"
194
+ file = file.to_s.gsub('\\', '/')
195
+ if file[0, $_app_path.length] == $_app_path
196
+ if event =~ /^line/
187
197
 
188
- $_wait = true
189
- while $_wait
190
- while debug_handle_cmd(true) do end
191
- sleep if $_wait
198
+ unhandled = true
199
+ step_stop = ($_step > 0) and (($_step_level < 0) or ($_call_stack <= $_step_level))
200
+ if (step_stop or ($_breakpoints_enabled and (not $_breakpoint.empty?)))
201
+ filename = file[$_app_path.length, file.length-$_app_path.length]
202
+ ln = line.to_i.to_s
203
+ if (step_stop or ($_breakpoints_enabled and ($_breakpoint.has_key?(filename + ':' + ln))))
204
+ fn = filename.gsub(/:/, '|')
205
+ cl = classname.to_s.gsub(/:/,'#')
206
+ $_s.write((step_stop ? DEBUGGER_STEP_TYPE[$_step-1] : "BP") + ":#{fn}:#{ln}:#{cl}:#{id}\n")
207
+ puts "[Debugger] " + (step_stop ? DEBUGGER_STEP_COMMENT[$_step-1] : "Breakpoint") + " in #{fn} at #{ln}"
208
+ $_step = 0
209
+ $_step_level = -1
210
+
211
+ $_wait = true
212
+ while $_wait
213
+ while debug_handle_cmd(true) do end
214
+ if System::get_property('main_window_closed')
215
+ $_wait = false
216
+ end
217
+ sleep if $_wait
218
+ end
219
+ unhandled = false
192
220
  end
193
- unhandled = false
194
221
  end
195
- end
196
222
 
197
- if unhandled
198
- debug_handle_cmd(true)
199
- end
223
+ if unhandled
224
+ debug_handle_cmd(true)
225
+ end
200
226
 
201
- elsif event =~ /^call/
202
- $_call_stack += 1
203
- elsif event =~ /^return/
204
- $_call_stack -= 1
227
+ elsif event =~ /^call/
228
+ $_call_stack += 1
229
+ elsif event =~ /^return/
230
+ $_call_stack -= 1
231
+ end
205
232
  end
206
233
 
207
234
  if $_resumed
@@ -224,11 +251,12 @@ begin
224
251
 
225
252
  $_breakpoint = Hash.new
226
253
  $_breakpoints_enabled = true
227
- $_step = false
254
+ $_step = 0
228
255
  $_step_level = -1
229
256
  $_call_stack = 0
230
257
  $_resumed = false
231
258
  $_cmd = ""
259
+ $_app_path = File.join(Rho::RhoApplication::get_base_app_path(), 'app/').gsub('\\', '/')
232
260
 
233
261
  at_exit {
234
262
  $_s.write("QUIT\n") if (not $_s.nil?)
@@ -10,15 +10,18 @@
10
10
  <uses-feature android:name="android.hardware.nfc" android:required="false" />
11
11
 
12
12
  <application>
13
-
13
+
14
14
  <activity android:name="com.rhomobile.nfc.NfcActivity">
15
15
  <intent-filter>
16
- <action android:name="android.nfc.action.TAG_DISCOVERED"/>
17
16
  <category android:name="android.intent.category.DEFAULT"/>
17
+ <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
18
+ </intent-filter>
19
+
20
+ <intent-filter>
21
+ <category android:name="android.intent.category.DEFAULT"/>
22
+ <action android:name="android.nfc.action.TAG_DISCOVERED"/>
18
23
  </intent-filter>
19
- </activity>
20
24
 
21
- <activity android:name="com.rhomobile.nfc.NfcTechActivity">
22
25
  <intent-filter>
23
26
  <category android:name="android.intent.category.DEFAULT"/>
24
27
  <action android:name="android.nfc.action.TECH_DISCOVERED" />
@@ -27,9 +30,8 @@
27
30
  <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
28
31
  android:resource="@xml/filter_nfc"
29
32
  />
30
-
31
33
  </activity>
32
-
34
+
33
35
  </application>
34
36
 
35
37
  <uses-permission android:name="android.permission.NFC" />
@@ -18,141 +18,317 @@
18
18
 
19
19
 
20
20
 
21
-
22
21
  #define logging_enable false
23
22
 
24
-
25
23
  void logi(const char* text) {
26
24
  if (logging_enable) __android_log_write(ANDROID_LOG_INFO, "NFC jni", text);
27
25
  }
28
26
 
27
+ void loge(const char* text) {
28
+ __android_log_write(ANDROID_LOG_INFO, "NFC jni ERROR : ", text);
29
+ }
29
30
 
30
- extern "C" void rho_nfc_set_callback(const char* callback_url) {
31
- JNIEnv *env = jnienv();
32
- jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
33
- if (!cls) return;
34
- jmethodID mid = env->GetStaticMethodID( cls, "setCallback", "(Ljava/lang/String;)V");
35
- if (!mid) return;
36
- jstring objCallback = env->NewStringUTF(callback_url);
37
- env->CallStaticVoidMethod(cls, mid, objCallback);
38
- env->DeleteLocalRef(objCallback);
39
- }
40
31
 
41
- extern "C" void rho_nfc_enable(int enable) {
42
- JNIEnv *env = jnienv();
43
- jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
44
- if (!cls) return;
45
- jmethodID mid = env->GetStaticMethodID( cls, "setEnable", "(I)V");
46
- if (!mid) return;
47
- env->CallStaticVoidMethod(cls, mid, enable);
48
- }
32
+ class CNfcJavaClass {
33
+ public:
34
+ CNfcJavaClass() {
35
+ JNIEnv *env = jnienv();
36
+ mNfcClass = rho_find_class(env, "com/rhomobile/nfc/Nfc");
37
+ }
38
+
39
+ ~CNfcJavaClass() {
40
+ JNIEnv *env = jnienv();
41
+ env->DeleteLocalRef(mNfcClass);
42
+ }
43
+
44
+ jclass get() {
45
+ return mNfcClass;
46
+ }
47
+
48
+ private:
49
+ jclass mNfcClass;
50
+ };
49
51
 
50
- extern "C" int rho_nfc_is_enabled(void) {
51
- JNIEnv *env = jnienv();
52
- jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
53
- if (!cls) return 0;
54
- jmethodID mid = env->GetStaticMethodID( cls, "isEnabled", "()I");
55
- if (!mid) return 0;
56
- return env->CallStaticIntMethod(cls, mid);
57
- }
58
52
 
59
- extern "C" int rho_nfc_is_supported(void) {
60
- JNIEnv *env = jnienv();
61
- jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
62
- if (!cls) return 0;
63
- jmethodID mid = env->GetStaticMethodID( cls, "isSupported", "()I");
64
- if (!mid) return 0;
65
- return env->CallStaticIntMethod(cls, mid);
66
- }
53
+ class CRubyString {
54
+ public:
55
+
56
+ CRubyString(const char* str) {
57
+ mStr = str;
58
+ mJavaObject = NULL;
59
+ mEnv = NULL;
60
+ }
61
+
62
+ ~CRubyString() {
63
+ if (mJavaObject != NULL) {
64
+ mEnv->DeleteLocalRef(mJavaObject);
65
+ }
66
+ }
67
+
68
+ jstring makeJavaString(JNIEnv* env) {
69
+ mEnv = env;
70
+ mJavaObject = env->NewStringUTF(mStr);
71
+ return mJavaObject;
72
+ }
73
+
74
+ private:
75
+ jstring mJavaObject;
76
+ JNIEnv* mEnv;
77
+ const char* mStr;
78
+ };
67
79
 
80
+ class CRubyByteArray {
81
+ public:
82
+ CRubyByteArray(VALUE array) {
83
+ if (array != 0) {
84
+ mSize = rho_ruby_unpack_byte_array(array, 0, 0);
85
+ mBuf = new unsigned char[mSize];
86
+ rho_ruby_unpack_byte_array(array, mBuf, mSize);
87
+ }
88
+ else {
89
+ mBuf = NULL;
90
+ mSize = 0;
91
+ }
92
+ mJavaObject = NULL;
93
+ }
94
+
95
+ jbyteArray makeJavaByteArray(JNIEnv* env) {
96
+ if (mBuf != NULL) {
97
+ mEnv = env;
98
+ mJavaObject = (jbyteArray)env->NewByteArray(mSize);
99
+ jbyte* buf_p = env->GetByteArrayElements(mJavaObject, 0);
100
+ int i;
101
+ for (i = 0; i < mSize; i++) {
102
+ buf_p[i] = mBuf[i];
103
+ }
104
+ env->ReleaseByteArrayElements(mJavaObject, buf_p, 0);
105
+ }
106
+ return mJavaObject;
107
+ }
108
+
109
+ ~CRubyByteArray() {
110
+ if (mJavaObject != NULL) {
111
+ mEnv->DeleteLocalRef(mJavaObject);
112
+ }
113
+ if (mBuf != NULL) {
114
+ delete mBuf;
115
+ }
116
+ }
117
+
118
+ private:
119
+ unsigned char* mBuf;
120
+ int mSize;
121
+ jbyteArray mJavaObject;
122
+ JNIEnv* mEnv;
123
+ };
68
124
 
69
125
 
70
- extern "C" void rho_nfc_set_tech_callback(const char* callback_url) {
71
- JNIEnv *env = jnienv();
72
- jclass cls = rho_find_class(env, "com/rhomobile/nfc/Nfc");
73
- if (!cls) return;
74
- jmethodID mid = env->GetStaticMethodID( cls, "setTechCallback", "(Ljava/lang/String;)V");
75
- if (!mid) return;
76
- jstring objCallback = env->NewStringUTF(callback_url);
77
- env->CallStaticVoidMethod(cls, mid, objCallback);
78
- env->DeleteLocalRef(objCallback);
79
- }
126
+ class CNFCString {
127
+ public:
128
+ CNFCString(JNIEnv* env, jobject jo_string) {
129
+ mBuf = NULL;
130
+ if (jo_string != NULL) {
131
+ const char* msg = env->GetStringUTFChars((jstring)jo_string,0);
132
+ mSize = strlen(msg);
133
+ mBuf = new char[mSize+1];
134
+ strcpy(mBuf, msg);
135
+ env->ReleaseStringUTFChars((jstring)jo_string, msg);
136
+ }
137
+ }
80
138
 
81
- extern "C" void rho_nfc_set_listen_tech_list(VALUE tech_list) {
139
+ virtual ~CNFCString() {
140
+ if (mBuf != NULL) {
141
+ delete mBuf;
142
+ }
143
+ }
82
144
 
83
- }
145
+ VALUE makeVALUE() {
146
+ if (mBuf != NULL) {
147
+ return rho_ruby_create_string((const char*)mBuf);
148
+ }
149
+ else {
150
+ return rho_ruby_get_NIL();
151
+ }
152
+
153
+ }
154
+
155
+
156
+ char* mBuf;
157
+ int mSize;
158
+ };
84
159
 
85
- extern "C" VALUE rho_nfc_get_tech_list() {
86
- return rho_ruby_get_NIL();
87
- }
88
160
 
89
- extern "C" void rho_nfc_tech_connect(const char* name) {
90
161
 
91
- }
162
+ class CNFCByteArray {
163
+ public:
164
+ CNFCByteArray(JNIEnv* env, jobject jo_bytearray) {
165
+ logi("Construct ByteArray from java object START");
166
+ mBuf = NULL;
167
+ if (jo_bytearray != NULL) {
168
+ mSize = env->GetArrayLength((jbyteArray)jo_bytearray);
169
+ if (mSize > 0) {
170
+ if (logging_enable) {
171
+ char msg[128];
172
+ sprintf(msg, " array size = %d", mSize);
173
+ logi(msg);
174
+ }
175
+ mBuf = new unsigned char[mSize];
176
+ unsigned char* jarray_buf = (unsigned char*)env->GetByteArrayElements((jbyteArray)jo_bytearray, 0);
177
+ int i;
178
+ for (i = 0; i < mSize; i++) {
179
+ mBuf[i] = jarray_buf[i];
180
+ }
181
+ env->ReleaseByteArrayElements((jbyteArray)jo_bytearray, (jbyte*)jarray_buf, 0);
182
+ }
183
+ else {
184
+ logi(" invalid size !");
185
+ mBuf = NULL;
186
+ }
187
+ }
188
+ logi("Construct ByteArray from java object FINISH");
189
+ }
190
+
191
+ VALUE makeVALUE() {
192
+ logi("make VALUE from byte array START");
193
+ if (mBuf != NULL) {
194
+ VALUE v = rho_ruby_create_byte_array(mBuf, mSize);
195
+ logi("make VALUE from byte array FINISH");
196
+ return v;
197
+ }
198
+ else {
199
+ logi("make VALUE from byte array FINISH NIL");
200
+ return rho_ruby_get_NIL();
201
+ }
202
+
203
+ }
92
204
 
93
- extern "C" void rho_nfc_tech_close(const char* name) {
94
205
 
95
- }
206
+ virtual ~CNFCByteArray() {
207
+ if (mBuf != NULL) {
208
+ delete mBuf;
209
+ }
210
+ }
96
211
 
97
- extern "C" int rho_nfc_tech_is_connected(const char* name) {
98
- return 0;
99
- }
212
+ unsigned char* mBuf;
213
+ int mSize;
214
+ };
100
215
 
101
- extern "C" int rho_nfc_tech_MifareClassic_get_size() {
102
- return 0;
103
- }
104
216
 
105
- extern "C" void rho_nfc_tech_MifareClassic_write_block(int index, VALUE block) {
106
217
 
107
- }
108
218
 
109
- extern "C" VALUE rho_nfc_tech_MifareClassic_read_block(int index) {
110
- return rho_ruby_get_NIL();
219
+ VALUE JavaHelper_exec_bytearray_bytearray(VALUE array, const char* method_name) {
220
+ JNIEnv *env = jnienv();
221
+ CNfcJavaClass cls;
222
+ if (!cls.get()) {
223
+ loge("Nfc class not found !");
224
+ return rho_ruby_get_NIL();
225
+ }
226
+ jmethodID mid = env->GetStaticMethodID(cls.get(), method_name, "([B)[B");
227
+ if (!mid) {
228
+ loge("Nfc method :");
229
+ loge(method_name);
230
+ loge("NOT FOUND !");
231
+ return rho_ruby_get_NIL();
232
+ }
233
+ int size = rho_ruby_unpack_byte_array(array, 0, 0);
234
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(size);
235
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
236
+
237
+ rho_ruby_unpack_byte_array(array, (unsigned char*)buf_p, size);
238
+
239
+ jbyteArray j_arr = (jbyteArray)env->CallStaticObjectMethod(cls.get(), mid, buf_j);
240
+
241
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
242
+ env->DeleteLocalRef(buf_j);
243
+
244
+ CNFCByteArray ar(env, j_arr);
245
+
246
+ return ar.makeVALUE();
111
247
  }
112
248
 
113
- extern "C" int rho_nfc_tech_MifareUltralight_get_size() {
114
- return 0;
249
+ void JavaHelper_exec_void_bytearray(VALUE array, const char* method_name) {
250
+ JNIEnv *env = jnienv();
251
+ CNfcJavaClass cls;
252
+ if (!cls.get()) {
253
+ loge("Nfc class not found !");
254
+ return;
255
+ }
256
+ jmethodID mid = env->GetStaticMethodID(cls.get(), method_name, "([B)V");
257
+ if (!mid) {
258
+ loge("Nfc method :");
259
+ loge(method_name);
260
+ loge("NOT FOUND !");
261
+ return;
262
+ }
263
+ int size = rho_ruby_unpack_byte_array(array, 0, 0);
264
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(size);
265
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
266
+
267
+ rho_ruby_unpack_byte_array(array, (unsigned char*)buf_p, size);
268
+
269
+ env->CallStaticVoidMethod(cls.get(), mid, buf_j);
270
+
271
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
272
+ env->DeleteLocalRef(buf_j);
115
273
  }
116
274
 
117
- extern "C" void rho_nfc_tech_MifareUltralight_write_page(int index, VALUE block) {
118
-
275
+ VALUE JavaHelper_exec_bytearray_void(const char* method_name) {
276
+ JNIEnv *env = jnienv();
277
+ CNfcJavaClass cls;
278
+ if (!cls.get()) {
279
+ loge("Nfc class not found !");
280
+ return rho_ruby_get_NIL();
281
+ }
282
+ jmethodID mid = env->GetStaticMethodID(cls.get(), method_name, "()[B");
283
+ if (!mid) {
284
+ loge("Nfc method :");
285
+ loge(method_name);
286
+ loge("NOT FOUND !");
287
+ return rho_ruby_get_NIL();
288
+ }
289
+ jbyteArray j_arr = (jbyteArray)env->CallStaticObjectMethod(cls.get(), mid);
290
+
291
+ CNFCByteArray ar(env, j_arr);
292
+
293
+ return ar.makeVALUE();
119
294
  }
120
295
 
121
- extern "C" VALUE rho_nfc_tech_MifareUltralight_read_pages(int index) {
122
- return rho_ruby_get_NIL();
296
+ int JavaHelper_exec_int_void(const char* method_name) {
297
+ JNIEnv *env = jnienv();
298
+ CNfcJavaClass cls;
299
+ if (!cls.get()) {
300
+ loge("Nfc class not found !");
301
+ return 0;
302
+ }
303
+ jmethodID mid = env->GetStaticMethodID(cls.get(), method_name, "()I");
304
+ if (!mid) {
305
+ loge("Nfc method :");
306
+ loge(method_name);
307
+ loge("NOT FOUND !");
308
+ return 0;
309
+ }
310
+ return env->CallStaticIntMethod(cls.get(), mid);
123
311
  }
124
312
 
125
-
126
- // private native void callTechCallback(String callback_url, String event);
127
- extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_callTechCallback
128
- (JNIEnv *env, jclass, jstring js_callback_url, jstring js_event)
129
- {
130
- char url[2048];
131
- char body[2048];
132
-
133
- const char* jurl = env->GetStringUTFChars(js_callback_url,0);
134
- const char* jevent = env->GetStringUTFChars(js_event,0);
135
- strcpy(url, jurl);
136
- env->ReleaseStringUTFChars(js_callback_url, jurl);
137
-
138
- strcpy(body, "&rho_callback=1");
139
- strcat(body, "&");
140
- strcat(body, "Tag_event=");
141
- strcat(body, jevent);
142
- env->ReleaseStringUTFChars(js_event, jevent);
143
-
144
- rho_net_request_with_data(rho_http_normalizeurl(url), body);
313
+ void JavaHelper_exec_void_int(int value, const char* method_name) {
314
+ JNIEnv *env = jnienv();
315
+ CNfcJavaClass cls;
316
+ if (!cls.get()) {
317
+ loge("Nfc class not found !");
318
+ return;
319
+ }
320
+ jmethodID mid = env->GetStaticMethodID(cls.get(), method_name, "(I)V");
321
+ if (!mid) {
322
+ loge("Nfc method :");
323
+ loge(method_name);
324
+ loge("NOT FOUND !");
325
+ return;
326
+ }
327
+ env->CallStaticVoidMethod(cls.get(), mid, value);
145
328
  }
146
329
 
147
330
 
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
331
+ static bool ourNeedToFree = false;
156
332
  static jclass jclass_NfcMessagePack = NULL;
157
333
  static jclass jclass_NfcMessage = NULL;
158
334
  static jclass jclass_NfcRecord = NULL;
@@ -163,6 +339,8 @@ static jmethodID jmethod_NfcMessagePack_getItem = NULL;
163
339
  static jmethodID jmethod_NfcMessage_getItemCount = NULL;
164
340
  static jmethodID jmethod_NfcMessage_getItem = NULL;
165
341
  static jmethodID jmethod_NfcMessage_getByteArray = NULL;
342
+ static jmethodID jmethod_NfcMessage_addConstructRecord = NULL;
343
+ static jmethodID jmethod_NfcMessage_initFromConstructRecordList = NULL;
166
344
 
167
345
  static jmethodID jmethod_NfcRecord_getId = NULL;
168
346
  static jmethodID jmethod_NfcRecord_getPayload = NULL;
@@ -174,72 +352,60 @@ static jmethodID jmethod_NfcRecord_getSubrecords = NULL;
174
352
 
175
353
 
176
354
 
177
- class CNFCString {
178
- public:
179
- CNFCString(JNIEnv* env, jobject jo_string) {
180
- const char* msg = env->GetStringUTFChars((jstring)jo_string,0);
181
- mSize = strlen(msg);
182
- mBuf = new char[mSize+1];
183
- strcpy(mBuf, msg);
184
- env->ReleaseStringUTFChars((jstring)jo_string, msg);
185
- }
186
-
187
- virtual ~CNFCString() {
188
- delete mBuf;
189
- }
190
-
191
- char* mBuf;
192
- int mSize;
193
- };
194
-
195
-
196
-
197
- class CNFCByteArray {
198
- public:
199
- CNFCByteArray(JNIEnv* env, jobject jo_bytearray) {
200
- logi("Construct ByteArray from java object START");
201
- mSize = env->GetArrayLength((jbyteArray)jo_bytearray);
202
- if (mSize > 0) {
203
- if (logging_enable) {
204
- char msg[128];
205
- sprintf(msg, " array size = %d", mSize);
206
- logi(msg);
207
- }
208
- mBuf = new unsigned char[mSize];
209
- unsigned char* jarray_buf = (unsigned char*)env->GetByteArrayElements((jbyteArray)jo_bytearray, 0);
210
- int i;
211
- for (i = 0; i < mSize; i++) {
212
- mBuf[i] = jarray_buf[i];
213
- }
214
- env->ReleaseByteArrayElements((jbyteArray)jo_bytearray, (jbyte*)jarray_buf, 0);
215
- }
216
- else {
217
- logi(" invalid size !");
218
- mBuf = NULL;
219
- }
220
- logi("Construct ByteArray from java object FINISH");
221
- }
222
-
223
-
224
- virtual ~CNFCByteArray() {
225
- if (mBuf != NULL) {
226
- delete mBuf;
227
- }
228
- }
229
-
355
+ void initJavaIds(JNIEnv *env_param = NULL) {
356
+
357
+ JNIEnv *env = NULL;//jnienv();
358
+ if (env_param != NULL) {
359
+ env = env_param;
360
+ }
361
+ else {
362
+ env = jnienv();
363
+ }
364
+
365
+ if (env_param != NULL) {
366
+ jclass_NfcMessagePack = env->FindClass("com/rhomobile/nfc/NfcMessagePack");
367
+ jclass_NfcMessage = env->FindClass("com/rhomobile/nfc/NfcMessage");
368
+ jclass_NfcRecord = env->FindClass("com/rhomobile/nfc/NfcRecord");
369
+ ourNeedToFree = false;
370
+ }
371
+ else {
372
+ jclass_NfcMessagePack = rho_find_class(env, "com/rhomobile/nfc/NfcMessagePack");
373
+ jclass_NfcMessage = rho_find_class(env, "com/rhomobile/nfc/NfcMessage");
374
+ jclass_NfcRecord = rho_find_class(env, "com/rhomobile/nfc/NfcRecord");
375
+ ourNeedToFree = true;
376
+ }
377
+ // fill java ids
378
+
379
+ jmethod_NfcMessagePack_getItemCount = env->GetMethodID( jclass_NfcMessagePack, "getItemCount", "()I");
380
+ jmethod_NfcMessagePack_getItem = env->GetMethodID( jclass_NfcMessagePack, "getItem", "(I)Lcom/rhomobile/nfc/NfcMessage;");
381
+
382
+ jmethod_NfcMessage_getItemCount = env->GetMethodID( jclass_NfcMessage, "getItemCount", "()I");
383
+ jmethod_NfcMessage_getItem = env->GetMethodID( jclass_NfcMessage, "getItem", "(I)Lcom/rhomobile/nfc/NfcRecord;");
384
+ jmethod_NfcMessage_getByteArray = env->GetMethodID( jclass_NfcMessage, "getByteArray", "()[B");
385
+ jmethod_NfcMessage_addConstructRecord = env->GetMethodID( jclass_NfcMessage, "addConstructRecord", "(Lcom/rhomobile/nfc/NfcRecord;)V");
386
+ jmethod_NfcMessage_initFromConstructRecordList = env->GetMethodID( jclass_NfcMessage, "initFromConstructRecordList", "()V");
387
+
388
+ jmethod_NfcRecord_getId = env->GetMethodID( jclass_NfcRecord, "getId", "()[B");
389
+ jmethod_NfcRecord_getPayload = env->GetMethodID( jclass_NfcRecord, "getPayload", "()[B");
390
+ jmethod_NfcRecord_getPayloadString = env->GetMethodID( jclass_NfcRecord, "getPayloadString", "()Ljava/lang/String;");
391
+ jmethod_NfcRecord_getTnf = env->GetMethodID( jclass_NfcRecord, "getTnf", "()I");
392
+ jmethod_NfcRecord_getType = env->GetMethodID( jclass_NfcRecord, "getType", "()[B");
393
+ jmethod_NfcRecord_getByteArray = env->GetMethodID( jclass_NfcRecord, "getByteArray", "()[B");
394
+ jmethod_NfcRecord_getSubrecords = env->GetMethodID( jclass_NfcRecord, "getSubrecords", "()Lcom/rhomobile/nfc/NfcMessage;");
395
+
396
+ }
230
397
 
231
- unsigned char* mBuf;
232
- int mSize;
233
- };
234
398
 
235
399
  class CNFCMessage;
236
400
 
237
401
  class CNFCRecord {
238
402
  public:
239
403
  CNFCRecord(JNIEnv* env, jobject jrec);
240
-
404
+
405
+ VALUE makeHashValue();
406
+
241
407
  virtual ~CNFCRecord();
242
-
408
+
243
409
  CNFCByteArray* mId;
244
410
  CNFCByteArray* mPayload;
245
411
  CNFCString* mPayloadString;
@@ -263,7 +429,7 @@ public:
263
429
  }
264
430
  mByteArray = new CNFCByteArray(env, env->CallObjectMethod(jmsg, jmethod_NfcMessage_getByteArray));
265
431
  }
266
-
432
+
267
433
  virtual ~CNFCMessage() {
268
434
  int i;
269
435
  for (i = 0; i < mRecordCount; i++) {
@@ -272,7 +438,9 @@ public:
272
438
  delete[] mRecords;
273
439
  delete mByteArray;
274
440
  }
275
-
441
+
442
+ VALUE makeHashValue();
443
+
276
444
  CNFCRecordPtr* mRecords;
277
445
  int mRecordCount;
278
446
  CNFCByteArray* mByteArray;
@@ -305,10 +473,40 @@ CNFCRecord::~CNFCRecord() {
305
473
  }
306
474
  }
307
475
 
476
+ VALUE CNFCRecord::makeHashValue() {
477
+ VALUE hash = rho_ruby_createHash();
478
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("raw_record"), mByteArray->makeVALUE());
479
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("id"), mId->makeVALUE());
480
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("payload"), mPayload->makeVALUE());
481
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("tnf"), rho_ruby_create_integer(mTnf));
482
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("type"), mType->makeVALUE());
483
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("payload_as_string"), mPayloadString->makeVALUE());
484
+ if (mSubrecords != NULL) {
485
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("subrecords"), mSubrecords->makeHashValue());
486
+ }
487
+ return hash;
488
+ }
489
+
490
+ VALUE CNFCMessage::makeHashValue() {
491
+ VALUE hash = rho_ruby_createHash();
492
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("raw_message"), mByteArray->makeVALUE());
493
+
494
+ VALUE records = rho_ruby_create_array();
495
+ int i;
496
+ for (i = 0; i < mRecordCount; i++) {
497
+ rho_ruby_add_to_array(records, mRecords[i]->makeHashValue());
498
+ }
499
+
500
+ rho_ruby_add_to_hash(hash, rho_ruby_create_string("records"), records);
501
+
502
+ return hash;
503
+
504
+ }
505
+
308
506
 
309
507
  class CNFCMessagePack {
310
508
  public:
311
-
509
+
312
510
  CNFCMessagePack(JNIEnv* env, jobject jmsg_pack) {
313
511
  mMessageCount = env->CallIntMethod(jmsg_pack, jmethod_NfcMessagePack_getItemCount);
314
512
  int i;
@@ -317,7 +515,7 @@ public:
317
515
  mMessages[i] = new CNFCMessage(env, env->CallObjectMethod(jmsg_pack, jmethod_NfcMessagePack_getItem, i));
318
516
  }
319
517
  }
320
-
518
+
321
519
  virtual ~CNFCMessagePack() {
322
520
  int i;
323
521
  for (i = 0; i < mMessageCount; i++) {
@@ -325,7 +523,7 @@ public:
325
523
  }
326
524
  delete[] mMessages;
327
525
  }
328
-
526
+
329
527
  CNFCMessagePtr* mMessages;
330
528
  int mMessageCount;
331
529
  };
@@ -338,16 +536,16 @@ public:
338
536
  RhoCallbackNFCContainer(CNFCMessagePack* pack) {
339
537
  mMessagePack = pack;
340
538
  }
341
-
539
+
342
540
  virtual ~RhoCallbackNFCContainer() {
343
541
  delete mMessagePack;
344
542
  }
345
-
543
+
346
544
  VALUE makeString(CNFCString* str) {
347
545
  logi(" make ruby string");
348
546
  return rho_ruby_create_string((const char*)str->mBuf);
349
547
  }
350
-
548
+
351
549
  VALUE makeByteArray(CNFCByteArray* array) {
352
550
  logi(" make ruby byte array");
353
551
  if (array->mBuf != NULL) {
@@ -363,110 +561,738 @@ public:
363
561
  return rho_ruby_get_NIL();
364
562
  }
365
563
  }
366
-
367
- VALUE makeRecordHash(CNFCRecord* record) {
368
- logi(" make record START");
369
- VALUE hash = rho_ruby_createHash();
370
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("raw_record"), makeByteArray(record->mByteArray));
371
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("id"), makeByteArray(record->mId));
372
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("payload"), makeByteArray(record->mPayload));
373
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("tnf"), rho_ruby_create_integer(record->mTnf));
374
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("type"), makeByteArray(record->mType));
375
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("payload_as_string"), makeString(record->mPayloadString));
376
- if (record->mSubrecords != NULL) {
377
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("subrecords"), makeMessageHash(record->mSubrecords));
378
- }
379
- logi(" make record FINISH");
380
- return hash;
381
- }
382
-
383
- VALUE makeMessageHash(CNFCMessage* msg) {
384
- logi(" make message START");
385
- VALUE hash = rho_ruby_createHash();
386
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("raw_message"), makeByteArray(msg->mByteArray));
387
-
388
- VALUE records = rho_ruby_create_array();
389
- int i;
390
- logi(" make message make records :");
391
- for (i = 0; i < msg->mRecordCount; i++) {
392
- rho_ruby_add_to_array(records, makeRecordHash(msg->mRecords[i]));
393
- }
394
-
395
- rho_ruby_add_to_hash(hash, rho_ruby_create_string("records"), records);
396
-
397
- logi(" make message FINISH");
398
- return hash;
399
- }
400
-
401
-
564
+
565
+
402
566
  /*
403
- # in callback
404
- # @params['messages'] - array of messages (each message is hash)
405
- # message hash items :
406
- # 'raw_message' - array of bytes (raw message)
407
- # 'records' - array of records (each record is hash)
408
- # record hash items :
409
- # 'raw_record' - array of bytes (raw record)
410
- # ' id' - array of bytes
411
- # 'payload' - array of bytes
412
- # 'tnf' - int
413
- # 'type' - array of bytes
414
- # 'payload_as_string' - string, payload prepared to string (support specail formats for URI, TEXT)
415
- # 'subrecords' - array of subrecords, each records is hash (only for SMART_POSTER type)
416
- */
417
-
567
+ # in callback
568
+ # @params['messages'] - array of messages (each message is hash)
569
+ # message hash items :
570
+ # 'raw_message' - array of bytes (raw message)
571
+ # 'records' - array of records (each record is hash)
572
+ # record hash items :
573
+ # 'raw_record' - array of bytes (raw record)
574
+ # ' id' - array of bytes
575
+ # 'payload' - array of bytes
576
+ # 'tnf' - int
577
+ # 'type' - array of bytes
578
+ # 'payload_as_string' - string, payload prepared to string (support specail formats for URI, TEXT)
579
+ # 'subrecords' - array of subrecords, each records is hash (only for SMART_POSTER type)
580
+ */
581
+
418
582
  // return Ruby object
419
583
  virtual unsigned long getObjectValue() {
420
584
  logi("make Ruby value for callback START");
421
-
585
+
422
586
  VALUE messages_array = rho_ruby_create_array();
423
587
  int i;
424
-
588
+
425
589
  logi(" make messages array :");
426
590
  for (i = 0; i < mMessagePack->mMessageCount; i++) {
427
- rho_ruby_add_to_array(messages_array, makeMessageHash(mMessagePack->mMessages[i]));
591
+ rho_ruby_add_to_array(messages_array, mMessagePack->mMessages[i]->makeHashValue());
428
592
  }
429
-
593
+
430
594
  logi("make Ruby value for callback FINISH");
431
595
  return messages_array;
432
596
  }
433
-
597
+
434
598
  private:
435
599
  CNFCMessagePack* mMessagePack;
436
600
  };
437
601
 
438
602
 
439
- // private native void callCallback(String callback_url, NfcMessagePack msgpack);
440
- extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_callCallback
441
- (JNIEnv *env, jclass, jstring js_callback_url, jobject jo_msgpack)
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+ extern "C" void rho_nfc_set_callback(const char* callback_url) {
611
+ JNIEnv *env = jnienv();
612
+ CNfcJavaClass cls;
613
+ if (!cls.get()) return;
614
+ jmethodID mid = env->GetStaticMethodID( cls.get(), "setCallback", "(Ljava/lang/String;)V");
615
+ if (!mid) return;
616
+ jstring objCallback = env->NewStringUTF(callback_url);
617
+ env->CallStaticVoidMethod(cls.get(), mid, objCallback);
618
+ env->DeleteLocalRef(objCallback);
619
+ }
620
+
621
+ extern "C" void rho_nfc_enable(int enable) {
622
+ JNIEnv *env = jnienv();
623
+ CNfcJavaClass cls;
624
+ if (!cls.get()) return;
625
+ jmethodID mid = env->GetStaticMethodID( cls.get(), "setEnable", "(I)V");
626
+ if (!mid) return;
627
+ env->CallStaticVoidMethod(cls.get(), mid, enable);
628
+ }
629
+
630
+ extern "C" int rho_nfc_is_enabled(void) {
631
+ return JavaHelper_exec_int_void("isEnabled");
632
+ }
633
+
634
+ extern "C" int rho_nfc_is_supported(void) {
635
+ return JavaHelper_exec_int_void("isSupported");
636
+ }
637
+
638
+ extern "C" void rho_nfc_set_tech_callback(const char* callback_url) {
639
+ JNIEnv *env = jnienv();
640
+ CNfcJavaClass cls;
641
+ if (!cls.get()) return;
642
+ jmethodID mid = env->GetStaticMethodID( cls.get(), "setTechCallback", "(Ljava/lang/String;)V");
643
+ if (!mid) return;
644
+ jstring objCallback = env->NewStringUTF(callback_url);
645
+ env->CallStaticVoidMethod(cls.get(), mid, objCallback);
646
+ env->DeleteLocalRef(objCallback);
647
+ }
648
+
649
+ extern "C" void rho_nfc_perform_open_application_event() {
650
+ JNIEnv *env = jnienv();
651
+ CNfcJavaClass cls;
652
+ if (!cls.get()) return;
653
+ jmethodID mid = env->GetStaticMethodID( cls.get(), "performOpenApplicationTag", "()V");
654
+ if (!mid) return;
655
+ env->CallStaticVoidMethod(cls.get(), mid);
656
+ }
657
+
658
+
659
+
660
+ extern "C" void rho_nfc_set_listen_tech_list(VALUE tech_list) {
661
+
662
+ }
663
+
664
+ extern "C" VALUE rho_nfc_get_tech_list() {
665
+
666
+ logi("rho_nfc_get_tech_list START");
667
+ JNIEnv *env = jnienv();
668
+ CNfcJavaClass cls;
669
+ if (!cls.get()) return rho_ruby_get_NIL();
670
+ jmethodID mid = env->GetStaticMethodID( cls.get(), "get_tech_list_count", "()I");
671
+ if (!mid) return rho_ruby_get_NIL();
672
+ jmethodID mids = env->GetStaticMethodID( cls.get(), "get_tech_list", "(I)Ljava/lang/String;");
673
+ if (!mids) return rho_ruby_get_NIL();
674
+ int count = env->CallStaticIntMethod(cls.get(), mid);
675
+
676
+ VALUE array = rho_ruby_create_array();
677
+
678
+ int i;
679
+
680
+ for (i = 0; i < count; i++) {
681
+ CNFCString cs(env, env->CallStaticObjectMethod(cls.get(), mids, i));
682
+ rho_ruby_add_to_array( array, rho_ruby_create_string(cs.mBuf));
683
+ logi("rho_nfc_get_tech_list 05");
684
+
685
+ }
686
+ return array;
687
+ }
688
+
689
+ extern "C" void rho_nfc_tech_connect(const char* name) {
690
+ logi("rho_nfc_tech_connect START");
691
+ JNIEnv *env = jnienv();
692
+ CNfcJavaClass cls;
693
+ if (!cls.get()) return;
694
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_connect", "(Ljava/lang/String;)V");
695
+ if (!mid) return;
696
+ jstring objCallback = env->NewStringUTF(name);
697
+ env->CallStaticVoidMethod(cls.get(), mid, objCallback);
698
+ env->DeleteLocalRef(objCallback);
699
+ logi("rho_nfc_tech_connect FINISH");
700
+ }
701
+
702
+ extern "C" void rho_nfc_tech_close(const char* name) {
703
+ JNIEnv *env = jnienv();
704
+ CNfcJavaClass cls;
705
+ if (!cls.get()) return;
706
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_close", "(Ljava/lang/String;)V");
707
+ if (!mid) return;
708
+ jstring objCallback = env->NewStringUTF(name);
709
+ env->CallStaticVoidMethod(cls.get(), mid, objCallback);
710
+ env->DeleteLocalRef(objCallback);
711
+ }
712
+
713
+ extern "C" int rho_nfc_tech_is_connected(const char* name) {
714
+ logi("rho_nfc_tech_is_connected START");
715
+ JNIEnv *env = jnienv();
716
+ CNfcJavaClass cls;
717
+ if (!cls.get()) return 0;
718
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_is_connected", "(Ljava/lang/String;)I");
719
+ if (!mid) return 0;
720
+ jstring objCallback = env->NewStringUTF(name);
721
+ int res = env->CallStaticIntMethod(cls.get(), mid, objCallback);
722
+ env->DeleteLocalRef(objCallback);
723
+ logi("rho_nfc_tech_is_connected FINISH");
724
+ return res;
725
+ }
726
+
727
+ extern "C" int rho_nfc_tech_MifareClassic_get_size() {
728
+ return JavaHelper_exec_int_void("tech_MifareClassic_get_size");
729
+ }
730
+
731
+ extern "C" void rho_nfc_tech_MifareClassic_write_block(int index, VALUE block) {
732
+
733
+ logi("rho_nfc_tech_MifareClassic_write_block START");
734
+ JNIEnv *env = jnienv();
735
+ CNfcJavaClass cls;
736
+ if (!cls.get()) return;
737
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareClassic_write_block", "(I[B)V");
738
+ if (!mid) return;
739
+
740
+ int res = 0;
741
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(16);
742
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
743
+
744
+ rho_ruby_unpack_byte_array(block, (unsigned char*)buf_p, 16);
745
+
746
+ env->CallStaticVoidMethod(cls.get(), mid, index, buf_j);
747
+
748
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
749
+ env->DeleteLocalRef(buf_j);
750
+
751
+ logi("rho_nfc_tech_MifareClassic_write_block FINISH");
752
+
753
+ }
754
+
755
+ extern "C" VALUE rho_nfc_tech_MifareClassic_read_block(int index) {
756
+
757
+ logi("rho_nfc_tech_MifareClassic_read_block START");
758
+ JNIEnv *env = jnienv();
759
+ CNfcJavaClass cls;
760
+ if (!cls.get()) return rho_ruby_get_NIL();
761
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareClassic_read_block", "(I[B)I");
762
+ if (!mid) return rho_ruby_get_NIL();
763
+
764
+ VALUE val = rho_ruby_get_NIL();
765
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(16);
766
+ int res = env->CallStaticIntMethod(cls.get(), mid, index, buf_j);
767
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
768
+ if (res != 0) {
769
+ logi("java Nfc return real array");
770
+ val = rho_ruby_create_byte_array((unsigned char*)buf_p, 16);
771
+ }
772
+ else {
773
+ logi("java Nfc not filled array !!!");
774
+ }
775
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
776
+ env->DeleteLocalRef(buf_j);
777
+ logi("rho_nfc_tech_MifareClassic_read_block FINISH");
778
+
779
+ return val;
780
+ }
781
+
782
+ extern "C" int rho_nfc_tech_MifareClassic_get_block_count() {
783
+ return JavaHelper_exec_int_void("tech_MifareClassic_get_block_count");
784
+ }
785
+
786
+ extern "C" int rho_nfc_tech_MifareClassic_get_sector_count() {
787
+ return JavaHelper_exec_int_void("tech_MifareClassic_get_sector_count");
788
+ }
789
+
790
+ extern "C" int rho_nfc_tech_MifareClassic_get_blocks_in_sector_count(int index) {
791
+ logi("rho_nfc_tech_MifareClassic_get_blocks_in_sector_count START");
792
+ JNIEnv *env = jnienv();
793
+ CNfcJavaClass cls;
794
+ if (!cls.get()) return 0;
795
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareClassic_get_blocks_in_sector_count", "(I)I");
796
+ if (!mid) return 0;
797
+ logi("rho_nfc_tech_MifareClassic_get_blocks_in_sector_count FINISH");
798
+ return env->CallStaticIntMethod(cls.get(), mid, index);
799
+ }
800
+
801
+ extern "C" int rho_nfc_tech_MifareClassic_sector_to_block(int index) {
802
+ logi("rho_nfc_tech_MifareClassic_sector_to_block START");
803
+ JNIEnv *env = jnienv();
804
+ CNfcJavaClass cls;
805
+ if (!cls.get()) return 0;
806
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareClassic_sector_to_block", "(I)I");
807
+ if (!mid) return 0;
808
+ logi("rho_nfc_tech_MifareClassic_sector_to_block FINISH");
809
+ return env->CallStaticIntMethod(cls.get(), mid, index);
810
+ }
811
+
812
+ extern "C" int rho_nfc_tech_MifareClassic_get_type() {
813
+ return JavaHelper_exec_int_void("tech_MifareClassic_get_type");
814
+ }
815
+
816
+ extern "C" VALUE rho_nfc_tech_MifareClassic_transceive(VALUE data) {
817
+ return JavaHelper_exec_bytearray_bytearray(data, "tech_MifareClassic_transceive");
818
+ }
819
+
820
+ extern "C" VALUE rho_nfc_tag_get_id() {
821
+ return JavaHelper_exec_bytearray_void("tag_get_id");
822
+ }
823
+
824
+
825
+ extern "C" int rho_nfc_tech_MifareClassic_authenticate_sector_with_key_A(int index, VALUE key) {
826
+
827
+ logi("rho_nfc_tech_MifareClassic_authenticate_sector_with_key_A START");
828
+ JNIEnv *env = jnienv();
829
+ CNfcJavaClass cls;
830
+ if (!cls.get()) return 0;
831
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareClassic_authenticate_sector_with_key_A", "(I[B)I");
832
+ if (!mid) return 0;
833
+
834
+ int res = 0;
835
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(6);
836
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
837
+
838
+ rho_ruby_unpack_byte_array(key, (unsigned char*)buf_p, 6);
839
+
840
+ res = env->CallStaticIntMethod(cls.get(), mid, index, buf_j);
841
+
842
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
843
+ env->DeleteLocalRef(buf_j);
844
+
845
+ logi("rho_nfc_tech_MifareClassic_authenticate_sector_with_key_A FINISH");
846
+
847
+ return res;
848
+
849
+ }
850
+
851
+ extern "C" int rho_nfc_tech_MifareClassic_authenticate_sector_with_key_B(int index, VALUE key) {
852
+ logi("rho_nfc_tech_MifareClassic_authenticate_sector_with_key_B START");
853
+ JNIEnv *env = jnienv();
854
+ CNfcJavaClass cls;
855
+ if (!cls.get()) return 0;
856
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareClassic_authenticate_sector_with_key_B", "(I[B)I");
857
+ if (!mid) return 0;
858
+
859
+ int res = 0;
860
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(6);
861
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
862
+
863
+ rho_ruby_unpack_byte_array(key, (unsigned char*)buf_p, 6);
864
+
865
+ res = env->CallStaticIntMethod(cls.get(), mid, index, buf_j);
866
+
867
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
868
+ env->DeleteLocalRef(buf_j);
869
+
870
+ logi("rho_nfc_tech_MifareClassic_authenticate_sector_with_key_B FINISH");
871
+
872
+ return res;
873
+
874
+ }
875
+
876
+
877
+ extern "C" int rho_nfc_tech_Ndef_get_max_size() {
878
+ return JavaHelper_exec_int_void("tech_Ndef_get_max_size");
879
+ }
880
+
881
+ // return string
882
+ extern "C" VALUE rho_nfc_tech_Ndef_get_type() {
883
+ JNIEnv *env = jnienv();
884
+ CNfcJavaClass cls;
885
+ if (!cls.get()) return rho_ruby_get_NIL();
886
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_Ndef_get_type", "()Ljava/lang/String;");
887
+ if (!mid) return rho_ruby_get_NIL();
888
+ jstring j_str = (jstring)env->CallStaticObjectMethod(cls.get(), mid);
889
+ CNFCString s(env, j_str);
890
+ return s.makeVALUE();
891
+ }
892
+
893
+ extern "C" int rho_nfc_tech_Ndef_is_writable() {
894
+ return JavaHelper_exec_int_void("tech_Ndef_is_writable");
895
+ }
896
+
897
+ extern "C" int rho_nfc_tech_Ndef_can_make_read_only() {
898
+ return JavaHelper_exec_int_void("tech_Ndef_can_make_read_only");
899
+ }
900
+
901
+ extern "C" int rho_nfc_tech_Ndef_make_read_only() {
902
+ return JavaHelper_exec_int_void("tech_Ndef_make_read_only");
903
+ }
904
+
905
+ extern "C" void rho_nfc_tech_Ndef_write_Nde_message(VALUE message_in_byte_array) {
906
+ JavaHelper_exec_void_bytearray(message_in_byte_array, "tech_Ndef_write_Nde_message");
907
+ }
908
+
909
+ // return byte[]
910
+ extern "C" VALUE rho_nfc_tech_Ndef_read_Nde_message() {
911
+ return JavaHelper_exec_bytearray_void("tech_Ndef_read_Nde_message");
912
+ }
913
+
914
+ // return byte[]
915
+ extern "C" VALUE rho_nfc_tech_NfcA_get_Atqa() {
916
+ return JavaHelper_exec_bytearray_void("tech_NfcA_get_Atqa");
917
+ }
918
+
919
+ extern "C" int rho_nfc_tech_NfcA_get_Sak() {
920
+ return JavaHelper_exec_int_void("tech_NfcA_get_Sak");
921
+ }
922
+
923
+ // return byte[]
924
+ extern "C" VALUE rho_nfc_tech_NfcA_transceive(VALUE data) {
925
+ return JavaHelper_exec_bytearray_bytearray(data, "tech_NfcA_transceive");
926
+ }
927
+
928
+
929
+ // return HASH
930
+ extern "C" VALUE rho_nfc_convert_byte_array_to_NdeRecord_hash(VALUE array) {
931
+ initJavaIds();
932
+
933
+ JNIEnv *env = jnienv();
934
+ CNfcJavaClass cls;
935
+ if (!cls.get()) return rho_ruby_get_NIL();
936
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "convert_byte_array_to_NdeRecord_hash", "([B)Lcom/rhomobile/nfc/NfcRecord;");
937
+ if (!mid) return rho_ruby_get_NIL();
938
+
939
+ int size = rho_ruby_unpack_byte_array(array, 0, 0);
940
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(size);
941
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
942
+
943
+ rho_ruby_unpack_byte_array(array, (unsigned char*)buf_p, size);
944
+
945
+ jobject j_o = env->CallStaticObjectMethod(cls.get(), mid, buf_j);
946
+
947
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
948
+ env->DeleteLocalRef(buf_j);
949
+
950
+ CNFCRecord r(env, j_o);
951
+
952
+ return r.makeHashValue();
953
+ }
954
+
955
+ // return byte array
956
+ extern "C" VALUE rho_nfc_convert_NdeRecord_hash_to_byte_array(VALUE hash) {
957
+ initJavaIds();
958
+
959
+ VALUE ruby_id = rho_ruby_hash_aref(hash, "id");
960
+ VALUE ruby_type = rho_ruby_hash_aref(hash, "type");
961
+ VALUE ruby_payload = rho_ruby_hash_aref(hash, "payload");
962
+ VALUE ruby_tnf = rho_ruby_hash_aref(hash, "tnf");
963
+
964
+ int tnf = (int)rho_ruby_get_int(ruby_tnf);
965
+ CRubyByteArray c_id(ruby_id);
966
+ CRubyByteArray c_type(ruby_type);
967
+ CRubyByteArray c_payload(ruby_payload);
968
+
969
+ JNIEnv *env = jnienv();
970
+ CNfcJavaClass cls;
971
+ if (!cls.get()) return rho_ruby_get_NIL();
972
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "convert_NdeRecord_hash_to_byte_array", "([B[BI[B)[B");
973
+ if (!mid) return rho_ruby_get_NIL();
974
+
975
+ jbyteArray j_result = (jbyteArray)env->CallStaticObjectMethod(cls.get(), mid, c_id.makeJavaByteArray(env), c_payload.makeJavaByteArray(env), tnf, c_type.makeJavaByteArray(env));
976
+
977
+ CNFCByteArray ar(env, j_result);
978
+
979
+ return ar.makeVALUE();
980
+ }
981
+
982
+ // return array of byte array
983
+ extern "C" VALUE rho_nfc_convert_NdeMessage_byte_array_to_NdeRecords_array(VALUE array) {
984
+
985
+ initJavaIds();
986
+
987
+ CRubyByteArray c_msg(array);
988
+
989
+ JNIEnv *env = jnienv();
990
+ CNfcJavaClass cls;
991
+ if (!cls.get()) return rho_ruby_get_NIL();
992
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "convert_NdeMessage_byte_array_to_NdeRecords_array", "([B)Lcom/rhomobile/nfc/NfcMessage;");
993
+ if (!mid) return rho_ruby_get_NIL();
994
+
995
+ jobject j_msg = env->CallStaticObjectMethod(cls.get(), mid, c_msg.makeJavaByteArray(env));
996
+
997
+ CNFCMessage msg(env, j_msg);
998
+
999
+ int i;
1000
+
1001
+ VALUE result = rho_ruby_create_array();
1002
+
1003
+ for (i = 0; i < msg.mRecordCount; i++) {
1004
+ CNFCRecord* rec = msg.mRecords[i];
1005
+ rho_ruby_add_to_array(result, rec->mByteArray->makeVALUE());
1006
+
1007
+ }
1008
+
1009
+ return result;
1010
+ }
1011
+
1012
+ // return byte array
1013
+ extern "C" VALUE rho_nfc_convert_NdeRecords_array_to_NdeMessage_byte_array(VALUE array) {
1014
+ initJavaIds();
1015
+
1016
+ JNIEnv *env = jnienv();
1017
+ CNfcJavaClass cls;
1018
+ if (!cls.get()) return rho_ruby_get_NIL();
1019
+ jmethodID mid_make_msg = env->GetStaticMethodID(cls.get(), "make_empty_NfcMessage", "()Lcom/rhomobile/nfc/NfcMessage;");
1020
+ if (!mid_make_msg) return rho_ruby_get_NIL();
1021
+ jmethodID mid_make_rec = env->GetStaticMethodID(cls.get(), "convert_byte_array_to_NdeRecord_hash", "([B)Lcom/rhomobile/nfc/NfcRecord;");
1022
+ if (!mid_make_rec) return rho_ruby_get_NIL();
1023
+
1024
+ jobject j_msg = env->CallStaticObjectMethod(cls.get(), mid_make_msg);
1025
+
1026
+ int count = rho_ruby_array_get_size(array);
1027
+ int i;
1028
+
1029
+ for (i = 0; i < count; i++) {
1030
+ CRubyByteArray c_rec(rho_ruby_array_get(array, i));
1031
+
1032
+ jobject j_rec = env->CallStaticObjectMethod(cls.get(), mid_make_rec, c_rec.makeJavaByteArray(env));
1033
+
1034
+ env->CallVoidMethod(j_msg, jmethod_NfcMessage_addConstructRecord, j_rec);
1035
+ }
1036
+ env->CallVoidMethod(j_msg, jmethod_NfcMessage_initFromConstructRecordList);
1037
+
1038
+ CNFCByteArray ar(env, env->CallObjectMethod(j_msg, jmethod_NfcMessage_getByteArray));
1039
+
1040
+ return ar.makeVALUE();
1041
+
1042
+ }
1043
+
1044
+ // String make_string_from_payload(byte[] payload, int tnf, byte[] type)
1045
+ // return string
1046
+ extern "C" VALUE rho_nfc_make_string_from_payload(VALUE payload, int tnf, VALUE type) {
1047
+
1048
+ CRubyByteArray c_payload(payload);
1049
+ CRubyByteArray c_type(type);
1050
+
1051
+ JNIEnv *env = jnienv();
1052
+ CNfcJavaClass cls;
1053
+ if (!cls.get()) return rho_ruby_get_NIL();
1054
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "make_string_from_payload", "([BI[B)Ljava/lang/String;");
1055
+ if (!mid) return rho_ruby_get_NIL();
1056
+
1057
+ jstring j_s = (jstring)env->CallStaticObjectMethod(cls.get(), mid, c_payload.makeJavaByteArray(env), tnf, c_type.makeJavaByteArray(env));
1058
+
1059
+ CNFCString s(env, j_s);
1060
+
1061
+ return s.makeVALUE();
1062
+ }
1063
+
1064
+ // return byte[]
1065
+ extern "C" VALUE rho_nfc_make_payload_with_absolute_uri(const char* str) {
1066
+
1067
+ CRubyString c_s(str);
1068
+
1069
+ JNIEnv *env = jnienv();
1070
+ CNfcJavaClass cls;
1071
+ if (!cls.get()) return rho_ruby_get_NIL();
1072
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "make_payload_with_absolute_uri", "(Ljava/lang/String;)[B");
1073
+ if (!mid) return rho_ruby_get_NIL();
1074
+
1075
+ jobject j_o = env->CallStaticObjectMethod(cls.get(), mid, c_s.makeJavaString(env));
1076
+
1077
+ CNFCByteArray ar(env, j_o);
1078
+
1079
+ return ar.makeVALUE();
1080
+
1081
+ }
1082
+
1083
+ // return byte[]
1084
+ extern "C" VALUE rho_nfc_make_payload_with_well_known_text(const char* language, const char* str) {
1085
+ CRubyString c_lang(language);
1086
+ CRubyString c_s(str);
1087
+
1088
+ JNIEnv *env = jnienv();
1089
+ CNfcJavaClass cls;
1090
+ if (!cls.get()) return rho_ruby_get_NIL();
1091
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "make_payload_with_well_known_text", "(Ljava/lang/String;Ljava/lang/String;)[B");
1092
+ if (!mid) return rho_ruby_get_NIL();
1093
+
1094
+ jobject j_o = env->CallStaticObjectMethod(cls.get(), mid, c_lang.makeJavaString(env), c_s.makeJavaString(env));
1095
+
1096
+ CNFCByteArray ar(env, j_o);
1097
+
1098
+ return ar.makeVALUE();
1099
+
1100
+ }
1101
+
1102
+ // return byte[]
1103
+ extern "C" VALUE rho_nfc_make_payload_with_well_known_uri(int prefix, const char* str) {
1104
+ CRubyString c_s(str);
1105
+
1106
+ JNIEnv *env = jnienv();
1107
+ CNfcJavaClass cls;
1108
+ if (!cls.get()) return rho_ruby_get_NIL();
1109
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "make_payload_with_well_known_uri", "(ILjava/lang/String;)[B");
1110
+ if (!mid) return rho_ruby_get_NIL();
1111
+
1112
+ jobject j_o = env->CallStaticObjectMethod(cls.get(), mid, prefix, c_s.makeJavaString(env));
1113
+
1114
+ CNFCByteArray ar(env, j_o);
1115
+
1116
+ return ar.makeVALUE();
1117
+ }
1118
+
1119
+ extern "C" void rho_nfc_p2p_enable_foreground_nde_push(VALUE nde_message_byte_array) {
1120
+ JavaHelper_exec_void_bytearray(nde_message_byte_array, "p2p_enable_foreground_nde_push");
1121
+ }
1122
+
1123
+ extern "C" void rho_nfc_p2p_disable_foreground_nde_push() {
1124
+ JNIEnv *env = jnienv();
1125
+ CNfcJavaClass cls;
1126
+ if (!cls.get()) return;
1127
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "p2p_disable_foreground_nde_push", "()V");
1128
+ if (!mid) return;
1129
+ env->CallStaticVoidMethod(cls.get(), mid);
1130
+ }
1131
+
1132
+ extern "C" void rho_nfc_tech_MifareUltralight_write_page(int index, VALUE block) {
1133
+ JNIEnv *env = jnienv();
1134
+ CNfcJavaClass cls;
1135
+ if (!cls.get()) return;
1136
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareUltralight_write_page", "(I[B)V");
1137
+ if (!mid) return;
1138
+
1139
+ int res = 0;
1140
+ int size = rho_ruby_unpack_byte_array(block, 0, 0);
1141
+ jbyteArray buf_j = (jbyteArray)env->NewByteArray(size);
1142
+ jbyte* buf_p = env->GetByteArrayElements(buf_j, 0);
1143
+
1144
+ rho_ruby_unpack_byte_array(block, (unsigned char*)buf_p, size);
1145
+
1146
+ env->CallStaticVoidMethod(cls.get(), mid, index, buf_j);
1147
+
1148
+ env->ReleaseByteArrayElements(buf_j, buf_p, 0);
1149
+ env->DeleteLocalRef(buf_j);
1150
+ }
1151
+
1152
+ extern "C" VALUE rho_nfc_tech_MifareUltralight_read_pages(int index) {
1153
+ JNIEnv *env = jnienv();
1154
+ CNfcJavaClass cls;
1155
+ if (!cls.get()) return rho_ruby_get_NIL();
1156
+ jmethodID mid = env->GetStaticMethodID(cls.get(), "tech_MifareUltralight_read_pages", "(I)[B");
1157
+ if (!mid) return rho_ruby_get_NIL();
1158
+
1159
+ jbyteArray j_arr = (jbyteArray)env->CallStaticIntMethod(cls.get(), mid, index);
1160
+
1161
+ CNFCByteArray ar(env, j_arr);
1162
+
1163
+ return ar.makeVALUE();
1164
+ }
1165
+
1166
+ extern "C" int rho_nfc_tech_MifareUltralight_get_type() {
1167
+ return JavaHelper_exec_int_void("tech_MifareUltralight_get_type");
1168
+ }
1169
+
1170
+ extern "C" VALUE rho_nfc_tech_MifareUltralight_transceive(VALUE data) {
1171
+ return JavaHelper_exec_bytearray_bytearray(data, "tech_MifareUltralight_transceive");
1172
+ }
1173
+
1174
+
1175
+ extern "C" VALUE rho_nfc_tech_IsoDep_get_hi_layer_responce() {
1176
+ return JavaHelper_exec_bytearray_void("tech_IsoDep_get_hi_layer_responce");
1177
+ }
1178
+
1179
+ extern "C" VALUE rho_nfc_tech_IsoDep_get_historical_bytes() {
1180
+ return JavaHelper_exec_bytearray_void("tech_IsoDep_get_historical_bytes");
1181
+ }
1182
+
1183
+ extern "C" void rho_nfc_tech_IsoDep_set_timeout(int timeout) {
1184
+ JavaHelper_exec_void_int(timeout, "tech_IsoDep_set_timeout");
1185
+ }
1186
+
1187
+ extern "C" VALUE rho_nfc_tech_IsoDep_transceive(VALUE data) {
1188
+ return JavaHelper_exec_bytearray_bytearray(data, "tech_IsoDep_transceive");
1189
+ }
1190
+
1191
+ extern "C" void rho_nfc_tech_NdefFormatable_format(VALUE ndef_message_byte_array) {
1192
+ JavaHelper_exec_void_bytearray(ndef_message_byte_array, "tech_NdefFormatable_format");
1193
+ }
1194
+
1195
+ extern "C" void rho_nfc_tech_NdefFormatable_format_read_only(VALUE ndef_message_byte_array) {
1196
+ JavaHelper_exec_void_bytearray(ndef_message_byte_array, "tech_NdefFormatable_format_read_only");
1197
+ }
1198
+
1199
+ // return byte[]
1200
+ extern "C" VALUE rho_nfc_tech_NfcB_get_application_data() {
1201
+ return JavaHelper_exec_bytearray_void("tech_NfcB_get_application_data");
1202
+ }
1203
+
1204
+ // return byte[]
1205
+ extern "C" VALUE rho_nfc_tech_NfcB_get_protocol_info() {
1206
+ return JavaHelper_exec_bytearray_void("tech_NfcB_get_protocol_info");
1207
+ }
1208
+
1209
+ // byte[] -> byte[]
1210
+ extern "C" VALUE rho_nfc_tech_NfcB_transceive(VALUE data) {
1211
+ return JavaHelper_exec_bytearray_bytearray(data, "tech_NfcB_transceive");
1212
+ }
1213
+
1214
+ // return byte[]
1215
+ extern "C" VALUE rho_nfc_tech_NfcF_get_manufacturer() {
1216
+ return JavaHelper_exec_bytearray_void("tech_NfcF_get_manufacturer");
1217
+ }
1218
+
1219
+ // return byte[]
1220
+ extern "C" VALUE rho_nfc_tech_NfcF_get_system_code() {
1221
+ return JavaHelper_exec_bytearray_void("tech_NfcF_get_system_code");
1222
+ }
1223
+
1224
+ // byte[] -> byte[]
1225
+ extern "C" VALUE rho_nfc_tech_NfcF_transceive(VALUE data) {
1226
+ return JavaHelper_exec_bytearray_bytearray(data, "tech_NfcF_transceive");
1227
+ }
1228
+
1229
+ extern "C" int rho_nfc_tech_NfcV_get_dsf_id() {
1230
+ return JavaHelper_exec_int_void("tech_NfcV_get_dsf_id");
1231
+ }
1232
+
1233
+ extern "C" int rho_nfc_tech_NfcV_get_responce_flags() {
1234
+ return JavaHelper_exec_int_void("tech_NfcV_get_responce_flags");
1235
+ }
1236
+
1237
+ // byte[] -> byte[]
1238
+ extern "C" VALUE rho_nfc_tech_NfcV_transceive(VALUE data) {
1239
+ return JavaHelper_exec_bytearray_bytearray(data, "tech_NfcV_transceive");
1240
+ }
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+
1247
+
1248
+ // private native void callTechCallback(String callback_url, String event);
1249
+ extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_callTechCallback
1250
+ (JNIEnv *env, jclass, jstring js_callback_url, jstring js_event)
442
1251
  {
443
- logi("native callback START");
444
- // fill java ids
445
- jclass_NfcMessagePack = env->FindClass("com/rhomobile/nfc/NfcMessagePack");
446
- jclass_NfcMessage = env->FindClass("com/rhomobile/nfc/NfcMessage");
447
- jclass_NfcRecord = env->FindClass("com/rhomobile/nfc/NfcRecord");
1252
+ char url[2048];
1253
+ char body[2048];
448
1254
 
449
- jmethod_NfcMessagePack_getItemCount = env->GetMethodID( jclass_NfcMessagePack, "getItemCount", "()I");
450
- jmethod_NfcMessagePack_getItem = env->GetMethodID( jclass_NfcMessagePack, "getItem", "(I)Lcom/rhomobile/nfc/NfcMessage;");
1255
+ const char* jurl = env->GetStringUTFChars(js_callback_url,0);
1256
+ const char* jevent = env->GetStringUTFChars(js_event,0);
1257
+ strcpy(url, jurl);
1258
+ env->ReleaseStringUTFChars(js_callback_url, jurl);
1259
+
1260
+ strcpy(body, "&rho_callback=1");
1261
+ strcat(body, "&");
1262
+ strcat(body, "Tag_event=");
1263
+ strcat(body, jevent);
1264
+ env->ReleaseStringUTFChars(js_event, jevent);
1265
+
1266
+ rho_net_request_with_data(rho_http_normalizeurl(url), body);
1267
+ }
1268
+
1269
+ // private native void callTechCallback(String callback_url, String event);
1270
+ extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_logNative
1271
+ (JNIEnv *env, jclass, jstring js_msg)
1272
+ {
1273
+ char msg[2048];
1274
+
1275
+ const char* jmsg = env->GetStringUTFChars(js_msg,0);
1276
+ strcpy(msg, jmsg);
1277
+ env->ReleaseStringUTFChars(js_msg, jmsg);
1278
+
1279
+ logi(msg);
1280
+ }
451
1281
 
452
- jmethod_NfcMessage_getItemCount = env->GetMethodID( jclass_NfcMessage, "getItemCount", "()I");
453
- jmethod_NfcMessage_getItem = env->GetMethodID( jclass_NfcMessage, "getItem", "(I)Lcom/rhomobile/nfc/NfcRecord;");
454
- jmethod_NfcMessage_getByteArray = env->GetMethodID( jclass_NfcMessage, "getByteArray", "()[B");
455
1282
 
456
- jmethod_NfcRecord_getId = env->GetMethodID( jclass_NfcRecord, "getId", "()[B");
457
- jmethod_NfcRecord_getPayload = env->GetMethodID( jclass_NfcRecord, "getPayload", "()[B");
458
- jmethod_NfcRecord_getPayloadString = env->GetMethodID( jclass_NfcRecord, "getPayloadString", "()Ljava/lang/String;");
459
- jmethod_NfcRecord_getTnf = env->GetMethodID( jclass_NfcRecord, "getTnf", "()I");
460
- jmethod_NfcRecord_getType = env->GetMethodID( jclass_NfcRecord, "getType", "()[B");
461
- jmethod_NfcRecord_getByteArray = env->GetMethodID( jclass_NfcRecord, "getByteArray", "()[B");
462
- jmethod_NfcRecord_getSubrecords = env->GetMethodID( jclass_NfcRecord, "getSubrecords", "()Lcom/rhomobile/nfc/NfcMessage;");
463
1283
 
464
- logi("native callback TMP 01 java IDs collected");
465
1284
 
1285
+
1286
+ // private native void callCallback(String callback_url, NfcMessagePack msgpack);
1287
+ extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_callCallback
1288
+ (JNIEnv *env, jclass, jstring js_callback_url, jobject jo_msgpack)
1289
+ {
1290
+ logi("native callback START");
1291
+
1292
+ initJavaIds(env);
1293
+
466
1294
  CNFCMessagePack* messagePack = new CNFCMessagePack(env, jo_msgpack);
467
1295
 
468
- logi("native callback TMP 02 C++ containers created");
469
-
470
1296
  char url[2048];
471
1297
  char body[2048];
472
1298
 
@@ -474,17 +1300,12 @@ extern "C" void JNICALL Java_com_rhomobile_nfc_Nfc_callCallback
474
1300
  strcpy(url, jurl);
475
1301
  env->ReleaseStringUTFChars(js_callback_url, jurl);
476
1302
 
477
- logi("native callback TMP 03 url prepared");
478
-
479
1303
  strcpy(body, "&rho_callback=1");
480
1304
  strcat(body, "&");
481
1305
  strcat(body, (RHODESAPP().addCallbackObject( new RhoCallbackNFCContainer(messagePack), "messages")).c_str());
482
1306
 
483
- logi("native callback TMP 03+1 body prepared");
484
-
485
1307
  rho_net_request_with_data(rho_http_normalizeurl(url), body);
486
1308
 
487
- logi("native callback FINISH");
488
1309
  }
489
1310
 
490
1311