rhodes 2.0.0.beta2 → 2.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. data/LICENSE +2 -0
  2. data/Manifest.txt +27 -148
  3. data/Rakefile +49 -3
  4. data/lib/framework/builtinME.rb +6 -0
  5. data/lib/framework/rho/render.rb +13 -8
  6. data/lib/framework/rho/rho.rb +97 -43
  7. data/lib/framework/rho/rhoapplication.rb +8 -3
  8. data/lib/framework/rho/rhocontroller.rb +1 -1
  9. data/lib/framework/rhodes-framework.rb +1 -1
  10. data/lib/framework/rhodes.rb +1 -1
  11. data/lib/framework/rhoframework.rb +7 -22
  12. data/lib/framework/rhofsconnector.rb +1 -1
  13. data/lib/framework/rholang/localization_simplified.rb +2 -2
  14. data/lib/framework/rhom/rhom.rb +1 -0
  15. data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
  16. data/lib/framework/rhom/rhom_model.rb +98 -0
  17. data/lib/framework/rhom/rhom_object_factory.rb +13 -12
  18. data/lib/rhodes.rb +1 -1
  19. data/platform/android/Rhodes/jni/include/{JNIRhodes.h → rhodes/JNIRhodes.h} +3 -54
  20. data/platform/android/Rhodes/jni/include/{RhoClassFactory.h → rhodes/RhoClassFactory.h} +0 -0
  21. data/platform/android/Rhodes/jni/include/{SystemInfoImpl.h → rhodes/SystemInfoImpl.h} +0 -0
  22. data/platform/android/Rhodes/jni/include/{details → rhodes/details}/rhojava.inc +1 -0
  23. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Logger.h +0 -0
  24. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoConf.h +0 -0
  25. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoLogConf.h +0 -0
  26. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoMenu.h +0 -0
  27. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Rhodes.h +0 -0
  28. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_SplashScreen.h +0 -0
  29. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_alert_Alert.h +0 -0
  30. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_camera_Camera.h +0 -0
  31. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_datetime_DateTimePicker.h +0 -0
  32. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_geolocation_GeoLocationImpl.h +0 -0
  33. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_RhoSocketImpl.h +0 -0
  34. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_SSLImpl.h +0 -0
  35. data/platform/android/Rhodes/jni/include/{sslimpl.h → rhodes/sslimpl.h} +0 -0
  36. data/platform/android/Rhodes/jni/include/rhodes.h +59 -0
  37. data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +3 -3
  38. data/platform/android/Rhodes/jni/src/alert.cpp +2 -2
  39. data/platform/android/Rhodes/jni/src/callbacks.cpp +4 -3
  40. data/platform/android/Rhodes/jni/src/camera.cpp +2 -2
  41. data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -2
  42. data/platform/android/Rhodes/jni/src/geolocation.cpp +2 -2
  43. data/platform/android/Rhodes/jni/src/logconf.cpp +2 -2
  44. data/platform/android/Rhodes/jni/src/logger.cpp +2 -2
  45. data/platform/android/Rhodes/jni/src/mapview.cpp +1 -1
  46. data/platform/android/Rhodes/jni/src/menu.cpp +2 -2
  47. data/platform/android/Rhodes/jni/src/nativebar.cpp +1 -1
  48. data/platform/android/Rhodes/jni/src/navbar.cpp +17 -3
  49. data/platform/android/Rhodes/jni/src/phonebook.cpp +1 -1
  50. data/platform/android/Rhodes/jni/src/rhoconf.cpp +2 -2
  51. data/platform/android/Rhodes/jni/src/rhodes.cpp +3 -3
  52. data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
  53. data/platform/android/Rhodes/jni/src/socketimpl.cpp +2 -2
  54. data/platform/android/Rhodes/jni/src/splashscreen.cpp +2 -2
  55. data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -3
  56. data/platform/android/Rhodes/jni/src/syncengine.cpp +2 -2
  57. data/platform/android/Rhodes/jni/src/webview.cpp +15 -12
  58. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeLibraries.java +11 -0
  59. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NavBar.java +52 -0
  60. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +8 -2
  61. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +26 -28
  62. data/platform/android/build/RhodesSRC_build.files +21 -20
  63. data/platform/android/build/android.rake +69 -24
  64. data/platform/android/build/androidcommon.rb +17 -12
  65. data/platform/bb/build/bb.rake +23 -21
  66. data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +5 -2
  67. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +6 -1
  68. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +9 -1
  69. data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +31 -2
  70. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +17 -6
  71. data/platform/bb/rhodes/src/rhomobile/Utilities.java +6 -0
  72. data/platform/iphone/Classes/AppManager/AppManager.m +16 -4
  73. data/platform/iphone/Classes/DateTime.h +5 -6
  74. data/platform/iphone/Classes/DateTimePicker.m +4 -18
  75. data/platform/iphone/Classes/DateTimePickerDelegate.h +7 -9
  76. data/platform/iphone/Classes/DateTimePickerDelegate.m +141 -152
  77. data/platform/iphone/Classes/Rhodes.h +6 -1
  78. data/platform/iphone/Classes/Rhodes.m +17 -43
  79. data/platform/iphone/Classes/SimpleMainView.h +1 -1
  80. data/platform/iphone/Classes/SimpleMainView.m +54 -4
  81. data/platform/iphone/Classes/WebView.m +17 -0
  82. data/platform/iphone/rbuild/iphone.rake +1 -0
  83. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +0 -45
  84. data/platform/shared/common/PosixThreadImpl.cpp +8 -0
  85. data/platform/shared/common/PosixThreadImpl.h +1 -0
  86. data/platform/shared/common/RhoThread.cpp +1 -0
  87. data/platform/shared/common/RhoThread.h +4 -2
  88. data/platform/shared/curl/include/curl/curl.h +4 -0
  89. data/platform/shared/db/DBAdapter.cpp +47 -60
  90. data/platform/shared/db/DBAdapter.h +6 -2
  91. data/platform/shared/net/AsyncHttp.cpp +27 -11
  92. data/platform/shared/net/AsyncHttp.h +3 -1
  93. data/platform/shared/net/CURLNetRequest.cpp +11 -10
  94. data/platform/shared/net/CURLNetRequest.h +6 -4
  95. data/platform/shared/net/HttpServer.cpp +11 -6
  96. data/platform/shared/ruby/ext/asynchttp/asynchttp.i +2 -2
  97. data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +22 -11
  98. data/platform/shared/ruby/ext/rho/rhoruby.c +2 -2
  99. data/platform/shared/ruby/ext/rho/rhosupport.c +23 -3
  100. data/platform/shared/ruby/ext/webview/webview.i +4 -0
  101. data/platform/shared/ruby/ext/webview/webview_wrap.c +39 -0
  102. data/platform/shared/ruby/re.c +8 -0
  103. data/platform/shared/ruby/string.c +1 -1
  104. data/platform/shared/rubyJVM/src/com/rho/IRhoRubyHelper.java +1 -0
  105. data/platform/shared/rubyJVM/src/com/rho/RhoClassFactory.java +6 -1
  106. data/platform/shared/rubyJVM/src/com/rho/RhoThread.java +3 -0
  107. data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +34 -0
  108. data/platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java +40 -53
  109. data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +32 -15
  110. data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +31 -17
  111. data/platform/shared/rubyJVM/src/com/rho/net/RhoConnection.java +3 -0
  112. data/platform/shared/rubyJVM/src/com/rho/sync/JSONArrayIterator.java +17 -0
  113. data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +158 -137
  114. data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +18 -17
  115. data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +10 -2
  116. data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubyFile_Methods.java +6 -0
  117. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyFile.java +18 -3
  118. data/platform/shared/rubyJVM/src/j2me/io/File.java +37 -9
  119. data/platform/shared/sqlite/sqlite3.c +14613 -13016
  120. data/platform/shared/sqlite/sqlite3.h +1461 -1499
  121. data/platform/shared/sqlite/sqlite3ext.h +0 -2
  122. data/platform/shared/sync/ClientRegister.cpp +3 -3
  123. data/platform/shared/sync/ClientRegister.h +2 -1
  124. data/platform/shared/sync/SyncEngine.cpp +20 -8
  125. data/platform/shared/sync/SyncSource.cpp +12 -12
  126. data/platform/shared/sync/SyncSource.h +4 -4
  127. data/platform/shared/sync/SyncThread.cpp +8 -1
  128. data/platform/shared/tcmalloc/rhomem.h +3 -0
  129. data/platform/shared/tcmalloc/tcmalloc_.cpp +11 -0
  130. data/platform/wm/rhodes/Alert.cpp +148 -101
  131. data/platform/wm/rhodes/Alert.h +4 -1
  132. data/platform/wm/rhodes/AppManager.cpp +212 -72
  133. data/platform/wm/rhodes/AppManager.h +24 -3
  134. data/platform/wm/rhodes/DateTimePicker.cpp +23 -11
  135. data/platform/wm/rhodes/DateTimePicker.h +16 -5
  136. data/platform/wm/rhodes/MainWindow.cpp +22 -7
  137. data/platform/wm/rhodes/OkCancelModalDialog.h +63 -0
  138. data/platform/wm/rhodes/Rhodes.cpp +29 -17
  139. data/platform/wm/rhodes/phonebook/NativeAddressBook.cpp +128 -4
  140. data/platform/wm/rhodes/phonebook/NativeAddressBook.h +33 -3
  141. data/platform/wm/rhodes/resource.h +1 -1
  142. data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +5 -0
  143. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +136 -102
  144. data/platform/wm/rhodes/rho/net/NetRequestImpl.h +12 -5
  145. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +24 -10
  146. data/platform/wm/rhodes/rho/rubyext/WebView.cpp +6 -0
  147. data/platform/wm/rhodes/rhodes.vcproj +4 -0
  148. data/platform/wm/tools/detool/detool.cpp +17 -4
  149. data/rakefile.rb +49 -3
  150. data/res/build-tools/db/syncdb.schema +2 -2
  151. data/res/build-tools/detool.exe +0 -0
  152. data/res/generators/rhogen.rb +10 -10
  153. data/res/generators/templates/application/app/helpers/browser_helper.rb +9 -4
  154. data/res/generators/templates/application/app/index.bb.erb +5 -5
  155. data/res/generators/templates/application/build.yml +1 -0
  156. data/res/generators/templates/application/public/css/android.css +10 -8
  157. data/res/generators/templates/application/public/css/blackberry.css +40 -31
  158. data/res/generators/templates/application/public/css/iphone.css +4 -4
  159. data/res/generators/templates/application/public/css/webkit.css +7 -0
  160. data/res/generators/templates/application/public/css/windows_mobile.css +31 -27
  161. data/res/generators/templates/application/rhoconfig.txt +2 -2
  162. data/res/generators/templates/model/edit.bb.erb +2 -2
  163. data/res/generators/templates/model/index.bb.erb +6 -4
  164. data/res/generators/templates/model/model.rb +2 -1
  165. data/res/generators/templates/model/new.bb.erb +2 -2
  166. data/res/generators/templates/model/show.bb.erb +2 -2
  167. data/rhobuild.yml +37 -0
  168. data/rhodes.gemspec +1 -1
  169. data/spec/framework_spec/app/Account/account.rb +7 -0
  170. data/spec/framework_spec/app/Case/case.rb +6 -0
  171. data/spec/framework_spec/app/Customer/customer.rb +6 -0
  172. data/spec/framework_spec/app/Product/product.rb +9 -0
  173. data/spec/framework_spec/app/spec/rhom_object_spec.rb +1 -1
  174. data/spec/framework_spec/app/spec/syncengine_spec.rb +2 -1
  175. metadata +45 -151
  176. data/lib/build/manifest/createAppManifest.rb +0 -18
  177. data/lib/build/tasks/android.rake +0 -317
  178. data/lib/build/tasks/blackberry.rake +0 -355
  179. data/lib/build/tasks/common.rake +0 -62
  180. data/lib/build/tasks/iphone.rake +0 -108
  181. data/lib/build/tasks/linux.rake +0 -81
  182. data/lib/build/tasks/rhodes-build.rb +0 -11
  183. data/lib/build/tasks/rspec.rake +0 -20
  184. data/lib/build/tasks/symbian.rake +0 -202
  185. data/lib/build/tasks/wm.rake +0 -166
  186. data/lib/framework/ServeME.rb +0 -7
  187. data/platform/bb/build/MANIFEST.MF +0 -12
  188. data/platform/iphone/Classes/DateTimePicker.h +0 -17
  189. data/res/generators/templates/application/public/icons/Read me first - license.txt +0 -14
  190. data/res/generators/templates/application/public/icons/about.png +0 -0
  191. data/res/generators/templates/application/public/icons/airplane.png +0 -0
  192. data/res/generators/templates/application/public/icons/baby.png +0 -0
  193. data/res/generators/templates/application/public/icons/badge.png +0 -0
  194. data/res/generators/templates/application/public/icons/bandaid.png +0 -0
  195. data/res/generators/templates/application/public/icons/bar-chart.png +0 -0
  196. data/res/generators/templates/application/public/icons/battery.png +0 -0
  197. data/res/generators/templates/application/public/icons/beaker.png +0 -0
  198. data/res/generators/templates/application/public/icons/beaker2.png +0 -0
  199. data/res/generators/templates/application/public/icons/beermug.png +0 -0
  200. data/res/generators/templates/application/public/icons/bird.png +0 -0
  201. data/res/generators/templates/application/public/icons/book.png +0 -0
  202. data/res/generators/templates/application/public/icons/bookmark.png +0 -0
  203. data/res/generators/templates/application/public/icons/brightness.png +0 -0
  204. data/res/generators/templates/application/public/icons/bug.png +0 -0
  205. data/res/generators/templates/application/public/icons/cabinet.png +0 -0
  206. data/res/generators/templates/application/public/icons/calendar.png +0 -0
  207. data/res/generators/templates/application/public/icons/camera.png +0 -0
  208. data/res/generators/templates/application/public/icons/changeName.rb +0 -22
  209. data/res/generators/templates/application/public/icons/chat2.png +0 -0
  210. data/res/generators/templates/application/public/icons/chicken.png +0 -0
  211. data/res/generators/templates/application/public/icons/clock.png +0 -0
  212. data/res/generators/templates/application/public/icons/cloud.png +0 -0
  213. data/res/generators/templates/application/public/icons/coffee.png +0 -0
  214. data/res/generators/templates/application/public/icons/compass.png +0 -0
  215. data/res/generators/templates/application/public/icons/contrast.png +0 -0
  216. data/res/generators/templates/application/public/icons/dashboard.png +0 -0
  217. data/res/generators/templates/application/public/icons/display.png +0 -0
  218. data/res/generators/templates/application/public/icons/dogpaw.png +0 -0
  219. data/res/generators/templates/application/public/icons/download.png +0 -0
  220. data/res/generators/templates/application/public/icons/dumbbell.png +0 -0
  221. data/res/generators/templates/application/public/icons/ekg.png +0 -0
  222. data/res/generators/templates/application/public/icons/envelope.png +0 -0
  223. data/res/generators/templates/application/public/icons/equalizer.png +0 -0
  224. data/res/generators/templates/application/public/icons/eye.png +0 -0
  225. data/res/generators/templates/application/public/icons/film-roll.png +0 -0
  226. data/res/generators/templates/application/public/icons/flag.png +0 -0
  227. data/res/generators/templates/application/public/icons/fork-and-knife.png +0 -0
  228. data/res/generators/templates/application/public/icons/fuel.png +0 -0
  229. data/res/generators/templates/application/public/icons/gameplan.png +0 -0
  230. data/res/generators/templates/application/public/icons/gear.png +0 -0
  231. data/res/generators/templates/application/public/icons/gear2.png +0 -0
  232. data/res/generators/templates/application/public/icons/gift.png +0 -0
  233. data/res/generators/templates/application/public/icons/heart.png +0 -0
  234. data/res/generators/templates/application/public/icons/house.png +0 -0
  235. data/res/generators/templates/application/public/icons/inbox.png +0 -0
  236. data/res/generators/templates/application/public/icons/index-cards.png +0 -0
  237. data/res/generators/templates/application/public/icons/iphone.png +0 -0
  238. data/res/generators/templates/application/public/icons/ipod.png +0 -0
  239. data/res/generators/templates/application/public/icons/key.png +0 -0
  240. data/res/generators/templates/application/public/icons/lifebuoy.png +0 -0
  241. data/res/generators/templates/application/public/icons/lightbulb.png +0 -0
  242. data/res/generators/templates/application/public/icons/line-chart.png +0 -0
  243. data/res/generators/templates/application/public/icons/location.png +0 -0
  244. data/res/generators/templates/application/public/icons/lock.png +0 -0
  245. data/res/generators/templates/application/public/icons/loopback.png +0 -0
  246. data/res/generators/templates/application/public/icons/magnifying-glass.png +0 -0
  247. data/res/generators/templates/application/public/icons/map-marker.png +0 -0
  248. data/res/generators/templates/application/public/icons/map.png +0 -0
  249. data/res/generators/templates/application/public/icons/medical-bag.png +0 -0
  250. data/res/generators/templates/application/public/icons/medical.png +0 -0
  251. data/res/generators/templates/application/public/icons/microphone.png +0 -0
  252. data/res/generators/templates/application/public/icons/movie1.png +0 -0
  253. data/res/generators/templates/application/public/icons/movie2.png +0 -0
  254. data/res/generators/templates/application/public/icons/network.png +0 -0
  255. data/res/generators/templates/application/public/icons/note.png +0 -0
  256. data/res/generators/templates/application/public/icons/outlet.png +0 -0
  257. data/res/generators/templates/application/public/icons/palette.png +0 -0
  258. data/res/generators/templates/application/public/icons/paperclip.png +0 -0
  259. data/res/generators/templates/application/public/icons/phone.png +0 -0
  260. data/res/generators/templates/application/public/icons/photos.png +0 -0
  261. data/res/generators/templates/application/public/icons/piano.png +0 -0
  262. data/res/generators/templates/application/public/icons/picture-frame.png +0 -0
  263. data/res/generators/templates/application/public/icons/pill.png +0 -0
  264. data/res/generators/templates/application/public/icons/pin.png +0 -0
  265. data/res/generators/templates/application/public/icons/pinetree.png +0 -0
  266. data/res/generators/templates/application/public/icons/planet.png +0 -0
  267. data/res/generators/templates/application/public/icons/puzzle.png +0 -0
  268. data/res/generators/templates/application/public/icons/radar.png +0 -0
  269. data/res/generators/templates/application/public/icons/redo.png +0 -0
  270. data/res/generators/templates/application/public/icons/refresh.png +0 -0
  271. data/res/generators/templates/application/public/icons/runner.png +0 -0
  272. data/res/generators/templates/application/public/icons/shoebox.png +0 -0
  273. data/res/generators/templates/application/public/icons/shopping-bag.png +0 -0
  274. data/res/generators/templates/application/public/icons/shopping-cart.png +0 -0
  275. data/res/generators/templates/application/public/icons/shuffle.png +0 -0
  276. data/res/generators/templates/application/public/icons/signpost.png +0 -0
  277. data/res/generators/templates/application/public/icons/skull-n-crossbones.png +0 -0
  278. data/res/generators/templates/application/public/icons/skull.png +0 -0
  279. data/res/generators/templates/application/public/icons/sliders.png +0 -0
  280. data/res/generators/templates/application/public/icons/spraycan.png +0 -0
  281. data/res/generators/templates/application/public/icons/squiggle.png +0 -0
  282. data/res/generators/templates/application/public/icons/star.png +0 -0
  283. data/res/generators/templates/application/public/icons/stopwatch.png +0 -0
  284. data/res/generators/templates/application/public/icons/suitcase.png +0 -0
  285. data/res/generators/templates/application/public/icons/tag.png +0 -0
  286. data/res/generators/templates/application/public/icons/tags.png +0 -0
  287. data/res/generators/templates/application/public/icons/target.png +0 -0
  288. data/res/generators/templates/application/public/icons/testtube.png +0 -0
  289. data/res/generators/templates/application/public/icons/thermometer.png +0 -0
  290. data/res/generators/templates/application/public/icons/toolbox.png +0 -0
  291. data/res/generators/templates/application/public/icons/trophy.png +0 -0
  292. data/res/generators/templates/application/public/icons/tshirt.png +0 -0
  293. data/res/generators/templates/application/public/icons/tv.png +0 -0
  294. data/res/generators/templates/application/public/icons/umbrella.png +0 -0
  295. data/res/generators/templates/application/public/icons/walk.png +0 -0
  296. data/res/generators/templates/application/public/icons/weather.png +0 -0
  297. data/res/generators/templates/application/public/icons/widescreen.png +0 -0
  298. data/res/generators/templates/application/public/icons/wineglass.png +0 -0
  299. data/res/generators/templates/application/public/icons/zap.png +0 -0
  300. data/res/generators/templates/application/public/js/jquery-1.2.6.min.js +0 -32
  301. data/res/generators/templates/model/config.rb +0 -3
  302. data/res/generators/templates/spec/app/spec/webview_spec.rb +0 -5
  303. data/spec/framework_spec/app/Account/config.rb +0 -59
  304. data/spec/framework_spec/app/Case/config.rb +0 -3
  305. data/spec/framework_spec/app/Customer/config.rb +0 -3
  306. data/spec/framework_spec/app/Product/config.rb +0 -17
@@ -110,6 +110,14 @@ public class NetRequest
110
110
  }
111
111
  }
112
112
 
113
+ private String getResponseEncoding() throws Exception
114
+ {
115
+ if ( m_OutHeaders != null )
116
+ return (String)m_OutHeaders.get("content-type");
117
+
118
+ return "";
119
+ }
120
+
113
121
  public NetResponse doRequest(String strMethod, String strUrl, String strBody, IRhoSession oSession, Hashtable headers ) throws Exception
114
122
  {
115
123
  String strRespBody = null;
@@ -159,6 +167,9 @@ public class NetRequest
159
167
 
160
168
  is = m_connection.openInputStream();
161
169
  LOG.INFO("openInputStream done");
170
+
171
+ readHeaders(headers);
172
+ copyHashtable(m_OutHeaders, headers);
162
173
 
163
174
  if (code != IHttpConnection.HTTP_OK)
164
175
  {
@@ -168,7 +179,7 @@ public class NetRequest
168
179
 
169
180
  //if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
170
181
  {
171
- strRespBody = readFully(is);
182
+ strRespBody = readFully(is, getResponseEncoding());
172
183
 
173
184
  if ( code == IHttpConnection.HTTP_MOVED_TEMPORARILY ||
174
185
  code == IHttpConnection.HTTP_MOVED_PERMANENTLY )
@@ -181,13 +192,11 @@ public class NetRequest
181
192
  long len = m_connection.getLength();
182
193
  LOG.INFO("fetchRemoteData data size:" + len );
183
194
 
184
- strRespBody = readFully(is);
195
+ strRespBody = readFully(is, getResponseEncoding());
185
196
 
186
197
  LOG.INFO("fetchRemoteData data readFully.");
187
198
  }
188
199
 
189
- readHeaders(headers);
190
- copyHashtable(m_OutHeaders, headers);
191
200
  }finally
192
201
  {
193
202
  if ( is != null )
@@ -283,7 +292,7 @@ public class NetRequest
283
292
  if (oItem.m_strFileName.length()>0)
284
293
  oItem.m_strDataPrefix += "; filename=\"" + oItem.m_strFileName + "\"";
285
294
  oItem.m_strDataPrefix += "\r\n";
286
- if ( oItem.m_strContentType.length() > 0 )
295
+ if ( oItem.m_strContentType != null && oItem.m_strContentType.length() > 0 )
287
296
  oItem.m_strDataPrefix += "Content-Type: " + oItem.m_strContentType + "\r\n";
288
297
 
289
298
  long nContentSize = 0;
@@ -306,7 +315,7 @@ public class NetRequest
306
315
  else
307
316
  nContentSize = oItem.m_strBody.length();
308
317
 
309
- if ( oItem.m_strContentType.length() > 0 )
318
+ if ( oItem.m_strContentType != null && oItem.m_strContentType.length() > 0 )
310
319
  oItem.m_strDataPrefix += "Content-Length: " + nContentSize + "\r\n";
311
320
 
312
321
  oItem.m_strDataPrefix += "\r\n";
@@ -392,6 +401,9 @@ public class NetRequest
392
401
  code = m_connection.getResponseCode();
393
402
 
394
403
  LOG.INFO("getResponseCode : " + code);
404
+
405
+ readHeaders(headers);
406
+ copyHashtable(m_OutHeaders, headers);
395
407
 
396
408
  if (code != IHttpConnection.HTTP_OK)
397
409
  {
@@ -400,19 +412,18 @@ public class NetRequest
400
412
  oSession.logout();
401
413
 
402
414
  if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
403
- strRespBody = readFully(is);
415
+ strRespBody = readFully(is, getResponseEncoding());
404
416
 
405
417
  }else
406
418
  {
407
419
  long len = m_connection.getLength();
408
420
  LOG.INFO("fetchRemoteData data size:" + len );
409
421
 
410
- strRespBody = readFully(is);
422
+ strRespBody = readFully(is, getResponseEncoding());
411
423
 
412
424
  LOG.INFO("fetchRemoteData data readFully.");
413
425
  }
414
426
 
415
- readHeaders(headers);
416
427
  }finally{
417
428
  try{
418
429
  if ( is != null )
@@ -425,7 +436,6 @@ public class NetRequest
425
436
  }catch(IOException exc2){}
426
437
  }
427
438
 
428
- copyHashtable(m_OutHeaders, headers);
429
439
  return makeResponse(strRespBody, code );
430
440
  }
431
441
 
@@ -452,7 +462,7 @@ public class NetRequest
452
462
  }
453
463
  }
454
464
 
455
- file = RhoClassFactory.createRAFile();
465
+ file = RhoClassFactory.createFSRAFile();
456
466
  file.open(strFileName, "rw");
457
467
  file.seek(file.size());
458
468
 
@@ -508,6 +518,7 @@ public class NetRequest
508
518
  LOG.INFO("getResponseCode : " + code);
509
519
 
510
520
  m_nCurDownloadSize = 0;
521
+ readHeaders(headers);
511
522
 
512
523
  if ( code == IHttpConnection.HTTP_RANGENOTSATISFY )
513
524
  code = IHttpConnection.HTTP_PARTIAL_CONTENT;
@@ -522,7 +533,7 @@ public class NetRequest
522
533
  if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
523
534
  {
524
535
  is = m_connection.openInputStream();
525
- strRespBody = readFully(is);
536
+ strRespBody = readFully(is, getResponseEncoding());
526
537
  }
527
538
  }else
528
539
  {
@@ -549,8 +560,6 @@ public class NetRequest
549
560
  }
550
561
 
551
562
  }
552
-
553
- readHeaders(headers);
554
563
  }finally
555
564
  {
556
565
  if ( is != null )
@@ -644,17 +653,22 @@ public class NetRequest
644
653
  return strRes;
645
654
  }
646
655
 
647
- private final String readFully(InputStream in) throws Exception
656
+ private final String readFully(InputStream in, String strContType) throws Exception
648
657
  {
649
658
  String strRes = "";
650
659
  byte[] byteBuffer = new byte[1024*4];
651
-
660
+ boolean bUTF8 = strContType != null && strContType.indexOf("UTF-8")>=0;
661
+
652
662
  int nRead = 0;
653
663
  do{
654
664
  nRead = in.read(byteBuffer);
655
665
  if (nRead>0)
656
666
  {
657
- String strTemp = new String(byteBuffer,0,nRead);
667
+ String strTemp;
668
+ if (bUTF8)
669
+ strTemp = new String(byteBuffer,0,nRead, "UTF-8");
670
+ else
671
+ strTemp = new String(byteBuffer,0,nRead);
658
672
  strRes += strTemp;
659
673
  }
660
674
  }while( nRead > 0 );
@@ -635,6 +635,8 @@ public class RhoConnection implements IHttpConnection {
635
635
  String url = uri.getPath();// + (nPos == 0 ? ".iseq" : "");
636
636
  RubyValue res = RhoRuby.processIndexRequest(url);//erb-compiled should load from class
637
637
  processResponse(res);
638
+
639
+ RhodesApp.getInstance().keepLastVisitedUrl(url_external);
638
640
  return true;
639
641
  }
640
642
 
@@ -762,6 +764,7 @@ public class RhoConnection implements IHttpConnection {
762
764
  actionid.charAt(0)=='{' && actionid.charAt(actionid.length()-1)=='}' )
763
765
  SyncThread.getInstance().addobjectnotify_bysrcname( model, actionid);
764
766
 
767
+ RhodesApp.getInstance().keepLastVisitedUrl(url_external);
765
768
  LOG.INFO("dispatch end");
766
769
  return true;
767
770
  }
@@ -20,6 +20,12 @@ class JSONArrayIterator
20
20
  m_array = (JSONArray)oEntry.m_object.get(strName);
21
21
  m_nCurItem = 0;
22
22
  }
23
+
24
+ private JSONArrayIterator()
25
+ {
26
+ m_array = null;
27
+ m_nCurItem = 0;
28
+ }
23
29
 
24
30
  boolean isEnd()
25
31
  {
@@ -42,4 +48,15 @@ class JSONArrayIterator
42
48
  {
43
49
  return new JSONEntry( isEnd() ? null : (JSONObject) m_array.get(m_nCurItem) );
44
50
  }
51
+
52
+ JSONArrayIterator getCurArrayIter()throws JSONException
53
+ {
54
+ JSONArrayIterator res = new JSONArrayIterator();
55
+ if ( isEnd() )
56
+ return res;
57
+
58
+ res.m_array = (JSONArray)m_array.get(m_nCurItem);
59
+ return res;
60
+ }
61
+
45
62
  }
@@ -25,6 +25,7 @@ import com.rho.RhoEmptyProfiler;
25
25
  import com.rho.RhoLogger;
26
26
  import com.rho.RhoProfiler;
27
27
  import com.rho.RhoRuby;
28
+ import com.rho.TimeInterval;
28
29
  import com.rho.db.*;
29
30
  import com.rho.net.*;
30
31
  import com.rho.*;
@@ -195,143 +196,160 @@ public class SyncEngine implements NetRequest.IRhoSession
195
196
 
196
197
  void doSearch(Vector/*<rho::String>*/ arSources, String strParams, String strAction, boolean bSearchSyncChanges, int nProgressStep)
197
198
  {
198
- /* prepareSync(esSearch);
199
- if ( !isContinueSync() )
200
- {
201
- if ( getState() != esExit )
202
- setState(esNone);
203
-
204
- return;
205
- }
206
-
207
- CTimeInterval startTime = CTimeInterval::getCurrentTime();
208
-
209
- if ( bSearchSyncChanges )
210
- {
211
- for ( int i = 0; i < (int)arSources.size(); i++ )
212
- {
213
- CSyncSource* pSrc = findSourceByName(arSources.elementAt(i));
214
- if ( pSrc != null )
215
- pSrc->syncClientChanges();
216
- }
217
- }
218
-
219
- int nErrCode = 0;
220
- while( isContinueSync() )
221
- {
222
- int nSearchCount = 0;
223
- String strUrl = getProtocol().getServerQueryUrl(strAction);
224
- String strQuery = getProtocol().getServerQueryBody("", getClientID(), getSyncPageSize());
225
-
226
- if ( strParams.length() > 0 )
227
- strQuery += strParams;
228
-
229
- for ( int i = 0; i < (int)arSources.size(); i++ )
230
- {
231
- CSyncSource* pSrc = findSourceByName(arSources.elementAt(i));
232
- if ( pSrc != null )
233
- {
234
- strQuery += "&sources[][name]=" + pSrc->getName();
235
-
236
- if ( !pSrc->isTokenFromDB() && pSrc->getToken() > 1 )
237
- strQuery += "&sources[][token]=" + convertToStringA(pSrc->getToken());
238
- }
239
- }
240
-
241
- LOG(INFO) + "Call search on server. Url: " + (strUrl+strQuery);
242
- NetResponse(resp,getNet().pullData(strUrl+strQuery, this));
243
-
244
- if ( !resp.isOK() )
245
- {
246
- stopSync();
247
- nErrCode = RhoRuby.getErrorFromResponse(resp);
248
- continue;
249
- }
250
-
251
- const char* szData = resp.getCharData();
252
-
253
- CJSONArrayIterator oJsonArr(szData);
254
-
255
- for( ; !oJsonArr.isEnd() && isContinueSync(); oJsonArr.next() )
256
- {
257
- CJSONArrayIterator oSrcArr(oJsonArr.getCurItem());
258
-
259
- int nVersion = 0;
260
- if ( !oSrcArr.isEnd() && oSrcArr.getCurItem().hasName("version") )
261
- {
262
- nVersion = oSrcArr.getCurItem().getInt("version");
263
- oJsonArr.next();
264
- }
265
-
266
- if ( nVersion != getProtocol().getVersion() )
267
- {
268
- LOG(ERROR) + "Sync server send search data with incompatible version. Client version: " + convertToStringA(getProtocol().getVersion()) +
269
- "; Server response version: " + convertToStringA(nVersion);
270
- stopSync();
271
- nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
272
- continue;
273
- }
274
-
275
- if ( !oSrcArr.getCurItem().hasName("source") )
276
- {
277
- LOG(ERROR) + "Sync server send search data without source name.";
278
- stopSync();
279
- nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
280
- continue;
281
- }
282
-
283
- String strSrcName = oSrcArr.getCurItem().getString("source");
284
- CSyncSource* pSrc = findSourceByName(strSrcName);
285
- if ( pSrc == null )
286
- {
287
- LOG(ERROR) + "Sync server send search data for unknown source name:" + strSrcName;
288
- stopSync();
289
- nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
290
- continue;
291
- }
292
-
293
- oSrcArr.reset(0);
294
- pSrc->m_bIsSearch = true;
295
- pSrc->setProgressStep(nProgressStep);
296
- pSrc->processServerResponse_ver3(oSrcArr);
297
-
298
- nSearchCount += pSrc->getCurPageCount();
299
- }
300
-
301
- if ( nSearchCount == 0 )
302
- break;
303
- }
304
-
305
- if ( isContinueSync() )
306
- getNotify().fireSyncNotification(null, true, RhoRuby.ERR_NONE, RhoRuby.getMessageText("sync_completed"));
307
- else if ( nErrCode != 0 )
308
- {
309
- CSyncSource& src = *m_sources.elementAt(getStartSource());
310
- src.m_nErrCode = nErrCode;
311
- src.m_bIsSearch = true;
312
- getNotify().fireSyncNotification(&src, true, src.m_nErrCode, "");
313
- }
199
+ try
200
+ {
201
+ prepareSync(esSearch);
202
+ if ( !isContinueSync() )
203
+ {
204
+ if ( getState() != esExit )
205
+ setState(esNone);
206
+
207
+ return;
208
+ }
209
+
210
+ TimeInterval startTime = TimeInterval.getCurrentTime();
211
+
212
+ if ( bSearchSyncChanges )
213
+ {
214
+ for ( int i = 0; i < (int)arSources.size(); i++ )
215
+ {
216
+ SyncSource pSrc = findSourceByName((String)arSources.elementAt(i));
217
+ if ( pSrc != null )
218
+ pSrc.syncClientChanges();
219
+ }
220
+ }
221
+
222
+ int nErrCode = 0;
223
+ while( isContinueSync() )
224
+ {
225
+ int nSearchCount = 0;
226
+ String strUrl = getProtocol().getServerQueryUrl(strAction);
227
+ String strQuery = getProtocol().getServerQueryBody("", getClientID(), getSyncPageSize());
228
+
229
+ if ( strParams.length() > 0 )
230
+ strQuery += strParams;
231
+
232
+ for ( int i = 0; i < (int)arSources.size(); i++ )
233
+ {
234
+ SyncSource pSrc = findSourceByName((String)arSources.elementAt(i));
235
+ if ( pSrc != null )
236
+ {
237
+ strQuery += "&source[][name]=" + pSrc.getName();
238
+
239
+ if ( !pSrc.isTokenFromDB() && pSrc.getToken() > 1 )
240
+ strQuery += "&source[][token]=" + pSrc.getToken();
241
+ }
242
+ }
243
+
244
+ LOG.INFO("Call search on server. Url: " + (strUrl+strQuery) );
245
+ NetResponse resp = getNet().pullData(strUrl+strQuery, this);
246
+
247
+ if ( !resp.isOK() )
248
+ {
249
+ stopSync();
250
+ nErrCode = RhoRuby.getErrorFromResponse(resp);
251
+ continue;
252
+ }
253
+
254
+ String szData = resp.getCharData();
255
+
256
+ JSONArrayIterator oJsonArr = new JSONArrayIterator(szData);
257
+
258
+ for( ; !oJsonArr.isEnd() && isContinueSync(); oJsonArr.next() )
259
+ {
260
+ JSONArrayIterator oSrcArr = oJsonArr.getCurArrayIter();//new JSONArrayIterator(oJsonArr.getCurItem());
261
+
262
+ int nVersion = 0;
263
+ if ( !oSrcArr.isEnd() && oSrcArr.getCurItem().hasName("version") )
264
+ {
265
+ nVersion = oSrcArr.getCurItem().getInt("version");
266
+ oJsonArr.next();
267
+ }
268
+
269
+ if ( nVersion != getProtocol().getVersion() )
270
+ {
271
+ LOG.ERROR( "Sync server send search data with incompatible version. Client version: " + getProtocol().getVersion() +
272
+ "; Server response version: " + nVersion );
273
+ stopSync();
274
+ nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
275
+ continue;
276
+ }
277
+
278
+ if ( !oSrcArr.getCurItem().hasName("source") )
279
+ {
280
+ LOG.ERROR( "Sync server send search data without source name." );
281
+ stopSync();
282
+ nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
283
+ continue;
284
+ }
285
+
286
+ String strSrcName = oSrcArr.getCurItem().getString("source");
287
+ SyncSource pSrc = findSourceByName(strSrcName);
288
+ if ( pSrc == null )
289
+ {
290
+ LOG.ERROR("Sync server send search data for unknown source name:" + strSrcName);
291
+ stopSync();
292
+ nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
293
+ continue;
294
+ }
295
+
296
+ oSrcArr.reset(0);
297
+ pSrc.m_bIsSearch = true;
298
+ pSrc.setProgressStep(nProgressStep);
299
+ pSrc.processServerResponse_ver3(oSrcArr);
300
+
301
+ nSearchCount += pSrc.getCurPageCount();
302
+ }
303
+
304
+ if ( nSearchCount == 0 )
305
+ break;
306
+ }
307
+
308
+ if ( isContinueSync() )
309
+ {
310
+ SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
311
+ src.m_bIsSearch = true;
312
+
313
+ getNotify().fireSyncNotification(src, true, RhoRuby.ERR_NONE, RhoRuby.getMessageText("sync_completed"));
314
+ }
315
+ else if ( nErrCode != 0 )
316
+ {
317
+ SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
318
+ src.m_nErrCode = nErrCode;
319
+ src.m_bIsSearch = true;
320
+ getNotify().fireSyncNotification(src, true, src.m_nErrCode, "");
321
+ }
322
+
323
+ //update db info
324
+ TimeInterval endTime = TimeInterval.getCurrentTime();
325
+ //unsigned long timeUpdated = CLocalTime().toULong();
326
+ for ( int i = 0; i < (int)arSources.size(); i++ )
327
+ {
328
+ SyncSource oSrc = findSourceByName((String)arSources.elementAt(i));
329
+ if ( oSrc == null )
330
+ continue;
331
+ oSrc.getDB().executeSQL("UPDATE sources set last_updated=?,last_inserted_size=?,last_deleted_size=?, "+
332
+ "last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
333
+ new Long(endTime.toULong()/1000), new Integer(oSrc.getInsertedCount()), new Integer(oSrc.getDeletedCount()),
334
+ new Long((endTime.minus(startTime)).toULong()), new Integer(oSrc.getGetAtLeastOnePage()?1:0),
335
+ new Integer(oSrc.getRefreshTime()), oSrc.getID() );
336
+ }
337
+ //
338
+
339
+ getNotify().cleanCreateObjectErrors();
340
+ if ( getState() != esExit )
341
+ setState(esNone);
314
342
 
315
- //update db info
316
- CTimeInterval endTime = CTimeInterval::getCurrentTime();
317
- unsigned long timeUpdated = CLocalTime().toULong();
318
- for ( int i = 0; i < (int)arSources.size(); i++ )
319
- {
320
- CSyncSource* pSrc = findSourceByName(arSources.elementAt(i));
321
- if ( pSrc == null )
322
- continue;
323
- CSyncSource& oSrc = *pSrc;
324
- oSrc.getDB().executeSQL("UPDATE sources set last_updated=?,last_inserted_size=?,last_deleted_size=?, \
325
- last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
326
- timeUpdated, oSrc.getInsertedCount(), oSrc.getDeletedCount(),
327
- (endTime-startTime).toULong(), oSrc.getGetAtLeastOnePage(), oSrc.getRefreshTime(),
328
- oSrc.getID() );
329
- }
330
- //
343
+ } catch(Exception exc) {
344
+ LOG.ERROR("Search failed.", exc);
331
345
 
332
- getNotify().cleanCreateObjectErrors();
333
- if ( getState() != esExit )
334
- setState(esNone);*/
346
+ SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
347
+ src.m_bIsSearch = true;
348
+ src.m_nErrCode = RhoRuby.ERR_RUNTIME;
349
+
350
+ getNotify().fireSyncNotification(src, true, src.m_nErrCode, "" );
351
+ }
352
+
335
353
  }
336
354
 
337
355
  void doSyncSource(SourceID oSrcID)
@@ -399,7 +417,7 @@ public class SyncEngine implements NetRequest.IRhoSession
399
417
  {
400
418
  m_sources.removeAllElements();
401
419
 
402
- IDBResult res = getUserDB().executeSQL("SELECT source_id,sync_type,name, partition from sources ORDER BY priority");
420
+ IDBResult res = getUserDB().executeSQL("SELECT source_id,sync_type,name, partition from sources ORDER BY sync_priority");
403
421
  for ( ; !res.isEnd(); res.next() )
404
422
  {
405
423
  String strShouldSync = res.getStringByIdx(1);
@@ -473,7 +491,7 @@ public class SyncEngine implements NetRequest.IRhoSession
473
491
 
474
492
  NetResponse resp = getNet().pullData(getProtocol().getClientResetUrl(strClientID), this);
475
493
  /*
476
- processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"priority\":\"0\","+
494
+ processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"sync_priority\":\"0\","+
477
495
  "\"schema_version\":\"7.0\",\"schema\":{"+
478
496
  "\"columns\":[\'brand\',\'created_at\',\'name\',\'price\',\'quantity\',\'sku\',\'updated_at\']"+
479
497
  "}}]}");
@@ -521,6 +539,8 @@ public class SyncEngine implements NetRequest.IRhoSession
521
539
 
522
540
  void doBulkSync()throws Exception
523
541
  {
542
+ // processServerSources("{\"partition\":\"" + "application" + "\"}");
543
+
524
544
  if ( !RhoConf.getInstance().isExist("bulksync_state") )
525
545
  return;
526
546
 
@@ -628,6 +648,7 @@ public class SyncEngine implements NetRequest.IRhoSession
628
648
  getNotify().fireBulkSyncNotification(false, "change_db", strPartition, RhoRuby.ERR_NONE);
629
649
 
630
650
  dbPartition.setBulkSyncDB(fDataName, fScriptName);
651
+ processServerSources("{\"partition\":\"" + strPartition + "\"}");
631
652
 
632
653
  LOG.INFO("Bulk sync: end change db");
633
654
  getNotify().fireBulkSyncNotification(false, "", strPartition, RhoRuby.ERR_NONE);
@@ -85,7 +85,7 @@ class SyncSource
85
85
  int m_nRefreshTime = 0;
86
86
  int m_nProgressStep = -1;
87
87
  boolean m_bSchemaSource;
88
- Hashtable/*<String,String>*/ m_hashLinks = new Hashtable();
88
+ Hashtable/*<String,String>*/ m_hashAssociations = new Hashtable();
89
89
  Vector/*Ptr<net::CMultipartItem*>*/ m_arMultipartItems = new Vector();
90
90
  Vector/*<String>*/ m_arBlobAttrs = new Vector();
91
91
 
@@ -160,7 +160,7 @@ class SyncSource
160
160
  m_nErrCode = RhoRuby.ERR_NONE;
161
161
  m_bIsSearch = false;
162
162
 
163
- IDBResult res = db.executeSQL("SELECT token,links from sources WHERE source_id=?", m_nID);
163
+ IDBResult res = db.executeSQL("SELECT token,associations from sources WHERE source_id=?", m_nID);
164
164
  if ( !res.isEnd() )
165
165
  {
166
166
  m_token = res.getLongByIdx(0);
@@ -172,15 +172,15 @@ class SyncSource
172
172
  }
173
173
 
174
174
  m_bSchemaSource = db.isTableExist(m_strName);
175
- parseLinks(res.getStringByIdx(1));
175
+ parseAssociations(res.getStringByIdx(1));
176
176
  }
177
177
 
178
- void parseLinks(String strLinks)
178
+ void parseAssociations(String strAssociations)
179
179
  {
180
- if (strLinks.length() == 0 )
180
+ if (strAssociations.length() == 0 )
181
181
  return;
182
182
 
183
- Tokenizer oTokenizer = new Tokenizer( strLinks, "," );
183
+ Tokenizer oTokenizer = new Tokenizer( strAssociations, "," );
184
184
 
185
185
  String strSrcName = "";
186
186
  while (oTokenizer.hasMoreTokens())
@@ -191,7 +191,7 @@ class SyncSource
191
191
 
192
192
  if ( strSrcName.length() > 0 )
193
193
  {
194
- m_hashLinks.put(strSrcName, tok);
194
+ m_hashAssociations.put(strSrcName, tok);
195
195
  strSrcName = "";
196
196
  }else
197
197
  strSrcName = tok;
@@ -220,9 +220,10 @@ class SyncSource
220
220
  }finally{
221
221
  TimeInterval endTime = TimeInterval.getCurrentTime();
222
222
  getDB().executeSQL("UPDATE sources set last_updated=?,last_inserted_size=?,last_deleted_size=?, "+
223
- "last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
224
- new Long(endTime.toULong()/1000), new Integer(getInsertedCount()), new Integer(getDeletedCount()), new Long((endTime.minus(startTime)).toULong()),
225
- new Integer(m_bGetAtLeastOnePage?1:0), new Integer(m_nRefreshTime), getID() );
223
+ "last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
224
+ new Long(endTime.toULong()/1000), new Integer(getInsertedCount()), new Integer(getDeletedCount()),
225
+ new Long((endTime.minus(startTime)).toULong()),
226
+ new Integer(m_bGetAtLeastOnePage?1:0), new Integer(m_nRefreshTime), getID() );
226
227
  }
227
228
  }
228
229
 
@@ -622,19 +623,19 @@ class SyncSource
622
623
  }
623
624
  }
624
625
 
625
- void processLinks(String strOldObject, String strNewObject)throws Exception
626
+ void processAssociations(String strOldObject, String strNewObject)throws Exception
626
627
  {
627
- Enumeration vals = m_hashLinks.elements();
628
- Enumeration keys = m_hashLinks.keys();
628
+ Enumeration vals = m_hashAssociations.elements();
629
+ Enumeration keys = m_hashAssociations.keys();
629
630
  while (vals.hasMoreElements())
630
631
  {
631
632
  SyncSource pSrc = getSync().findSourceByName((String)keys.nextElement());
632
633
  if ( pSrc != null )
633
- pSrc.updateLink(strOldObject, strNewObject, (String)vals.nextElement());
634
+ pSrc.updateAssociation(strOldObject, strNewObject, (String)vals.nextElement());
634
635
  }
635
636
  }
636
637
 
637
- void updateLink(String strOldObject, String strNewObject, String strAttrib)throws Exception
638
+ void updateAssociation(String strOldObject, String strNewObject, String strAttrib)throws Exception
638
639
  {
639
640
  if ( m_bSchemaSource )
640
641
  {
@@ -767,7 +768,7 @@ class SyncSource
767
768
  }else if ( strCmd.compareTo("links") == 0 )
768
769
  {
769
770
  String strValue = attrIter.getCurString();
770
- processLinks(strObject, strValue);
771
+ processAssociations(strObject, strValue);
771
772
 
772
773
  String strSqlUpdate = "UPDATE ";
773
774
  strSqlUpdate += getName() + " SET object=? WHERE object=?";
@@ -871,7 +872,7 @@ class SyncSource
871
872
  m_nDeleted++;
872
873
  }else if ( strCmd.compareTo("links") == 0 )
873
874
  {
874
- processLinks(strObject, oAttrValue.m_strValue);
875
+ processAssociations(strObject, oAttrValue.m_strValue);
875
876
 
876
877
  getDB().executeSQL("UPDATE object_values SET object=? where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
877
878
  getDB().executeSQL("UPDATE changed_values SET object=?,sent=3 where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
@@ -664,8 +664,16 @@ public class SyncThread extends RhoThread
664
664
  new RubyOneArgMethod() {
665
665
  protected RubyValue run(RubyValue receiver, RubyValue arg1, RubyBlock block) {
666
666
  try{
667
- String url = arg1.toStr();
668
- getSyncEngine().setSyncServer(url);
667
+ String syncserver = arg1.toStr();
668
+
669
+ stopSync();
670
+ getSyncEngine().setSyncServer(syncserver);
671
+
672
+ if ( syncserver != null && syncserver.length() > 0 )
673
+ SyncThread.getInstance().start(SyncThread.epLow);
674
+ else
675
+ SyncThread.getInstance().stop(SYNC_WAIT_BEFOREKILL_SECONDS);
676
+
669
677
  }catch(Exception e)
670
678
  {
671
679
  LOG.ERROR("set_syncserver failed", e);