rhoconnect-client 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -0
  3. data/CREDITS +0 -0
  4. data/LICENSE +9 -0
  5. data/README.md +47 -0
  6. data/ext/rhoconnect-client/RhoConnectClient.rb +190 -0
  7. data/ext/rhoconnect-client/ext/RhoConnectClient.xml +726 -0
  8. data/ext/rhoconnect-client/ext/build +26 -0
  9. data/ext/rhoconnect-client/ext/build.bat +30 -0
  10. data/ext/rhoconnect-client/ext/platform/android/ext_java.files +1 -0
  11. data/ext/rhoconnect-client/ext/platform/android/ext_native.files +14 -0
  12. data/ext/rhoconnect-client/ext/platform/android/src/com/rhoconnectclient/RhoconnectClient.java +1 -0
  13. data/ext/rhoconnect-client/ext/platform/iphone/.gitignore +1 -0
  14. data/ext/rhoconnect-client/ext/platform/iphone/Rakefile +74 -0
  15. data/ext/rhoconnect-client/ext/platform/iphone/RhoconnectClient.xcodeproj/project.pbxproj +390 -0
  16. data/ext/rhoconnect-client/ext/platform/iphone/RhoconnectClient_Prefix.pch +7 -0
  17. data/ext/rhoconnect-client/ext/platform/iphone/impl/readme.txt +7 -0
  18. data/ext/rhoconnect-client/ext/platform/qt/Rakefile +35 -0
  19. data/ext/rhoconnect-client/ext/platform/qt/rhoconnect-client.pro +88 -0
  20. data/ext/rhoconnect-client/ext/platform/wm/Rhoconnect-client.sln +36 -0
  21. data/ext/rhoconnect-client/ext/platform/wm/Rhoconnect-client.vcproj +774 -0
  22. data/ext/rhoconnect-client/ext/platform/wm/Rhoconnect-client.vsprops +15 -0
  23. data/ext/rhoconnect-client/ext/platform/wm/src/rhoconnectclient_wm.cpp +40 -0
  24. data/ext/rhoconnect-client/ext/platform/wm/src/rhoconnectclient_wm.h +2 -0
  25. data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.props +22 -0
  26. data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.sln +32 -0
  27. data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.vcxproj +220 -0
  28. data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.vcxproj.filters +103 -0
  29. data/ext/rhoconnect-client/ext/shared/RhoConnectClientImpl.cpp +273 -0
  30. data/ext/rhoconnect-client/ext/shared/RhoConnectClientImpl.h +60 -0
  31. data/ext/rhoconnect-client/ext/shared/RhoConnectClientSingletonImpl.h +53 -0
  32. data/ext/rhoconnect-client/ext/shared/initRhoconnectClient.cpp +207 -0
  33. data/ext/rhoconnect-client/ext/shared/rhoconnectclient.c +18 -0
  34. data/ext/rhoconnect-client/ext/shared/sync/ClientRegister.cpp +398 -0
  35. data/ext/rhoconnect-client/ext/shared/sync/ClientRegister.h +147 -0
  36. data/ext/rhoconnect-client/ext/shared/sync/ISyncProtocol.h +91 -0
  37. data/ext/rhoconnect-client/ext/shared/sync/SyncEngine.cpp +1245 -0
  38. data/ext/rhoconnect-client/ext/shared/sync/SyncEngine.h +213 -0
  39. data/ext/rhoconnect-client/ext/shared/sync/SyncNotify.cpp +737 -0
  40. data/ext/rhoconnect-client/ext/shared/sync/SyncNotify.h +209 -0
  41. data/ext/rhoconnect-client/ext/shared/sync/SyncProtocol_3.h +220 -0
  42. data/ext/rhoconnect-client/ext/shared/sync/SyncProtocol_4.h +259 -0
  43. data/ext/rhoconnect-client/ext/shared/sync/SyncSource.cpp +1694 -0
  44. data/ext/rhoconnect-client/ext/shared/sync/SyncSource.h +212 -0
  45. data/ext/rhoconnect-client/ext/shared/sync/SyncThread.cpp +583 -0
  46. data/ext/rhoconnect-client/ext/shared/sync/SyncThread.h +250 -0
  47. data/ext/rhoconnect-client/ext.yml +12 -0
  48. data/lib/build/run_rhoconnect_spec.rb +135 -0
  49. data/lib/rhoconnect-client.rb +3 -0
  50. data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +1673 -0
  51. data/platform/shared/RhoConnectClient/RhoConnectClient.h +181 -0
  52. data/platform/shared/RhoConnectClient/RhoError.h +77 -0
  53. data/rhoconnect-client/C++/Tests/RhoConnectClientTest.cpp +830 -0
  54. data/rhoconnect-client/C++/Tests/win32/.gitignore +3 -0
  55. data/rhoconnect-client/C++/Tests/win32/RhoConnectClient.sln +65 -0
  56. data/rhoconnect-client/C++/Tests/win32/RhoConnectClient.vcproj +634 -0
  57. data/rhoconnect-client/C++/Tests/win32/RhoConnectClientTest/RhoConnectClientTest.vcproj +222 -0
  58. data/rhoconnect-client/C++/Tests/win32/RhoConnectClientTest/stdafx.h +65 -0
  59. data/rhoconnect-client/C++/Tests/win32/stdafx.h +65 -0
  60. data/rhoconnect-client/CHANGELOG +18 -0
  61. data/rhoconnect-client/Java/Android/build/android.rake +387 -0
  62. data/rhoconnect-client/Java/Android/build/android_sdk.rb +582 -0
  63. data/rhoconnect-client/Java/Android/build/libcurl_build.files +73 -0
  64. data/rhoconnect-client/Java/Android/build/libjson_build.files +9 -0
  65. data/rhoconnect-client/Java/Android/build/librhocommon_build.files +14 -0
  66. data/rhoconnect-client/Java/Android/build/librhodb_build.files +5 -0
  67. data/rhoconnect-client/Java/Android/build/librhoimpl_build.files +13 -0
  68. data/rhoconnect-client/Java/Android/build/librholog_build.files +4 -0
  69. data/rhoconnect-client/Java/Android/build/libsqlite_build.files +1 -0
  70. data/rhoconnect-client/Java/Android/build/libsync_build.files +7 -0
  71. data/rhoconnect-client/Java/Android/build/libunzip_build.files +1 -0
  72. data/rhoconnect-client/Java/Android/build/rhoconnectclient_build.files +3 -0
  73. data/rhoconnect-client/Java/Android/build/rhoimpljava_build.files +21 -0
  74. data/rhoconnect-client/Java/Android/src/com/rhomobile/rhodes/Capabilities.java +63 -0
  75. data/rhoconnect-client/Java/Android/src/com/rhomobile/rhodes/MemoryInfoCollector.java +79 -0
  76. data/rhoconnect-client/Java/Android/src/com/rhomobile/rhodes/util/ContextFactory.java +63 -0
  77. data/rhoconnect-client/Java/Android/test/.classpath +9 -0
  78. data/rhoconnect-client/Java/Android/test/.project +33 -0
  79. data/rhoconnect-client/Java/Android/test/AndroidManifest.xml +14 -0
  80. data/rhoconnect-client/Java/Android/test/assets/apps/androidtest.png +0 -0
  81. data/rhoconnect-client/Java/Android/test/assets/apps/rhoconfig.txt +19 -0
  82. data/rhoconnect-client/Java/Android/test/assets/apps/rhoconfig.txt.timestamp +1 -0
  83. data/rhoconnect-client/Java/Android/test/assets/db/syncdb.schema +44 -0
  84. data/rhoconnect-client/Java/Android/test/assets/db/syncdb.triggers +10 -0
  85. data/rhoconnect-client/Java/Android/test/assets/db/syncdb_java.triggers +21 -0
  86. data/rhoconnect-client/Java/Android/test/assets/rho.dat +9 -0
  87. data/rhoconnect-client/Java/Android/test/proguard.cfg +36 -0
  88. data/rhoconnect-client/Java/Android/test/project.properties +11 -0
  89. data/rhoconnect-client/Java/Android/test/res/drawable-hdpi/icon.png +0 -0
  90. data/rhoconnect-client/Java/Android/test/res/drawable-ldpi/icon.png +0 -0
  91. data/rhoconnect-client/Java/Android/test/res/drawable-mdpi/icon.png +0 -0
  92. data/rhoconnect-client/Java/Android/test/res/layout/main.xml +12 -0
  93. data/rhoconnect-client/Java/Android/test/res/values/strings.xml +5 -0
  94. data/rhoconnect-client/Java/Android/test/rhoimpl.jar +0 -0
  95. data/rhoconnect-client/Java/Android/test/src/com/rhomobile/rhoconnect_client_test/TestRhoConnectClient.java +343 -0
  96. data/rhoconnect-client/Java/Android/test/src/com/rhomobile/rhoconnect_client_test/TestRhoConnectClientBlobs.java +219 -0
  97. data/rhoconnect-client/Java/RhoConnect/.classpath +6 -0
  98. data/rhoconnect-client/Java/RhoConnect/.project +93 -0
  99. data/rhoconnect-client/Java/RhoConnect/assets/apps/rhoconfig.txt +19 -0
  100. data/rhoconnect-client/Java/RhoConnect/assets/apps/rhoconfig.txt.timestamp +1 -0
  101. data/rhoconnect-client/Java/RhoConnect/assets/db/syncdb.schema +44 -0
  102. data/rhoconnect-client/Java/RhoConnect/assets/db/syncdb.triggers +10 -0
  103. data/rhoconnect-client/Java/RhoConnect/assets/db/syncdb_java.triggers +21 -0
  104. data/rhoconnect-client/Java/RhoConnect/assets/rho.dat +8 -0
  105. data/rhoconnect-client/Java/RhoConnect/jni/include/RhoConnectJniNotify.h +61 -0
  106. data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectClient.h +181 -0
  107. data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectNotify.h +13 -0
  108. data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectNotify_IDelegate.h +13 -0
  109. data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectObjectNotify.h +13 -0
  110. data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectObjectNotify_IDelegate.h +13 -0
  111. data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhomModel.h +103 -0
  112. data/rhoconnect-client/Java/RhoConnect/jni/include/rhojava.inc +76 -0
  113. data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniClient.cpp +401 -0
  114. data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniModel.cpp +332 -0
  115. data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniNotify.cpp +223 -0
  116. data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectUtil.cpp +82 -0
  117. data/rhoconnect-client/Java/RhoConnect/jni/src/RhodesApp.cpp +114 -0
  118. data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectClient.java +108 -0
  119. data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectNotify.java +78 -0
  120. data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectObjectNotify.java +71 -0
  121. data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhomModel.java +195 -0
  122. data/rhoconnect-client/JavaScript/.classpath +10 -0
  123. data/rhoconnect-client/JavaScript/.gitignore +4 -0
  124. data/rhoconnect-client/JavaScript/.project +17 -0
  125. data/rhoconnect-client/JavaScript/README.textile +1 -0
  126. data/rhoconnect-client/JavaScript/build.xml +185 -0
  127. data/rhoconnect-client/JavaScript/doc/fsm-sample.js +44 -0
  128. data/rhoconnect-client/JavaScript/doc/fsm-sample.png +0 -0
  129. data/rhoconnect-client/JavaScript/src/RhoSyncJS.gwt.xml +21 -0
  130. data/rhoconnect-client/JavaScript/stubs/RhoSyncStubsJS.gwt.xml +21 -0
  131. data/rhoconnect-client/JavaScript/stubs/com/rho/Capabilities.java +7 -0
  132. data/rhoconnect-client/JavaScript/stubs/com/rho/IRhoRubyHelper.java +7 -0
  133. data/rhoconnect-client/JavaScript/stubs/com/rho/Mutex.java +5 -0
  134. data/rhoconnect-client/JavaScript/stubs/com/rho/RhoAppAdapter.java +39 -0
  135. data/rhoconnect-client/JavaScript/stubs/com/rho/RhoClassFactory.java +29 -0
  136. data/rhoconnect-client/JavaScript/stubs/com/rho/RhoConf.java +100 -0
  137. data/rhoconnect-client/JavaScript/stubs/com/rho/RhoEmptyLogger.java +7 -0
  138. data/rhoconnect-client/JavaScript/stubs/com/rho/RhoEmptyProfiler.java +5 -0
  139. data/rhoconnect-client/JavaScript/stubs/com/rho/RhoLogger.java +32 -0
  140. data/rhoconnect-client/JavaScript/stubs/com/rho/RhoProfiler.java +27 -0
  141. data/rhoconnect-client/JavaScript/stubs/com/rho/RhodesApp.java +25 -0
  142. data/rhoconnect-client/JavaScript/stubs/com/rho/TimeInterval.java +22 -0
  143. data/rhoconnect-client/JavaScript/stubs/com/rho/Tokenizer.java +23 -0
  144. data/rhoconnect-client/JavaScript/stubs/com/rho/db/DBAdapter.java +174 -0
  145. data/rhoconnect-client/JavaScript/stubs/com/rho/db/DBAttrManager.java +15 -0
  146. data/rhoconnect-client/JavaScript/stubs/com/rho/db/DBException.java +5 -0
  147. data/rhoconnect-client/JavaScript/stubs/com/rho/db/IDBResult.java +27 -0
  148. data/rhoconnect-client/JavaScript/stubs/com/rho/file/IFileAccess.java +7 -0
  149. data/rhoconnect-client/JavaScript/stubs/com/rho/file/SimpleFile.java +15 -0
  150. data/rhoconnect-client/JavaScript/stubs/com/rho/net/IHttpConnection.java +22 -0
  151. data/rhoconnect-client/JavaScript/stubs/com/rho/net/NetRequest.java +324 -0
  152. data/rhoconnect-client/JavaScript/stubs/com/rho/net/NetResponse.java +51 -0
  153. data/rhoconnect-client/JavaScript/stubs/com/rho/net/URI.java +64 -0
  154. data/rhoconnect-client/JavaScript/stubs/com/rho/sync/ClientRegister.java +15 -0
  155. data/rhoconnect-client/JavaScript/stubs/com/rho/sync/JSONArrayIterator.java +37 -0
  156. data/rhoconnect-client/JavaScript/stubs/com/rho/sync/JSONEntry.java +48 -0
  157. data/rhoconnect-client/JavaScript/stubs/com/rho/sync/JSONStructIterator.java +41 -0
  158. data/rhoconnect-client/JavaScript/stubs/com/rho/sync/SyncNotify.java +98 -0
  159. data/rhoconnect-client/JavaScript/stubs/com/rho/sync/SyncThread.java +92 -0
  160. data/rhoconnect-client/JavaScript/war/WEB-INF/lib/gwt-servlet-deps.jar +0 -0
  161. data/rhoconnect-client/JavaScript/war/WEB-INF/lib/gwt-servlet.jar +0 -0
  162. data/rhoconnect-client/JavaScript/war/js/fsm-sample.js +54 -0
  163. data/rhoconnect-client/JavaScript/war/js/rhosync-api.js +237 -0
  164. data/rhoconnect-client/JavaScript/war/js/rhosync-fsm.js +307 -0
  165. data/rhoconnect-client/JavaScript/war/rhosyncjs/4C71D69C9BBC9E6F05C6BA49B01BCBC1.cache.html +3122 -0
  166. data/rhoconnect-client/JavaScript/war/rhosyncjs/5146F4FFF34511C8BB2661E920B49E3A.cache.html +3254 -0
  167. data/rhoconnect-client/JavaScript/war/rhosyncjs/5248C67481D9D27AD0703D15CDBD2A1C.cache.html +3147 -0
  168. data/rhoconnect-client/JavaScript/war/rhosyncjs/EE1DC2692C9C32367B53A39E2358AF23.cache.html +3195 -0
  169. data/rhoconnect-client/JavaScript/war/rhosyncjs/clear.cache.gif +0 -0
  170. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/corner.png +0 -0
  171. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/corner_ie6.png +0 -0
  172. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/hborder.png +0 -0
  173. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/hborder_ie6.png +0 -0
  174. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/corner_dialog_topleft.png +0 -0
  175. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/corner_dialog_topright.png +0 -0
  176. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/hborder_blue_shadow.png +0 -0
  177. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/hborder_gray_shadow.png +0 -0
  178. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/vborder_blue_shadow.png +0 -0
  179. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/vborder_gray_shadow.png +0 -0
  180. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/splitPanelThumb.png +0 -0
  181. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/vborder.png +0 -0
  182. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/vborder_ie6.png +0 -0
  183. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/standard.css +1144 -0
  184. data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/standard_rtl.css +1145 -0
  185. data/rhoconnect-client/JavaScript/war/rhosyncjs/hosted.html +350 -0
  186. data/rhoconnect-client/JavaScript/war/rhosyncjs/rhosyncjs.nocache.js +314 -0
  187. data/rhoconnect-client/JavaScript/war/test/SpecRunner.html +35 -0
  188. data/rhoconnect-client/JavaScript/war/test/dbtest.html +38 -0
  189. data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/MIT.LICENSE +20 -0
  190. data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/jasmine-html.js +188 -0
  191. data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/jasmine.css +166 -0
  192. data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/jasmine.js +2421 -0
  193. data/rhoconnect-client/JavaScript/war/test/spec/SpecHelper.js +7 -0
  194. data/rhoconnect-client/JavaScript/war/test/spec/SyncApiSpec.js +573 -0
  195. data/rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js +58 -0
  196. data/rhoconnect-client/JavaScript/war/test/worker-test.js +17 -0
  197. data/rhoconnect-client/LICENSE +41 -0
  198. data/rhoconnect-client/ObjectiveC/RhoConnectClient.h +118 -0
  199. data/rhoconnect-client/ObjectiveC/RhoConnectClient.m +641 -0
  200. data/rhoconnect-client/ObjectiveC/RhoConnectClient.xcodeproj/project.pbxproj +1434 -0
  201. data/rhoconnect-client/ObjectiveC/RhoConnectNotify.h +83 -0
  202. data/rhoconnect-client/ObjectiveC/RhoConnectNotify.m +181 -0
  203. data/rhoconnect-client/ObjectiveC/RhoConnectObjectNotify.h +65 -0
  204. data/rhoconnect-client/ObjectiveC/RhoConnectObjectNotify.m +73 -0
  205. data/rhoconnect-client/ObjectiveC/RhomModel.h +101 -0
  206. data/rhoconnect-client/ObjectiveC/RhomModel.m +320 -0
  207. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/MainWindow.xib +198 -0
  208. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTest-Info.plist +30 -0
  209. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTest.xcodeproj/project.pbxproj +373 -0
  210. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTestAppDelegate.h +58 -0
  211. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTestAppDelegate.m +84 -0
  212. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTest_Prefix.pch +8 -0
  213. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/invalid_import_db.zip +0 -0
  214. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/main.m +1096 -0
  215. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/test.png +0 -0
  216. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/test2.png +0 -0
  217. data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/valid_import_db.zip +0 -0
  218. data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsAppDelegate.h +62 -0
  219. data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsAppDelegate.m +35 -0
  220. data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsViewController.h +78 -0
  221. data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsViewController.m +549 -0
  222. data/rhoconnect-client/ObjectiveC/Tests/ptests/MainWindow.xib +227 -0
  223. data/rhoconnect-client/ObjectiveC/Tests/ptests/main.m +17 -0
  224. data/rhoconnect-client/ObjectiveC/Tests/ptests/ptests-Info.plist +30 -0
  225. data/rhoconnect-client/ObjectiveC/Tests/ptests/ptests.xcodeproj/project.pbxproj +363 -0
  226. data/rhoconnect-client/ObjectiveC/Tests/ptests/ptestsViewController.xib +641 -0
  227. data/rhoconnect-client/ObjectiveC/Tests/ptests/ptests_Prefix.pch +8 -0
  228. data/rhoconnect-client/README.textile +23 -0
  229. data/rhoconnect-client/Rakefile +20 -0
  230. data/rhoconnect-client/Samples/Java/android_store/.classpath +8 -0
  231. data/rhoconnect-client/Samples/Java/android_store/.project +33 -0
  232. data/rhoconnect-client/Samples/Java/android_store/AndroidManifest.xml +24 -0
  233. data/rhoconnect-client/Samples/Java/android_store/assets/apps/rhoconfig.txt +19 -0
  234. data/rhoconnect-client/Samples/Java/android_store/assets/apps/rhoconfig.txt.timestamp +1 -0
  235. data/rhoconnect-client/Samples/Java/android_store/assets/db/syncdb.schema +44 -0
  236. data/rhoconnect-client/Samples/Java/android_store/assets/db/syncdb.triggers +10 -0
  237. data/rhoconnect-client/Samples/Java/android_store/assets/db/syncdb_java.triggers +21 -0
  238. data/rhoconnect-client/Samples/Java/android_store/assets/rho.dat +8 -0
  239. data/rhoconnect-client/Samples/Java/android_store/default.properties +11 -0
  240. data/rhoconnect-client/Samples/Java/android_store/project.properties +14 -0
  241. data/rhoconnect-client/Samples/Java/android_store/res/drawable-hdpi/icon.png +0 -0
  242. data/rhoconnect-client/Samples/Java/android_store/res/drawable-ldpi/icon.png +0 -0
  243. data/rhoconnect-client/Samples/Java/android_store/res/drawable-mdpi/icon.png +0 -0
  244. data/rhoconnect-client/Samples/Java/android_store/res/layout/main.xml +12 -0
  245. data/rhoconnect-client/Samples/Java/android_store/res/values/strings.xml +5 -0
  246. data/rhoconnect-client/Samples/Java/android_store/rhoimpl.jar +0 -0
  247. data/rhoconnect-client/Samples/Java/android_store/src/com/rhomobile/android_store/StoreActivity.java +68 -0
  248. data/rhoconnect-client/Samples/Java/android_store/src/com/rhomobile/android_store/StoreApplication.java +15 -0
  249. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/LoginViewController.h +70 -0
  250. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/LoginViewController.m +94 -0
  251. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RhoConnectEngine.h +82 -0
  252. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RhoConnectEngine.m +119 -0
  253. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RootViewController.h +63 -0
  254. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RootViewController.m +314 -0
  255. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/WaitLoginController.h +65 -0
  256. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/WaitLoginController.m +110 -0
  257. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/storeAppDelegate.h +61 -0
  258. data/rhoconnect-client/Samples/ObjectiveC/store/Classes/storeAppDelegate.m +171 -0
  259. data/rhoconnect-client/Samples/ObjectiveC/store/LoginViewController.xib +779 -0
  260. data/rhoconnect-client/Samples/ObjectiveC/store/MainWindow.xib +580 -0
  261. data/rhoconnect-client/Samples/ObjectiveC/store/RootViewController.xib +384 -0
  262. data/rhoconnect-client/Samples/ObjectiveC/store/WaitLoginController.xib +557 -0
  263. data/rhoconnect-client/Samples/ObjectiveC/store/icon.png +0 -0
  264. data/rhoconnect-client/Samples/ObjectiveC/store/main.m +22 -0
  265. data/rhoconnect-client/Samples/ObjectiveC/store/store-Info.plist +30 -0
  266. data/rhoconnect-client/Samples/ObjectiveC/store/store.xcodeproj/project.pbxproj +367 -0
  267. data/rhoconnect-client/Samples/ObjectiveC/store/store_Prefix.pch +14 -0
  268. data/rhoconnect-client/build.yml +3 -0
  269. data/rhoconnect-client/version +1 -0
  270. metadata +314 -0
@@ -0,0 +1,213 @@
1
+ /*------------------------------------------------------------------------
2
+ * (The MIT License)
3
+ *
4
+ * Copyright (c) 2008-2011 Rhomobile, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ * http://rhomobile.com
25
+
26
+ * Copyright (c) 2011-2016 Symbol Technologies, Inc.
27
+ *
28
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
29
+ * of this software and associated documentation files (the "Software"), to deal
30
+ * in the Software without restriction, including without limitation the rights
31
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32
+ * copies of the Software, and to permit persons to whom the Software is
33
+ * furnished to do so, subject to the following conditions:
34
+ *
35
+ * The above copyright notice and this permission notice shall be included in
36
+ * all copies or substantial portions of the Software.
37
+ *
38
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44
+ * THE SOFTWARE.
45
+ *
46
+ * http://symbol.com
47
+ *------------------------------------------------------------------------*/
48
+
49
+ #pragma once
50
+
51
+ #include "common/RhoStd.h"
52
+ #include "common/IRhoClassFactory.h"
53
+ #include "common/RhoMutexLock.h"
54
+ #include "net/INetRequest.h"
55
+ #include "ISyncProtocol.h"
56
+
57
+ #include "SyncSource.h"
58
+ #include "SyncNotify.h"
59
+ #include "db/DBAdapter.h"
60
+ #include "logging/RhoLog.h"
61
+
62
+ namespace rho {
63
+ namespace sync {
64
+
65
+ class CSyncEngine : public net::IRhoSession
66
+ {
67
+ DEFINE_LOGCLASS;
68
+ public:
69
+ enum ESyncState{ esNone, esSyncAllSources, esSyncSource, esSearch, esStop, esExit };
70
+ enum EBulkSyncState { ebsNotSynced = 0, ebsSynced = 1, ebsLoadBlobs = 2 };
71
+
72
+ struct CSourceID
73
+ {
74
+ String m_strName;
75
+ int m_nID;
76
+
77
+ CSourceID(int id, const String& strName ){ m_nID = id; m_strName = strName; }
78
+ CSourceID(const String& strName ){ m_strName = strName; }
79
+
80
+ String toString()const;
81
+ boolean isEqual(CSyncSource& src)const;
82
+ };
83
+
84
+ class CSourceOptions
85
+ {
86
+ common::CMutex m_mxSrcOptions;
87
+ HashtablePtr<int, Hashtable<String,String>* > m_hashSrcOptions;
88
+ public:
89
+ void setProperty(int nSrcID, const char* szPropName, const char* szPropValue);
90
+ String getProperty(int nSrcID, const char* szPropName);
91
+ boolean getBoolProperty(int nSrcID, const char* szPropName);
92
+ int getIntProperty(int nSrcID, const char* szPropName);
93
+ void clearProperties();
94
+ };
95
+
96
+ private:
97
+ VectorPtr<CSyncSource*> m_sources;
98
+ NetRequest m_NetRequest, m_NetRequestClientID;
99
+ common::CAutoPtr<ISyncProtocol> m_SyncProtocol;
100
+ ESyncState m_syncState;
101
+ String m_clientID;
102
+ common::CMutex m_mxLoadClientID, m_mxSessionID;
103
+ String m_strSession;
104
+ CSyncNotify m_oSyncNotify;
105
+ boolean m_bStopByUser;
106
+ int m_nSyncPageSize;
107
+ boolean m_bNoThreaded;
108
+ int m_nErrCode;
109
+ String m_strError;
110
+ boolean m_bIsSearch, m_bIsSchemaChanged;
111
+ static CSourceOptions m_oSourceOptions;
112
+
113
+ net::CNetRequestWrapper getNetClientID(){ return getNetRequest(&m_NetRequestClientID); }
114
+
115
+ public:
116
+ CSyncEngine();
117
+ ~CSyncEngine(void){}
118
+
119
+ static CSourceOptions& getSourceOptions(){ return m_oSourceOptions; }
120
+ net::CNetRequestWrapper getNet(){ return getNetRequest(&m_NetRequest); }
121
+
122
+ void doSyncAllSources(const String& strQueryParams, boolean bSyncOnlyChangedSources);
123
+ void doSyncSource(const CSourceID& oSrcID, const String& strQueryParams);
124
+ void doSearch(rho::Vector<rho::String>& arSources, String strParams, const String& from, boolean bSearchSyncChanges, int nProgressStep);
125
+
126
+ void login(String name, String password, const CSyncNotification& oNotify);
127
+ boolean isLoggedIn();
128
+ String loadSession();
129
+ void logout();
130
+ void logout_int();
131
+
132
+ void setSyncServer(const char* syncserver);
133
+ String getSyncServer() const;
134
+
135
+ void setState(ESyncState eState){ m_syncState = eState; }
136
+ ESyncState getState()const{ return m_syncState; }
137
+ boolean isSearch()const{ return m_bIsSearch; }
138
+ boolean isContinueSync()const{ return m_syncState != esExit && m_syncState != esStop; }
139
+ boolean isSyncing()const{ return m_syncState == esSyncAllSources || m_syncState == esSyncSource || m_syncState == esSearch; }
140
+ void stopSync(){ if (isContinueSync()){ setState(esStop); m_NetRequest.cancel();m_NetRequestClientID.cancel();} }
141
+ void stopSyncByUser(){ m_bStopByUser = true; stopSync(); }
142
+ void exitSync(){ setState(esExit); m_NetRequest.cancel(); m_NetRequestClientID.cancel();}
143
+ boolean isStoppedByUser(){ return m_bStopByUser; }
144
+ void setSslVerifyPeer(boolean b);
145
+ bool getSslVerifyPeer();
146
+
147
+ //private:
148
+ String getClientID()const{ return m_clientID; }
149
+ void setSession(String strSession){m_strSession=strSession;}
150
+ boolean isSessionExist(){ return m_strSession.length() > 0; }
151
+
152
+ void setSchemaChanged(boolean bChanged){ m_bIsSchemaChanged = bChanged; }
153
+ boolean isSchemaChanged(){ return m_bIsSchemaChanged; }
154
+ //IRhoSession
155
+ virtual const String& getSession()
156
+ {
157
+ synchronized(m_mxSessionID){
158
+ return m_strSession;
159
+ }
160
+ }
161
+ virtual const String& getContentType(){ return getProtocol().getContentType();}
162
+
163
+ void loadAllSources();
164
+ void prepareSync(ESyncState eState, const CSourceID* oSrcID);
165
+
166
+ VectorPtr<CSyncSource*>& getSources(){ return m_sources; }
167
+ //int getStartSource();
168
+ String loadClientID();
169
+ String readClientID();
170
+ String requestClientIDByNet();
171
+ boolean resetClientIDByNet(const String& strClientID);//throws Exception
172
+ void doBulkSync();//throws Exception
173
+
174
+ CSyncNotify& getNotify(){ return m_oSyncNotify; }
175
+ ISyncProtocol& getProtocol(){ return *m_SyncProtocol; }
176
+
177
+ CSyncSource* findSourceByName(const String& strSrcName);
178
+ CSyncSource* findSourceById(int srcId);
179
+
180
+
181
+ int getSyncPageSize() { return m_nSyncPageSize; }
182
+ void setSyncPageSize(int nPageSize){ m_nSyncPageSize = nPageSize; }
183
+
184
+ boolean isNoThreadedMode(){ return m_bNoThreaded; }
185
+ void setNonThreadedMode(boolean b){m_bNoThreaded = b;}
186
+
187
+ void applyChangedValues(db::CDBAdapter& db);
188
+ private:
189
+
190
+ bool recoverSearch( const String& strUrl, const String& strBody, int& errorCode, String& strError, int nProgressStep );
191
+
192
+ CSyncSource* findSource(const CSourceID& oSrcID);
193
+
194
+ void loadBulkPartition(const String& strPartition);
195
+ String makeBulkDataFileName(String strDataUrl, String strDbPath, String strExt);
196
+ db::CDBAdapter& getUserDB(){ return db::CDBAdapter::getUserDB(); }
197
+ db::CDBAdapter& getDB(const String& strPartition){ return db::CDBAdapter::getDB(strPartition.c_str()); }
198
+
199
+ void initProtocol();
200
+ void processServerSources(String strSources);
201
+ void checkSourceAssociations();
202
+
203
+ void syncOneSource(int i, const String& strQueryParams, boolean bSyncOnlyIfChanged);
204
+ void syncAllSources(const String& strQueryParams, boolean bSyncOnlyChangedSources);
205
+
206
+ boolean processBlobs();
207
+ void loadBulkPartitions();
208
+
209
+ friend class CSyncSource;
210
+ };
211
+
212
+ }
213
+ }
@@ -0,0 +1,737 @@
1
+ /*------------------------------------------------------------------------
2
+ * (The MIT License)
3
+ *
4
+ * Copyright (c) 2008-2011 Rhomobile, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ * http://rhomobile.com
25
+
26
+ * Copyright (c) 2011-2016 Symbol Technologies, Inc.
27
+ *
28
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
29
+ * of this software and associated documentation files (the "Software"), to deal
30
+ * in the Software without restriction, including without limitation the rights
31
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32
+ * copies of the Software, and to permit persons to whom the Software is
33
+ * furnished to do so, subject to the following conditions:
34
+ *
35
+ * The above copyright notice and this permission notice shall be included in
36
+ * all copies or substantial portions of the Software.
37
+ *
38
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44
+ * THE SOFTWARE.
45
+ *
46
+ * http://symbol.com
47
+ *------------------------------------------------------------------------*/
48
+
49
+ #include "SyncNotify.h"
50
+ #include "SyncEngine.h"
51
+ //#include "net/URI.h"
52
+ #include "common/RhoFilePath.h"
53
+ #include "common/RhoAppAdapter.h"
54
+ #include "common/RhodesApp.h"
55
+ #include "json/JSONIterator.h"
56
+
57
+ #ifndef RHO_NO_RUBY
58
+ #include "rubyext/WebView.h"
59
+ #endif
60
+
61
+ namespace rho {
62
+ namespace sync {
63
+ IMPLEMENT_LOGCLASS(CSyncNotify,"Sync");
64
+ using namespace rho::net;
65
+ using namespace rho::common;
66
+ using namespace rho::db;
67
+
68
+ common::CAutoPtr<CObjectNotification> CSyncNotify::m_pObjectNotify;
69
+ common::CMutex CSyncNotify::m_mxObjectNotify;
70
+
71
+ void CSyncNotify::addObjectNotify(int nSrcID, const String& strObject)
72
+ {
73
+ synchronized(m_mxObjectNotify)
74
+ {
75
+ Hashtable<String,int>* phashObject = m_hashSrcIDAndObject.get(nSrcID);
76
+ if ( phashObject == null )
77
+ {
78
+ phashObject = new Hashtable<String,int>();
79
+ m_hashSrcIDAndObject.put( nSrcID, phashObject );
80
+ }
81
+
82
+ Hashtable<String,int>& hashObject = *phashObject;
83
+ hashObject.put(strObject,enNone);
84
+ }
85
+ }
86
+
87
+ void CSyncNotify::addObjectNotify(const String& strSrcName, const String& strObject )
88
+ {
89
+ synchronized(m_mxObjectNotify)
90
+ {
91
+ m_strSingleObjectSrcName = strSrcName;
92
+ m_strSingleObjectID = strObject[0] == '{' ? strObject.substr(1,strObject.length()-2) : strObject ;
93
+ }
94
+ }
95
+
96
+ void CSyncNotify::cleanObjectNotifications()
97
+ {
98
+ synchronized(m_mxObjectNotify)
99
+ {
100
+ m_strSingleObjectSrcName = "";
101
+ m_strSingleObjectID = "";
102
+ m_hashSrcIDAndObject.clear();
103
+ }
104
+ }
105
+
106
+ void CSyncNotify::cleanCreateObjectErrors()
107
+ {
108
+ synchronized(m_mxObjectNotify)
109
+ {
110
+ m_hashCreateObjectErrors.clear();
111
+ }
112
+ }
113
+
114
+ void CSyncNotify::processSingleObject()
115
+ {
116
+ if ( m_strSingleObjectSrcName.length() == 0 )
117
+ return;
118
+
119
+ CSyncSource* pSrc = getSync().findSourceByName(m_strSingleObjectSrcName);
120
+ if ( pSrc )
121
+ {
122
+ int nSrcID = pSrc->getID();
123
+ addObjectNotify(nSrcID,m_strSingleObjectID);
124
+ }
125
+
126
+ m_strSingleObjectSrcName = "";
127
+ m_strSingleObjectID = "";
128
+ }
129
+
130
+ void CSyncNotify::fireObjectsNotification()
131
+ {
132
+ Hashtable<String, String> result;
133
+ Hashtable<String, Hashtable<String,String> > l2Result;
134
+ Hashtable<String, String> hashDeleted,hashUpdated,hashCreated;
135
+
136
+ {
137
+ synchronized(m_mxObjectNotify)
138
+
139
+ if ( !m_pObjectNotify)
140
+ return;
141
+
142
+ for (HashtablePtr<int, Hashtable<String,int>* >::iterator it = m_hashSrcIDAndObject.begin(); it != m_hashSrcIDAndObject.end(); ++it )
143
+ {
144
+ int nSrcID = it->first;
145
+ Hashtable<String,int>& hashObject = *(it->second);
146
+ for ( Hashtable<String,int>::iterator itObject = hashObject.begin(); itObject != hashObject.end(); ++itObject )
147
+ {
148
+ int nNotifyType = itObject->second;
149
+ if (nNotifyType == enNone)
150
+ continue;
151
+ //This is slow operation
152
+ /*
153
+ if ( nNotifyType == enDelete )
154
+ {
155
+ //TODO: get db for source
156
+ IDBResult res = getDB().executeSQL("SELECT object FROM object_values where object=? LIMIT 1 OFFSET 0", itObject->first );
157
+ if ( !res.isEnd() )
158
+ nNotifyType = enUpdate;
159
+ }
160
+ */
161
+ Hashtable<String,String>* pHash = 0;
162
+ switch(nNotifyType)
163
+ {
164
+ case enDelete:
165
+ pHash = &hashDeleted;
166
+ break;
167
+ case enUpdate:
168
+ pHash = &hashUpdated;
169
+ break;
170
+ case enCreate:
171
+ pHash = &hashCreated;
172
+ break;
173
+ }
174
+
175
+ if (pHash != 0) {
176
+ pHash->put( itObject->first, convertToStringA(nSrcID) );
177
+ }
178
+
179
+ hashObject.put(itObject->first, enNone);
180
+ }
181
+ }
182
+
183
+ if ( (hashDeleted.size() + hashCreated.size() + hashUpdated.size() ) == 0 )
184
+ return;
185
+ }
186
+
187
+ l2Result.put("created",hashCreated);
188
+ l2Result.put("updated",hashUpdated);
189
+ l2Result.put("deleted",hashDeleted);
190
+
191
+ callNotify( CSyncNotification(m_pObjectNotify->m_callbackData,false), result, &l2Result );
192
+ }
193
+
194
+ void CSyncNotify::onObjectChanged(int nSrcID, const String& strObject, int nType)
195
+ {
196
+ synchronized(m_mxObjectNotify)
197
+ {
198
+ processSingleObject();
199
+
200
+ Hashtable<String,int>* phashObject = m_hashSrcIDAndObject.get(nSrcID);
201
+ if ( phashObject == null )
202
+ return;
203
+
204
+ Hashtable<String,int>& hashObject = *phashObject;
205
+ if( hashObject.containsKey(strObject) )
206
+ hashObject.put(strObject,nType);
207
+ }
208
+ }
209
+
210
+ void CSyncNotify::addCreateObjectError(int nSrcID, const String& strObject, const String& strError)
211
+ {
212
+ synchronized(m_mxObjectNotify)
213
+ {
214
+ Hashtable<String,String>* phashErrors = m_hashCreateObjectErrors.get(nSrcID);
215
+ if ( phashErrors == null )
216
+ {
217
+ phashErrors = new Hashtable<String,String>();
218
+ m_hashCreateObjectErrors.put( nSrcID, phashErrors );
219
+ }
220
+
221
+ Hashtable<String,String>& hashErrors = *phashErrors;
222
+ hashErrors.put(strObject,strError);
223
+ }
224
+ }
225
+
226
+ void CSyncNotify::appendCreateObjectErrorInfo(int nSrcID, Hashtable< String, Hashtable<String, String> >& result )
227
+ {
228
+ String strBody = "";
229
+
230
+ synchronized(m_mxObjectNotify)
231
+ {
232
+ Hashtable<String,String>* phashErrors = m_hashCreateObjectErrors.get(nSrcID);
233
+
234
+
235
+ if ( phashErrors == null )
236
+ return ;
237
+
238
+ Hashtable<String,String>& hashErrors = *phashErrors;
239
+
240
+ result.put("create_error",hashErrors);
241
+
242
+ hashErrors.clear();
243
+ }
244
+ }
245
+
246
+ void CSyncNotify::setObjectNotification(CObjectNotification* pNotify)
247
+ {
248
+ synchronized(m_mxObjectNotify)
249
+ {
250
+ m_pObjectNotify = pNotify;
251
+ }
252
+ }
253
+
254
+ CObjectNotification* CSyncNotify::getObjectNotification()
255
+ {
256
+ synchronized(m_mxObjectNotify)
257
+ {
258
+ return m_pObjectNotify;
259
+ }
260
+ }
261
+
262
+ void CSyncNotify::onSyncSourceEnd( int nSrc, VectorPtr<CSyncSource*>& sources )
263
+ {
264
+ CSyncSource& src = *sources.elementAt(nSrc);
265
+
266
+ /* if ( getSync().getState() == CSyncEngine::esStop && src.m_nErrCode != RhoAppAdapter.ERR_NONE )
267
+ {
268
+ CSyncNotification* pSN = getSyncNotifyBySrc(&src);
269
+ if ( pSN != null )
270
+ fireSyncNotification(&src, true, src.m_nErrCode, "");
271
+ else
272
+ fireAllSyncNotifications(true, src.m_nErrCode, src.m_strError, "" );
273
+ }
274
+ else*/
275
+ fireSyncNotification(&src, true, src.m_nErrCode, "");
276
+
277
+ cleanCreateObjectErrors();
278
+ }
279
+
280
+ void CSyncNotify::setSyncNotification(int source_id, CSyncNotification* pNotify )
281
+ {
282
+ LOG(INFO) + "Set notification. Source ID: " + source_id + ";" + (pNotify ? pNotify->toString() : "");
283
+
284
+ if ( source_id == -1 )
285
+ {
286
+ synchronized(m_mxSyncNotifications)
287
+ {
288
+ m_pAllNotification = pNotify;
289
+ }
290
+ }else
291
+ {
292
+ synchronized(m_mxSyncNotifications)
293
+ {
294
+ m_mapSyncNotifications.put( source_id, pNotify );
295
+ }
296
+ }
297
+ }
298
+
299
+ CSyncNotification::CSyncNotification(const apiGenerator::CMethodResult& callbackData, boolean bRemoveAfterFire) :
300
+ m_callbackData(callbackData), m_cCallback(null), m_cCallbackData(null), m_bRemoveAfterFire(bRemoveAfterFire)
301
+ {
302
+ // if ( m_callbackData.strUrl.length() > 0 )
303
+ // m_callbackData.strUrl = RHODESAPPBASE().canonicalizeRhoUrl(m_callbackData.strUrl);
304
+ }
305
+
306
+ CSyncNotification::~CSyncNotification()
307
+ {
308
+ if ( m_cCallbackData )
309
+ rho_free_callbackdata(m_cCallbackData);
310
+ }
311
+
312
+ String CSyncNotification::toString()const
313
+ {
314
+ if ( m_cCallback )
315
+ return "C_Callback";
316
+
317
+ String strRes = "Url :";
318
+ // strRes += m_strUrl;
319
+ strRes += "; Params: ";
320
+ // strRes += m_strParams;
321
+ return strRes;
322
+ }
323
+
324
+ CObjectNotification::CObjectNotification(const apiGenerator::CMethodResult& callbackData) :
325
+ m_callbackData(callbackData), m_cCallback(null), m_cCallbackData(null)
326
+ {
327
+ }
328
+
329
+ CObjectNotification::~CObjectNotification()
330
+ {
331
+ if ( m_cCallbackData )
332
+ rho_free_callbackdata(m_cCallbackData);
333
+ }
334
+
335
+ String CObjectNotification::toString()const
336
+ {
337
+ if ( m_cCallback )
338
+ return "C_Callback";
339
+
340
+ String strRes = "Url :";
341
+ // strRes += m_callbackData.strUrl;
342
+ return strRes;
343
+ }
344
+
345
+ void CSyncNotify::setSearchNotification(CSyncNotification* pNotify )
346
+ {
347
+ LOG(INFO) + "Set search notification." + (pNotify ? pNotify->toString() : "");
348
+ synchronized(m_mxSyncNotifications)
349
+ {
350
+ m_pSearchNotification = pNotify;
351
+ }
352
+ }
353
+
354
+ void CSyncNotify::showStatusPopup(const String& status)
355
+ {
356
+ LOG(INFO) + "Status: "+status;
357
+
358
+ if ( m_strStatusHide.length() == 0 )
359
+ m_strStatusHide = RhoAppAdapter.getMessageText("hide");
360
+
361
+ if ( status.length() > 0 )
362
+ alert_show_status("", status.c_str(), m_strStatusHide.c_str());
363
+ }
364
+
365
+ void CSyncNotify::reportSyncStatus(String status, int error, String strDetails)
366
+ {
367
+ synchronized(m_mxSyncNotifications)
368
+ {
369
+ if (/*m_syncStatusListener != null && */(isReportingEnabled() || error == RhoAppAdapter.ERR_SYNCVERSION) ) {
370
+
371
+ if ( error == RhoAppAdapter.ERR_SYNCVERSION )
372
+ {
373
+ status = RhoAppAdapter.getErrorText(error);
374
+ showStatusPopup(status);
375
+ }
376
+ else if ( isReportingEnabled() )
377
+ {
378
+ if ( strDetails.length() == 0 && error != RhoAppAdapter.ERR_NONE)
379
+ strDetails = RhoAppAdapter.getErrorText(error);
380
+ status += (strDetails.length() > 0 ? RhoAppAdapter.getMessageText("details") + strDetails: "");
381
+
382
+ //m_syncStatusListener.reportStatus( status, error);
383
+ showStatusPopup(status);
384
+ }
385
+ }
386
+ }
387
+ }
388
+
389
+ void CSyncNotify::fireBulkSyncNotification( boolean bFinish, String status, String partition, int nErrCode )
390
+ {
391
+ if ( getSync().getState() == CSyncEngine::esExit )
392
+ return;
393
+
394
+ if( nErrCode != RhoAppAdapter.ERR_NONE)
395
+ {
396
+ String strMessage = RhoAppAdapter.getMessageText("sync_failed_for") + "bulk.";
397
+ reportSyncStatus(strMessage,nErrCode,"");
398
+ }
399
+
400
+ Hashtable<String,String> params;
401
+ params.put("partition",partition);
402
+ params.put("bulk_status",status);
403
+ params.put("sync_type","bulk");
404
+
405
+ doFireSyncNotification( null, bFinish, nErrCode, "", &params, 0 );
406
+ }
407
+
408
+
409
+ void CSyncNotify::fireAllSyncNotifications( boolean bFinish, int nErrCode, String strError/*, String strServerError*/ )
410
+ {
411
+ if ( getSync().getState() == CSyncEngine::esExit )
412
+ return;
413
+
414
+ synchronized(m_mxSyncNotifications)
415
+ {
416
+ CSyncNotification* pSN = getSyncNotifyBySrc(null);
417
+ if ( pSN != null )
418
+ doFireSyncNotification( null, bFinish, nErrCode, strError, 0, 0/*strServerError*/ );
419
+ }
420
+ }
421
+
422
+
423
+ void CSyncNotify::fireSyncNotification( CSyncSource* src, boolean bFinish, int nErrCode, String strMessage)
424
+ {
425
+ if ( getSync().getState() == CSyncEngine::esExit )
426
+ return;
427
+
428
+ if( strMessage.length() > 0 || nErrCode != RhoAppAdapter.ERR_NONE)
429
+ {
430
+ if ( !getSync().isSearch() )
431
+ {
432
+ if ( src != null && strMessage.length() == 0 )
433
+ strMessage = RhoAppAdapter.getMessageText("sync_failed_for") + (*src).getName() + ".";
434
+
435
+ reportSyncStatus(strMessage,nErrCode, (src != null ? (*src).m_strError : "") );
436
+ }
437
+ }
438
+
439
+ doFireSyncNotification(src, bFinish, nErrCode, "", 0, 0 );
440
+ }
441
+
442
+ CSyncNotification* CSyncNotify::getSyncNotifyBySrc(CSyncSource* src)
443
+ {
444
+ CSyncNotification* pSN = null;
445
+ if ( getSync().isSearch() )
446
+ pSN = m_pSearchNotification;
447
+ else
448
+ {
449
+ if ( src != null )
450
+ pSN = m_mapSyncNotifications.get( (*src).getID());
451
+
452
+ if ( pSN == null )
453
+ pSN = m_pAllNotification;
454
+ }
455
+
456
+ if ( pSN == null && !getSync().isNoThreadedMode() )
457
+ return null;
458
+
459
+ return pSN != null ? pSN : &m_emptyNotify;
460
+ }
461
+
462
+ void CSyncNotify::fireSyncNotification2( CSyncSource* src, boolean bFinish, int nErrCode, const Hashtable<String,String>& serverErrors)
463
+ {
464
+ doFireSyncNotification(src, bFinish, nErrCode, "", 0, &serverErrors);
465
+ }
466
+
467
+ void CSyncNotify::doFireSyncNotification( CSyncSource* src, boolean bFinish, int nErrCode, String strError, const Hashtable<String,String>* params, const Hashtable<String,String>* pServerErrors)
468
+ {
469
+ if ( getSync().isStoppedByUser() )
470
+ return;
471
+
472
+ CSyncNotification* pSN;
473
+
474
+ Hashtable<String, String> result;
475
+ Hashtable<String, Hashtable<String,String> > errorsL2;
476
+
477
+ boolean bRemoveAfterFire = bFinish;
478
+ {
479
+ synchronized(m_mxSyncNotifications)
480
+ {
481
+ pSN = getSyncNotifyBySrc(src);
482
+ if ( pSN == null )
483
+ return;
484
+
485
+ if ( params != 0 ) {
486
+ result = *params;
487
+ }else {
488
+ result.put("sync_type","incremental");
489
+ }
490
+
491
+ if ( src != null )
492
+ {
493
+ result.put("total_count", convertToStringA( (*src).getTotalCount()));
494
+ result.put("processed_count", convertToStringA( (*src).getTotalCount()));
495
+ result.put("cumulative_count", convertToStringA( (*src).getCurPageCount()));
496
+ result.put("source_id", convertToStringA( (*src).getID()));
497
+ result.put("source_name", (*src).getName());
498
+ }
499
+
500
+ String status;
501
+ if ( bFinish )
502
+ {
503
+ if ( nErrCode == RhoAppAdapter.ERR_NONE )
504
+ {
505
+ if ( getSync().isSchemaChanged() )
506
+ status = "schema_changed";
507
+ else
508
+ status = (src == null && ( (params==0) || params->size()==0 ) ) ? "complete" : "ok";
509
+ }
510
+ else
511
+ {
512
+ if ( getSync().isStoppedByUser() )
513
+ nErrCode = RhoAppAdapter.ERR_CANCELBYUSER;
514
+
515
+ status = "error";
516
+
517
+ result.put("error_code", convertToStringA(nErrCode) );
518
+
519
+ String error;
520
+ if ( strError.length() > 0 ) {
521
+ error = strError;
522
+ } else if ( src != null ) {
523
+ error = (*src).m_strError;
524
+ }
525
+
526
+ result.put("error_message",error);
527
+
528
+ if ( pServerErrors != 0 ) {
529
+ errorsL2.put("server_errors",*pServerErrors);
530
+ }
531
+ }
532
+
533
+ if ( src != null ) {
534
+ appendCreateObjectErrorInfo( (*src).getID(), errorsL2 );
535
+ }
536
+ } else {
537
+ status = "in_progress";
538
+ }
539
+
540
+ result.put("status",status);
541
+
542
+ bRemoveAfterFire = bRemoveAfterFire && pSN->m_bRemoveAfterFire;
543
+ }
544
+ }
545
+ LOG(INFO) + "Fire notification. Source : " + (src != null ? (*src).getName():"") + "; " + pSN->toString();
546
+
547
+ if ( callNotify(*pSN, result, &errorsL2 ) || bRemoveAfterFire)
548
+ clearNotification(src);
549
+ }
550
+
551
+ const String& CSyncNotify::getNotifyBody()
552
+ {
553
+ const static String emptyBody = String();
554
+ if ( m_arNotifyBody.size() == 0 )
555
+ return emptyBody;
556
+
557
+ if ( isFakeServerResponse() )
558
+ return m_arNotifyBody[0];
559
+
560
+ return m_arNotifyBody[m_arNotifyBody.size()-1];
561
+ }
562
+
563
+
564
+ String CSyncNotify::notifyParamToStr( const Hashtable<String,String>& result, const Hashtable< String, Hashtable< String, String > >* l2Hashes) {
565
+
566
+ String ret = "";
567
+
568
+ struct JSONCreator {
569
+ static String& addCommaIfNeeded( String& result ) {
570
+ result = String_trimRight(result);
571
+ if ( (result.length()>0) && !(String_endsWith(result,"[" ) || String_endsWith(result,"{") ) ) { //|| String_endsWith(result,",")
572
+ result += ",";
573
+ }
574
+ return result;
575
+ }
576
+
577
+ static String& addNode( const String& key, const String& value, bool jsonValue, String& result ) {
578
+ addCommaIfNeeded(result);
579
+ //String quote = jsonValue?"":"\"";
580
+ result += "\"" + key + "\":" + (jsonValue?value: rho::json::CJSONEntry::quoteValue(value));
581
+ return result;
582
+ }
583
+
584
+ static String& addNode( const Hashtable<String,String>& objects, const Hashtable< String, Hashtable< String, String > >* l2Hashes, String& result, bool skipComma = false ) {
585
+ if ( !skipComma ) {
586
+ addCommaIfNeeded(result);
587
+ }
588
+
589
+ //TODO : fix object notify with empty hash
590
+ if ( (objects.size()==0) && ((l2Hashes==0) || (l2Hashes->size()==0)) ) {
591
+ return result;
592
+ }
593
+
594
+ result += "{";
595
+
596
+ for ( Hashtable<String,String>::const_iterator it = objects.begin(); it != objects.end(); ++it ) {
597
+ String key = it->first;
598
+ bool jsonValue = false;
599
+ if ( String_endsWith(it->first,"-json")) {
600
+ jsonValue = true;
601
+ key = key.substr( 0, key.length() - 5 );
602
+ }
603
+ addNode( key, it->second, jsonValue, result );
604
+ }
605
+
606
+ if ( l2Hashes !=0 ) {
607
+ if ( l2Hashes->size() > 0 ) {
608
+ addCommaIfNeeded(result);
609
+ }
610
+
611
+ for ( Hashtable< String, Hashtable< String, String > >::const_iterator it = l2Hashes->begin(); it != l2Hashes->end(); ++it ) {
612
+ //addCommaIfNeeded(result);
613
+ result += "\"" + it->first + "\":";
614
+ addNode( it->second, 0, result, true );
615
+ }
616
+ }
617
+
618
+ result += "}";
619
+
620
+ return result;
621
+ }
622
+
623
+ };
624
+
625
+ JSONCreator::addNode( result, l2Hashes, ret );
626
+
627
+ return ret;
628
+ }
629
+
630
+
631
+ boolean CSyncNotify::callNotify(const CSyncNotification& oNotify, const Hashtable<String, String>& result, const Hashtable<String,Hashtable<String,String> >* l2Hashes )
632
+ {
633
+ apiGenerator::CMethodResult cb = oNotify.m_callbackData;
634
+
635
+ String strBody = notifyParamToStr( result, l2Hashes );
636
+
637
+ if ( getSync().isNoThreadedMode() )
638
+ {
639
+ m_arNotifyBody.addElement( strBody );
640
+ return false;
641
+ }
642
+
643
+ if ( oNotify.m_cCallback )
644
+ {
645
+ m_isInsideCallback = true;
646
+ int nRet = (*oNotify.m_cCallback)(strBody.c_str(), oNotify.m_cCallbackData);
647
+ m_isInsideCallback = false;
648
+ return nRet == 1;
649
+ }
650
+
651
+ m_isInsideCallback = true;
652
+
653
+ cb.setJSON(strBody);
654
+
655
+
656
+ m_isInsideCallback = false;
657
+
658
+ return true;
659
+ }
660
+
661
+ void CSyncNotify::clearNotification(CSyncSource* src)
662
+ {
663
+ LOG(INFO) + "Clear notification. Source : " + (src != null ? (*src).getName() : "");
664
+
665
+ synchronized(m_mxSyncNotifications)
666
+ {
667
+ if ( getSync().isSearch() )
668
+ m_pSearchNotification = null;
669
+ else if ( src != null )
670
+ m_mapSyncNotifications.remove( (*src).getID());
671
+ }
672
+ }
673
+
674
+ void CSyncNotify::clearSyncNotification(int source_id)
675
+ {
676
+ LOG(INFO) + "Clear notification. Source ID: " + source_id;
677
+
678
+ synchronized(m_mxSyncNotifications)
679
+ {
680
+ if ( source_id == -1 )//Clear all
681
+ m_pAllNotification = null;
682
+ else
683
+ m_mapSyncNotifications.remove(source_id);
684
+ }
685
+ }
686
+
687
+ void CSyncNotify::cleanLastSyncObjectCount()
688
+ {
689
+ synchronized(m_mxSyncNotifications)
690
+ {
691
+ m_hashSrcObjectCount.clear();
692
+ }
693
+ }
694
+
695
+ int CSyncNotify::incLastSyncObjectCount(int nSrcID)
696
+ {
697
+ int nCount = 0;
698
+ synchronized(m_mxSyncNotifications)
699
+ {
700
+ nCount = m_hashSrcObjectCount.get(nSrcID)+1;
701
+ m_hashSrcObjectCount.put(nSrcID,nCount);
702
+ }
703
+
704
+ return nCount;
705
+ }
706
+
707
+ int CSyncNotify::getLastSyncObjectCount(int nSrcID)
708
+ {
709
+ int nCount = 0;
710
+ synchronized(m_mxSyncNotifications)
711
+ {
712
+ nCount = m_hashSrcObjectCount.get(nSrcID);
713
+ }
714
+
715
+ return nCount;
716
+ }
717
+
718
+ void CSyncNotify::callLoginCallback(const CSyncNotification& oNotify, int nErrCode, String strMessage)
719
+ {
720
+ if ( getSync().isStoppedByUser() )
721
+ return;
722
+
723
+ Hashtable<String, String> result;
724
+ String strErrorCode = convertToStringA(nErrCode);
725
+ String strEncodedMessage = strMessage;//URI::urlEncode(strMessage);
726
+
727
+ result.put("error_code", strErrorCode);
728
+ result.put("error_message", strEncodedMessage);
729
+
730
+ LOG(INFO) + "Login callback: " + oNotify.toString() + ". Error code: "+ strErrorCode + ". Message: " + strEncodedMessage;
731
+
732
+ callNotify(oNotify,result);
733
+ }
734
+
735
+ }
736
+ }
737
+