rhodes 2.2.6 → 2.3.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (486) hide show
  1. data/CHANGELOG +20 -0
  2. data/README.md +46 -0
  3. data/Rakefile +85 -80
  4. data/bin/rhodes +2 -2
  5. data/bin/rhogen +1 -1
  6. data/doc/application.txt +277 -0
  7. data/doc/bb-css.txt +209 -0
  8. data/doc/build.txt +785 -0
  9. data/doc/configuration.txt +236 -0
  10. data/doc/connect-to-web-services.txt +282 -0
  11. data/doc/contributing.txt +64 -0
  12. data/doc/css-framework.txt +144 -0
  13. data/doc/device-caps.txt +1152 -0
  14. data/doc/extensions.txt +528 -0
  15. data/doc/files.txt +4 -0
  16. data/doc/generator.txt +141 -0
  17. data/doc/install.txt +35 -0
  18. data/doc/introduction.txt +88 -0
  19. data/doc/rhom.txt +826 -0
  20. data/doc/standard-css.txt +392 -0
  21. data/doc/synchronization.txt +542 -0
  22. data/doc/test-log-debug.txt +148 -0
  23. data/doc/tutorial.txt +136 -0
  24. data/doc/ui.txt +766 -0
  25. data/installer/EnvVarUpdate.nsh +328 -0
  26. data/installer/README.html +81 -0
  27. data/installer/RHOSYNC-LICENSE.txt +675 -0
  28. data/installer/icon.ico +0 -0
  29. data/installer/instant-rhodes.nsi +427 -0
  30. data/lib/build/jake.rb +15 -1
  31. data/lib/extensions/barcode/ext/barcode/platform/android/jni/src/imageprovider.cpp +1 -1
  32. data/lib/extensions/barcode/ext/barcode/platform/bb/Barcode6.files +45 -0
  33. data/lib/extensions/barcode/ext/barcode/platform/bb/Rakefile +6 -0
  34. data/lib/extensions/barcode/ext/barcode/platform/bb/barcode6.jdp +92 -0
  35. data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +7 -4
  36. data/lib/extensions/barcode/ext/barcode/platform/iphone/Rakefile +2 -1
  37. data/lib/extensions/barcode/ext/barcode/platform/wm/src/wm_imageprovider.cpp +1 -1
  38. data/lib/extensions/digest-sha1/ext/build.bat +1 -0
  39. data/lib/extensions/digest-sha1/ext/digest-sha1.vcproj +335 -0
  40. data/lib/extensions/esri/ext/build +17 -0
  41. data/lib/extensions/esri/ext/build.bat +29 -0
  42. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactory.h +7 -0
  43. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactory.mm +58 -0
  44. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactoryRegister.mm +22 -0
  45. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewManager.h +21 -0
  46. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewManager.mm +32 -0
  47. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/InitESRI.c +5 -0
  48. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/MapViewControllerESRI.h +143 -0
  49. data/lib/extensions/esri/ext/esri/platform/iphone/Classes/MapViewControllerESRI.m +919 -0
  50. data/lib/extensions/esri/ext/esri/platform/iphone/ESRI.xcodeproj/project.pbxproj +320 -0
  51. data/lib/extensions/esri/ext/esri/platform/iphone/ESRI_Prefix.pch +7 -0
  52. data/lib/extensions/esri/ext/esri/platform/iphone/Rakefile +76 -0
  53. data/lib/extensions/esri/ext.yml +3 -0
  54. data/lib/extensions/net-http/monitor.rb +265 -0
  55. data/lib/extensions/net-http/net/ftp.rb +981 -0
  56. data/lib/extensions/net-http/thread.rb +367 -0
  57. data/lib/extensions/rhocgi/cgi.rb +16 -0
  58. data/lib/extensions/rhospec/rhospec.rb +118 -0
  59. data/lib/framework/base64.rb +91 -0
  60. data/lib/framework/builtinME.rb +13 -10
  61. data/lib/framework/ostruct.rb +145 -0
  62. data/lib/framework/res/back_btn.wm.png +0 -0
  63. data/lib/framework/res/blue_pushpin.wm.png +0 -0
  64. data/lib/framework/res/blue_pushpin_small.wm.png +0 -0
  65. data/lib/framework/res/callout.wm.png +0 -0
  66. data/lib/framework/res/callout_link.wm.png +0 -0
  67. data/lib/framework/res/forward_btn.wm.png +0 -0
  68. data/lib/framework/res/home_btn.wm.png +0 -0
  69. data/lib/framework/res/options_btn.wm.png +0 -0
  70. data/lib/framework/res/refresh_btn.wm.png +0 -0
  71. data/lib/framework/rho/render.rb +5 -2
  72. data/lib/framework/rho/rho.rb +320 -50
  73. data/lib/framework/rho/rhoapplication.rb +48 -10
  74. data/lib/framework/rho/rhonativeviewmanager.rb +73 -0
  75. data/lib/framework/rho/rhosupport.rb +15 -1
  76. data/lib/framework/rho/rhotabbar.rb +29 -0
  77. data/lib/framework/rho/rhotoolbar.rb +17 -0
  78. data/lib/framework/rho/rhoutils.rb +22 -6
  79. data/lib/framework/rhodes.rb +1 -1
  80. data/lib/framework/rholang/rhomsg_de.rb +4 -3
  81. data/lib/framework/rholang/rhomsg_en.rb +1 -0
  82. data/lib/framework/rholang/rhomsg_es.rb +1 -0
  83. data/lib/framework/rholang/rhomsg_it.rb +1 -0
  84. data/lib/framework/rhom/rhom.rb +31 -10
  85. data/lib/framework/rhom/rhom_db_adapter.rb +33 -23
  86. data/lib/framework/rhom/rhom_object_factory.rb +465 -249
  87. data/lib/framework/rhom/rhom_source.rb +22 -7
  88. data/lib/framework/version.rb +1 -1
  89. data/lib/rhodes.rb +1 -1
  90. data/platform/android/Rhodes/AndroidManifest.xml +83 -20
  91. data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +5 -0
  92. data/platform/android/Rhodes/jni/include/rhodes/RhoClassFactory.h +2 -0
  93. data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +9 -5
  94. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesAppOptions.h +53 -0
  95. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +46 -56
  96. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_SplashScreen.h +10 -0
  97. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_mapview_MapView.h +93 -0
  98. data/platform/android/Rhodes/jni/include/rhodes/rhocryptimpl.h +38 -0
  99. data/platform/android/Rhodes/jni/include/rhodes.h +64 -8
  100. data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +6 -0
  101. data/platform/android/Rhodes/jni/src/alert.cpp +5 -11
  102. data/platform/android/Rhodes/jni/src/bluetooth.cpp +66 -29
  103. data/platform/android/Rhodes/jni/src/callbacks.cpp +24 -21
  104. data/platform/android/Rhodes/jni/src/camera.cpp +2 -6
  105. data/platform/android/Rhodes/jni/src/datetimepicker.cpp +13 -11
  106. data/platform/android/Rhodes/jni/src/event.cpp +9 -15
  107. data/platform/android/Rhodes/jni/src/fileapi.cpp +13 -27
  108. data/platform/android/Rhodes/jni/src/logconf.cpp +3 -3
  109. data/platform/android/Rhodes/jni/src/mapview.cpp +696 -16
  110. data/platform/android/Rhodes/jni/src/menu.cpp +3 -3
  111. data/platform/android/Rhodes/jni/src/nativebar.cpp +55 -4
  112. data/platform/android/Rhodes/jni/src/nativeview.cpp +33 -0
  113. data/platform/android/Rhodes/jni/src/phonebook.cpp +6 -11
  114. data/platform/android/Rhodes/jni/src/rhoconf.cpp +4 -4
  115. data/platform/android/Rhodes/jni/src/rhocryptimpl.cpp +87 -0
  116. data/platform/android/Rhodes/jni/src/rhodes.cpp +55 -34
  117. data/platform/android/Rhodes/jni/src/ringtones.cpp +2 -3
  118. data/platform/android/Rhodes/jni/src/signature.cpp +3 -5
  119. data/platform/android/Rhodes/jni/src/splashscreen.cpp +7 -0
  120. data/platform/android/Rhodes/jni/src/sslimpl.cpp +17 -20
  121. data/platform/android/Rhodes/jni/src/webview.cpp +13 -12
  122. data/platform/android/Rhodes/res/drawable/callout.png +0 -0
  123. data/platform/android/Rhodes/res/drawable/callout_link.png +0 -0
  124. data/platform/android/Rhodes/res/drawable/signature_cancel.png +0 -0
  125. data/platform/android/Rhodes/res/drawable/signature_clear.png +0 -0
  126. data/platform/android/Rhodes/res/drawable/signature_ok.png +0 -0
  127. data/platform/android/Rhodes/res/layout/datetime.xml +4 -0
  128. data/platform/android/Rhodes/res/layout/signature.xml +24 -17
  129. data/platform/android/Rhodes/res/layout/status_bar_ongoing_event_progress_bar.xml +102 -0
  130. data/platform/android/Rhodes/res/values/strings.xml +1 -1
  131. data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +6 -0
  132. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Base64.java +575 -0
  133. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +83 -0
  134. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +21 -3
  135. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +23 -15
  136. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +2 -2
  137. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +151 -0
  138. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +2 -2
  139. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +372 -0
  140. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesAppOptions.java +11 -0
  141. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +58 -0
  142. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +705 -523
  143. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RingtoneManager.java +1 -1
  144. data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +167 -85
  145. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java +36 -1
  146. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +4 -2
  147. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +33 -20
  148. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/IRhoBluetoothManager.java +2 -6
  149. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManager.java +2 -24
  150. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerNew.java +106 -36
  151. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerOld.java +15 -58
  152. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothSession.java +0 -7
  153. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +6 -4
  154. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/FileList.java +4 -3
  155. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +91 -27
  156. data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePicker.java +6 -3
  157. data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +275 -42
  158. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +1 -1
  159. data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +1 -3
  160. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +1 -1
  161. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +1 -0
  162. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +120 -43
  163. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +518 -28
  164. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/AnnotationsOverlay.java +2 -2
  165. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/GoogleMapView.java +434 -0
  166. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapTouch.java +20 -0
  167. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +296 -336
  168. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MultiTouchHandler.java +111 -0
  169. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/OneTouchHandler.java +77 -0
  170. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/TouchHandler.java +10 -0
  171. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +0 -1
  172. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +5 -1
  173. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +1 -1
  174. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +1 -1
  175. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/ImageCapture.java +6 -11
  176. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/Signature.java +6 -4
  177. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +0 -7
  178. data/platform/android/Rhodes/src/com/rhomobile/rhodes/ui/LogViewDialog.java +9 -4
  179. data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +8 -8
  180. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +5 -1
  181. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +11 -7
  182. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +3 -5
  183. data/platform/android/build/RhodesSRC_build.files +32 -23
  184. data/platform/android/build/android.rake +28 -11
  185. data/platform/android/build/androidcommon.rb +2 -0
  186. data/platform/android/build/librhocommon_build.files +9 -5
  187. data/platform/android/build/librhodes_build.files +1 -0
  188. data/platform/android/build/libruby_build.files +1 -0
  189. data/platform/bb/Hsqldb/Hsqldb.jdp +0 -2
  190. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +10 -2
  191. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +37 -5
  192. data/platform/bb/Hsqldb/src/org/hsqldb/Column.java +5 -5
  193. data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +1 -1
  194. data/platform/bb/Hsqldb/src/org/hsqldb/Function.java +73 -78
  195. data/platform/bb/Hsqldb/src/org/hsqldb/Library.java +288 -8
  196. data/platform/bb/RubyVM/RubyVM.jdp +3 -0
  197. data/platform/bb/RubyVM/src/com/rho/FilePath.java +13 -1
  198. data/platform/bb/RubyVM/src/com/rho/IRhoRubyHelper.java +2 -2
  199. data/platform/bb/RubyVM/src/com/rho/RhoAppAdapter.java +12 -0
  200. data/platform/bb/RubyVM/src/com/rho/RhoClassFactory.java +18 -1
  201. data/platform/bb/RubyVM/src/com/rho/RhoConf.java +128 -108
  202. data/platform/bb/RubyVM/src/com/rho/RhoLogConf.java +9 -10
  203. data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +16 -1
  204. data/platform/bb/RubyVM/src/com/rho/RhoProfiler.java +1 -1
  205. data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +20 -0
  206. data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +5 -2
  207. data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +65 -46
  208. data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +192 -50
  209. data/platform/bb/RubyVM/src/com/rho/db/DBAttrManager.java +8 -114
  210. data/platform/bb/RubyVM/src/com/rho/db/DBException.java +1 -1
  211. data/platform/bb/RubyVM/src/com/rho/db/IDBCallback.java +1 -1
  212. data/platform/bb/RubyVM/src/com/rho/db/IDBResult.java +5 -3
  213. data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +5 -1
  214. data/platform/bb/RubyVM/src/com/rho/file/FileAccessBB.java +109 -0
  215. data/platform/bb/RubyVM/src/com/rho/file/RhoFile.java +85 -0
  216. data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +12 -4
  217. data/platform/bb/RubyVM/src/com/rho/net/NetResponse.java +5 -0
  218. data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +37 -23
  219. data/platform/bb/RubyVM/src/com/rho/net/URI.java +84 -0
  220. data/platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java +1 -1
  221. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +119 -61
  222. data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +61 -24
  223. data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +108 -54
  224. data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +121 -163
  225. data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +23 -0
  226. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyMutex.java +1 -1
  227. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyRange.java +3 -1
  228. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyRegexp.java +3 -1
  229. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +208 -25
  230. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +3 -1
  231. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +5 -1
  232. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyAPI.java +12 -5
  233. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyID.java +1 -0
  234. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +16 -0
  235. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule_Methods.java +5 -0
  236. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyValue.java +1 -1
  237. data/platform/bb/RubyVM/src/com/xruby/runtime/stdlib/RubyStringIO.java +4 -1
  238. data/platform/bb/{Hsqldb → RubyVM}/src/j2me/math/Number.java +33 -0
  239. data/platform/bb/build/RubyVM_build.files +3 -0
  240. data/platform/bb/build/bb.rake +140 -62
  241. data/platform/bb/build/hsqldb_build.files +0 -2
  242. data/platform/bb/build/rhodes_build.files +5 -0
  243. data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +43 -7
  244. data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +23 -2
  245. data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +5 -0
  246. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteCopyResult.java +143 -0
  247. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteResult.java +269 -0
  248. data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +446 -0
  249. data/platform/bb/rhodes/platform/common/com/rho/BrowserAdapter5.java +3 -0
  250. data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +12 -2
  251. data/platform/bb/rhodes/platform/common/com/rho/db/SqliteCopyResult.java +2 -0
  252. data/platform/bb/rhodes/platform/common/com/rho/db/SqliteResult.java +2 -0
  253. data/platform/bb/rhodes/platform/common/com/rho/db/SqliteStorage.java +2 -0
  254. data/platform/bb/rhodes/resources/mappin.png +0 -0
  255. data/platform/bb/rhodes/rhodes.jdp +3 -0
  256. data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +21 -18
  257. data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +150 -0
  258. data/platform/bb/rhodes/src/com/rho/IBrowserAdapter.java +1 -0
  259. data/platform/bb/rhodes/src/com/rho/RhoMainScreen.java +63 -4
  260. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +6 -5
  261. data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +242 -2
  262. data/platform/bb/rhodes/src/com/rho/db/SqliteCopyResult.java +143 -0
  263. data/platform/bb/rhodes/src/com/rho/db/SqliteResult.java +269 -0
  264. data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +446 -0
  265. data/platform/bb/rhodes/src/com/rho/file/Jsr75File.java +1 -1
  266. data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +71 -14
  267. data/platform/bb/rhodes/src/com/rho/net/bb/BBHttpConnection.java +4 -2
  268. data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +28 -12
  269. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +100 -4
  270. data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +3 -2
  271. data/platform/bb/rhodes/src/com/rho/rubyext/XMLParser.java +1 -1
  272. data/platform/bb/rhodes/src/rhomobile/NativeBar.java +32 -0
  273. data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +9 -2
  274. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +174 -41
  275. data/platform/bb/rhodes/src/rhomobile/datetime/DateTimePicker.java +52 -3
  276. data/platform/bb/rhodes/src/rhomobile/datetime/DateTimeScreen.java +33 -1
  277. data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +2 -14
  278. data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapField.java +686 -0
  279. data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapProvider.java +14 -0
  280. data/platform/bb/rhodes/src/rhomobile/mapview/GeoCoding.java +13 -0
  281. data/platform/bb/rhodes/src/rhomobile/mapview/GoogleGeoCoding.java +174 -0
  282. data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +104 -330
  283. data/platform/bb/rhodes/src/rhomobile/mapview/MapTools.java +79 -0
  284. data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +35 -12
  285. data/platform/bb/rhodes/src/rhomobile/mapview/MapViewParent.java +2 -1
  286. data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +336 -44
  287. data/platform/bb/rhodes/src/rhomobile/mapview/RhoMapField.java +3 -6
  288. data/platform/iphone/Classes/AppManager/AppManager.m +19 -4
  289. data/platform/iphone/Classes/DateTime.h +4 -0
  290. data/platform/iphone/Classes/DateTime.m +1 -1
  291. data/platform/iphone/Classes/DateTimePicker.m +8 -1
  292. data/platform/iphone/Classes/DateTimePickerDelegate.m +7 -1
  293. data/platform/iphone/Classes/Event/Event.m +2 -2
  294. data/platform/iphone/Classes/MapView/MapViewController.h +4 -1
  295. data/platform/iphone/Classes/MapView/MapViewController.m +6 -46
  296. data/platform/iphone/Classes/MapView/MapViewManager.h +26 -0
  297. data/platform/iphone/Classes/MapView/MapViewManager.m +172 -0
  298. data/platform/iphone/Classes/NativeBar.h +34 -0
  299. data/platform/iphone/Classes/NativeBar.m +131 -26
  300. data/platform/iphone/Classes/NativeView/NVDelegate.h +26 -0
  301. data/platform/iphone/Classes/NativeView/NVDelegate.m +40 -0
  302. data/platform/iphone/Classes/NativeView/NVViewController.h +24 -0
  303. data/platform/iphone/Classes/NativeView/NVViewController.m +90 -0
  304. data/platform/iphone/Classes/NativeView/RhoNativeViewManager.mm +449 -0
  305. data/platform/iphone/Classes/{RhoNativeViewManagerOC.h → NativeView/RhoNativeViewManagerOC.h} +15 -0
  306. data/platform/iphone/Classes/RhoAlert.m +3 -3
  307. data/platform/iphone/Classes/RhoMainView.h +3 -0
  308. data/platform/iphone/Classes/Rhodes.h +6 -2
  309. data/platform/iphone/Classes/Rhodes.m +47 -79
  310. data/platform/iphone/Classes/Signature/SignatureViewController.m +1 -0
  311. data/platform/iphone/Classes/SimpleMainView.h +18 -1
  312. data/platform/iphone/Classes/SimpleMainView.m +180 -35
  313. data/platform/iphone/Classes/SplitView/LeftViewController.h +1 -1
  314. data/platform/iphone/Classes/SplitView/LeftViewController.m +13 -7
  315. data/platform/iphone/Classes/SplitView/RightViewController.h +1 -1
  316. data/platform/iphone/Classes/SplitView/RightViewController.m +26 -11
  317. data/platform/iphone/Classes/SplitView/SplittedMainView.h +1 -6
  318. data/platform/iphone/Classes/SplitView/SplittedMainView.m +14 -52
  319. data/platform/iphone/Classes/TabbedMainView.h +25 -3
  320. data/platform/iphone/Classes/TabbedMainView.m +340 -14
  321. data/platform/iphone/ESRI/BluePushpin.png +0 -0
  322. data/platform/iphone/ESRI/BluePushpin@2x.png +0 -0
  323. data/platform/iphone/ESRI/esri.png +0 -0
  324. data/platform/iphone/ESRI/esri@2x.png +0 -0
  325. data/platform/iphone/Info.plist +1 -1
  326. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +26 -3
  327. data/platform/iphone/rbuild/iphone.rake +100 -4
  328. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +12 -0
  329. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +116 -12
  330. data/platform/shared/SyncClient/SyncClient.cpp +29 -3
  331. data/platform/shared/SyncClient/SyncClient.h +2 -1
  332. data/platform/shared/common/IRhoClassFactory.h +3 -0
  333. data/platform/shared/common/IRhoCrypt.h +16 -0
  334. data/platform/shared/common/IRhoThreadImpl.h +1 -0
  335. data/platform/shared/common/RhoAppAdapter.h +2 -0
  336. data/platform/shared/common/RhoConf.cpp +97 -46
  337. data/platform/shared/common/RhoConf.h +14 -13
  338. data/platform/shared/common/RhoFile.cpp +10 -0
  339. data/platform/shared/common/RhoFile.h +1 -0
  340. data/platform/shared/common/RhoMath.cpp +43 -0
  341. data/platform/shared/common/RhoMath.h +27 -0
  342. data/platform/shared/common/RhoNativeViewManager.h +27 -1
  343. data/platform/shared/common/RhoPort.h +11 -0
  344. data/platform/shared/common/RhoStd.h +5 -0
  345. data/platform/shared/common/RhoThread.cpp +1 -1
  346. data/platform/shared/common/RhoThread.h +1 -1
  347. data/platform/shared/common/RhodesApp.cpp +381 -139
  348. data/platform/shared/common/RhodesApp.h +24 -10
  349. data/platform/shared/common/RhodesAppBase.cpp +72 -1
  350. data/platform/shared/common/RhodesAppBase.h +5 -1
  351. data/platform/shared/common/SplashScreen.h +4 -4
  352. data/platform/shared/common/ThreadQueue.cpp +44 -17
  353. data/platform/shared/common/ThreadQueue.h +4 -0
  354. data/platform/shared/common/app_build_configs.c +0 -1
  355. data/platform/shared/common/iphone/RhoClassfactory.h +6 -0
  356. data/platform/shared/common/iphone/RhoCryptImpl.h +47 -0
  357. data/platform/shared/common/iphone/RhoCryptImpl.mm +286 -0
  358. data/platform/shared/common/map/ESRIMapEngine.cpp +921 -0
  359. data/platform/shared/common/map/ESRIMapEngine.h +255 -0
  360. data/platform/shared/common/map/GoogleMapEngine.cpp +160 -0
  361. data/platform/shared/common/map/GoogleMapEngine.h +52 -0
  362. data/platform/shared/common/map/MapEngine.cpp +304 -0
  363. data/platform/shared/common/map/MapEngine.h +214 -0
  364. data/platform/shared/db/DBAdapter.cpp +147 -18
  365. data/platform/shared/db/DBAdapter.h +38 -12
  366. data/platform/shared/db/DBAttrManager.cpp +4 -3
  367. data/platform/shared/db/DBAttrManager.h +7 -7
  368. data/platform/shared/db/res/db/syncdb.triggers +0 -5
  369. data/platform/shared/db/res/db/syncdb_java.triggers +21 -0
  370. data/platform/shared/json/JSONIterator.cpp +11 -1
  371. data/platform/shared/json/JSONIterator.h +1 -0
  372. data/platform/shared/logging/RhoLogConf.cpp +29 -12
  373. data/platform/shared/net/CURLNetRequest.cpp +80 -25
  374. data/platform/shared/net/CURLNetRequest.h +6 -2
  375. data/platform/shared/net/HttpServer.cpp +12 -6
  376. data/platform/shared/net/HttpServer.h +2 -1
  377. data/platform/shared/net/INetRequest.h +1 -0
  378. data/platform/shared/ruby/ext/alert/alert.i +5 -0
  379. data/platform/shared/ruby/ext/alert/alert_wrap.c +439 -108
  380. data/platform/shared/ruby/ext/datetimepicker/datetimepicker.i +42 -0
  381. data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +521 -120
  382. data/platform/shared/ruby/ext/nativebar/nativebar.i +16 -0
  383. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +623 -128
  384. data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager.i +18 -0
  385. data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager_wrap.c +2321 -0
  386. data/platform/shared/ruby/ext/rho/extensions.c +0 -1
  387. data/platform/shared/ruby/ext/rho/rhoruby.c +53 -0
  388. data/platform/shared/ruby/ext/rho/rhoruby.h +6 -0
  389. data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +6 -3
  390. data/platform/shared/ruby/ext/syncengine/syncengine.i +9 -1
  391. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +61 -0
  392. data/platform/shared/ruby/ext/system/system.i +4 -0
  393. data/platform/shared/ruby/ext/system/system_wrap.c +33 -5
  394. data/platform/shared/rubyext/RhoAppAdapter.cpp +11 -1
  395. data/platform/shared/rubyext/System.cpp +9 -0
  396. data/platform/shared/rubyext/WebView.h +1 -0
  397. data/platform/shared/sqlite/crypto.c +907 -0
  398. data/platform/shared/sqlite/sqlite3.c +6 -0
  399. data/platform/shared/sync/SyncEngine.cpp +49 -19
  400. data/platform/shared/sync/SyncEngine.h +0 -1
  401. data/platform/shared/sync/SyncNotify.cpp +14 -5
  402. data/platform/shared/sync/SyncNotify.h +2 -2
  403. data/platform/shared/sync/SyncSource.cpp +79 -33
  404. data/platform/shared/sync/SyncSource.h +1 -0
  405. data/platform/shared/sync/SyncThread.cpp +26 -11
  406. data/platform/shared/xruby/src/com/xruby/compiler/codedom/StringExpression.java +4 -2
  407. data/platform/wm/RhoLib/RhoLib.vcproj +108 -72
  408. data/platform/wm/build/wm.rake +6 -0
  409. data/platform/wm/rhodes/Alert.cpp +4 -3
  410. data/platform/wm/rhodes/Alert.h +1 -1
  411. data/platform/wm/rhodes/DateTimePicker.cpp +30 -3
  412. data/platform/wm/rhodes/DateTimePicker.h +9 -1
  413. data/platform/wm/rhodes/MainWindow.cpp +121 -61
  414. data/platform/wm/rhodes/MainWindow.h +29 -4
  415. data/platform/wm/rhodes/MapView/Graphics.cpp +547 -0
  416. data/platform/wm/rhodes/MapView/Graphics.h +136 -0
  417. data/platform/wm/rhodes/MapView/MapViewManager.cpp +391 -0
  418. data/platform/wm/rhodes/MapView/MapViewManager.h +158 -0
  419. data/platform/wm/rhodes/RhoCryptImpl.cpp +248 -0
  420. data/platform/wm/rhodes/RhoCryptImpl.h +51 -0
  421. data/platform/wm/rhodes/RhoNativeViewManager.cpp +208 -0
  422. data/platform/wm/rhodes/Rhodes.cpp +94 -102
  423. data/platform/wm/rhodes/Rhodes.rc +27 -0
  424. data/platform/wm/rhodes/SyncStatusDlg.cpp +1 -0
  425. data/platform/wm/rhodes/SyncStatusDlg.h +2 -1
  426. data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +7 -4
  427. data/platform/wm/rhodes/camera/Camera.cpp +36 -15
  428. data/platform/wm/rhodes/camera/Camera.h +0 -4
  429. data/platform/wm/rhodes/resource.h +10 -2
  430. data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +7 -0
  431. data/platform/wm/rhodes/rho/common/RhoClassFactory.h +1 -0
  432. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +10 -2
  433. data/platform/wm/rhodes/rho/net/NetRequestImpl.h +10 -0
  434. data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +513 -0
  435. data/platform/wm/rhodes/rho/rubyext/NativeToolbar.h +74 -0
  436. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +22 -10
  437. data/platform/wm/rhodes/rho/rubyext/WebView.cpp +5 -0
  438. data/platform/wm/rhodes/rhodes.vcproj +38 -2
  439. data/platform/wm/rhodes/stdafx.h +2 -1
  440. data/platform/wm/rubylib/rubylib.vcproj +12 -0
  441. data/rakefile.rb +85 -80
  442. data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +14 -3
  443. data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
  444. data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +2 -0
  445. data/res/build-tools/xruby-0.3.3.jar +0 -0
  446. data/res/generators/templates/application/app/application.rb +2 -2
  447. data/res/generators/templates/application/app/helpers/application_helper.rb +1 -1
  448. data/res/generators/templates/application/public/css/android.css +1 -0
  449. data/res/generators/templates/application/public/jqtouch/jquery.1.3.2.min.js +1 -1
  450. data/res/generators/templates/application/rhoconfig.txt +66 -14
  451. data/rhodes.gemspec +3 -3
  452. data/spec/framework_spec/app/spec/core/file/expand_path_spec.rb +7 -3
  453. data/spec/framework_spec/build.yml +1 -1
  454. data/spec/phone_spec/Rakefile +1 -0
  455. data/spec/phone_spec/app/Account/account.rb +2 -0
  456. data/spec/phone_spec/app/Account_s/account_s.rb +7 -0
  457. data/spec/phone_spec/app/spec/{fixtures → array/fixtures}/classes.rb +0 -0
  458. data/spec/phone_spec/app/spec/{array_pack_spec.rb → array/pack_spec.rb} +2 -1
  459. data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
  460. data/spec/phone_spec/app/spec/contacts_spec.rb +2 -0
  461. data/spec/phone_spec/app/spec/rho_spec.rb +34 -233
  462. data/spec/phone_spec/app/spec/rhom_object_spec.rb +396 -87
  463. data/spec/phone_spec/app/spec/string/element_set_spec.rb +251 -0
  464. data/spec/phone_spec/app/spec/string/end_with_spec.rb +49 -0
  465. data/spec/phone_spec/app/spec/string/fixtures/classes.rb +27 -0
  466. data/spec/phone_spec/app/spec/{lstrip_spec.rb → string/lstrip_spec.rb} +0 -0
  467. data/spec/phone_spec/app/spec/string/replace_spec.rb +52 -0
  468. data/spec/phone_spec/app/spec/{rstrip_spec.rb → string/rstrip_spec.rb} +0 -0
  469. data/spec/phone_spec/app/spec/string/slice_spec.rb +473 -0
  470. data/spec/phone_spec/app/spec/string/split_spec.rb +302 -0
  471. data/spec/phone_spec/app/spec/string/start_with_spec.rb +48 -0
  472. data/spec/phone_spec/app/spec/{strip_spec.rb → string/strip_spec.rb} +0 -0
  473. data/spec/phone_spec/app/spec/syncengine_spec.rb +30 -1
  474. data/spec/phone_spec/app/spec_runner.rb +15 -7
  475. data/spec/phone_spec/build.yml +2 -2
  476. metadata +154 -25
  477. data/README.textile +0 -45
  478. data/platform/android/Rhodes/AndroidManifest.full.xml +0 -62
  479. data/platform/android/Rhodes/gen/com/rhomobile/rhodes/Manifest.java +0 -14
  480. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoActivity.java +0 -20
  481. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +0 -193
  482. data/platform/bb/Hsqldb/src/com/rho/file/FileAccessBB.java +0 -25
  483. data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +0 -22
  484. data/platform/bb/RubyVM/src/com/rho/Capabilities.java +0 -6
  485. data/platform/bb/RubyVM/src/com/rho/Extensions.java +0 -11
  486. data/platform/iphone/Classes/RhoNativeViewManager.mm +0 -226
@@ -0,0 +1,542 @@
1
+ Synchronization with Rhodes
2
+ ===
3
+ As we've shown in the [Rhom section](/rhodes/rhom), adding synchronized data via [RhoSync](/rhosync/introduction) to your Rhodes application is as simple as generating a model and enabling a `:sync` flag. This triggers the internal Rhodes sync system called the **`SyncEngine`** to synchronize data for the model and transparently handle bi-directional updates between the Rhodes application and the RhoSync server.
4
+
5
+ This section covers in detail how the `SyncEngine` works in Rhodes and how you can use its flexible APIs to build data-rich native applications.
6
+
7
+ ## Sync Workflow
8
+ The `SyncEngine` interacts with RhoSync over http(s) using [JSON](http://www.json.org/) as a data exchange format. With the exception of [bulk sync](/rhosync/bulk-sync), pages of synchronized data, or "sync pages" as we will refer to them here, are sent as JSON from RhoSync to the `SyncEngine`.
9
+
10
+ Below is a simplified diagram of the `SyncEngine` workflow:
11
+
12
+ <a href="https://img.skitch.com/20110121-8qqyi7n2mg9fampmhcpqb5g9fi.png"><img height="80%" src="https://img.skitch.com/20110121-8qqyi7n2mg9fampmhcpqb5g9fi.png"/></a>
13
+
14
+ This workflow consists of the following steps:
15
+
16
+ * `SyncEngine` sends authentication request to RhoSync via [`SyncEngine.login`](#syncengine-api). RhoSync calls [`Application.authenticate`](/rhosync/authentication) with supplied credentials and returns `true` or `false`.
17
+
18
+ * If this is a new client (i.e. fresh install or reset), the `SyncEngine` will initialize with RhoSync:
19
+
20
+ * It requests a new unique id (client id) from RhoSync. This id will be referenced throughout the sync process.
21
+
22
+ * It will register platform information with RhoSync. If this is a [push-enabled application](/rhodes/device-caps#push-notifications) application, the `SyncEngine` will send additional information like device push pin.
23
+
24
+ * `SyncEngine` requests sync pages from RhoSync, one model(or [Rhom](/rhodes/rhom) model) at a time. The order the models are synchronized is determined by the model's [`:sync_priority`](/rhodes/rhom#property-bag), or determined automatically by the `SyncEngine`.
25
+
26
+ ## Sync Authentication
27
+ When you generate a Rhodes application, you'll notice there is an included directory called `app/Settings`. This contains a default `settings_controller.rb` and some views to manage authentication with [RhoSync](/rhosync/introduction).
28
+
29
+ ### `login`
30
+ In `settings_controller.rb#do_login`, the `SyncEngine.login` method is called:
31
+
32
+ :::ruby
33
+ SyncEngine.login(
34
+ @params['login'],
35
+ @params['password'],
36
+ url_for(:action => :login_callback)
37
+ )
38
+
39
+ Here login is called with the `login` and `password` provided by the `login.erb` form. A `:login_callback` action is declared to handle the asynchronous result of the `SyncEngine.login` request.
40
+
41
+ ### `login_callback`
42
+ When `SyncEngine.login` completes, the callback declared is executed and receives parameters including success or failure and error messages (if any).
43
+
44
+ :::ruby
45
+ def login_callback
46
+ error_code = @params['error_code'].to_i
47
+ if error_code == 0
48
+ # run sync if we were successful
49
+ WebView.navigate Rho::RhoConfig.options_path
50
+ SyncEngine.dosync
51
+ else
52
+ if error_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER
53
+ @msg = @params['error_message']
54
+ end
55
+
56
+ if not @msg or @msg.length == 0
57
+ @msg = Rho::RhoError.new(error_code).message
58
+ end
59
+
60
+ WebView.navigate(
61
+ url_for(:action => :login, :query => {:msg => @msg})
62
+ )
63
+ end
64
+ end
65
+
66
+ This sample checks the login `error_code`, if it is `0`, perform a full sync and render the settings page. Otherwise, it sets up an error message and re-displays the login page with an error.
67
+
68
+
69
+ ### `application.rb#on_sync_user_changed`
70
+ If the `SyncEngine` already knows about a logged-in user and a new user logs in, then the `on_sync_user_changed` hook is called (if it exists) before the `login_callback`. This is useful, for example, if you want to re-initialize personalized settings for a new user.
71
+
72
+ :::ruby
73
+ require 'rho/rhoapplication'
74
+
75
+ class AppApplication < Rho::RhoApplication
76
+ def initialize
77
+ super
78
+ end
79
+
80
+ def on_sync_user_changed
81
+ super
82
+ MyCoolApp.reset_user_preferences!
83
+ end
84
+ end
85
+
86
+ **NOTE: If `on_sync_user_changed`, data for all sync-enabled models will be removed. To remove data for all local models as well:**
87
+
88
+ :::ruby
89
+ def on_sync_user_changed
90
+ super
91
+ Rhom::Rhom.database_local_reset
92
+ end
93
+
94
+ Other auth-related methods are described in the [`SyncEngine` API section](/rhodes/synchronization#syncengine-api).
95
+
96
+ ## Notifications
97
+ The `SyncEngine` system uses notifications to provide information about the sync process to a Rhodes application. Notifications can be setup once for the duration of runtime or each time a sync is triggered. One a sync is processing for a model, notifications are called with parameters containing sync process state. Your application can use this information to display different wait pages, progress bars, etc.
98
+
99
+ To set a notification for a model, you can use the following method:
100
+
101
+ :::ruby
102
+ SyncEngine.set_notification(
103
+ Account.get_source_id,
104
+ url_for(:action => :sync_notify),
105
+ "sync_complete=true"
106
+ )
107
+
108
+ Which is the same as:
109
+
110
+ :::ruby
111
+ Account.set_notification(
112
+ url_for(:action => :sync_notify),
113
+ "sync_complete=true"
114
+ )
115
+
116
+ In this example, once the sync process for the `Account` model is complete, the view will be directed to the `sync_notify` action (with params 'sync_complete=true') if user is on the same page.
117
+
118
+ **NOTE: In these examples, after the sync is complete the notifications are removed.**
119
+
120
+ You can also set a notification for all models:
121
+
122
+ :::ruby
123
+ SyncEngine.set_notification(
124
+ -1, url_for(:action => :sync_notify),
125
+ "sync_complete=true"
126
+ )
127
+
128
+ **NOTE: This notification will not be removed automatically.**
129
+
130
+ ### Notification Parameters
131
+ When the notification is called, it will receive a variable called `@params`, just like a normal Rhodes controller action.
132
+
133
+ #### Common Parameters
134
+ These parameters are included in all notifications.
135
+
136
+ * `@params["source_id"]` - The id of the current model that is synchronizing.
137
+ * `@params["source_name"]` - Name of the model (i.e. "Product")
138
+ * `@params["sync_type"]` - Type of sync used for this model: "incremental" or "bulk"
139
+ * `@params["status"]` - Status of the current sync process: "in_progress", "error", "ok", "complete", "schema-changed"
140
+
141
+ #### "in_progress" - incremental sync
142
+ * `@params["total_count"]` - Total number of records that exist for this RhoSync source.
143
+ * `@params["processed_count"]` - Number of records included in the sync page.
144
+ * `@params["cumulative_count"]` - Number of records the `SyncEngine` has processed so far for this source.
145
+
146
+ #### "in_progress" - bulk sync
147
+ * `@params["bulk_status"]` - The state of the bulk sync process: "start", "download", "change_db".
148
+
149
+
150
+ #### "error"
151
+ * `@params["error_code"]` - HTTP response code of the RhoSync server error: 401, 500, 404, etc.
152
+ * `@params["error_message"]` - Response body (if any)
153
+ * `@params["error_type"]` - Type of RhoSync adapter error (if exists): "login-error", "query-error", "create-error", "update-error", "delete-error", "logoff-error"
154
+ * `@params["create_error"]` - Array of hashes each containing an "object" (that failed to create) and a corresponding "error_message".
155
+
156
+ #### "ok"
157
+ * `@params["total_count"]` - Total number of records that exist for this RhoSync source.
158
+ * `@params["processed_count"]` - Number of records included in the last sync page.
159
+ * `@params["cumulative_count"]` - Number of records the `SyncEngine` has processed so far for this source.
160
+
161
+ #### "complete"
162
+ This status returns only when the `SyncEngine` process is complete.
163
+
164
+ #### "schema-changed"
165
+ This status returns for bulk-sync models that use [`FixedSchema`](/rhom#fixed-schema) when the schema has changed in the RhoSync server.
166
+
167
+ **NOTE: In this scenario the sync callback should notify the user with a wait screen and start the bulk sync process.**
168
+
169
+ ### Notification Example
170
+ Here is a simple example of a sync notification method that uses some of the parameters described above:
171
+
172
+ :::ruby
173
+ def sync_notify
174
+ status = @params['status'] ? @params['status'] : ""
175
+ bulk_sync? = @params['sync_type'] == 'bulk'
176
+
177
+ if status == "in_progress"
178
+ # do nothing
179
+
180
+ elsif status == "complete" or status == "ok"
181
+ WebView.navigate Rho::RhoConfig.start_path
182
+
183
+ elsif status == "error"
184
+ err_code = @params['error_code'].to_i
185
+ rho_error = Rho::RhoError.new(err_code)
186
+
187
+ if err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER
188
+ @msg = @params['error_message']
189
+ end
190
+
191
+ @msg = rho_error.message unless @msg and @msg.length > 0
192
+
193
+ if rho_error.unknown_client?(@params['error_message'])
194
+ Rhom::Rhom.database_client_reset
195
+ SyncEngine.dosync
196
+
197
+ elsif err_code == Rho::RhoError::ERR_UNATHORIZED
198
+ WebView.navigate(
199
+ url_for(
200
+ :action => :login,
201
+ :query => { :msg => "Server credentials expired!" }
202
+ )
203
+ )
204
+ else
205
+ WebView.navigate(
206
+ url_for(
207
+ :action => :err_sync,
208
+ :query => { :msg => @msg }
209
+ )
210
+ )
211
+ end
212
+ end
213
+ end
214
+
215
+ **NOTE: If the view was updated using AJAX calls, this mechanism may not work correctly as the view location will not change from one AJAX call to another. Therefore, you might need to specify the `:controller` option in WebView.navigate.**
216
+
217
+ ### Sync Object Notifications
218
+ The `SyncEngine` can also send a notification when a specific object on the current page has been modified. This is useful if you have frequently-changing data like feeds or timelines in your application and want them to update without the user taking any action.
219
+
220
+ To use object notifications, first set the notification callback in `application.rb#initialize`:
221
+
222
+ :::ruby
223
+ class AppApplication < Rho::RhoApplication
224
+ def initialize
225
+ super
226
+
227
+ SyncEngine.set_objectnotify_url(
228
+ url_for(
229
+ :controller => "Product",
230
+ :action => :sync_object_notify
231
+ )
232
+ )
233
+ end
234
+ end
235
+
236
+ Next, in your controller action that displays the object(s), add the object notification by passing in a record or collection of records:
237
+
238
+ :::ruby
239
+ class ProductController < Rho::RhoController
240
+
241
+ # GET /Product
242
+ def index
243
+ @products = Product.find(:all)
244
+
245
+ add_objectnotify(@products)
246
+ render
247
+ end
248
+
249
+ # ...
250
+
251
+ def sync_object_notify
252
+ #... do something with notification data ...
253
+
254
+ # refresh the current page
255
+ WebView.refresh
256
+ end
257
+ end
258
+
259
+ **NOTE: If you use `url_for` in your .erb files, then when you select a specific object(s) to view, those objects are added to the object notify map automatically.**
260
+
261
+ #### Object Notification Parameters
262
+ The object notification callback receives three arrays of hashes: "deleted", "updated" and "created". Each hash contains values for the keys "object" and "source_id" so you can display which records were changed.
263
+
264
+ ## Binary Data and Blob Sync
265
+ Synchronizing images or binary objects between RhoSync and the `SyncEngine` is declared by having a 'blob attribute' on the [Rhom model](/rhodes/rhom). Please see the [blob sync section](/rhosync/blob-sync) for more information.
266
+
267
+ ## Filtering Datasets with Search
268
+ If you have a large dataset in your backend service, you don't have to synchronize everything with the `SyncEngine`. Instead you can filter the synchronized dataset using the `SyncEngine`'s `search` function.
269
+
270
+ Like everything else with the `SyncEngine`, `search` requires a defined callback which is executed when the `search` results are retrieved from RhoSync.
271
+
272
+ ### Using Search
273
+ First, call `search` from your controller action:
274
+
275
+ :::ruby
276
+ def search
277
+ page = @params['page'] || 0
278
+ page_size = @params['page_size'] || 10
279
+ Contact.search(
280
+ :from => 'search',
281
+ :search_params => {
282
+ :FirstName => @params['FirstName'],
283
+ :LastName => @params['LastName'],
284
+ :Company => @params['Company']
285
+ },
286
+ :offset => page * page_size,
287
+ :max_results => page_size,
288
+ :callback => url_for(:action => :search_callback),
289
+ :callback_param => ""
290
+ )
291
+ render :action => :search_wait
292
+ end
293
+
294
+
295
+ Your callback might look like:
296
+
297
+ :::ruby
298
+ def search_callback
299
+ status = @params["status"]
300
+ if (status and status == "ok")
301
+ WebView.navigate(
302
+ url_for(
303
+ :action => :show_page,
304
+ :query => @params['search_params']
305
+ )
306
+ )
307
+ else
308
+ render :action => :search_error
309
+ end
310
+ end
311
+
312
+ **NOTE: Typically you want to forward the original search query `@params['search_params']` to your view that displays the results so you can perform the same query locally.**
313
+
314
+ Next, the resulting action `:show_page` will be called. Here we demonstrate using Rhom's [advanced find query syntax](/rhodes/rhom#advanced-queries) since we are filtering a very large dataset:
315
+
316
+ :::ruby
317
+ def show_page
318
+ @contacts = Contact.find(
319
+ :all,
320
+ :conditions => {
321
+ {
322
+ :func => 'LOWER',
323
+ :name => 'FirstName',
324
+ :op => 'LIKE'
325
+ } => @params[:FirstName],
326
+ {
327
+ :func => 'LOWER',
328
+ :name=>'LastName',
329
+ :op=>'LIKE'
330
+ } => @params[:LastName],
331
+ {
332
+ :func=>'LOWER',
333
+ :name=>'Company',
334
+ :op=>'LIKE'
335
+ } => @params[:Company],
336
+ },
337
+ :op => 'OR',
338
+ :select => ['FirstName','LastName', 'Company'],
339
+ :per_page => page_size,
340
+ :offset => page * page_size
341
+ )
342
+ render :action => :show_page
343
+ end
344
+
345
+
346
+ If you want to stop or cancel the search, return "stop" in your callback:
347
+
348
+ :::ruby
349
+ def search_callback
350
+ if(status and status == 'ok')
351
+ WebView.navigate( url_for :action => :show_page )
352
+ else
353
+ 'stop'
354
+ end
355
+ end
356
+
357
+ Finally, you will need to implement the `search` method in your source adapter. See the [RhoSync search method](/rhosync/source-adapters#source-adapter-api) for more details.
358
+
359
+ ## SyncEngine API
360
+ Below is the full list of methods available on the `SyncEngine`:
361
+
362
+ ### `login(login, password, callback)`
363
+ Authenticates the user with RhoSync. The callback will be executed when it is finished. See the [authentication section](/rhodes/synchronization#sync-authentication) for details.
364
+
365
+ :::ruby
366
+ SyncEngine.login(
367
+ @params['login'],
368
+ @params['password'],
369
+ url_for(:action => :login_callback)
370
+ )
371
+
372
+ ### `logout`
373
+ Logout the user from the RhoSync server. This removes the local user session. See the [authentication section](/rhodes/synchronization#sync-authentication) for details.
374
+
375
+ :::ruby
376
+ SyncEngine.logout
377
+
378
+ ### `logged_in`
379
+ Returns 1 if the `SyncEngine` currently has a user session, 0 if not.
380
+
381
+ :::ruby
382
+ if SyncEngine::logged_in == 1
383
+ render :action => :index
384
+ else
385
+ render :action => :login
386
+ end
387
+
388
+ ### `dosync(show_sync_status = true)`
389
+ Start the `SyncEngine` process and display an optional status popup (defaults to true).
390
+
391
+ :::ruby
392
+ SyncEngine.dosync(false)
393
+ #=> no status popups are displayed
394
+
395
+ ### `dosync_source(source_id, show_sync_status = true)`
396
+ Star the `SyncEngine` process for a given source_id and display an optional status popup (defaults to true).
397
+
398
+ :::ruby
399
+ SyncEngine.dosync_source(Product.get_source_id, true)
400
+
401
+ ### `lock_sync_mutex`
402
+ Blocking call to wait for `SyncEngine` lock (useful for performing batch operations).
403
+
404
+ :::ruby
405
+ SyncEngine.lock_sync_mutex
406
+ #... perform blocking tasks...
407
+ SyncEngine.unlock_sync_mutex
408
+
409
+ ### `unlock_sync_mutex`
410
+ Release the acquired `SyncEngine` lock (make sure you do this if you call `lock_sync_mutex`!).
411
+
412
+ ### `stop_sync`
413
+ Stops any sync operations currently in progress.
414
+
415
+ :::ruby
416
+ SyncEngine.stop_sync
417
+ #=> no callback is called
418
+
419
+ ### `set_notification(source_id, callback_url, params = nil)`
420
+ See the [sync notification section](/rhodes/synchronization#notifications).
421
+
422
+ ### `set_notification(-1, callback_url, params = nil)`
423
+ Set notification callback for all models. This callback is not removed after the sync process completes. See the [sync notification section](/rhodes/synchronization#notifications).
424
+
425
+ ### `clear_notification(source_id)`
426
+ Clears the sync notification for a given source id.
427
+
428
+ :::ruby
429
+ SyncEngine.clear_notification(Product.get_source_id)
430
+
431
+ ### `set_pollinterval(interval)`
432
+ Update the `SyncEngine` poll interval. Setting this to 0 will disable polling-based sync. However, you may still use [push-based-sync](/rhosync/push).
433
+
434
+ :::ruby
435
+ SyncEngine.set_pollinterval(20)'
436
+ #=> now polls every 20 seconds
437
+
438
+ ### `set_syncserver(server_url)`
439
+ Sets the RhoSync server address and stores it in [`rhoconfig.txt`](/rhodes/configuration).
440
+
441
+ :::ruby
442
+ SyncEngine.set_syncserver("http://myapp.com/application")
443
+ #=> don't forget the '/application' path
444
+
445
+ ### `set_objectnotify_url(url)`
446
+ See the [sync notification section](/rhodes/synchronization#notifications).
447
+
448
+ ### `set_pagesize(size)`
449
+ Set the sync page size for the `SyncEngine`. Default size is 2000. See [the `SyncEngine` workflow](/rhodes/synchronization#syncengine-workflow) for how this is used.
450
+
451
+ :::ruby
452
+ SyncEngine.set_pagesize(5000)
453
+
454
+ ### `get_pagesize`
455
+ Get the current sync page size for the `SyncEngine`. See [the `SyncEngine` workflow](/rhodes/synchronization#syncengine-workflow) for how this is used.
456
+
457
+ :::ruby
458
+ SyncEngine.get_pagesize
459
+ #=> 2000
460
+
461
+ SyncEngine.set_pagesize(5000)
462
+ SyncEngine.get_pagesize
463
+ #=> 5000
464
+
465
+ ### `enable_status_popup(false)`
466
+ Enable or disable show status popup. True by default for Blackberry, false for other platforms.
467
+
468
+ :::ruby
469
+ SyncEngine.enable_status_popup(true)
470
+
471
+ ### `set_ssl_verify_peer(true)`
472
+ Enable or disable verification of RhoSync ssl certificates, true by default.
473
+
474
+ :::ruby
475
+ # using a self-signed cert
476
+ SyncEngine.set_ssl_verify_peer(false)
477
+
478
+ ### `get_user_name`
479
+ Returns current username of the `SyncEngine` session if `logged_in` is true, otherwise returns the last logged in username.
480
+
481
+ :::ruby
482
+ SyncEngine.get_user_name
483
+ #=> "testuser"
484
+
485
+ ### `search(*args)`
486
+ Call search on the RhoSync application with given parameters. See the [search section](#filtering-datasets-with-search) for more details.
487
+
488
+ :::ruby
489
+ # :from Sets the RhoSync path that records
490
+ # will be fetched with (optional).
491
+ # Default is 'search'.
492
+ #
493
+ # :search_params Hash containing key/value search items.
494
+ #
495
+ # :offset Starting record to be returned.
496
+ #
497
+ # :max_results Max number of records to be returned.
498
+ #
499
+ # :callback Callback to be executed after search
500
+ # is completed.
501
+ #
502
+ # :callback_param (optional) Parameters passed to callback.
503
+ #
504
+ # :progress_step (optional) Define how often search callback
505
+ # will be executed with 'in_progress' state.
506
+ Contact.search(
507
+ :from => 'search',
508
+ :search_params => {
509
+ :FirstName => @params['FirstName'],
510
+ :LastName => @params['LastName'],
511
+ :Company => @params['Company']
512
+ },
513
+ :offset => page * page_size,
514
+ :max_results => page_size,
515
+ :callback => url_for(:action => :search_callback),
516
+ :callback_param => ""
517
+ )
518
+
519
+ ### `search(*args) (multiple sources)`
520
+ Call search on the RhoSync application with multiple source names. This is useful if your `search` spans across multiple models.
521
+
522
+ For example:
523
+
524
+ :::ruby
525
+ SyncEngine.search(
526
+ :source_names => ['Product', 'Customer'],
527
+ :from => 'search',
528
+ :search_params => {
529
+ :FirstName => @params['FirstName'],
530
+ :LastName => @params['LastName'],
531
+ :Company => @params['Company']
532
+ },
533
+ :offset => page * page_size,
534
+ :max_results => page_size,
535
+ :callback => url_for(:action => :search_callback),
536
+ :callback_param => ""
537
+ )
538
+
539
+
540
+ Parameters are the same as for ModelName.search with an additional parameter:
541
+
542
+ * `:source_names` - Sends a list of source adapter names to RhoSync to search across.
@@ -0,0 +1,148 @@
1
+ # Testing, Logging, and Debugging
2
+
3
+ ## Testing
4
+
5
+ ### Adding Unit Tests
6
+
7
+ When you [generate a model](generator#add-new-model), you will now get an _spec.rb file generated along with your controller.
8
+
9
+ Generating with model generator:
10
+ ....
11
+ [ADDED] app/Person/person_spec.rb
12
+
13
+ This file contains tests for your controller and is in the mspec format: [rubyspec.org](http://rubyspec.org/)
14
+
15
+ :::ruby
16
+ describe "Person" do
17
+ #this test always fails, you really should have tests!
18
+
19
+ it "should have tests" do
20
+ true.should == false
21
+ end
22
+ end
23
+
24
+ We use this test format internally as well. You can see our specs for the core framework [here](http://github.com/rhomobile/rhodes/tree/1.4.0/spec/framework_spec/app/spec/) which use many functions of mspec.
25
+
26
+ To run these tests however, you need the testing framework to be included in your app. To add this, you would run the rhogen task in your application folder:
27
+
28
+ :::term
29
+ $ rhogen spec
30
+
31
+ You will then see the mspec framework added to your application:
32
+
33
+ Generating with spec generator:
34
+ [ADDED] app/SpecRunner
35
+ [ADDED] app/spec
36
+ [ADDED] app/mspec.rb
37
+ [ADDED] app/spec_runner.rb
38
+
39
+ Finally, add the fileutils and mspec extensions to your build.yml:
40
+
41
+ extensions: ["fileutils", "mspec"]
42
+
43
+ You are now ready to run the tests. Simply add a link to the SpecRunner controller, and you will get a summary of number of passing/failing tests
44
+
45
+ In your index.erb:
46
+ :::html
47
+ <li><a href="SpecRunner">Run tests</a></li>
48
+
49
+ A summary of the results will be displayed on the screen.
50
+
51
+ Detailed results will be displayed in your rholog.txt:
52
+
53
+ I 01/15/2010 16:36:33 b0185000 APP| FAIL: Product - Expected true
54
+ to equal false
55
+
56
+ apps/app/mspec/expectations/expectations.rb:15:in `fail_with'
57
+ apps/app/mspec/matchers/base.rb:8:in `=='
58
+ apps/app/Product/product_spec.rb:5:in `block (2 levels) in <main>'
59
+ ...
60
+
61
+ And finally, a summary will be printed in rholog.txt as well:
62
+
63
+ I 01/15/2010 16:36:33 b0185000 APP| ***Total: 3
64
+ I 01/15/2010 16:36:33 b0185000 APP| ***Passed: 1
65
+ I 01/15/2010 16:36:33 b0185000 APP| ***Failed: 2
66
+
67
+ ### Disabling tests
68
+ When you are ready to do a production build of your application, change build.yml's build property to 'release' and the specs will not be included in the binary:
69
+
70
+ ...
71
+ vendor: Acme, Inc.
72
+ build: release
73
+ ...
74
+
75
+ ## Logging
76
+ There are two methods to log messages.
77
+
78
+ From any controller you can log using the methods app_info and app_error. These methods take a string and will write that to rholog.txt with the category of your controllers name. See platform specific [build topic](build) to see notes on how to get rholog.txt.
79
+
80
+ There also is a logging Ruby class called RhoLog. This class has methods info and error which take 2 strings. The first string is the category, the second string is the message.
81
+
82
+ In rholog.txt the lines appear as follows:
83
+
84
+ <Timestamp> <category> | <message>
85
+
86
+ ### RhoError class
87
+ You may find access to the error class useful in logging and reporting:
88
+
89
+ This class contains error codes and the method message() to translate error code to a text message.
90
+ All callbacks return an error code from this class. The status text in the callback contains some internal error message, so in most cases it should not be exposed to user.
91
+ Currently RhoError contains the following error codes:
92
+
93
+ ERR_NONE = 0
94
+ ERR_NETWORK = 1
95
+ ERR_REMOTESERVER = 2
96
+ ERR_RUNTIME = 3
97
+ ERR_UNEXPECTEDSERVERRESPONSE = 4
98
+ ERR_DIFFDOMAINSINSYNCSRC = 5
99
+ ERR_NOSERVERRESPONSE = 6
100
+ ERR_CLIENTISNOTLOGGEDIN = 7
101
+ ERR_CUSTOMSYNCSERVER = 8
102
+ ERR_UNATHORIZED = 9
103
+
104
+ ### Sample
105
+ See [Login/Logout Manager]() as an example.
106
+
107
+ ## Debugging
108
+
109
+ You can debug your Rhodes app running on OSX using the Rhodes Debugger.
110
+
111
+ The Rhodes Debugger app is located in [platform/osx/Rhodes Debugger](https://github.com/rhomobile/rhodes/tree/master/platform/osx/Rhodes%20Debugger). An xcode project is located there that you can use to build the debugger.
112
+
113
+ Launching the debugger, by default it listens for debugger connections over tcp. There is a checkbox to enable scanning using gdb for a local emulator running.
114
+
115
+ Be aware that debugging using the methods below will have a noticeable performance penalty on your application. GDB performance penalty is incurred when the debugger connects to the application and until the application is relaunched. TCP performance penalty is incurred if the application makes a successful connection to the debugger.
116
+
117
+ [This video demonstrates debugging using TCP on iPhone and Android](http://www.youtube.com/watch?v=xtpjlIdOdQE).
118
+
119
+ [This video demonstrates debugging using GDB](http://www.youtube.com/watch?v=dHJ3qvzjcuA).
120
+
121
+ ### TCP debugging
122
+
123
+ Tcp debugging works across multiple platforms, and can be run from the device.
124
+
125
+ To enable tcp debugging, you have two make a few small modifications to your application:
126
+
127
+ Include the extensions net-http and debugger in your build.yml.
128
+
129
+ extensions: ["net-http", "debugger"]
130
+
131
+ Modify your rhoconfig.txt add a line at the bottom debug_host. This should be set to an ip address of the machine that the debugger app is running on that is reachable by the phone or emulator.
132
+
133
+ debug_host = '192.168.1.106'
134
+
135
+ Modify your application.rb. At the top of the application.rb file in your app, after the first require add the line:
136
+
137
+ :::ruby
138
+ require 'debugger'
139
+
140
+ Then you can launch your application and you should see the text in the bottom left of the debugger change from 'Waiting for Rhodes' to 'Connected'. Once this is connected, browse to your rhodes application and then you can set breakpoints or execute ruby commands.
141
+
142
+ Once you are done debugging, you should click the disconnect button on the debugger to disconnect the debugger from the app.
143
+
144
+ ### Gdb debugging
145
+
146
+ Gdb debugging only works when you run the debugger and iphone simulator on the same machine. It only works with the iphone simulator.
147
+
148
+ There is no changes needed to your application to use gdb debugging. Simply launch the Rhodes Debugger app select the gdb checkbox and then launch your application in the iphone simulator. The debugger will detect your application and connect to it automatically.