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,181 @@
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 "RhoError.h"
52
+
53
+ #ifdef __cplusplus
54
+ extern "C" {
55
+ #endif //__cplusplus
56
+
57
+ typedef enum _RHOM_MODEL_TYPE { RMT_PROPERTY_BAG=1, RMT_PROPERTY_FIXEDSCHEMA=2 } RHOM_MODEL_TYPE;
58
+ typedef enum _RHOM_SYNC_TYPE { RST_NONE = 0, RST_INCREMENTAL=1, RST_BULK_ONLY=2 } RHOM_SYNC_TYPE;
59
+ typedef struct _RHOM_MODEL
60
+ {
61
+ const char* name;
62
+ RHOM_MODEL_TYPE type;
63
+ int source_id; //generated when insert to database
64
+
65
+ RHOM_SYNC_TYPE sync_type;
66
+ int sync_priority;
67
+
68
+ const char* partition;
69
+
70
+ unsigned long associations; //hash string to string: rho_connectclient_hash_create
71
+
72
+ const char* blob_attribs;
73
+ }RHOM_MODEL;
74
+
75
+ typedef struct _RHO_CONNECT_NOTIFY
76
+ {
77
+ int total_count;
78
+ int processed_count;
79
+ int cumulative_count;
80
+ int source_id;
81
+ char* source_name;
82
+ char* status;
83
+ char* sync_type;
84
+ char* bulk_status;
85
+ char* partition;
86
+ int error_code;
87
+ char* error_message;
88
+ char* callback_params;
89
+
90
+ unsigned long create_errors_messages;
91
+
92
+ unsigned long update_errors_obj;
93
+ unsigned long update_errors_attrs;
94
+ unsigned long update_errors_messages;
95
+
96
+ unsigned long update_rollback_obj;
97
+ unsigned long update_rollback_attrs;
98
+
99
+ unsigned long delete_errors_obj;
100
+ unsigned long delete_errors_attrs;
101
+ unsigned long delete_errors_messages;
102
+
103
+ }RHO_CONNECT_NOTIFY;
104
+
105
+ typedef struct _RHO_CONNECT_OBJECT_NOTIFY
106
+ {
107
+ int deleted_count;
108
+ int updated_count;
109
+ int created_count;
110
+ int* deleted_source_ids;
111
+ int* updated_source_ids;
112
+ int* created_source_ids;
113
+
114
+ char** deleted_objects;
115
+ char** updated_objects;
116
+ char** created_objects;
117
+ }RHO_CONNECT_OBJECT_NOTIFY;
118
+
119
+ void rho_connectclient_initmodel(RHOM_MODEL* model);
120
+ void rho_connectclient_destroymodel(RHOM_MODEL* model);
121
+
122
+ void rho_connectclient_init(RHOM_MODEL* pModels, int nModels);
123
+ void rho_connectclient_updatemodels(RHOM_MODEL* pModels, int nModels);
124
+
125
+ void rho_connectclient_destroy();
126
+ void rho_connectclient_database_client_reset();
127
+ void rho_connectclient_database_full_reset_and_logout();
128
+ void rho_connectclient_database_fullclient_reset_and_logout();
129
+ void rho_connectclient_database_full_reset(bool bClientReset);
130
+
131
+ char* rho_connectclient_database_export(const char* partition);
132
+ int rho_connectclient_database_import(const char* partition, const char* zipName);
133
+
134
+ void rho_connectclient_parsenotify(const char* msg, RHO_CONNECT_NOTIFY* pNotify);
135
+ void rho_connectclient_free_syncnotify(RHO_CONNECT_NOTIFY* pNotify);
136
+
137
+ void rho_connectclient_parse_objectnotify(const char* msg, RHO_CONNECT_OBJECT_NOTIFY* pNotify);
138
+ void rho_connectclient_free_sync_objectnotify(RHO_CONNECT_OBJECT_NOTIFY* pNotify);
139
+
140
+ unsigned long rho_connectclient_strarray_create();
141
+ int rho_connectclient_strarray_add(unsigned long ar, const char* szStr);
142
+ void rho_connectclient_strarray_delete(unsigned long ar);
143
+ int rho_connectclient_strarray_find(unsigned long ar, const char* szStr);
144
+
145
+ unsigned long rho_connectclient_strhasharray_create();
146
+ void rho_connectclient_strhasharray_add(unsigned long ar, unsigned long hash);
147
+ void rho_connectclient_strhasharray_delete(unsigned long ar);
148
+ int rho_connectclient_strhasharray_size(unsigned long ar);
149
+ unsigned long rho_connectclient_strhasharray_get(unsigned long ar, int nIndex);
150
+
151
+ void rho_connectclient_create_object(const char* szModel, unsigned long hash);
152
+ unsigned long rho_connectclient_find(const char* szModel,const char* szObject );
153
+ unsigned long rho_connectclient_find_first(const char* szModel, unsigned long hashCond );
154
+ unsigned long rho_connectclient_find_all(const char* szModel, unsigned long hashCond );
155
+ unsigned long rho_connectclient_findbysql(const char* szModel, const char* szSql, unsigned long arParams );
156
+
157
+ int rho_connectclient_is_changed(const char* szModel);
158
+ void rho_connectclient_set_synctype(const char* szModel, RHOM_SYNC_TYPE sync_type);
159
+
160
+ void rho_connectclient_save( const char* szModel, unsigned long hash );
161
+ void rho_connectclient_itemdestroy( const char* szModel, unsigned long hash );
162
+
163
+ unsigned long rho_connectclient_hash_create();
164
+ void rho_connectclient_hash_put(unsigned long hash, const char* szKey, const char* szValue);
165
+ void rho_connectclient_hash_delete(unsigned long hash);
166
+ const char* rho_connectclient_hash_get(unsigned long hash, const char* szKey);
167
+ int rho_connectclient_hash_equal(unsigned long hash1, unsigned long hash2);
168
+ int rho_connectclient_hash_size(unsigned long hash);
169
+ void rho_connectclient_hash_enumerate(unsigned long hash, int (*enum_func)(const char* szKey, const char* szValue, void* pThis), void* pThis );
170
+
171
+ void rho_connectclient_start_bulkupdate(const char* szModel);
172
+ void rho_connectclient_stop_bulkupdate(const char* szModel);
173
+
174
+ void rho_connectclient_on_sync_create_error(const char* szModel, RHO_CONNECT_NOTIFY* oNotify, const char* szAction );
175
+ void rho_connectclient_on_sync_update_error(const char* szModel, RHO_CONNECT_NOTIFY* oNotify, const char* szAction );
176
+ void rho_connectclient_on_sync_delete_error(const char* szModel, RHO_CONNECT_NOTIFY* oNotify, const char* szAction );
177
+ void rho_connectclient_push_changes(const char* szModel );
178
+
179
+ #ifdef __cplusplus
180
+ };
181
+ #endif //__cplusplus
@@ -0,0 +1,77 @@
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
+ #ifndef _RHOERROR_H_
50
+ #define _RHOERROR_H_
51
+
52
+ #define RHO_ERR_NONE 0
53
+ #define RHO_ERR_NETWORK 1
54
+ #define RHO_ERR_REMOTESERVER 2
55
+ #define RHO_ERR_RUNTIME 3
56
+ #define RHO_ERR_UNEXPECTEDSERVERRESPONSE 4
57
+ #define RHO_ERR_DIFFDOMAINSINSYNCSRC 5
58
+ #define RHO_ERR_NOSERVERRESPONSE 6
59
+ #define RHO_ERR_CLIENTISNOTLOGGEDIN 7
60
+ #define RHO_ERR_CUSTOMSYNCSERVER 8
61
+ #define RHO_ERR_UNATHORIZED 9
62
+ #define RHO_ERR_CANCELBYUSER 10
63
+ #define RHO_ERR_SYNCVERSION 11
64
+ #define RHO_ERR_GEOLOCATION 12
65
+
66
+ #ifdef __cplusplus
67
+ extern "C" {
68
+ #endif //__cplusplus
69
+
70
+ char* rho_error_getErrorText(int nError);
71
+ void rho_error_freeString(char* sz);
72
+
73
+ #ifdef __cplusplus
74
+ };
75
+ #endif //__cplusplus
76
+
77
+ #endif //_RHOERROR_H_
@@ -0,0 +1,830 @@
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
+ //Copy files(syncdb.schema, syncdb.triggers ) to this folders: rhoconnect-client\C++\Tests\win32\bin\Win32\RhoConnectClientTest\<Debug/Release>\rho\db
50
+ //!!!!!!!!!!!!!!!!!!!!
51
+
52
+ #define _CRT_SECURE_NO_WARNINGS 1
53
+ #define _CRT_NON_CONFORMING_SWPRINTFS 1
54
+
55
+ #ifdef WIN32
56
+ #include <stdio.h>
57
+ #include <tchar.h>
58
+ #endif //WIN32
59
+
60
+ #include "RhoConnectClient/RhoConnectClient.h"
61
+ #include "sync/SyncThread.h"
62
+ #include "common/RhoConf.h"
63
+ #include "RhoConnectClient/RhoError.h"
64
+ #include "common/RhoTime.h"
65
+
66
+ #include "gtest/gtest.h"
67
+ #include "test/test_helper.h"
68
+
69
+ using namespace rho;
70
+ using namespace rho::common;
71
+ const char* g_szProduct = "Product";
72
+ const char* g_szCustomer = "Customer";
73
+ String g_product_test_name;
74
+ int m_nProductSrcID = 0;
75
+ RHOM_MODEL models[2] = {0};
76
+
77
+ #ifdef WIN32
78
+ int _tmain(int argc, _TCHAR* argv[])
79
+ {
80
+ #else
81
+ extern "C" int runSyncClientTests()
82
+ {
83
+ int argc = 0;
84
+ char** argv = 0;
85
+ #endif
86
+
87
+ rho_connectclient_initmodel(&models[0]);
88
+ models[0].name = g_szProduct;
89
+ //models[0].type = RMT_PROPERTY_FIXEDSCHEMA;
90
+ //For schema model - add this create to rhoconnect-client\C++\Tests\win32\bin\Win32\RhoConnectClientTest\Debug\rho\db\syncdb.schema:
91
+ /*
92
+ CREATE TABLE "Product_s" (
93
+ "brand" varchar default null,
94
+ "created_at" varchar default null,
95
+ "name" varchar default null,
96
+ "price" varchar default null,
97
+ "quantity" varchar default null,
98
+ "sku" varchar default null,
99
+ "updated_at" varchar default null,
100
+ "object" varchar(255) PRIMARY KEY );
101
+ */
102
+ models[0].sync_type = RST_INCREMENTAL;
103
+
104
+ models[0].associations = rho_connectclient_hash_create();
105
+ rho_connectclient_hash_put( models[0].associations, "quantity", g_szCustomer );
106
+ rho_connectclient_hash_put( models[0].associations, "sku", g_szCustomer );
107
+
108
+ rho_connectclient_initmodel(&models[1]);
109
+ models[1].name = g_szCustomer;
110
+ models[1].sync_type = RST_INCREMENTAL;
111
+
112
+ rho_connectclient_init(models, 2);
113
+
114
+ rho_sync_set_threaded_mode(0);
115
+ rho_sync_set_pollinterval(0);
116
+ rho_logconf_setSeverity(1);
117
+
118
+ m_nProductSrcID = models[0].source_id;
119
+ //run tests
120
+ testing::InitGoogleTest(&argc, argv);
121
+ RUN_ALL_TESTS();
122
+ //
123
+
124
+ rho_connectclient_destroy();
125
+
126
+ return 0;
127
+ }
128
+
129
+ TEST(SyncClient, shouldFindProductBySql)
130
+ {
131
+ unsigned long items = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM sources", 0 );
132
+ EXPECT_NE( items, 0 );
133
+ EXPECT_EQ(rho_connectclient_strhasharray_size(items), 2 );
134
+ rho_connectclient_strhasharray_delete(items);
135
+
136
+
137
+ unsigned long params = rho_connectclient_strarray_create();
138
+ rho_connectclient_strarray_add(params, g_szProduct);
139
+
140
+ unsigned long items2 = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM sources WHERE name=?", params );
141
+ EXPECT_NE( items2, 0 );
142
+ EXPECT_EQ(rho_connectclient_strhasharray_size(items2), 1 );
143
+
144
+ rho_connectclient_strarray_delete(params);
145
+ rho_connectclient_strhasharray_delete(items2);
146
+
147
+ }
148
+
149
+ TEST(SyncClient, UpdateSyncServer)
150
+ {
151
+ char* saveSrv = rho_conf_getString("syncserver");
152
+ rho_sync_set_syncserver("http://example.com/sources/");
153
+ char* newSrv = rho_conf_getString("syncserver");
154
+ EXPECT_EQ(String(newSrv), "http://example.com/sources/");
155
+ rho_conf_freeString(newSrv);
156
+
157
+ rho_sync_set_syncserver(saveSrv);
158
+ newSrv = rho_conf_getString("syncserver");
159
+ EXPECT_EQ(String(newSrv), saveSrv);
160
+ rho_conf_freeString(saveSrv);
161
+ }
162
+
163
+ TEST(SyncClient, shouldNotSyncWithoutLogin)
164
+ {
165
+ EXPECT_EQ(rho_sync_logged_in(), 0);
166
+
167
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
168
+ RHO_CONNECT_NOTIFY oNotify = {0};
169
+ rho_connectclient_parsenotify(szRes, &oNotify);
170
+
171
+ EXPECT_EQ(String(oNotify.status), "error");
172
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_CLIENTISNOTLOGGEDIN);
173
+
174
+ rho_connectclient_free_syncnotify(&oNotify);
175
+ rho_sync_free_string(szRes);
176
+ }
177
+ /*
178
+ TEST(SyncClient, shouldLoginToBulk)
179
+ {
180
+ EXPECT_EQ(rho_sync_logged_in(), 0);
181
+
182
+ rho_sync_set_syncserver("http://store-bulk.rhohub.com/application");
183
+
184
+ char* szRes = (char*)rho_sync_login("lars", "larspass", "");
185
+ RHO_CONNECT_NOTIFY oNotify = {0};
186
+ rho_connectclient_parsenotify(szRes, &oNotify);
187
+
188
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
189
+ EXPECT_EQ(rho_sync_logged_in(), 1);
190
+
191
+ rho_connectclient_free_syncnotify(&oNotify);
192
+ rho_sync_free_string(szRes);
193
+
194
+ }
195
+
196
+ TEST(SyncClient, shouldBulkSync)
197
+ {
198
+ EXPECT_EQ(rho_sync_logged_in(), 1);
199
+ rho_conf_setInt("bulksync_state", 0 );
200
+
201
+ char* szRes = (char*)rho_sync_doSyncAllSources(0,0);
202
+ RHO_CONNECT_NOTIFY oNotify = {0};
203
+ rho_connectclient_parsenotify(szRes, &oNotify);
204
+
205
+ EXPECT_EQ(String(oNotify.status), "complete");
206
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
207
+
208
+ unsigned long cond = rho_connectclient_hash_create();
209
+ unsigned long items = rho_connectclient_find_all(g_szProduct, cond );
210
+ EXPECT_NE( rho_connectclient_strhasharray_size(items), 0 );
211
+
212
+ rho_connectclient_free_syncnotify(&oNotify);
213
+ rho_sync_free_string(szRes);
214
+
215
+ rho_connectclient_updatemodels(models, 2);
216
+ } */
217
+
218
+ TEST(SyncClient, ResetAndLogout)
219
+ {
220
+ //rho_sync_set_syncserver("http://rhodes-store-server.herokuapp.com/application");
221
+ rho_sync_set_syncserver("http://rhoconnect-spec-win32.heroku.com");
222
+ rho_conf_remove_property("bulksync_state");
223
+ rho_connectclient_database_full_reset_and_logout();
224
+
225
+ EXPECT_EQ(rho_sync_logged_in(), 0);
226
+ EXPECT_EQ( rho_conf_is_property_exists("bulksync_state"), 0 );
227
+ }
228
+
229
+
230
+ TEST(SyncClient, shouldLogin)
231
+ {
232
+ EXPECT_EQ(rho_sync_logged_in(), 0);
233
+
234
+ char* szRes = (char*)rho_sync_login_c("lars", "larspass", 0, 0);
235
+ RHO_CONNECT_NOTIFY oNotify = {0};
236
+ rho_connectclient_parsenotify(szRes, &oNotify);
237
+
238
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
239
+ EXPECT_EQ(rho_sync_logged_in(), 1);
240
+
241
+ rho_connectclient_free_syncnotify(&oNotify);
242
+ rho_sync_free_string(szRes);
243
+
244
+ }
245
+
246
+
247
+ TEST(SyncClient, shouldSyncProductByName)
248
+ {
249
+ EXPECT_EQ(rho_sync_logged_in(), 1);
250
+
251
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
252
+ RHO_CONNECT_NOTIFY oNotify = {0};
253
+ rho_connectclient_parsenotify(szRes, &oNotify);
254
+
255
+ EXPECT_EQ(String(oNotify.status), "ok");
256
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
257
+
258
+ unsigned long cond = rho_connectclient_hash_create();
259
+ unsigned long items = rho_connectclient_find_all(g_szProduct, cond );
260
+ EXPECT_NE( rho_connectclient_strhasharray_size(items), 0 );
261
+
262
+ rho_connectclient_free_syncnotify(&oNotify);
263
+ rho_sync_free_string(szRes);
264
+
265
+ }
266
+
267
+ TEST(SyncClient, shouldPushChanges)
268
+ {
269
+ EXPECT_EQ(rho_sync_logged_in(), 1);
270
+
271
+ rho_connectclient_push_changes(g_szProduct);
272
+
273
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
274
+ RHO_CONNECT_NOTIFY oNotify = {0};
275
+ rho_connectclient_parsenotify(szRes, &oNotify);
276
+
277
+ EXPECT_EQ(String(oNotify.status), "ok");
278
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
279
+
280
+ rho_connectclient_free_syncnotify(&oNotify);
281
+ rho_sync_free_string(szRes);
282
+
283
+ szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
284
+ RHO_CONNECT_NOTIFY oNotify2 = {0};
285
+ rho_connectclient_parsenotify(szRes, &oNotify2);
286
+
287
+ EXPECT_EQ(String(oNotify2.status), "ok");
288
+ EXPECT_EQ(oNotify2.error_code, RHO_ERR_NONE);
289
+
290
+ rho_connectclient_free_syncnotify(&oNotify2);
291
+ rho_sync_free_string(szRes);
292
+
293
+ }
294
+
295
+ TEST(SyncClient, shouldSearchProduct)
296
+ {
297
+ EXPECT_EQ(rho_sync_logged_in(), 1);
298
+
299
+ unsigned long ar_sources = rho_connectclient_strarray_create();
300
+ rho_connectclient_strarray_add(ar_sources, g_szProduct);
301
+
302
+ String strParams = "offset=0&max_results=10&filterData=Test&search_id=" +
303
+ convertToStringA( CLocalTime().toULong() );
304
+ char* szRes = (char*)rho_sync_doSearchByNames( ar_sources, "search",
305
+ strParams.c_str(), false, 0, "", "" );
306
+
307
+ rho_connectclient_strarray_delete(ar_sources);
308
+
309
+ RHO_CONNECT_NOTIFY oNotify = {0};
310
+ rho_connectclient_parsenotify(szRes, &oNotify);
311
+
312
+ EXPECT_EQ(String(oNotify.status), "complete");
313
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
314
+
315
+ rho_connectclient_free_syncnotify(&oNotify);
316
+ rho_sync_free_string(szRes);
317
+
318
+ }
319
+
320
+ TEST(SyncClient, shouldCreateNewProduct)
321
+ {
322
+ EXPECT_EQ(rho_sync_logged_in(), 1);
323
+
324
+ unsigned long item = rho_connectclient_hash_create();
325
+ rho_connectclient_hash_put(item, "name", "Test");
326
+ rho_connectclient_create_object(g_szProduct, item);
327
+
328
+ unsigned long item2 = rho_connectclient_find(g_szProduct, rho_connectclient_hash_get(item, "object") );
329
+ EXPECT_EQ( rho_connectclient_hash_equal(item2, item), 1 );
330
+
331
+ EXPECT_EQ( rho_connectclient_is_changed(g_szProduct), 1 );
332
+
333
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
334
+ RHO_CONNECT_NOTIFY oNotify = {0};
335
+ rho_connectclient_parsenotify(szRes, &oNotify);
336
+
337
+ EXPECT_EQ(String(oNotify.status), "ok");
338
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
339
+
340
+ unsigned long item3 = rho_connectclient_find(g_szProduct, rho_connectclient_hash_get(item, "object") );
341
+ EXPECT_EQ( item3, 0 );
342
+
343
+ EXPECT_EQ( rho_connectclient_is_changed(g_szProduct), 0 );
344
+
345
+ rho_connectclient_hash_delete(item);
346
+ rho_connectclient_hash_delete(item2);
347
+ rho_connectclient_hash_delete(item3);
348
+
349
+ rho_connectclient_free_syncnotify(&oNotify);
350
+ rho_sync_free_string(szRes);
351
+ }
352
+
353
+ TEST(SyncClient, shouldCreateNewProductWithCustomers)
354
+ {
355
+ EXPECT_EQ(rho_sync_logged_in(), 1);
356
+
357
+ unsigned long cust1 = rho_connectclient_hash_create();
358
+ rho_connectclient_hash_put(cust1, "first", "CustTest1");
359
+ rho_connectclient_create_object(g_szCustomer, cust1);
360
+
361
+ unsigned long cust2 = rho_connectclient_hash_create();
362
+ rho_connectclient_hash_put(cust2, "first", "CustTest2");
363
+ rho_connectclient_create_object(g_szCustomer, cust2);
364
+
365
+ g_product_test_name = CLocalTime().toString(true, true);
366
+ unsigned long item = rho_connectclient_hash_create();
367
+ rho_connectclient_hash_put(item, "name", g_product_test_name.c_str());
368
+ rho_connectclient_hash_put(item, "quantity", rho_connectclient_hash_get(cust1, "object"));
369
+ rho_connectclient_hash_put(item, "sku", rho_connectclient_hash_get(cust2, "object"));
370
+ rho_connectclient_create_object(g_szProduct, item);
371
+
372
+ char* szRes = (char*)rho_sync_doSyncAllSources(0,0,false);
373
+ RHO_CONNECT_NOTIFY oNotify = {0};
374
+ rho_connectclient_parsenotify(szRes, &oNotify);
375
+
376
+ EXPECT_EQ(String(oNotify.status), "complete");
377
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
378
+ rho_connectclient_free_syncnotify(&oNotify);
379
+ rho_sync_free_string(szRes);
380
+
381
+ unsigned long prodCond = rho_connectclient_hash_create();
382
+ rho_connectclient_hash_put(prodCond, "name", g_product_test_name.c_str());
383
+ unsigned long prod = rho_connectclient_find_first(g_szProduct, prodCond );
384
+ rho_connectclient_hash_delete(prodCond);
385
+
386
+ EXPECT_NE( prod, 0 );
387
+ EXPECT_NE( String(rho_connectclient_hash_get(prod, "object")), rho_connectclient_hash_get(item, "object") );
388
+ EXPECT_NE( String(rho_connectclient_hash_get(prod, "quantity")), rho_connectclient_hash_get(cust1, "object") );
389
+ EXPECT_NE( String(rho_connectclient_hash_get(prod, "sku")), rho_connectclient_hash_get(cust2, "object") );
390
+
391
+ unsigned long cust11 = rho_connectclient_find(g_szCustomer, rho_connectclient_hash_get(prod, "quantity") );
392
+ EXPECT_NE( cust11, 0 );
393
+ EXPECT_EQ( String(rho_connectclient_hash_get(cust11, "first")), rho_connectclient_hash_get(cust1, "first") );
394
+
395
+ unsigned long cust22 = rho_connectclient_find(g_szCustomer, rho_connectclient_hash_get(prod, "sku") );
396
+ EXPECT_NE( cust22, 0 );
397
+ EXPECT_EQ( String(rho_connectclient_hash_get(cust22, "first")), rho_connectclient_hash_get(cust2, "first") );
398
+
399
+ rho_connectclient_hash_delete(cust22);
400
+ rho_connectclient_hash_delete(cust11);
401
+ rho_connectclient_hash_delete(cust1);
402
+ rho_connectclient_hash_delete(cust2);
403
+ rho_connectclient_hash_delete(item);
404
+ rho_connectclient_hash_delete(prod);
405
+ }
406
+
407
+ TEST(SyncClient, shouldModifyProduct)
408
+ {
409
+ EXPECT_EQ(rho_sync_logged_in(), 1);
410
+
411
+ unsigned long cond = rho_connectclient_hash_create();
412
+ rho_connectclient_hash_put(cond, "name", "Test");
413
+
414
+ unsigned long item = rho_connectclient_find_first(g_szProduct, cond );
415
+ rho_connectclient_hash_delete(cond);
416
+
417
+ EXPECT_NE( item, 0 );
418
+ String saved_obj = rho_connectclient_hash_get(item, "object");
419
+
420
+ const char* szSku = rho_connectclient_hash_get(item, "sku");
421
+ String new_sku = szSku ? szSku : "";
422
+ new_sku += "_TEST";
423
+
424
+ rho_connectclient_hash_put(item, "sku", new_sku.c_str());
425
+ rho_connectclient_save( g_szProduct, item );
426
+
427
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
428
+ RHO_CONNECT_NOTIFY oNotify = {0};
429
+ rho_connectclient_parsenotify(szRes, &oNotify);
430
+
431
+ EXPECT_EQ(String(oNotify.status), "ok");
432
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
433
+
434
+ unsigned long item3 = rho_connectclient_find(g_szProduct, saved_obj.c_str() );
435
+ //EXPECT_EQ( rho_connectclient_hash_equal(item3, item), 1 );
436
+
437
+ rho_connectclient_hash_delete(item);
438
+ rho_connectclient_hash_delete(item3);
439
+
440
+ rho_connectclient_free_syncnotify(&oNotify);
441
+ rho_sync_free_string(szRes);
442
+
443
+ }
444
+
445
+ unsigned long beforeProcessCreateError1(RHO_CONNECT_NOTIFY& oNotify)
446
+ {
447
+ unsigned long item = rho_connectclient_hash_create();
448
+ rho_connectclient_hash_put(item, "name", "Test");
449
+ rho_connectclient_hash_put(item, "brand", "Rho");
450
+ rho_connectclient_create_object(g_szProduct, item);
451
+
452
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='create'", 0 );
453
+ EXPECT_NE( records, 0 );
454
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 1 );
455
+ unsigned long rec0 = rho_connectclient_strhasharray_get(records, 0);
456
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "object");
457
+ rho_connectclient_strhasharray_delete(records);
458
+
459
+ rho_connectclient_hash_put(item, "price", "123");
460
+ rho_connectclient_save( g_szProduct, item );
461
+
462
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='create'", 0 );
463
+ EXPECT_NE( records, 0 );
464
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 1 );
465
+ rec0 = rho_connectclient_strhasharray_get(records, 0);
466
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "object");
467
+ rho_connectclient_strhasharray_delete(records);
468
+
469
+ String err_resp = String("[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":0},{\"total_count\":0},{\"create-error\":{\"") + rho_connectclient_hash_get(item,"object") + "\":{\"name\":\"wrongname\",\"an_attribute\":\"error create\"},\"" + rho_connectclient_hash_get(item,"object") + "-error\":{\"message\":\"error create\"}}}]";
470
+ int nSrcID = 0;
471
+ convertFromStringA(rho_connectclient_hash_get(item,"source_id"), nSrcID );
472
+ rho_sync_set_source_property( nSrcID, "rho_server_response", err_resp.c_str() );
473
+
474
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
475
+
476
+ rho_connectclient_parsenotify(szRes, &oNotify);
477
+
478
+ EXPECT_EQ(String(oNotify.status), "error");
479
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_CUSTOMSYNCSERVER);
480
+ EXPECT_NE(oNotify.create_errors_messages, 0);
481
+ EXPECT_NE( rho_connectclient_hash_get(oNotify.create_errors_messages, rho_connectclient_hash_get(item,"object")), (char*)0);
482
+
483
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='create'", 0 );
484
+ EXPECT_NE( records, 0 );
485
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 3 );
486
+ rec0 = rho_connectclient_strhasharray_get(records, 0);
487
+ EXPECT_NE( String(rho_connectclient_hash_get(rec0, "attrib")), "object");
488
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "sent")), "2");
489
+ rho_connectclient_strhasharray_delete(records);
490
+
491
+ return item;
492
+ }
493
+
494
+ unsigned long beforeProcessCreateError(RHO_CONNECT_NOTIFY& oNotify)
495
+ {
496
+ unsigned long item = beforeProcessCreateError1(oNotify);
497
+
498
+ rho_connectclient_hash_put(item, "price", "456");
499
+ rho_connectclient_save( g_szProduct, item );
500
+
501
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='create'", 0 );
502
+ EXPECT_NE( records, 0 );
503
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 3 );
504
+ unsigned long rec0 = rho_connectclient_strhasharray_get(records, 0);
505
+ EXPECT_NE( String(rho_connectclient_hash_get(rec0, "attrib")), "object");
506
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "sent")), "2");
507
+ rho_connectclient_strhasharray_delete(records);
508
+
509
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='update'", 0 );
510
+ EXPECT_NE( records, 0 );
511
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 1 );
512
+ if ( rho_connectclient_strhasharray_size(records) == 1)
513
+ {
514
+ rec0 = rho_connectclient_strhasharray_get(records, 0);
515
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "price");
516
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "sent")), "0");
517
+ }
518
+ rho_connectclient_strhasharray_delete(records);
519
+
520
+ return item;
521
+ }
522
+
523
+ TEST(SyncClient, shouldProcessCreateError_Delete)
524
+ {
525
+ RHO_CONNECT_NOTIFY oNotify = {0};
526
+ unsigned long item = beforeProcessCreateError(oNotify);
527
+
528
+ rho_connectclient_on_sync_create_error(g_szProduct, &oNotify, "delete" );
529
+
530
+ unsigned long params = rho_connectclient_strarray_create();
531
+ rho_connectclient_strarray_add(params, rho_connectclient_hash_get(item,"object"));
532
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE object=?", params );
533
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
534
+
535
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='create'", 0 );
536
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
537
+
538
+ item = rho_connectclient_find(g_szProduct, rho_connectclient_hash_get(item,"object") );
539
+ EXPECT_EQ(item, 0 );
540
+
541
+ rho_connectclient_findbysql(g_szProduct, "DELETE FROM changed_values", 0 );
542
+ }
543
+
544
+ TEST(SyncClient, shouldProcessCreateError_Recreate)
545
+ {
546
+ RHO_CONNECT_NOTIFY oNotify = {0};
547
+ unsigned long item = beforeProcessCreateError(oNotify);
548
+
549
+ rho_connectclient_on_sync_create_error(g_szProduct, &oNotify, "recreate" );
550
+
551
+ unsigned long params = rho_connectclient_strarray_create();
552
+ rho_connectclient_strarray_add(params, rho_connectclient_hash_get(item,"object"));
553
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE object=?", params );
554
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 1 );
555
+ unsigned long rec0 = rho_connectclient_strhasharray_get(records, 0);
556
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "object");
557
+ rho_connectclient_strhasharray_delete(records);
558
+
559
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='update'", 0 );
560
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
561
+
562
+ item = rho_connectclient_find(g_szProduct, rho_connectclient_hash_get(item,"object") );
563
+ EXPECT_NE(item, 0 );
564
+
565
+ rho_connectclient_findbysql(g_szProduct, "DELETE FROM changed_values", 0 );
566
+ }
567
+
568
+ TEST(SyncClient, shouldProcessCreateError_RecreateDeleted)
569
+ {
570
+ RHO_CONNECT_NOTIFY oNotify = {0};
571
+ unsigned long item = beforeProcessCreateError1(oNotify);
572
+
573
+ rho_connectclient_itemdestroy(g_szProduct, item);
574
+
575
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='create'", 0 );
576
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 3 );
577
+ if (rho_connectclient_strhasharray_size(records)== 3)
578
+ {
579
+ unsigned long rec0 = rho_connectclient_strhasharray_get(records, 0);
580
+ EXPECT_NE( String(rho_connectclient_hash_get(rec0, "attrib")), "object");
581
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "sent")), "2");
582
+ }
583
+ rho_connectclient_strhasharray_delete(records);
584
+
585
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='delete'", 0 );
586
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 3 ); //7 for schema
587
+ if ( rho_connectclient_strhasharray_size(records)== 3)
588
+ {
589
+ unsigned long rec0 = rho_connectclient_strhasharray_get(records, 0);
590
+ EXPECT_NE( String(rho_connectclient_hash_get(rec0, "attrib")), "object");
591
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "sent")), "0");
592
+ }
593
+ rho_connectclient_strhasharray_delete(records);
594
+
595
+ rho_connectclient_on_sync_create_error(g_szProduct, &oNotify, "recreate" );
596
+
597
+ unsigned long params = rho_connectclient_strarray_create();
598
+ rho_connectclient_strarray_add(params, rho_connectclient_hash_get(item,"object"));
599
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE object=?", params );
600
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
601
+ rho_connectclient_strhasharray_delete(records);
602
+
603
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='update'", 0 );
604
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
605
+
606
+ item = rho_connectclient_find(g_szProduct, rho_connectclient_hash_get(item,"object") );
607
+ EXPECT_EQ(item, 0 );
608
+
609
+ rho_connectclient_findbysql(g_szProduct, "DELETE FROM changed_values", 0 );
610
+ }
611
+
612
+ TEST(SyncClient, shouldProcessUpdateError_Retry)
613
+ {
614
+ String err_resp = "[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":0},{\"total_count\":0},{\"update-error\":{\"broken_object_id\":{\"name\":\"wrongname\",\"an_attribute\":\"error update\"},\"broken_object_id-error\":{\"message\":\"error update\"}}}]";
615
+ rho_sync_set_source_property( m_nProductSrcID, "rho_server_response", err_resp.c_str() );
616
+
617
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
618
+
619
+ RHO_CONNECT_NOTIFY oNotify = {0};
620
+ rho_connectclient_parsenotify(szRes, &oNotify);
621
+
622
+ EXPECT_EQ(String(oNotify.status), "error");
623
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_CUSTOMSYNCSERVER);
624
+ EXPECT_NE(oNotify.update_errors_obj, 0);
625
+ EXPECT_NE( rho_connectclient_strarray_find(oNotify.update_errors_obj, "broken_object_id"), -1);
626
+
627
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='update'", 0 );
628
+ EXPECT_NE( records, 0 );
629
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
630
+
631
+ rho_connectclient_on_sync_update_error(g_szProduct, &oNotify, "retry" );
632
+
633
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='update'", 0 );
634
+ EXPECT_NE( records, 0 );
635
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 2 );
636
+ unsigned long rec0 = rho_connectclient_strhasharray_get(records, 0);
637
+ unsigned long rec1 = rho_connectclient_strhasharray_get(records, 1);
638
+ if ( strcmp(rho_connectclient_hash_get(rec0, "attrib"), "name") == 0)
639
+ {
640
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "object")), "broken_object_id");
641
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "name");
642
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "value")), "wrongname");
643
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "update_type")), "update");
644
+ }else
645
+ {
646
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "object")), "broken_object_id");
647
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "attrib")), "name");
648
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "value")), "wrongname");
649
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "update_type")), "update");
650
+ }
651
+ if ( strcmp(rho_connectclient_hash_get(rec1, "attrib"), "an_attribute") == 0)
652
+ {
653
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "object")), "broken_object_id");
654
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "attrib")), "an_attribute");
655
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "value")), "error update");
656
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "update_type")), "update");
657
+ }else
658
+ {
659
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "object")), "broken_object_id");
660
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "an_attribute");
661
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "value")), "error update");
662
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "update_type")), "update");
663
+ }
664
+
665
+ rho_connectclient_strhasharray_delete(records);
666
+
667
+ rho_connectclient_findbysql(g_szProduct, "DELETE FROM changed_values", 0 );
668
+ }
669
+
670
+ TEST(SyncClient, shouldProcessUpdateError_Rollback)
671
+ {
672
+ unsigned long cond = rho_connectclient_hash_create();
673
+ unsigned long item = rho_connectclient_find_first( g_szProduct, cond );
674
+ EXPECT_NE(item, 0 );
675
+ String obj_id = rho_connectclient_hash_get(item,"object");
676
+ String prod_name = rho_connectclient_hash_get(item,"name");
677
+
678
+ String err_resp = String("[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":0},{\"total_count\":0},{\"update-rollback\": {\"") + obj_id + "\": {\"name\": \"OLD_NAME\"}},\"update-error\":{\"" + obj_id + "\":{\"name\":\"wrongname\",\"an_attribute\":\"error update\"},\"" + obj_id + "-error\":{\"message\":\"error update\"}}}]";
679
+ rho_sync_set_source_property( m_nProductSrcID, "rho_server_response", err_resp.c_str() );
680
+
681
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
682
+
683
+ RHO_CONNECT_NOTIFY oNotify = {0};
684
+ rho_connectclient_parsenotify(szRes, &oNotify);
685
+
686
+ EXPECT_EQ(String(oNotify.status), "error");
687
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_CUSTOMSYNCSERVER);
688
+ EXPECT_NE(oNotify.update_errors_obj, 0);
689
+ EXPECT_NE( rho_connectclient_strarray_find(oNotify.update_errors_obj, obj_id.c_str()), -1);
690
+
691
+ EXPECT_NE(oNotify.update_rollback_obj, 0);
692
+
693
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='update'", 0 );
694
+ EXPECT_NE( records, 0 );
695
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
696
+ rho_connectclient_strhasharray_delete(records);
697
+
698
+ item = rho_connectclient_find(g_szProduct, obj_id.c_str() );
699
+ EXPECT_NE(item, 0 );
700
+ EXPECT_EQ(rho_connectclient_hash_get(item,"name"), prod_name );
701
+
702
+ rho_connectclient_on_sync_update_error(g_szProduct, &oNotify, "rollback" );
703
+
704
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='update'", 0 );
705
+ EXPECT_NE( records, 0 );
706
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
707
+ rho_connectclient_strhasharray_delete(records);
708
+
709
+ item = rho_connectclient_find(g_szProduct, obj_id.c_str() );
710
+ EXPECT_NE(item, 0 );
711
+ EXPECT_EQ( String(rho_connectclient_hash_get(item,"name")), "OLD_NAME" );
712
+
713
+ rho_connectclient_findbysql(g_szProduct, "DELETE FROM changed_values", 0 );
714
+ }
715
+
716
+ TEST(SyncClient, shouldProcessDeleteError_Retry)
717
+ {
718
+ String err_resp = "[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":0},{\"total_count\":0},{\"delete-error\":{\"broken_object_id\":{\"name\":\"wrongname\",\"an_attribute\":\"error delete\"},\"broken_object_id-error\":{\"message\":\"Error delete record\"}}}]";
719
+ rho_sync_set_source_property( m_nProductSrcID, "rho_server_response", err_resp.c_str() );
720
+
721
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
722
+
723
+ RHO_CONNECT_NOTIFY oNotify = {0};
724
+ rho_connectclient_parsenotify(szRes, &oNotify);
725
+
726
+ EXPECT_EQ(String(oNotify.status), "error");
727
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_CUSTOMSYNCSERVER);
728
+ EXPECT_NE(oNotify.delete_errors_obj, 0);
729
+ EXPECT_NE( rho_connectclient_strarray_find(oNotify.delete_errors_obj, "broken_object_id"), -1);
730
+
731
+ unsigned long records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='delete'", 0 );
732
+ EXPECT_NE( records, 0 );
733
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 0 );
734
+ rho_connectclient_strhasharray_delete(records);
735
+
736
+ rho_connectclient_on_sync_delete_error(g_szProduct, &oNotify, "retry" );
737
+
738
+ records = rho_connectclient_findbysql(g_szProduct, "SELECT * FROM changed_values WHERE update_type='delete'", 0 );
739
+ EXPECT_NE( records, 0 );
740
+ EXPECT_EQ(rho_connectclient_strhasharray_size(records), 2 );
741
+ unsigned long rec0 = rho_connectclient_strhasharray_get(records, 0);
742
+ unsigned long rec1 = rho_connectclient_strhasharray_get(records, 1);
743
+ if ( strcmp(rho_connectclient_hash_get(rec0, "attrib"), "name") == 0)
744
+ {
745
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "object")), "broken_object_id");
746
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "name");
747
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "value")), "wrongname");
748
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "update_type")), "delete");
749
+ }else
750
+ {
751
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "object")), "broken_object_id");
752
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "attrib")), "name");
753
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "value")), "wrongname");
754
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "update_type")), "delete");
755
+ }
756
+ if ( strcmp(rho_connectclient_hash_get(rec1, "attrib"), "an_attribute") == 0)
757
+ {
758
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "object")), "broken_object_id");
759
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "attrib")), "an_attribute");
760
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "value")), "error delete");
761
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec1, "update_type")), "delete");
762
+ }else
763
+ {
764
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "object")), "broken_object_id");
765
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "attrib")), "an_attribute");
766
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "value")), "error delete");
767
+ EXPECT_EQ( String(rho_connectclient_hash_get(rec0, "update_type")), "delete");
768
+ }
769
+
770
+ rho_connectclient_strhasharray_delete(records);
771
+ rho_connectclient_findbysql(g_szProduct, "DELETE FROM changed_values", 0 );
772
+
773
+ rho_sync_set_source_property( m_nProductSrcID, "rho_server_response", "" );
774
+ }
775
+
776
+ TEST(SyncClient, shouldDeleteAllTestProduct)
777
+ {
778
+ EXPECT_EQ(rho_sync_logged_in(), 1);
779
+
780
+ unsigned long cond = rho_connectclient_hash_create();
781
+ rho_connectclient_hash_put(cond, "name", "Test");
782
+
783
+ unsigned long items = rho_connectclient_find_all(g_szProduct, cond );
784
+ EXPECT_NE( items, 0 );
785
+
786
+ for ( int i = 0; i < rho_connectclient_strhasharray_size(items); i++ )
787
+ {
788
+ rho_connectclient_itemdestroy(g_szProduct, rho_connectclient_strhasharray_get(items, i));
789
+ }
790
+
791
+ unsigned long cond2 = rho_connectclient_hash_create();
792
+ rho_connectclient_hash_put(cond2, "name", g_product_test_name.c_str());
793
+
794
+ unsigned long items2 = rho_connectclient_find_all(g_szProduct, cond2 );
795
+ EXPECT_NE( items2, 0 );
796
+
797
+ for ( int i = 0; i < rho_connectclient_strhasharray_size(items2); i++ )
798
+ {
799
+ rho_connectclient_itemdestroy(g_szProduct, rho_connectclient_strhasharray_get(items2, i));
800
+ }
801
+
802
+ unsigned long cond3 = rho_connectclient_hash_create();
803
+ rho_connectclient_hash_put(cond3, "first", "CustTest1");
804
+ rho_connectclient_itemdestroy(g_szCustomer, cond3);
805
+
806
+ unsigned long cond4 = rho_connectclient_hash_create();
807
+ rho_connectclient_hash_put(cond4, "first", "CustTest2");
808
+ rho_connectclient_itemdestroy(g_szCustomer, cond4);
809
+
810
+ char* szRes = (char*)rho_sync_doSyncSourceByName(g_szProduct);
811
+ RHO_CONNECT_NOTIFY oNotify = {0};
812
+ rho_connectclient_parsenotify(szRes, &oNotify);
813
+
814
+ EXPECT_EQ(String(oNotify.status), "ok");
815
+ EXPECT_EQ(oNotify.error_code, RHO_ERR_NONE);
816
+
817
+ unsigned long item2 = rho_connectclient_find_first(g_szProduct, cond );
818
+ EXPECT_EQ(item2, 0);
819
+
820
+ rho_connectclient_hash_delete(cond);
821
+ rho_connectclient_hash_delete(cond2);
822
+ rho_connectclient_hash_delete(cond3);
823
+ rho_connectclient_hash_delete(cond4);
824
+ rho_connectclient_strhasharray_delete(items);
825
+ }
826
+
827
+ extern "C" void rho_free_callbackdata(void* pData)
828
+ {
829
+ //It is used in SyncClient.
830
+ }