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,212 @@
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 "db/DBResult.h"
53
+ #include "logging/RhoLog.h"
54
+
55
+ namespace rho {
56
+
57
+ namespace db {
58
+ class CDBAdapter;
59
+ }
60
+ namespace net {
61
+ struct CMultipartItem;
62
+ class CNetRequestWrapper;
63
+ }
64
+ namespace json {
65
+ class CJSONEntry;
66
+ class CJSONArrayIterator;
67
+ class CJSONStructIterator;
68
+ }
69
+
70
+ namespace sync {
71
+ struct ISyncProtocol;
72
+
73
+ class CAttrValue
74
+ {
75
+ public:
76
+ String m_strAttrib;
77
+ String m_strValue;
78
+ String m_strBlobSuffix;
79
+
80
+ CAttrValue(const String& strAttrib, const String& strValue);
81
+ };
82
+
83
+ class CSyncEngine;
84
+ class CSyncNotify;
85
+ class CSyncSource
86
+ {
87
+ DEFINE_LOGCLASS;
88
+
89
+ CSyncEngine& m_syncEngine;
90
+ db::CDBAdapter& m_dbAdapter;
91
+
92
+ int m_nID;
93
+ String m_strName;
94
+ uint64 m_token;
95
+ String m_strSyncType;
96
+ boolean m_bTokenFromDB;
97
+
98
+ int m_nCurPageCount, m_nInserted, m_nDeleted, m_nTotalCount;
99
+ int m_nRefreshTime;
100
+ int m_nProgressStep;
101
+ boolean m_bSchemaSource;
102
+ public:
103
+ struct CAssociation
104
+ {
105
+ String m_strSrcName, m_strAttrib;
106
+ CAssociation( String strSrcName, String strAttrib ){m_strSrcName = strSrcName; m_strAttrib = strAttrib; }
107
+ };
108
+ private:
109
+ Vector<CAssociation> m_arAssociations;
110
+ VectorPtr<net::CMultipartItem*> m_arMultipartItems;
111
+ Vector<String> m_arBlobAttrs;
112
+ Hashtable<String,int> m_hashIgnorePushObjects;
113
+ Hashtable<String,int> m_hashBelongsTo;
114
+
115
+ public:
116
+ int m_nErrCode;
117
+ String m_strError;
118
+ String m_strQueryParams;
119
+
120
+ public:
121
+ CSyncSource(int id, const String& strName, const String& strSyncType, db::CDBAdapter& db, CSyncEngine& syncEngine );
122
+ virtual void sync();
123
+ virtual void syncClientChanges();
124
+
125
+ int getID()const { return m_nID; }
126
+ String getName() { return m_strName; }
127
+ String getSyncType(){ return m_strSyncType; }
128
+ int getErrorCode(){ return m_nErrCode; }
129
+
130
+ int getServerObjectsCount()const{ return m_nInserted+m_nDeleted; }
131
+
132
+ uint64 getToken()const{ return m_token; }
133
+ boolean isTokenFromDB(){ return m_bTokenFromDB; }
134
+ void setToken(uint64 token){ m_token = token; m_bTokenFromDB = false; }
135
+ virtual boolean isEmptyToken()
136
+ {
137
+ return m_token == 0;
138
+ }
139
+
140
+ int getProgressStep(){ return m_nProgressStep; }
141
+ void setProgressStep(int nProgressStep){ m_nProgressStep = nProgressStep; }
142
+
143
+ int getRefreshTime(){ return m_nRefreshTime; }
144
+
145
+ Vector<CAssociation>& getAssociations(){ return m_arAssociations; }
146
+ //private:
147
+ //CSyncSource();
148
+ CSyncSource(CSyncEngine& syncEngine, db::CDBAdapter& db );
149
+
150
+ void doSyncClientChanges();
151
+ void checkIgnorePushObjects();
152
+ int getBelongsToSrcID(const String& strAttrib);
153
+ void addBelongsTo(const String& strAttrib, int nSrcID);
154
+
155
+ //boolean isPendingClientChanges();
156
+
157
+ void syncServerChanges();
158
+ void makePushBody_Ver3(String& strBody, const String& strUpdateType, boolean isSync);
159
+
160
+ void processToken(uint64 token);
161
+
162
+ int getInsertedCount()const { return m_nInserted; }
163
+ int getDeletedCount()const { return m_nDeleted; }
164
+ void setCurPageCount(int nCurPageCount){m_nCurPageCount = nCurPageCount;}
165
+ void setTotalCount(int nTotalCount){m_nTotalCount = nTotalCount;}
166
+ int getCurPageCount(){return m_nCurPageCount;}
167
+ int getTotalCount(){return m_nTotalCount;}
168
+
169
+ void processServerResponse_ver3(json::CJSONArrayIterator& oJsonArr, bool isRecoveryMode = false);
170
+ void processServerCmd_Ver3(const String& strCmd, const String& strObject, const String& strAttrib, const String& strValue, boolean bCheckUIRequest);//throws Exception
171
+
172
+ String makeFileName(const CAttrValue& value);//throws Exception
173
+ boolean downloadBlob(CAttrValue& value);//throws Exception
174
+ boolean processBlob( const String& strCmd, const String& strObject, CAttrValue& oAttrValue );
175
+ boolean processAllBlobs();
176
+ boolean processServerBlobAttrs();
177
+
178
+ void setRefreshTime( int nRefreshTime ){ m_nRefreshTime = nRefreshTime;}
179
+
180
+ db::CDBAdapter& getDB(){ return m_dbAdapter; }
181
+
182
+ void processSyncCommand(const String& strCmd, json::CJSONEntry oCmdEntry, boolean bCheckUIRequest );
183
+
184
+ void processServerCmd_Ver3_Schema(const String& strCmd, const String& strObject, json::CJSONStructIterator& attrIter, boolean bCheckUIRequest);//throws Exception
185
+
186
+ void parseAssociations(const String& strAssociations);
187
+ void processAssociations(const String& strOldObject, const String& strNewObject);
188
+ void updateAssociation(const String& strOldObject, const String& strNewObject, const String& strAttrib);
189
+
190
+ void applyChangedValues();
191
+ void processServerErrors(json::CJSONEntry& oCmds);
192
+
193
+ void checkProgressStepNotify(boolean bEndTransaction);
194
+ boolean checkFreezedProps(String strProp);
195
+
196
+ bool haveChangedValues();
197
+
198
+ private:
199
+ CSyncEngine& getSync(){ return m_syncEngine; }
200
+ CSyncNotify& getNotify();
201
+ net::CNetRequestWrapper getNet();
202
+ ISyncProtocol& getProtocol();
203
+
204
+ // process oCmdEntry that should point to "insert" section and create temprorary table for inserted elements
205
+ int propertyBagInsertAndUpdate(const String& tableName, const String& to, json::CJSONEntry oCmdEntry, boolean bCheckUIRequest, rho::Hashtable<String, bool>& changedObjects);
206
+
207
+ // create hashtable with freezed properties
208
+ void makeFreezedPropsHash(rho::Hashtable<String, bool>& hash);
209
+ };
210
+
211
+ }
212
+ }
@@ -0,0 +1,583 @@
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 "SyncThread.h"
50
+ #include "common/RhoTime.h"
51
+ #include "common/RhoSettingsDefs.h"
52
+ #include "common/RhoConf.h"
53
+ #include "common/RhoFilePath.h"
54
+
55
+ #ifndef RHO_NO_RUBY
56
+ #include "ruby/ext/rho/rhoruby.h"
57
+ #endif //RHO_NO_RUBY
58
+ #include "sync/ClientRegister.h"
59
+ #include "common/RhoAppAdapter.h"
60
+
61
+ #undef DEFAULT_LOGCATEGORY
62
+ #define DEFAULT_LOGCATEGORY "SyncThread"
63
+
64
+ namespace rho {
65
+ namespace sync {
66
+
67
+ using namespace rho::common;
68
+ using namespace rho::db;
69
+
70
+ IMPLEMENT_LOGCLASS(CSyncThread,"Sync");
71
+ CSyncThread* CSyncThread::m_pInstance = 0;
72
+
73
+ /*static*/ CSyncThread* CSyncThread::Create()
74
+ {
75
+ if ( m_pInstance )
76
+ return m_pInstance;
77
+
78
+ m_pInstance = new CSyncThread();
79
+ return m_pInstance;
80
+ }
81
+
82
+ /*static*/void CSyncThread::Destroy()
83
+ {
84
+ if ( m_pInstance )
85
+ delete m_pInstance;
86
+
87
+ m_pInstance = 0;
88
+ }
89
+
90
+ CSyncThread::CSyncThread() : CThreadQueue()
91
+ {
92
+ CThreadQueue::setLogCategory(getLogCategory());
93
+
94
+ int pollInterval = 60;
95
+
96
+ if( RHOCONF().isExist("sync_poll_interval") ) {
97
+ pollInterval = RHOCONF().getInt("sync_poll_interval");
98
+ }
99
+
100
+ setPollInterval(pollInterval);
101
+
102
+ LOG(INFO) + "sync_poll_interval: " + pollInterval;
103
+ LOG(INFO) + "syncserver: " + RHOCONF().getString("syncserver");
104
+ LOG(INFO) + "bulksync_state: " + RHOCONF().getInt("bulksync_state");
105
+ #ifdef OS_WINCE
106
+ start(epCritical);
107
+ #else
108
+ start(epLow);
109
+ #endif
110
+ }
111
+
112
+ CSyncThread::~CSyncThread(void)
113
+ {
114
+ m_oSyncEngine.exitSync();
115
+ LOG(INFO) + "Stopping Sync thread";
116
+ stop(SYNC_WAIT_BEFOREKILL_SECONDS);
117
+ }
118
+
119
+ /*
120
+ #ifndef RHO_NO_RUBY
121
+ unsigned long CSyncThread::getRetValue()
122
+ {
123
+ unsigned long ret = rho_ruby_get_NIL();
124
+ if ( isNoThreadedMode() )
125
+ {
126
+ ret = rho_ruby_create_string( getSyncEngine().getNotify().getNotifyBody().c_str() );
127
+ getSyncEngine().getNotify().cleanNotifyBody();
128
+ }
129
+
130
+ return ret;
131
+ }
132
+ #else
133
+ */
134
+ unsigned long CSyncThread::getRetValue()
135
+ {
136
+ unsigned long ret = 0;
137
+ if ( isNoThreadedMode() )
138
+ {
139
+ ret = (unsigned long)rho_sync_create_string( getSyncEngine().getNotify().getNotifyBody().c_str() );
140
+ getSyncEngine().getNotify().cleanNotifyBody();
141
+ }
142
+
143
+ return ret;
144
+ }
145
+ //#endif
146
+
147
+ int CSyncThread::getLastPollInterval()
148
+ {
149
+ uint64 nowTime = CLocalTime().toULong();
150
+ uint64 latestTimeUpdated = 0;
151
+
152
+ Vector<String> arPartNames = db::CDBAdapter::getDBAllPartitionNames();
153
+ for( int i = 0; i < (int)arPartNames.size(); i++ )
154
+ {
155
+ db::CDBAdapter& dbPart = db::CDBAdapter::getDB(arPartNames.elementAt(i).c_str());
156
+
157
+ IDBResult res = dbPart.executeSQL("SELECT last_updated from sources");
158
+ for ( ; !res.isEnd(); res.next() )
159
+ {
160
+ uint64 timeUpdated = res.getUInt64ByIdx(0);
161
+ if ( latestTimeUpdated < timeUpdated )
162
+ latestTimeUpdated = timeUpdated;
163
+ }
164
+ }
165
+
166
+ return latestTimeUpdated > 0 ? (int)(nowTime-latestTimeUpdated) : 0;
167
+ }
168
+
169
+ void CSyncThread::onTimeout()//throws Exception
170
+ {
171
+ if ( isNoCommands() && getPollInterval()>0 )
172
+ addQueueCommandInt(new CSyncCommand(scSyncAll,false,"",false));
173
+ }
174
+
175
+ void CSyncThread::checkShowStatus(CSyncCommand& oSyncCmd)
176
+ {
177
+ boolean bShowStatus = oSyncCmd.m_bShowStatus;
178
+ m_oSyncEngine.getNotify().enableReporting(bShowStatus);
179
+ if (m_oSyncEngine.getNotify().isReportingEnabled())
180
+ m_oSyncEngine.getNotify().showStatusPopup(RhoAppAdapter.getMessageText("syncronizing_data"));
181
+ //m_statusListener.createStatusPopup(RhoRuby.getMessageText("syncronizing_data"));
182
+ }
183
+
184
+ void CSyncThread::processCommand(IQueueCommand* pCmd)
185
+ {
186
+ CSyncCommand& oSyncCmd = *((CSyncCommand*)pCmd);
187
+ switch(oSyncCmd.m_nCmdCode)
188
+ {
189
+ case scSyncAll:
190
+ checkShowStatus(oSyncCmd);
191
+ m_oSyncEngine.doSyncAllSources(oSyncCmd.m_strQueryParams,oSyncCmd.m_bSyncOnlyChangedSources);
192
+ break;
193
+ case scSyncOne:
194
+ {
195
+ checkShowStatus(oSyncCmd);
196
+ m_oSyncEngine.doSyncSource(CSyncEngine::CSourceID(oSyncCmd.m_nCmdParam,oSyncCmd.m_strCmdParam), oSyncCmd.m_strQueryParams );
197
+ }
198
+ break;
199
+ case scSearchOne:
200
+ {
201
+ checkShowStatus(oSyncCmd);
202
+ m_oSyncEngine.doSearch( ((CSyncSearchCommand&)oSyncCmd).m_arSources, oSyncCmd.m_strCmdParam, ((CSyncSearchCommand&)oSyncCmd).m_strFrom,
203
+ ((CSyncSearchCommand&)oSyncCmd).m_bSyncChanges,
204
+ oSyncCmd.m_nCmdParam);
205
+ }
206
+ break;
207
+ case scLogin:
208
+ {
209
+ CSyncLoginCommand& oLoginCmd = (CSyncLoginCommand&)oSyncCmd;
210
+
211
+ checkShowStatus(oSyncCmd);
212
+ m_oSyncEngine.login(oLoginCmd.m_strName, oLoginCmd.m_strPassword, *oLoginCmd.m_pNotify );
213
+ }
214
+ break;
215
+ }
216
+ }
217
+
218
+ void CSyncThread::setPollInterval(int nInterval)
219
+ {
220
+ // if ( nInterval == 0 )
221
+ // m_oSyncEngine.stopSync();
222
+
223
+ CThreadQueue::setPollInterval(nInterval);
224
+ }
225
+
226
+ void CSyncThread::stopAll() {
227
+ LOG(INFO)+"STOP sync";
228
+
229
+ if (CSyncThread::getSyncEngine().isSyncing() )
230
+ {
231
+ LOG(INFO)+"STOP sync in progress.";
232
+
233
+ {
234
+ synchronized(getCommandLock());
235
+
236
+ getCommands().clear();
237
+ }
238
+
239
+ CSyncThread::getSyncEngine().stopSyncByUser();
240
+
241
+ //don't wait if calling from notify callback
242
+ if ( CSyncThread::getSyncEngine().getNotify().isInsideCallback() )
243
+ {
244
+ LOG(INFO)+"STOP sync called inside notify.";
245
+ return;
246
+ }
247
+
248
+ CSyncThread::getInstance()->stopWait();
249
+
250
+ while (!CSyncThread::getInstance()->isWaiting()) {
251
+ CSyncThread::getInstance()->sleep(100);
252
+ }
253
+
254
+ while( CDBAdapter::isAnyInsideTransaction() )
255
+ CSyncThread::getInstance()->sleep(100);
256
+ }
257
+ }
258
+
259
+
260
+ String CSyncThread::CSyncCommand::toString()
261
+ {
262
+ switch(m_nCmdCode)
263
+ {
264
+ case scNone:
265
+ return "CheckPollInterval";
266
+
267
+ case scSyncAll:
268
+ return "SyncAll";
269
+ case scSyncOne:
270
+ return "SyncOne";
271
+ case scLogin:
272
+ return "Login";
273
+ case scSearchOne:
274
+ return "Search";
275
+ }
276
+
277
+ return "Unknown; Code : " + convertToStringA(m_nCmdCode);
278
+ }
279
+
280
+ };
281
+ };
282
+
283
+ extern "C" {
284
+
285
+ using namespace rho::sync;
286
+ using namespace rho::db;
287
+
288
+ unsigned long rho_sync_doSyncAllSources(int show_status_popup, const char * query_params/* = 0*/, int sync_only_changed_sources)
289
+ {
290
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncCommand(CSyncThread::scSyncAll,show_status_popup!=0,query_params,sync_only_changed_sources!=0));
291
+
292
+ return CSyncThread::getInstance()->getRetValue();
293
+ }
294
+
295
+ unsigned long rho_sync_doSyncSourceByID(int nSrcID)
296
+ {
297
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncCommand(CSyncThread::scSyncOne, "", nSrcID, false, "" ) );
298
+ return CSyncThread::getInstance()->getRetValue();
299
+ }
300
+
301
+ unsigned long rho_sync_doSyncSourceByName(const char* szSrcName)
302
+ {
303
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncCommand(CSyncThread::scSyncOne, szSrcName, 0, false, "" ) );
304
+ return CSyncThread::getInstance()->getRetValue();
305
+ }
306
+
307
+ #ifndef RHO_NO_RUBY
308
+ unsigned long rho_sync_doSyncSource(unsigned long nSrcID,int show_status_popup, const char * query_params/* = 0*/)
309
+ {
310
+ CRhoRubyStringOrInt oSrcID = rho_ruby_getstringorint(nSrcID);
311
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncCommand(CSyncThread::scSyncOne, oSrcID.m_szStr, (int)oSrcID.m_nInt, show_status_popup!=0, query_params, false ) );
312
+
313
+ return CSyncThread::getInstance()->getRetValue();
314
+ }
315
+ #endif //RHO_NO_RUBY
316
+
317
+ void rho_sync_set_bulksyncstate(const int new_state)
318
+ {
319
+ RHOCONF().setInt(RHO_SETTING_BULKSYNC_STATE, new_state, true);
320
+ }
321
+
322
+ int rho_sync_get_bulksyncstate()
323
+ {
324
+ if(!RHOCONF().isExist(RHO_SETTING_BULKSYNC_STATE))
325
+ return -1;
326
+ return RHOCONF().getInt(RHO_SETTING_BULKSYNC_STATE);
327
+ }
328
+
329
+ bool rho_sync_has_bulksyncstate()
330
+ {
331
+ return RHOCONF().isExist(RHO_SETTING_BULKSYNC_STATE);
332
+ }
333
+
334
+ void rho_sync_stop()
335
+ {
336
+ CSyncThread::getInstance()->stopAll();
337
+ }
338
+
339
+ int rho_sync_issyncing()
340
+ {
341
+ return CSyncThread::getSyncEngine().isSyncing() ? 1 : 0;
342
+ }
343
+
344
+ #ifndef RHO_NO_RUBY
345
+ unsigned long rho_sync_is_syncing()
346
+ {
347
+ return rho_ruby_create_boolean(rho_sync_issyncing());
348
+ }
349
+ #endif //RHO_NO_RUBY
350
+
351
+ void
352
+ source_iter(const char* szName, int nameLen, void* parSources)
353
+ {
354
+ rho::Vector<rho::String>& arSources = *((rho::Vector<rho::String>*)(parSources));
355
+ arSources.addElement(szName);
356
+ }
357
+ }
358
+
359
+ #ifndef RHO_NO_RUBY
360
+ unsigned long rho_sync_doSearch(unsigned long ar_sources, const char *from, const char *params, bool sync_changes, int nProgressStep,
361
+ /*const char* callback, const char* callback_params*/const rho::apiGenerator::CMethodResult& oResult)
362
+ {
363
+ rho_sync_stop();
364
+ // if ( callback && *callback )
365
+ CSyncThread::getSyncEngine().getNotify().setSearchNotification( new CSyncNotification( oResult, true) );
366
+
367
+ rho::Vector<rho::String> arSources;
368
+ rho_ruby_enum_strary(ar_sources, source_iter, &arSources);
369
+
370
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncSearchCommand(from,params,arSources,sync_changes,nProgressStep) );
371
+
372
+ return CSyncThread::getInstance()->getRetValue();
373
+ }
374
+ #endif //RHO_NO_RUBY
375
+
376
+ extern "C"
377
+ {
378
+ unsigned long rho_sync_doSearchByNames(unsigned long ar_sources, const char *from, const char *params, bool sync_changes, int nProgressStep,
379
+ /*RHOC_CALLBACK*/void* callback, void* callback_data)
380
+ {
381
+ rho_sync_stop();
382
+ if ( callback )
383
+ CSyncThread::getSyncEngine().getNotify().setSearchNotification( new CSyncNotification( (RHOC_CALLBACK)callback, callback_data, true ) );
384
+
385
+ rho::Vector<rho::String>& arSources = *((rho::Vector<rho::String>*)ar_sources);
386
+
387
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncSearchCommand(from,params,arSources,sync_changes,nProgressStep) );
388
+
389
+ return CSyncThread::getInstance()->getRetValue();
390
+ }
391
+
392
+ int rho_sync_set_pollinterval(int nInterval)
393
+ {
394
+ int nOldInterval = CSyncThread::getInstance()->getPollInterval();
395
+ CSyncThread::getInstance()->setPollInterval(nInterval);
396
+
397
+ return nOldInterval;
398
+ }
399
+
400
+ int rho_sync_get_pollinterval()
401
+ {
402
+ return CSyncThread::getInstance()->getPollInterval();
403
+ }
404
+
405
+ void rho_sync_set_syncserver(const char* syncserver)
406
+ {
407
+ rho_sync_stop();
408
+
409
+ CSyncThread::getSyncEngine().setSyncServer(syncserver);
410
+
411
+ if ( syncserver && *syncserver )
412
+ {
413
+ CSyncThread::getInstance()->start(CSyncThread::epLow);
414
+ //CClientRegister::Create();
415
+ }
416
+ else
417
+ {
418
+ CSyncThread::getInstance()->stop(CSyncThread::SYNC_WAIT_BEFOREKILL_SECONDS);
419
+ CClientRegister::Stop();
420
+ }
421
+ }
422
+ }
423
+
424
+ unsigned long rho_sync_login(const char *name, const char *password, const rho::apiGenerator::CMethodResult& oResult)
425
+ {
426
+ rho_sync_stop();
427
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncLoginCommand(name, password,
428
+ new CSyncNotification(oResult, false) ) );
429
+
430
+ return CSyncThread::getInstance()->getRetValue();
431
+ }
432
+
433
+ extern "C"
434
+ {
435
+ unsigned long rho_sync_login_c(const char *name, const char *password, /*RHOC_CALLBACK*/void* callback, void* callback_data)
436
+ {
437
+ rho_sync_stop();
438
+ CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncLoginCommand(name, password,
439
+ new CSyncNotification((RHOC_CALLBACK)callback,callback_data,false)) );
440
+
441
+ return CSyncThread::getInstance()->getRetValue();
442
+ }
443
+
444
+ int rho_sync_logged_in()
445
+ {
446
+ //CDBAdapter& db = CDBAdapter::getUserDB();
447
+ return CSyncThread::getSyncEngine().isLoggedIn() ? 1 : 0;
448
+ }
449
+
450
+ void rho_sync_logout()
451
+ {
452
+ LOG(INFO) + "Logout";
453
+
454
+ rho_sync_stop();
455
+
456
+ //CDBAdapter& db = CDBAdapter::getUserDB();
457
+ LOG(INFO) + "stopSyncByUser";
458
+ CSyncThread::getSyncEngine().logout_int();
459
+ }
460
+ }
461
+
462
+ void rho_sync_set_notification(int source_id, const rho::apiGenerator::CMethodResult& oResult)
463
+ {
464
+ CSyncThread::getSyncEngine().getNotify().setSyncNotification(source_id, new CSyncNotification(oResult, source_id != -1) );
465
+ }
466
+
467
+ extern "C"
468
+ {
469
+ void rho_sync_set_notification_c(int source_id, /*RHOC_CALLBACK*/void* callback, void* callback_data)
470
+ {
471
+ CSyncThread::getSyncEngine().getNotify().setSyncNotification(source_id, new CSyncNotification((RHOC_CALLBACK)callback, callback_data, source_id != -1) );
472
+ }
473
+
474
+ void rho_sync_clear_notification(int source_id)
475
+ {
476
+ CSyncThread::getSyncEngine().getNotify().clearSyncNotification(source_id);
477
+ }
478
+
479
+ #ifndef RHO_NO_RUBY
480
+ unsigned long rho_sync_get_attrs(const char* szPartition, int nSrcID)
481
+ {
482
+ return 0;//(VALUE)CDBAdapter::getDB(szPartition).getAttrMgr().getAttrsBySrc(nSrcID);
483
+ }
484
+
485
+ #endif //RHO_NO_RUBY
486
+
487
+ void rho_sync_setobjectnotify_url(const char* szUrl)
488
+ {
489
+ // commented out because it will cause a crash: constructor parameter should be a MethodResult, not char*
490
+ //CSyncNotify::setObjectNotification(new CObjectNotification(szUrl));
491
+ }
492
+
493
+ void rho_sync_setobjectnotify_url_c(/*RHOC_CALLBACK*/void* callback, void* callback_data)
494
+ {
495
+ CSyncNotify::setObjectNotification( new CObjectNotification((RHOC_CALLBACK)callback, callback_data));
496
+ }
497
+
498
+ void rho_sync_clear_object_notification()
499
+ {
500
+ CSyncNotify::setObjectNotification(0);
501
+ }
502
+
503
+ void rho_sync_addobjectnotify(int nSrcID, const char* szObject)
504
+ {
505
+ CSyncThread::getSyncEngine().getNotify().addObjectNotify(nSrcID, szObject);
506
+ }
507
+
508
+ void rho_sync_addobjectnotify_bysrcname(const char* szSrcName, const char* szObject)
509
+ {
510
+ CSyncThread::getSyncEngine().getNotify().addObjectNotify(szSrcName, szObject);
511
+ }
512
+
513
+ void rho_sync_cleanobjectnotify()
514
+ {
515
+ CSyncThread::getSyncEngine().getNotify().cleanObjectNotifications();
516
+ }
517
+
518
+ int rho_sync_get_lastsync_objectcount(int nSrcID)
519
+ {
520
+ return CSyncThread::getSyncEngine().getNotify().getLastSyncObjectCount(nSrcID);
521
+ }
522
+
523
+ int rho_sync_get_pagesize()
524
+ {
525
+ return CSyncThread::getSyncEngine().getSyncPageSize();
526
+ }
527
+
528
+ void rho_sync_set_pagesize(int nPageSize)
529
+ {
530
+ CSyncThread::getSyncEngine().setSyncPageSize(nPageSize);
531
+ }
532
+
533
+ void rho_sync_set_threaded_mode(int b)
534
+ {
535
+ if(!CSyncThread::getInstance())
536
+ {
537
+ RAWLOG_ERROR("No SyncThread instance!");
538
+ }
539
+
540
+ CSyncThread::getInstance()->setNonThreadedMode(b==0);
541
+ CSyncThread::getSyncEngine().setNonThreadedMode(b==0);
542
+ }
543
+
544
+ char* rho_sync_create_string(const char* szStr)
545
+ {
546
+ return strdup(szStr);
547
+ }
548
+
549
+ void rho_sync_free_string(char* szStr)
550
+ {
551
+ if (NULL != szStr)
552
+ free(szStr);
553
+ }
554
+
555
+ void rho_sync_enable_status_popup(int b)
556
+ {
557
+ CSyncThread::getSyncEngine().getNotify().enableStatusPopup(b == 0 ? false : true);
558
+ }
559
+
560
+ void rho_sync_set_source_property(int nSrcID, const char* szPropName, const char* szPropValue)
561
+ {
562
+ CSyncEngine::getSourceOptions().setProperty(nSrcID, szPropName, szPropValue);
563
+ }
564
+
565
+ #ifndef RHO_NO_RUBY
566
+ unsigned long rho_sync_get_source_property(int nSrcID, const char* szPropName)
567
+ {
568
+ return rho_ruby_create_string( CSyncEngine::getSourceOptions().getProperty(nSrcID, szPropName).c_str() );
569
+ }
570
+ #endif //RHO_NO_RUBY
571
+
572
+ void rho_sync_set_ssl_verify_peer(int b)
573
+ {
574
+ CSyncThread::getSyncEngine().setSslVerifyPeer(b == 0 ? false : true);
575
+ }
576
+
577
+
578
+ void rho_sync_register_push()
579
+ {
580
+ RAWLOG_WARNING("'register_push' is not implemented!");
581
+ }
582
+
583
+ }