rhoconnect-client 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/CREDITS +0 -0
- data/LICENSE +9 -0
- data/README.md +47 -0
- data/ext/rhoconnect-client/RhoConnectClient.rb +190 -0
- data/ext/rhoconnect-client/ext/RhoConnectClient.xml +726 -0
- data/ext/rhoconnect-client/ext/build +26 -0
- data/ext/rhoconnect-client/ext/build.bat +30 -0
- data/ext/rhoconnect-client/ext/platform/android/ext_java.files +1 -0
- data/ext/rhoconnect-client/ext/platform/android/ext_native.files +14 -0
- data/ext/rhoconnect-client/ext/platform/android/src/com/rhoconnectclient/RhoconnectClient.java +1 -0
- data/ext/rhoconnect-client/ext/platform/iphone/.gitignore +1 -0
- data/ext/rhoconnect-client/ext/platform/iphone/Rakefile +74 -0
- data/ext/rhoconnect-client/ext/platform/iphone/RhoconnectClient.xcodeproj/project.pbxproj +390 -0
- data/ext/rhoconnect-client/ext/platform/iphone/RhoconnectClient_Prefix.pch +7 -0
- data/ext/rhoconnect-client/ext/platform/iphone/impl/readme.txt +7 -0
- data/ext/rhoconnect-client/ext/platform/qt/Rakefile +35 -0
- data/ext/rhoconnect-client/ext/platform/qt/rhoconnect-client.pro +88 -0
- data/ext/rhoconnect-client/ext/platform/wm/Rhoconnect-client.sln +36 -0
- data/ext/rhoconnect-client/ext/platform/wm/Rhoconnect-client.vcproj +774 -0
- data/ext/rhoconnect-client/ext/platform/wm/Rhoconnect-client.vsprops +15 -0
- data/ext/rhoconnect-client/ext/platform/wm/src/rhoconnectclient_wm.cpp +40 -0
- data/ext/rhoconnect-client/ext/platform/wm/src/rhoconnectclient_wm.h +2 -0
- data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.props +22 -0
- data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.sln +32 -0
- data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.vcxproj +220 -0
- data/ext/rhoconnect-client/ext/platform/wp8/Rhoconnect-client.vcxproj.filters +103 -0
- data/ext/rhoconnect-client/ext/shared/RhoConnectClientImpl.cpp +273 -0
- data/ext/rhoconnect-client/ext/shared/RhoConnectClientImpl.h +60 -0
- data/ext/rhoconnect-client/ext/shared/RhoConnectClientSingletonImpl.h +53 -0
- data/ext/rhoconnect-client/ext/shared/initRhoconnectClient.cpp +207 -0
- data/ext/rhoconnect-client/ext/shared/rhoconnectclient.c +18 -0
- data/ext/rhoconnect-client/ext/shared/sync/ClientRegister.cpp +398 -0
- data/ext/rhoconnect-client/ext/shared/sync/ClientRegister.h +147 -0
- data/ext/rhoconnect-client/ext/shared/sync/ISyncProtocol.h +91 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncEngine.cpp +1245 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncEngine.h +213 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncNotify.cpp +737 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncNotify.h +209 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncProtocol_3.h +220 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncProtocol_4.h +259 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncSource.cpp +1694 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncSource.h +212 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncThread.cpp +583 -0
- data/ext/rhoconnect-client/ext/shared/sync/SyncThread.h +250 -0
- data/ext/rhoconnect-client/ext.yml +12 -0
- data/lib/build/run_rhoconnect_spec.rb +135 -0
- data/lib/rhoconnect-client.rb +3 -0
- data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +1673 -0
- data/platform/shared/RhoConnectClient/RhoConnectClient.h +181 -0
- data/platform/shared/RhoConnectClient/RhoError.h +77 -0
- data/rhoconnect-client/C++/Tests/RhoConnectClientTest.cpp +830 -0
- data/rhoconnect-client/C++/Tests/win32/.gitignore +3 -0
- data/rhoconnect-client/C++/Tests/win32/RhoConnectClient.sln +65 -0
- data/rhoconnect-client/C++/Tests/win32/RhoConnectClient.vcproj +634 -0
- data/rhoconnect-client/C++/Tests/win32/RhoConnectClientTest/RhoConnectClientTest.vcproj +222 -0
- data/rhoconnect-client/C++/Tests/win32/RhoConnectClientTest/stdafx.h +65 -0
- data/rhoconnect-client/C++/Tests/win32/stdafx.h +65 -0
- data/rhoconnect-client/CHANGELOG +18 -0
- data/rhoconnect-client/Java/Android/build/android.rake +387 -0
- data/rhoconnect-client/Java/Android/build/android_sdk.rb +582 -0
- data/rhoconnect-client/Java/Android/build/libcurl_build.files +73 -0
- data/rhoconnect-client/Java/Android/build/libjson_build.files +9 -0
- data/rhoconnect-client/Java/Android/build/librhocommon_build.files +14 -0
- data/rhoconnect-client/Java/Android/build/librhodb_build.files +5 -0
- data/rhoconnect-client/Java/Android/build/librhoimpl_build.files +13 -0
- data/rhoconnect-client/Java/Android/build/librholog_build.files +4 -0
- data/rhoconnect-client/Java/Android/build/libsqlite_build.files +1 -0
- data/rhoconnect-client/Java/Android/build/libsync_build.files +7 -0
- data/rhoconnect-client/Java/Android/build/libunzip_build.files +1 -0
- data/rhoconnect-client/Java/Android/build/rhoconnectclient_build.files +3 -0
- data/rhoconnect-client/Java/Android/build/rhoimpljava_build.files +21 -0
- data/rhoconnect-client/Java/Android/src/com/rhomobile/rhodes/Capabilities.java +63 -0
- data/rhoconnect-client/Java/Android/src/com/rhomobile/rhodes/MemoryInfoCollector.java +79 -0
- data/rhoconnect-client/Java/Android/src/com/rhomobile/rhodes/util/ContextFactory.java +63 -0
- data/rhoconnect-client/Java/Android/test/.classpath +9 -0
- data/rhoconnect-client/Java/Android/test/.project +33 -0
- data/rhoconnect-client/Java/Android/test/AndroidManifest.xml +14 -0
- data/rhoconnect-client/Java/Android/test/assets/apps/androidtest.png +0 -0
- data/rhoconnect-client/Java/Android/test/assets/apps/rhoconfig.txt +19 -0
- data/rhoconnect-client/Java/Android/test/assets/apps/rhoconfig.txt.timestamp +1 -0
- data/rhoconnect-client/Java/Android/test/assets/db/syncdb.schema +44 -0
- data/rhoconnect-client/Java/Android/test/assets/db/syncdb.triggers +10 -0
- data/rhoconnect-client/Java/Android/test/assets/db/syncdb_java.triggers +21 -0
- data/rhoconnect-client/Java/Android/test/assets/rho.dat +9 -0
- data/rhoconnect-client/Java/Android/test/proguard.cfg +36 -0
- data/rhoconnect-client/Java/Android/test/project.properties +11 -0
- data/rhoconnect-client/Java/Android/test/res/drawable-hdpi/icon.png +0 -0
- data/rhoconnect-client/Java/Android/test/res/drawable-ldpi/icon.png +0 -0
- data/rhoconnect-client/Java/Android/test/res/drawable-mdpi/icon.png +0 -0
- data/rhoconnect-client/Java/Android/test/res/layout/main.xml +12 -0
- data/rhoconnect-client/Java/Android/test/res/values/strings.xml +5 -0
- data/rhoconnect-client/Java/Android/test/rhoimpl.jar +0 -0
- data/rhoconnect-client/Java/Android/test/src/com/rhomobile/rhoconnect_client_test/TestRhoConnectClient.java +343 -0
- data/rhoconnect-client/Java/Android/test/src/com/rhomobile/rhoconnect_client_test/TestRhoConnectClientBlobs.java +219 -0
- data/rhoconnect-client/Java/RhoConnect/.classpath +6 -0
- data/rhoconnect-client/Java/RhoConnect/.project +93 -0
- data/rhoconnect-client/Java/RhoConnect/assets/apps/rhoconfig.txt +19 -0
- data/rhoconnect-client/Java/RhoConnect/assets/apps/rhoconfig.txt.timestamp +1 -0
- data/rhoconnect-client/Java/RhoConnect/assets/db/syncdb.schema +44 -0
- data/rhoconnect-client/Java/RhoConnect/assets/db/syncdb.triggers +10 -0
- data/rhoconnect-client/Java/RhoConnect/assets/db/syncdb_java.triggers +21 -0
- data/rhoconnect-client/Java/RhoConnect/assets/rho.dat +8 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/RhoConnectJniNotify.h +61 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectClient.h +181 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectNotify.h +13 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectNotify_IDelegate.h +13 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectObjectNotify.h +13 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectObjectNotify_IDelegate.h +13 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhomModel.h +103 -0
- data/rhoconnect-client/Java/RhoConnect/jni/include/rhojava.inc +76 -0
- data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniClient.cpp +401 -0
- data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniModel.cpp +332 -0
- data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniNotify.cpp +223 -0
- data/rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectUtil.cpp +82 -0
- data/rhoconnect-client/Java/RhoConnect/jni/src/RhodesApp.cpp +114 -0
- data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectClient.java +108 -0
- data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectNotify.java +78 -0
- data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectObjectNotify.java +71 -0
- data/rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhomModel.java +195 -0
- data/rhoconnect-client/JavaScript/.classpath +10 -0
- data/rhoconnect-client/JavaScript/.gitignore +4 -0
- data/rhoconnect-client/JavaScript/.project +17 -0
- data/rhoconnect-client/JavaScript/README.textile +1 -0
- data/rhoconnect-client/JavaScript/build.xml +185 -0
- data/rhoconnect-client/JavaScript/doc/fsm-sample.js +44 -0
- data/rhoconnect-client/JavaScript/doc/fsm-sample.png +0 -0
- data/rhoconnect-client/JavaScript/src/RhoSyncJS.gwt.xml +21 -0
- data/rhoconnect-client/JavaScript/stubs/RhoSyncStubsJS.gwt.xml +21 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/Capabilities.java +7 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/IRhoRubyHelper.java +7 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/Mutex.java +5 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhoAppAdapter.java +39 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhoClassFactory.java +29 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhoConf.java +100 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhoEmptyLogger.java +7 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhoEmptyProfiler.java +5 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhoLogger.java +32 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhoProfiler.java +27 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/RhodesApp.java +25 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/TimeInterval.java +22 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/Tokenizer.java +23 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/db/DBAdapter.java +174 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/db/DBAttrManager.java +15 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/db/DBException.java +5 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/db/IDBResult.java +27 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/file/IFileAccess.java +7 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/file/SimpleFile.java +15 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/net/IHttpConnection.java +22 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/net/NetRequest.java +324 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/net/NetResponse.java +51 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/net/URI.java +64 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/sync/ClientRegister.java +15 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/sync/JSONArrayIterator.java +37 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/sync/JSONEntry.java +48 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/sync/JSONStructIterator.java +41 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/sync/SyncNotify.java +98 -0
- data/rhoconnect-client/JavaScript/stubs/com/rho/sync/SyncThread.java +92 -0
- data/rhoconnect-client/JavaScript/war/WEB-INF/lib/gwt-servlet-deps.jar +0 -0
- data/rhoconnect-client/JavaScript/war/WEB-INF/lib/gwt-servlet.jar +0 -0
- data/rhoconnect-client/JavaScript/war/js/fsm-sample.js +54 -0
- data/rhoconnect-client/JavaScript/war/js/rhosync-api.js +237 -0
- data/rhoconnect-client/JavaScript/war/js/rhosync-fsm.js +307 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/4C71D69C9BBC9E6F05C6BA49B01BCBC1.cache.html +3122 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/5146F4FFF34511C8BB2661E920B49E3A.cache.html +3254 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/5248C67481D9D27AD0703D15CDBD2A1C.cache.html +3147 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/EE1DC2692C9C32367B53A39E2358AF23.cache.html +3195 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/clear.cache.gif +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/corner.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/corner_ie6.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/hborder.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/hborder_ie6.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/corner_dialog_topleft.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/corner_dialog_topright.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/hborder_blue_shadow.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/hborder_gray_shadow.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/vborder_blue_shadow.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/ie6/vborder_gray_shadow.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/splitPanelThumb.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/vborder.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/images/vborder_ie6.png +0 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/standard.css +1144 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/gwt/standard/standard_rtl.css +1145 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/hosted.html +350 -0
- data/rhoconnect-client/JavaScript/war/rhosyncjs/rhosyncjs.nocache.js +314 -0
- data/rhoconnect-client/JavaScript/war/test/SpecRunner.html +35 -0
- data/rhoconnect-client/JavaScript/war/test/dbtest.html +38 -0
- data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/MIT.LICENSE +20 -0
- data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/jasmine-html.js +188 -0
- data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/jasmine.css +166 -0
- data/rhoconnect-client/JavaScript/war/test/lib/jasmine-1.0.1/jasmine.js +2421 -0
- data/rhoconnect-client/JavaScript/war/test/spec/SpecHelper.js +7 -0
- data/rhoconnect-client/JavaScript/war/test/spec/SyncApiSpec.js +573 -0
- data/rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js +58 -0
- data/rhoconnect-client/JavaScript/war/test/worker-test.js +17 -0
- data/rhoconnect-client/LICENSE +41 -0
- data/rhoconnect-client/ObjectiveC/RhoConnectClient.h +118 -0
- data/rhoconnect-client/ObjectiveC/RhoConnectClient.m +641 -0
- data/rhoconnect-client/ObjectiveC/RhoConnectClient.xcodeproj/project.pbxproj +1434 -0
- data/rhoconnect-client/ObjectiveC/RhoConnectNotify.h +83 -0
- data/rhoconnect-client/ObjectiveC/RhoConnectNotify.m +181 -0
- data/rhoconnect-client/ObjectiveC/RhoConnectObjectNotify.h +65 -0
- data/rhoconnect-client/ObjectiveC/RhoConnectObjectNotify.m +73 -0
- data/rhoconnect-client/ObjectiveC/RhomModel.h +101 -0
- data/rhoconnect-client/ObjectiveC/RhomModel.m +320 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/MainWindow.xib +198 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTest-Info.plist +30 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTest.xcodeproj/project.pbxproj +373 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTestAppDelegate.h +58 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTestAppDelegate.m +84 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTest_Prefix.pch +8 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/invalid_import_db.zip +0 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/main.m +1096 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/test.png +0 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/test2.png +0 -0
- data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/valid_import_db.zip +0 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsAppDelegate.h +62 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsAppDelegate.m +35 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsViewController.h +78 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/Classes/ptestsViewController.m +549 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/MainWindow.xib +227 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/main.m +17 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/ptests-Info.plist +30 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/ptests.xcodeproj/project.pbxproj +363 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/ptestsViewController.xib +641 -0
- data/rhoconnect-client/ObjectiveC/Tests/ptests/ptests_Prefix.pch +8 -0
- data/rhoconnect-client/README.textile +23 -0
- data/rhoconnect-client/Rakefile +20 -0
- data/rhoconnect-client/Samples/Java/android_store/.classpath +8 -0
- data/rhoconnect-client/Samples/Java/android_store/.project +33 -0
- data/rhoconnect-client/Samples/Java/android_store/AndroidManifest.xml +24 -0
- data/rhoconnect-client/Samples/Java/android_store/assets/apps/rhoconfig.txt +19 -0
- data/rhoconnect-client/Samples/Java/android_store/assets/apps/rhoconfig.txt.timestamp +1 -0
- data/rhoconnect-client/Samples/Java/android_store/assets/db/syncdb.schema +44 -0
- data/rhoconnect-client/Samples/Java/android_store/assets/db/syncdb.triggers +10 -0
- data/rhoconnect-client/Samples/Java/android_store/assets/db/syncdb_java.triggers +21 -0
- data/rhoconnect-client/Samples/Java/android_store/assets/rho.dat +8 -0
- data/rhoconnect-client/Samples/Java/android_store/default.properties +11 -0
- data/rhoconnect-client/Samples/Java/android_store/project.properties +14 -0
- data/rhoconnect-client/Samples/Java/android_store/res/drawable-hdpi/icon.png +0 -0
- data/rhoconnect-client/Samples/Java/android_store/res/drawable-ldpi/icon.png +0 -0
- data/rhoconnect-client/Samples/Java/android_store/res/drawable-mdpi/icon.png +0 -0
- data/rhoconnect-client/Samples/Java/android_store/res/layout/main.xml +12 -0
- data/rhoconnect-client/Samples/Java/android_store/res/values/strings.xml +5 -0
- data/rhoconnect-client/Samples/Java/android_store/rhoimpl.jar +0 -0
- data/rhoconnect-client/Samples/Java/android_store/src/com/rhomobile/android_store/StoreActivity.java +68 -0
- data/rhoconnect-client/Samples/Java/android_store/src/com/rhomobile/android_store/StoreApplication.java +15 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/LoginViewController.h +70 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/LoginViewController.m +94 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RhoConnectEngine.h +82 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RhoConnectEngine.m +119 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RootViewController.h +63 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/RootViewController.m +314 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/WaitLoginController.h +65 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/WaitLoginController.m +110 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/storeAppDelegate.h +61 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/Classes/storeAppDelegate.m +171 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/LoginViewController.xib +779 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/MainWindow.xib +580 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/RootViewController.xib +384 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/WaitLoginController.xib +557 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/icon.png +0 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/main.m +22 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/store-Info.plist +30 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/store.xcodeproj/project.pbxproj +367 -0
- data/rhoconnect-client/Samples/ObjectiveC/store/store_Prefix.pch +14 -0
- data/rhoconnect-client/build.yml +3 -0
- data/rhoconnect-client/version +1 -0
- metadata +314 -0
data/rhoconnect-client/ObjectiveC/Tests/RhoConnectClientTest/RhoConnectClientTestAppDelegate.m
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
//
|
2
|
+
// SyncClientTestAppDelegate.m
|
3
|
+
// SyncClientTest
|
4
|
+
//
|
5
|
+
// Created by evgeny vovchenko on 8/19/10.
|
6
|
+
// Copyright RhoMobile 2010. All rights reserved.
|
7
|
+
// Copyright Symbol Technologies 2011-2016. All rights reserved.
|
8
|
+
//
|
9
|
+
|
10
|
+
#import "SyncClientTestAppDelegate.h"
|
11
|
+
|
12
|
+
@implementation SyncClientTestAppDelegate
|
13
|
+
|
14
|
+
@synthesize window;
|
15
|
+
|
16
|
+
|
17
|
+
#pragma mark -
|
18
|
+
#pragma mark Application lifecycle
|
19
|
+
|
20
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
21
|
+
|
22
|
+
// Override point for customization after application launch.
|
23
|
+
|
24
|
+
[window makeKeyAndVisible];
|
25
|
+
|
26
|
+
return YES;
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
- (void)applicationWillResignActive:(UIApplication *)application {
|
31
|
+
/*
|
32
|
+
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
33
|
+
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
34
|
+
*/
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
39
|
+
/*
|
40
|
+
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
41
|
+
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
42
|
+
*/
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
47
|
+
/*
|
48
|
+
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
49
|
+
*/
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
54
|
+
/*
|
55
|
+
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
56
|
+
*/
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
- (void)applicationWillTerminate:(UIApplication *)application {
|
61
|
+
/*
|
62
|
+
Called when the application is about to terminate.
|
63
|
+
See also applicationDidEnterBackground:.
|
64
|
+
*/
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
#pragma mark -
|
69
|
+
#pragma mark Memory management
|
70
|
+
|
71
|
+
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
|
72
|
+
/*
|
73
|
+
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
|
74
|
+
*/
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
- (void)dealloc {
|
79
|
+
[window release];
|
80
|
+
[super dealloc];
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
@end
|
Binary file
|
@@ -0,0 +1,1096 @@
|
|
1
|
+
//
|
2
|
+
// main.m
|
3
|
+
// SyncClientTest
|
4
|
+
//
|
5
|
+
// Created by evgeny vovchenko on 8/19/10.
|
6
|
+
// Copyright RhoMobile 2010. All rights reserved.
|
7
|
+
// Copyright Symbol Technologies 2011-2016. All rights reserved.
|
8
|
+
//
|
9
|
+
|
10
|
+
#import <UIKit/UIKit.h>
|
11
|
+
#import "../../RhoConnectClient.h"
|
12
|
+
|
13
|
+
RhoConnectClient* sclient;
|
14
|
+
|
15
|
+
RhomModel* customer;
|
16
|
+
RhomModel* product;
|
17
|
+
RhomModel* perftest;
|
18
|
+
RhomModel* blobTest;
|
19
|
+
|
20
|
+
NSFileManager* fileManager;
|
21
|
+
|
22
|
+
int ResetAndLogout()
|
23
|
+
{
|
24
|
+
[sclient database_full_reset_and_logout];
|
25
|
+
if ([sclient is_logged_in])
|
26
|
+
return 0;
|
27
|
+
|
28
|
+
return 1;
|
29
|
+
}
|
30
|
+
|
31
|
+
int shouldNotSyncWithoutLogin()
|
32
|
+
{
|
33
|
+
return 1;
|
34
|
+
}
|
35
|
+
|
36
|
+
int shouldFindBySql()
|
37
|
+
{
|
38
|
+
NSMutableArray* items = [product find_bysql:@"SELECT * FROM sources" args: nil];
|
39
|
+
if ( !items )
|
40
|
+
return 0;
|
41
|
+
|
42
|
+
if ( [items count] != 3 )
|
43
|
+
return 0;
|
44
|
+
|
45
|
+
NSArray* params = [NSArray arrayWithObjects: product.name, nil];
|
46
|
+
NSMutableArray* items2 = [product find_bysql:@"SELECT * FROM sources WHERE name=?" args: params];
|
47
|
+
if ( !items2 )
|
48
|
+
return 0;
|
49
|
+
|
50
|
+
if ( [items2 count] != 1 )
|
51
|
+
return 0;
|
52
|
+
|
53
|
+
return 1;
|
54
|
+
}
|
55
|
+
|
56
|
+
int shouldLogin()
|
57
|
+
{
|
58
|
+
RhoConnectNotify* res = [sclient loginWithUser:@"test" pwd:@""];
|
59
|
+
int nErr = res.error_code;
|
60
|
+
if ( nErr!= RHO_ERR_NONE || ![sclient is_logged_in]) {
|
61
|
+
return 0;
|
62
|
+
}
|
63
|
+
|
64
|
+
return 1;
|
65
|
+
}
|
66
|
+
|
67
|
+
int shouldLogout()
|
68
|
+
{
|
69
|
+
[sclient logout];
|
70
|
+
if ([sclient is_logged_in]) {
|
71
|
+
return 0;
|
72
|
+
}
|
73
|
+
|
74
|
+
return 1;
|
75
|
+
}
|
76
|
+
|
77
|
+
int shouldSyncProductByName()
|
78
|
+
{
|
79
|
+
RhoConnectNotify* res = [product sync];
|
80
|
+
int nErr = res.error_code;
|
81
|
+
if ( nErr!= RHO_ERR_NONE ) {
|
82
|
+
return 0;
|
83
|
+
}
|
84
|
+
|
85
|
+
return 1;
|
86
|
+
}
|
87
|
+
|
88
|
+
int shouldSearchProduct()
|
89
|
+
{
|
90
|
+
return 1;
|
91
|
+
}
|
92
|
+
|
93
|
+
@interface CObjectCallback : NSObject {
|
94
|
+
}
|
95
|
+
@property(readonly) RhoConnectObjectNotify* m_pNotify;
|
96
|
+
|
97
|
+
- (id) init;
|
98
|
+
- (void)objectNotifyCallback:(RhoConnectObjectNotify*) notify;
|
99
|
+
@end
|
100
|
+
|
101
|
+
@implementation CObjectCallback
|
102
|
+
@synthesize m_pNotify;
|
103
|
+
- (id) init
|
104
|
+
{
|
105
|
+
self = [super init];
|
106
|
+
|
107
|
+
[sclient setObjectNotification:@selector(objectNotifyCallback:) target:self];
|
108
|
+
return self;
|
109
|
+
}
|
110
|
+
|
111
|
+
- (void)objectNotifyCallback:(RhoConnectObjectNotify*) notify
|
112
|
+
{
|
113
|
+
m_pNotify = notify;
|
114
|
+
}
|
115
|
+
@end
|
116
|
+
|
117
|
+
int shouldCreateNewProduct()
|
118
|
+
{
|
119
|
+
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
120
|
+
[item setValue:@"Test" forKey:@"name"];
|
121
|
+
[item setValue:@"123" forKey:@"sku"];
|
122
|
+
[product create:item];
|
123
|
+
if ( [item objectForKey:@"object"] == NULL || [item objectForKey:@"source_id"] == NULL )
|
124
|
+
return 0;
|
125
|
+
|
126
|
+
if ( ![product is_changed] )
|
127
|
+
return 0;
|
128
|
+
|
129
|
+
NSDictionary* item2 = [product find:[item valueForKey:@"object"]];
|
130
|
+
if ( ![item2 isEqualToDictionary: item])
|
131
|
+
return 0;
|
132
|
+
|
133
|
+
CObjectCallback* pObjectCallback = [[ CObjectCallback alloc] init];
|
134
|
+
[sclient addObjectNotify: [[item objectForKey:@"source_id"] intValue] szObject:[item valueForKey:@"object"] ];
|
135
|
+
|
136
|
+
RhoConnectNotify* res = [product sync];
|
137
|
+
if ( res.error_code!= RHO_ERR_NONE )
|
138
|
+
return 0;
|
139
|
+
|
140
|
+
NSDictionary* item3 = [product find:[item valueForKey:@"object"]];
|
141
|
+
if ( item3 )
|
142
|
+
return 0;
|
143
|
+
/*
|
144
|
+
if ( !pObjectCallback.m_pNotify.created_objects )
|
145
|
+
return 0;
|
146
|
+
|
147
|
+
if ( [pObjectCallback.m_pNotify.created_objects count] <= 0 )
|
148
|
+
return 0;
|
149
|
+
|
150
|
+
if ( [[pObjectCallback.m_pNotify.created_objects objectAtIndex:0] compare: [item valueForKey:@"object"]] != 0 )
|
151
|
+
return 0;
|
152
|
+
*/
|
153
|
+
if ( [product is_changed] )
|
154
|
+
return 0;
|
155
|
+
|
156
|
+
if ( [sclient is_syncing] )
|
157
|
+
return 0;
|
158
|
+
|
159
|
+
[item release];
|
160
|
+
[pObjectCallback release];
|
161
|
+
|
162
|
+
return 1;
|
163
|
+
}
|
164
|
+
|
165
|
+
int shouldModifyProduct()
|
166
|
+
{
|
167
|
+
NSMutableDictionary* cond = [[NSMutableDictionary alloc] init];
|
168
|
+
[cond setValue:@"Test" forKey:@"name"];
|
169
|
+
|
170
|
+
NSMutableDictionary* item = [product find_first: cond];
|
171
|
+
if ( !item )
|
172
|
+
return 0;
|
173
|
+
|
174
|
+
NSString* saved_object = [NSString stringWithString: [item valueForKey:@"object"]];
|
175
|
+
NSMutableString* new_sku = [[NSMutableString alloc]init];
|
176
|
+
if ( [item valueForKey:@"sku"] != nil)
|
177
|
+
{
|
178
|
+
[new_sku appendString:[item valueForKey:@"sku"]];
|
179
|
+
}
|
180
|
+
|
181
|
+
[new_sku appendString: @"_TEST"];
|
182
|
+
|
183
|
+
[item setValue:new_sku forKey:@"sku"];
|
184
|
+
[product save: item];
|
185
|
+
|
186
|
+
RhoConnectNotify* res = [product sync];
|
187
|
+
if ( res.error_code!= RHO_ERR_NONE )
|
188
|
+
return 0;
|
189
|
+
|
190
|
+
NSDictionary* item3 = [product find: saved_object];
|
191
|
+
if ( !item3 )
|
192
|
+
return 0;
|
193
|
+
|
194
|
+
if ( ![[item3 valueForKey:@"sku"] isEqual: [item valueForKey:@"sku"]])
|
195
|
+
return 0;
|
196
|
+
|
197
|
+
[cond release];
|
198
|
+
[new_sku release];
|
199
|
+
|
200
|
+
return 1;
|
201
|
+
}
|
202
|
+
|
203
|
+
int shouldProcessCreateError()
|
204
|
+
{
|
205
|
+
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
206
|
+
[item setValue:@"Test" forKey:@"name"];
|
207
|
+
[product create:item];
|
208
|
+
if ( [item objectForKey:@"object"] == NULL || [item objectForKey:@"source_id"] == NULL )
|
209
|
+
return 0;
|
210
|
+
|
211
|
+
NSMutableString* err_resp = [NSMutableString stringWithString:@"[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":0},{\"total_count\":0},{\"create-error\":{\""];
|
212
|
+
[err_resp appendString: [item objectForKey:@"object"]];
|
213
|
+
[err_resp appendString: @"\":{\"name\":\"wrongname\",\"an_attribute\":\"error create\"},\""];
|
214
|
+
[err_resp appendString: [item objectForKey:@"object"]];
|
215
|
+
[err_resp appendString: @"-error\":{\"message\":\"error create\"}}}]"];
|
216
|
+
[sclient setSourceProperty: [product source_id] szPropName:@"rho_server_response" szPropValue:err_resp];
|
217
|
+
|
218
|
+
RhoConnectNotify* res = [product sync];
|
219
|
+
if ( ![res hasCreateErrors] )
|
220
|
+
return 0;
|
221
|
+
|
222
|
+
NSString* msg = [res.create_errors objectForKey:[item objectForKey:@"object"]];
|
223
|
+
if ( (msg == NULL ) || ( [msg compare:@"error create"]!=0 ) )
|
224
|
+
return 0;
|
225
|
+
|
226
|
+
[sclient onCreateError: res action: @"delete"];
|
227
|
+
|
228
|
+
NSArray* params = [NSArray arrayWithObjects: [item objectForKey:@"object"], nil];
|
229
|
+
NSMutableArray* items2 = [product find_bysql:@"SELECT * FROM changed_values WHERE object=?" args: params];
|
230
|
+
if ( !items2 )
|
231
|
+
return 0;
|
232
|
+
|
233
|
+
if ( [items2 count] != 0 )
|
234
|
+
return 0;
|
235
|
+
|
236
|
+
items2 = [product find_bysql:@"SELECT * FROM changed_values WHERE update_type='create'" args: nil];
|
237
|
+
if ( !items2 )
|
238
|
+
return 0;
|
239
|
+
|
240
|
+
if ( [items2 count] != 0 )
|
241
|
+
return 0;
|
242
|
+
|
243
|
+
[product find_bysql:@"DELETE FROM changed_values" args: nil];
|
244
|
+
|
245
|
+
return 1;
|
246
|
+
}
|
247
|
+
|
248
|
+
int shouldProcessUpdateError()
|
249
|
+
{
|
250
|
+
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
251
|
+
[item setValue:@"Test" forKey:@"name"];
|
252
|
+
[product create:item];
|
253
|
+
if ( [item objectForKey:@"object"] == NULL || [item objectForKey:@"source_id"] == NULL )
|
254
|
+
return 0;
|
255
|
+
|
256
|
+
NSMutableString* err_resp = [NSMutableString stringWithString:@"[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":0},{\"total_count\":0},{\"update-rollback\": {\""];
|
257
|
+
[err_resp appendString: [item objectForKey:@"object"]];
|
258
|
+
[err_resp appendString: @"\": {\"name\": \"OLD_NAME\"}},\"update-error\":{\""];
|
259
|
+
[err_resp appendString: [item objectForKey:@"object"]];
|
260
|
+
[err_resp appendString: @"\":{\"name\":\"wrongname\",\"an_attribute\":\"error update\"},\""];
|
261
|
+
[err_resp appendString: [item objectForKey:@"object"]];
|
262
|
+
[err_resp appendString: @"-error\":{\"message\":\"error update\"}}}]"];
|
263
|
+
[sclient setSourceProperty: [product source_id] szPropName:@"rho_server_response" szPropValue:err_resp];
|
264
|
+
|
265
|
+
RhoConnectNotify* res = [product sync];
|
266
|
+
if ( ![res hasUpdateErrors] )
|
267
|
+
return 0;
|
268
|
+
|
269
|
+
NSString* msg = [res.update_errors objectForKey:[item objectForKey:@"object"]];
|
270
|
+
if ( (msg == NULL ) || ( [msg compare:@"error update"]!=0 ) )
|
271
|
+
return 0;
|
272
|
+
|
273
|
+
[sclient onUpdateError: res action: @"rollback"];
|
274
|
+
|
275
|
+
NSMutableArray* items2 = [product find_bysql:@"SELECT * FROM changed_values WHERE update_type='update'" args: nil];
|
276
|
+
if ( !items2 )
|
277
|
+
return 0;
|
278
|
+
|
279
|
+
if ( [items2 count] != 0 )
|
280
|
+
return 0;
|
281
|
+
|
282
|
+
return 1;
|
283
|
+
}
|
284
|
+
|
285
|
+
int shouldProcessDeleteError()
|
286
|
+
{
|
287
|
+
NSString* 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\"}}}]";
|
288
|
+
[sclient setSourceProperty: [product source_id] szPropName:@"rho_server_response" szPropValue:err_resp];
|
289
|
+
|
290
|
+
RhoConnectNotify* res = [product sync];
|
291
|
+
if ( ![res hasDeleteErrors] )
|
292
|
+
return 0;
|
293
|
+
|
294
|
+
if ( (res.delete_errors==NULL) || ([res.delete_errors count] != 1) )
|
295
|
+
return 0;
|
296
|
+
|
297
|
+
for ( NSString* key in res.delete_errors )
|
298
|
+
{
|
299
|
+
NSString* msg = [res.delete_errors objectForKey:key];
|
300
|
+
if ( (msg==NULL) || ([msg compare:@"Error delete record"]!=0) )
|
301
|
+
{
|
302
|
+
return 0;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
[sclient onDeleteError: res action: @"retry"];
|
307
|
+
|
308
|
+
NSMutableArray* items2 = [product find_bysql:@"SELECT * FROM changed_values WHERE update_type='delete'" args: nil];
|
309
|
+
if ( !items2 )
|
310
|
+
return 0;
|
311
|
+
|
312
|
+
if ( [items2 count] != 2 )
|
313
|
+
return 0;
|
314
|
+
|
315
|
+
return 1;
|
316
|
+
}
|
317
|
+
|
318
|
+
int shouldProcessServerErrors()
|
319
|
+
{
|
320
|
+
|
321
|
+
if ( !shouldProcessCreateError() )
|
322
|
+
return 0;
|
323
|
+
|
324
|
+
if ( !shouldProcessUpdateError() )
|
325
|
+
return 0;
|
326
|
+
|
327
|
+
if ( !shouldProcessDeleteError() )
|
328
|
+
return 0;
|
329
|
+
|
330
|
+
[sclient setSourceProperty: [product source_id] szPropName:@"rho_server_response" szPropValue:@""];
|
331
|
+
|
332
|
+
return 1;
|
333
|
+
}
|
334
|
+
|
335
|
+
int shouldDeleteAllTestProduct()
|
336
|
+
{
|
337
|
+
NSMutableDictionary* cond = [[NSMutableDictionary alloc] init];
|
338
|
+
[cond setValue:@"Test" forKey:@"name"];
|
339
|
+
|
340
|
+
NSMutableArray* items = [product find_all:cond];
|
341
|
+
if ( !items )
|
342
|
+
return 0;
|
343
|
+
|
344
|
+
for( NSDictionary* item in items)
|
345
|
+
{
|
346
|
+
[product destroy: item];
|
347
|
+
}
|
348
|
+
|
349
|
+
RhoConnectNotify* res = [product sync];
|
350
|
+
//if ( res.error_code!= RHO_ERR_NONE )
|
351
|
+
// return 0;
|
352
|
+
|
353
|
+
NSMutableDictionary* item = [product find_first:cond];
|
354
|
+
if ( item )
|
355
|
+
return 0;
|
356
|
+
|
357
|
+
[cond release];
|
358
|
+
return 1;
|
359
|
+
}
|
360
|
+
|
361
|
+
int shouldPerfomanceTest_create(int nCount)
|
362
|
+
{
|
363
|
+
[perftest startBulkUpdate];
|
364
|
+
for (int i = 0; i < nCount; i++)
|
365
|
+
{
|
366
|
+
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
367
|
+
[item setValue: [NSString stringWithFormat:@"Test%d", i] forKey:@"name"];
|
368
|
+
[perftest create:item];
|
369
|
+
}
|
370
|
+
[perftest stopBulkUpdate];
|
371
|
+
|
372
|
+
return 1;
|
373
|
+
}
|
374
|
+
|
375
|
+
int shouldPerfomanceTest_delete()
|
376
|
+
{
|
377
|
+
NSMutableArray* items = [perftest find_all:nil];
|
378
|
+
if ( !items )
|
379
|
+
return 0;
|
380
|
+
|
381
|
+
[perftest startBulkUpdate];
|
382
|
+
for( NSDictionary* item in items)
|
383
|
+
{
|
384
|
+
[perftest destroy: item];
|
385
|
+
}
|
386
|
+
[perftest stopBulkUpdate];
|
387
|
+
|
388
|
+
return 1;
|
389
|
+
}
|
390
|
+
|
391
|
+
int shouldCreateNewProductWithCustomers()
|
392
|
+
{
|
393
|
+
NSMutableDictionary* cust1;
|
394
|
+
NSMutableDictionary* cust2;
|
395
|
+
NSMutableDictionary* item;
|
396
|
+
|
397
|
+
// exception to throw on test failure
|
398
|
+
NSException *e = [NSException
|
399
|
+
exceptionWithName: @"NSException"
|
400
|
+
reason: @"test faled"
|
401
|
+
userInfo: nil];
|
402
|
+
|
403
|
+
int result = 1;
|
404
|
+
@try {
|
405
|
+
|
406
|
+
cust1 = [[NSMutableDictionary alloc] init];
|
407
|
+
[cust1 setValue: @"CustTest1" forKey: @"first"];
|
408
|
+
[customer create:cust1];
|
409
|
+
|
410
|
+
cust2 = [[NSMutableDictionary alloc] init];
|
411
|
+
[cust2 setValue: @"CustTest2" forKey: @"first"];
|
412
|
+
[customer create:cust2];
|
413
|
+
|
414
|
+
item = [[NSMutableDictionary alloc] init];
|
415
|
+
[item setValue: [NSString stringWithFormat: @"%f", [[NSDate date] timeIntervalSince1970]] forKey:@"name"];
|
416
|
+
[item setValue: [cust1 objectForKey: @"object"] forKey:@"quantity"];
|
417
|
+
[item setValue: [cust2 objectForKey: @"object"] forKey:@"sku"];
|
418
|
+
[product create: item];
|
419
|
+
|
420
|
+
RhoConnectNotify* res = [sclient syncAll];
|
421
|
+
if ( res.error_code != RHO_ERR_NONE
|
422
|
+
|| NO == [@"complete" isEqualToString: res.status] ) {
|
423
|
+
@throw e;
|
424
|
+
}
|
425
|
+
|
426
|
+
NSMutableDictionary* cond = [[NSMutableDictionary alloc] init];
|
427
|
+
[cond setValue: [item objectForKey: @"name"] forKey:@"name"];
|
428
|
+
NSMutableDictionary* prod = [product find_first: cond];
|
429
|
+
[cond release];
|
430
|
+
|
431
|
+
if ( !prod )
|
432
|
+
@throw e;
|
433
|
+
|
434
|
+
// we shoud have all object id changed after sync performed
|
435
|
+
if ( [prod objectForKey: @"object"] == [item objectForKey: @"object"]
|
436
|
+
|| [prod objectForKey: @"quantity"] == [cust1 objectForKey: @"object"]
|
437
|
+
|| [prod objectForKey: @"sku"] == [cust2 objectForKey: @"object"]
|
438
|
+
)
|
439
|
+
@throw e;
|
440
|
+
|
441
|
+
NSMutableDictionary* cust11 = [customer find: [prod objectForKey: @"quantity"]];
|
442
|
+
if ( !cust11
|
443
|
+
|| NO == [[cust11 objectForKey: @"first"] isEqualToString: [cust1 objectForKey: @"first"]] )
|
444
|
+
@throw e;
|
445
|
+
|
446
|
+
|
447
|
+
NSMutableDictionary* cust22 = [customer find: [prod objectForKey: @"sku"]];
|
448
|
+
if ( !cust22
|
449
|
+
|| NO == [[cust22 objectForKey: @"first"] isEqualToString: [cust2 objectForKey: @"first"]] )
|
450
|
+
@throw e;
|
451
|
+
|
452
|
+
} @catch( NSException* e) {
|
453
|
+
result = 0;
|
454
|
+
} @finally {
|
455
|
+
[customer destroy: cust1];
|
456
|
+
[customer destroy: cust2];
|
457
|
+
[product destroy: item];
|
458
|
+
[cust1 release];
|
459
|
+
[cust2 release];
|
460
|
+
[item release];
|
461
|
+
}
|
462
|
+
|
463
|
+
return result;
|
464
|
+
}
|
465
|
+
|
466
|
+
int runObjCClientTest()
|
467
|
+
{
|
468
|
+
customer = [[RhomModel alloc] init];
|
469
|
+
customer.name = @"Customer";
|
470
|
+
|
471
|
+
product = [[RhomModel alloc] init];
|
472
|
+
product.name = @"Product";
|
473
|
+
/*
|
474
|
+
IMPORTANT NOTE:
|
475
|
+
Here is no any real meaning to associate product with customer via "quantity" or "sku" attribute,
|
476
|
+
it has been used just to test it works from the technical point of view.
|
477
|
+
Please, don't consider it as some real application logic sample. It demonstrates just an API capabilities.
|
478
|
+
In a real world application it looks like you will need additional model named Order to refer Product and
|
479
|
+
Customer models.
|
480
|
+
*/
|
481
|
+
product.associations = [NSDictionary dictionaryWithObjectsAndKeys: @"Customer", @"quantity", @"Customer", @"sku", nil];
|
482
|
+
|
483
|
+
//product.name = @"Product_s";
|
484
|
+
//product.model_type = RMT_PROPERTY_FIXEDSCHEMA;
|
485
|
+
//add to schema:
|
486
|
+
/*CREATE TABLE "Product_s" (
|
487
|
+
"brand" varchar default null,
|
488
|
+
"created_at" varchar default null,
|
489
|
+
"name" varchar default null,
|
490
|
+
"price" varchar default null,
|
491
|
+
"quantity" varchar default null,
|
492
|
+
"sku" varchar default null,
|
493
|
+
"updated_at" varchar default null,
|
494
|
+
"object" varchar(255) PRIMARY KEY );
|
495
|
+
|
496
|
+
*/
|
497
|
+
perftest = [[RhomModel alloc] init];
|
498
|
+
perftest.name = @"Perftest";
|
499
|
+
perftest.sync_type = RST_NONE;
|
500
|
+
|
501
|
+
[RhoConnectClient initDatabase];
|
502
|
+
sclient = [[RhoConnectClient alloc] init];
|
503
|
+
NSMutableArray* models = [NSMutableArray arrayWithObjects:customer, product, perftest, nil];
|
504
|
+
|
505
|
+
[sclient addModels:models];
|
506
|
+
|
507
|
+
[product setSyncType:RST_INCREMENTAL];
|
508
|
+
|
509
|
+
//sclient.threaded_mode = FALSE;
|
510
|
+
//sclient.poll_interval = 0;
|
511
|
+
[sclient setLogSeverity:1];
|
512
|
+
|
513
|
+
// exception to throw on test failure
|
514
|
+
NSException *e = [NSException
|
515
|
+
exceptionWithName: @"NSException"
|
516
|
+
reason: @"test faled"
|
517
|
+
userInfo: nil];
|
518
|
+
int result = 1;
|
519
|
+
@try {
|
520
|
+
if ( !ResetAndLogout() )
|
521
|
+
@throw e;
|
522
|
+
|
523
|
+
sclient.sync_server = @"http://rhoconnect-spec-iphone.heroku.com/";
|
524
|
+
//sclient.sync_server = @"http://192.168.0.103:9292/application";
|
525
|
+
sclient.bulksync_state = 1;
|
526
|
+
|
527
|
+
if ( !shouldFindBySql() )
|
528
|
+
@throw e;
|
529
|
+
|
530
|
+
if ( !shouldNotSyncWithoutLogin() )
|
531
|
+
@throw e;
|
532
|
+
|
533
|
+
if ( !shouldLogin() )
|
534
|
+
@throw e;
|
535
|
+
|
536
|
+
if ( !shouldSyncProductByName() )
|
537
|
+
@throw e;
|
538
|
+
|
539
|
+
|
540
|
+
if ( !shouldSearchProduct() )
|
541
|
+
@throw e;
|
542
|
+
|
543
|
+
if ( !shouldCreateNewProduct() )
|
544
|
+
@throw e;
|
545
|
+
|
546
|
+
if ( !shouldModifyProduct() )
|
547
|
+
@throw e;
|
548
|
+
|
549
|
+
if ( !shouldProcessServerErrors() )
|
550
|
+
@throw e;
|
551
|
+
|
552
|
+
if ( !shouldDeleteAllTestProduct() )
|
553
|
+
@throw e;
|
554
|
+
|
555
|
+
if ( !shouldCreateNewProductWithCustomers() )
|
556
|
+
@throw e;
|
557
|
+
|
558
|
+
if ( !shouldPerfomanceTest_create(100) )
|
559
|
+
@throw e;
|
560
|
+
|
561
|
+
if ( !shouldPerfomanceTest_delete() )
|
562
|
+
@throw e;
|
563
|
+
|
564
|
+
} @catch( NSException* e) {
|
565
|
+
result = 0;
|
566
|
+
}
|
567
|
+
|
568
|
+
[customer release];
|
569
|
+
[product release];
|
570
|
+
[perftest release];
|
571
|
+
[sclient release];
|
572
|
+
|
573
|
+
return result;
|
574
|
+
}
|
575
|
+
|
576
|
+
|
577
|
+
int shouldSupportBlobType()
|
578
|
+
{
|
579
|
+
NSString* blobUri = [[RhoConnectClient blobFolder] stringByAppendingString: @"MyText123.txt"];
|
580
|
+
NSString* blobContent = [@"Blob test at " stringByAppendingString: [[NSDate date] description]];
|
581
|
+
NSString* fileName = [RhoConnectClient pathForBlob: blobUri];
|
582
|
+
|
583
|
+
NSError* error;
|
584
|
+
|
585
|
+
// verify file file doesn't exist
|
586
|
+
if ([fileManager fileExistsAtPath: fileName]) {
|
587
|
+
[fileManager removeItemAtPath: fileName error: &error];
|
588
|
+
}
|
589
|
+
if ([fileManager fileExistsAtPath: fileName])
|
590
|
+
return 0;
|
591
|
+
|
592
|
+
// create file with content
|
593
|
+
[blobContent writeToFile: fileName atomically: YES encoding: NSUTF8StringEncoding error: &error];
|
594
|
+
if ( ![fileManager fileExistsAtPath: fileName] )
|
595
|
+
return 0;
|
596
|
+
|
597
|
+
// create item with blob attribute value
|
598
|
+
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
599
|
+
[item setValue: [NSString stringWithFormat: @"%f", [[NSDate date] timeIntervalSince1970]] forKey:@"name"];
|
600
|
+
[item setValue: blobUri forKey:@"image_uri"];
|
601
|
+
[blobTest create: item];
|
602
|
+
|
603
|
+
// blob attribute still contain the same value
|
604
|
+
if ( ![blobUri isEqualToString: [item valueForKey: @"image_uri"]] )
|
605
|
+
return 0;
|
606
|
+
// file should still in place
|
607
|
+
if ( ![fileManager fileExistsAtPath: fileName] )
|
608
|
+
return 0;
|
609
|
+
|
610
|
+
// ensure item has been destroyed
|
611
|
+
[blobTest destroy: item];
|
612
|
+
NSMutableDictionary* cond = [[NSMutableDictionary alloc] init];
|
613
|
+
[cond setValue: [item objectForKey: @"name"] forKey:@"name"];
|
614
|
+
NSMutableDictionary* item2 = [blobTest find_first: cond];
|
615
|
+
[cond release];
|
616
|
+
if ( item2 )
|
617
|
+
return 0;
|
618
|
+
|
619
|
+
// file should be destroyed too
|
620
|
+
if ( [fileManager fileExistsAtPath: fileName] )
|
621
|
+
return 0;
|
622
|
+
|
623
|
+
[item release];
|
624
|
+
|
625
|
+
return 1;
|
626
|
+
}
|
627
|
+
|
628
|
+
int shouldSyncBlobTest()
|
629
|
+
{
|
630
|
+
// should be logged in
|
631
|
+
if ( ![sclient is_logged_in] )
|
632
|
+
return 0;
|
633
|
+
|
634
|
+
RhoConnectNotify* res = [blobTest sync];
|
635
|
+
int nErr = res.error_code;
|
636
|
+
if ( nErr!= RHO_ERR_NONE
|
637
|
+
|| NO == [@"ok" isEqualToString: res.status] ) {
|
638
|
+
return 0;
|
639
|
+
}
|
640
|
+
|
641
|
+
return 1;
|
642
|
+
}
|
643
|
+
|
644
|
+
int shouldDeleteAllBlobTestObjects()
|
645
|
+
{
|
646
|
+
// should be logged in
|
647
|
+
if ( ![sclient is_logged_in] )
|
648
|
+
return 0;
|
649
|
+
|
650
|
+
// find all blob items
|
651
|
+
NSMutableArray* items = [blobTest find_all:nil];
|
652
|
+
if ( !items )
|
653
|
+
return 0;
|
654
|
+
|
655
|
+
// check blob files for items and destroy them
|
656
|
+
NSMutableDictionary* item;
|
657
|
+
for( item in items ) {
|
658
|
+
// blob file name for item
|
659
|
+
NSString* fileName = [RhoConnectClient pathForBlob: [item objectForKey: @"image_uri"]];
|
660
|
+
// file should be in place
|
661
|
+
if ( ![fileManager fileExistsAtPath: fileName] )
|
662
|
+
return 0;
|
663
|
+
// item destroy
|
664
|
+
[blobTest destroy: item];
|
665
|
+
// file should be destroyed too
|
666
|
+
if ( [fileManager fileExistsAtPath: fileName] )
|
667
|
+
return 0;
|
668
|
+
}
|
669
|
+
|
670
|
+
// sync to push items destroy to the server
|
671
|
+
RhoConnectNotify* res = [blobTest sync];
|
672
|
+
int nErr = res.error_code;
|
673
|
+
if ( nErr!= RHO_ERR_NONE
|
674
|
+
|| NO == [@"ok" isEqualToString: res.status] ) {
|
675
|
+
return 0;
|
676
|
+
}
|
677
|
+
|
678
|
+
// there shuld be no items anymore
|
679
|
+
item = [blobTest find_first: nil];
|
680
|
+
if ( item )
|
681
|
+
return 0;
|
682
|
+
|
683
|
+
return 1;
|
684
|
+
}
|
685
|
+
|
686
|
+
int shouldCreateNewBlobTestObject()
|
687
|
+
{
|
688
|
+
NSString* fileName = @"test.png";
|
689
|
+
NSString* filePath = [RhoConnectClient pathForStorageFile: fileName];
|
690
|
+
|
691
|
+
// should be logged in
|
692
|
+
if ( ![sclient is_logged_in] )
|
693
|
+
return 0;
|
694
|
+
|
695
|
+
// copy test.png file from bundle to blob directory
|
696
|
+
[RhoConnectClient fromMainBundle: fileManager copyFile: fileName toStorage: fileName forceRemove: YES];
|
697
|
+
if ( ![fileManager fileExistsAtPath: filePath] )
|
698
|
+
return 0;
|
699
|
+
|
700
|
+
NSError* err;
|
701
|
+
NSNumber* fileSize = [[fileManager attributesOfItemAtPath: filePath error: &err] objectForKey: NSFileSize];
|
702
|
+
NSData* fileContent = [NSData dataWithContentsOfFile: filePath];
|
703
|
+
|
704
|
+
// create item with blob attribute value
|
705
|
+
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
706
|
+
//[item setValue: [NSString stringWithFormat: @"%f", [[NSDate date] timeIntervalSince1970]] forKey:@"name"];
|
707
|
+
[item setValue: fileName forKey:@"image_uri"];
|
708
|
+
[blobTest create: item];
|
709
|
+
[blobTest save: item];
|
710
|
+
|
711
|
+
// sync to push items to the server
|
712
|
+
RhoConnectNotify* res = [blobTest sync];
|
713
|
+
int nErr = res.error_code;
|
714
|
+
if ( nErr!= RHO_ERR_NONE
|
715
|
+
|| NO == [@"ok" isEqualToString: res.status] ) {
|
716
|
+
return 0;
|
717
|
+
}
|
718
|
+
|
719
|
+
// find all blob items, there should be exact one
|
720
|
+
NSMutableArray* items = [blobTest find_all:nil];
|
721
|
+
if ( !items || 1 != [items count])
|
722
|
+
return 0;
|
723
|
+
|
724
|
+
// the only item should have image_uri changed
|
725
|
+
NSString* newFileName = [[items objectAtIndex: 0] objectForKey:@"image_uri"];
|
726
|
+
if ( [fileName isEqualToString: newFileName] )
|
727
|
+
return 0;
|
728
|
+
|
729
|
+
// but file size should be the same
|
730
|
+
NSString* newFilePath = [RhoConnectClient pathForStorageFile: newFileName];
|
731
|
+
NSNumber* newFileSize = [[fileManager attributesOfItemAtPath: newFilePath error: &err] objectForKey: NSFileSize];
|
732
|
+
if ( ![newFileSize isEqualToNumber: fileSize] )
|
733
|
+
return 0;
|
734
|
+
|
735
|
+
// file content should be the same too
|
736
|
+
NSData* newFileContent = [NSData dataWithContentsOfFile: newFilePath];
|
737
|
+
if ( ![newFileContent isEqualToData: fileContent] )
|
738
|
+
return 0;
|
739
|
+
|
740
|
+
[item release];
|
741
|
+
|
742
|
+
return 1;
|
743
|
+
}
|
744
|
+
|
745
|
+
int shouldModifyBlobTestObject()
|
746
|
+
{
|
747
|
+
NSString* fileName = @"test2.png";
|
748
|
+
NSString* filePath = [RhoConnectClient pathForStorageFile: fileName];
|
749
|
+
|
750
|
+
// should be logged in
|
751
|
+
if ( ![sclient is_logged_in] )
|
752
|
+
return 0;
|
753
|
+
|
754
|
+
// at least one item should exist
|
755
|
+
NSMutableDictionary* item = [blobTest find_first: nil];
|
756
|
+
if ( !item )
|
757
|
+
return 0;
|
758
|
+
NSString* savedId = [item objectForKey: @"object"];
|
759
|
+
|
760
|
+
// copy test2.png file from bundle to blob directory
|
761
|
+
[RhoConnectClient fromMainBundle: fileManager copyFile: fileName toStorage: fileName forceRemove: YES];
|
762
|
+
if ( ![fileManager fileExistsAtPath: filePath] )
|
763
|
+
return 0;
|
764
|
+
|
765
|
+
// save old and set new file value
|
766
|
+
NSString* oldFileName = [item objectForKey: @"image_uri"];
|
767
|
+
[item setObject: fileName forKey: @"image_uri"];
|
768
|
+
[blobTest save: item];
|
769
|
+
|
770
|
+
// old file should be removed
|
771
|
+
if ( [fileManager fileExistsAtPath: [RhoConnectClient pathForStorageFile: oldFileName]] )
|
772
|
+
return 0;
|
773
|
+
|
774
|
+
// sync to push items to the server
|
775
|
+
RhoConnectNotify* res = [blobTest sync];
|
776
|
+
int nErr = res.error_code;
|
777
|
+
if ( nErr!= RHO_ERR_NONE
|
778
|
+
|| NO == [@"ok" isEqualToString: res.status] ) {
|
779
|
+
return 0;
|
780
|
+
}
|
781
|
+
|
782
|
+
// readn item back, it should still present
|
783
|
+
NSMutableDictionary* item2 = [blobTest find: savedId];
|
784
|
+
if ( !item2 )
|
785
|
+
return 0;
|
786
|
+
|
787
|
+
// file name should keep new value
|
788
|
+
if ( ![fileName isEqualToString: [item2 objectForKey: @"image_uri"]] )
|
789
|
+
return 0;
|
790
|
+
|
791
|
+
return 1;
|
792
|
+
}
|
793
|
+
|
794
|
+
int runObjCClientBlobTest()
|
795
|
+
{
|
796
|
+
blobTest = [[RhomModel alloc] init];
|
797
|
+
blobTest.name = @"BlobTest";
|
798
|
+
// BlobTest is not very good class name for the model, but
|
799
|
+
// it should be the same as the Source name on server side
|
800
|
+
[blobTest add_blob_attribute: @"image_uri"];
|
801
|
+
|
802
|
+
[RhoConnectClient initDatabase];
|
803
|
+
sclient = [[RhoConnectClient alloc] init];
|
804
|
+
NSMutableArray* models = [NSMutableArray arrayWithObjects: blobTest, nil];
|
805
|
+
[sclient addModels:models];
|
806
|
+
|
807
|
+
//sclient.threaded_mode = FALSE;
|
808
|
+
//sclient.poll_interval = 0;
|
809
|
+
[sclient setLogSeverity:1];
|
810
|
+
|
811
|
+
// exception to throw on test failure
|
812
|
+
NSException *e = [NSException
|
813
|
+
exceptionWithName: @"NSException"
|
814
|
+
reason: @"test faled"
|
815
|
+
userInfo: nil];
|
816
|
+
int result = 1;
|
817
|
+
@try {
|
818
|
+
if ( !ResetAndLogout() )
|
819
|
+
@throw e;
|
820
|
+
|
821
|
+
sclient.sync_server = @"http://rhodes-samples-server.heroku.com";
|
822
|
+
sclient.bulksync_state = 1;
|
823
|
+
|
824
|
+
if ( !shouldNotSyncWithoutLogin() )
|
825
|
+
@throw e;
|
826
|
+
|
827
|
+
if ( !shouldLogin() )
|
828
|
+
@throw e;
|
829
|
+
|
830
|
+
if ( !shouldSupportBlobType() )
|
831
|
+
@throw e;
|
832
|
+
|
833
|
+
if( !shouldSyncBlobTest() )
|
834
|
+
@throw e;
|
835
|
+
|
836
|
+
if( !shouldDeleteAllBlobTestObjects() )
|
837
|
+
@throw e;
|
838
|
+
|
839
|
+
if( !shouldCreateNewBlobTestObject() )
|
840
|
+
@throw e;
|
841
|
+
|
842
|
+
if( !shouldModifyBlobTestObject() )
|
843
|
+
@throw e;
|
844
|
+
|
845
|
+
} @catch( NSException* e) {
|
846
|
+
result = 0;
|
847
|
+
}
|
848
|
+
|
849
|
+
[blobTest release];
|
850
|
+
[sclient release];
|
851
|
+
|
852
|
+
return result;
|
853
|
+
}
|
854
|
+
|
855
|
+
NSMutableArray* savedSyncSources;
|
856
|
+
|
857
|
+
int shouldPrepareSourceTypes()
|
858
|
+
{
|
859
|
+
savedSyncSources = [product find_bysql:@"SELECT name, sync_type FROM sources" args: nil];
|
860
|
+
if ( !savedSyncSources )
|
861
|
+
return 0;
|
862
|
+
|
863
|
+
if ( [savedSyncSources count] == 0 )
|
864
|
+
return 0;
|
865
|
+
|
866
|
+
[product find_bysql:@"UPDATE sources SET sync_type='none'" args: nil];
|
867
|
+
[product find_bysql:@"UPDATE sources SET sync_type='incremental' WHERE name='Product'" args: nil];
|
868
|
+
|
869
|
+
return 1;
|
870
|
+
}
|
871
|
+
|
872
|
+
int shouldRestoreSourceTypes()
|
873
|
+
{
|
874
|
+
for (NSDictionary* src in savedSyncSources) {
|
875
|
+
NSArray* params = [NSArray arrayWithObjects:
|
876
|
+
[src objectForKey: @"sync_type"],
|
877
|
+
[src objectForKey: @"name"],
|
878
|
+
nil];
|
879
|
+
|
880
|
+
[product find_bysql:@"UPDATE sources SET sync_type='?' WHERE name='?'" args: nil];
|
881
|
+
}
|
882
|
+
|
883
|
+
|
884
|
+
return 1;
|
885
|
+
}
|
886
|
+
|
887
|
+
|
888
|
+
int shouldBulkSync()
|
889
|
+
{
|
890
|
+
if ( ![sclient is_logged_in] ) {
|
891
|
+
return 0;
|
892
|
+
}
|
893
|
+
|
894
|
+
RhoConnectNotify* res = [sclient syncAll];
|
895
|
+
if ( res.error_code != RHO_ERR_NONE
|
896
|
+
|| NO == [@"complete" isEqualToString: res.status] ) {
|
897
|
+
return 0;
|
898
|
+
}
|
899
|
+
if ( sclient.bulksync_state != 1 ) {
|
900
|
+
return 0;
|
901
|
+
}
|
902
|
+
|
903
|
+
NSMutableArray* items = [product find_all:nil];
|
904
|
+
if ( !items || 0 == [items count])
|
905
|
+
return 0;
|
906
|
+
|
907
|
+
return 1;
|
908
|
+
}
|
909
|
+
|
910
|
+
int shouldBulkSyncWithCreate()
|
911
|
+
{
|
912
|
+
if ( ![sclient is_logged_in] ) {
|
913
|
+
return 0;
|
914
|
+
}
|
915
|
+
|
916
|
+
[sclient database_full_reset_and_logout];
|
917
|
+
|
918
|
+
RhoConnectNotify* res = [sclient loginWithUser:@"test" pwd:@""];
|
919
|
+
int nErr = res.error_code;
|
920
|
+
if ( nErr!= RHO_ERR_NONE || ![sclient is_logged_in]) {
|
921
|
+
return 0;
|
922
|
+
}
|
923
|
+
|
924
|
+
sclient.bulksync_state = 1;
|
925
|
+
res = [sclient syncAll];
|
926
|
+
if ( res.error_code != RHO_ERR_NONE
|
927
|
+
|| NO == [@"complete" isEqualToString: res.status] ) {
|
928
|
+
return 0;
|
929
|
+
}
|
930
|
+
|
931
|
+
NSMutableDictionary* item1;
|
932
|
+
item1 = [[NSMutableDictionary alloc] init];
|
933
|
+
[item1 setValue: @"PhoneSpec" forKey:@"name"];
|
934
|
+
[item1 setValue: @"22" forKey:@"sku"];
|
935
|
+
[product create: item1];
|
936
|
+
|
937
|
+
sclient.bulksync_state = 0;
|
938
|
+
res = [sclient syncAll];
|
939
|
+
if ( res.error_code != RHO_ERR_NONE
|
940
|
+
|| NO == [@"complete" isEqualToString: res.status] ) {
|
941
|
+
return 0;
|
942
|
+
}
|
943
|
+
if ( sclient.bulksync_state != 1 ) {
|
944
|
+
return 0;
|
945
|
+
}
|
946
|
+
|
947
|
+
NSMutableArray* items = [product find_all:nil];
|
948
|
+
if ( !items || 0 == [items count])
|
949
|
+
return 0;
|
950
|
+
|
951
|
+
NSMutableDictionary* item2 = [product find:[item1 objectForKey:@"object"]];
|
952
|
+
if ( item2 )
|
953
|
+
return 0;
|
954
|
+
|
955
|
+
NSMutableDictionary* cond = [[NSMutableDictionary alloc] init];
|
956
|
+
[cond setValue:@"PhoneSpec" forKey:@"name"];
|
957
|
+
NSMutableArray* items2 = [product find_all:cond];
|
958
|
+
if ( !items2 || 0 == [items2 count])
|
959
|
+
return 0;
|
960
|
+
|
961
|
+
BOOL bFound = NO;
|
962
|
+
for (NSMutableDictionary* item in items2) {
|
963
|
+
if (NO == bFound) {
|
964
|
+
bFound = [@"22" isEqualToString: [item objectForKey:@"sku"]];
|
965
|
+
}
|
966
|
+
|
967
|
+
[item setObject:@"44" forKey:@"sku"];
|
968
|
+
[product save: item];
|
969
|
+
}
|
970
|
+
if ( !bFound )
|
971
|
+
return 0;
|
972
|
+
|
973
|
+
sclient.bulksync_state = 0;
|
974
|
+
res = [sclient syncAll];
|
975
|
+
if ( res.error_code != RHO_ERR_NONE
|
976
|
+
|| NO == [@"complete" isEqualToString: res.status] ) {
|
977
|
+
return 0;
|
978
|
+
}
|
979
|
+
if ( sclient.bulksync_state != 1 ) {
|
980
|
+
return 0;
|
981
|
+
}
|
982
|
+
|
983
|
+
items2 = [product find_all:cond];
|
984
|
+
if ( !items2 || 0 == [items2 count])
|
985
|
+
return 0;
|
986
|
+
|
987
|
+
for (NSMutableDictionary* item in items2) {
|
988
|
+
if ( NO == [@"44" isEqualToString: [item objectForKey:@"sku"]] )
|
989
|
+
return 0;
|
990
|
+
|
991
|
+
[product destroy: item];
|
992
|
+
}
|
993
|
+
|
994
|
+
sclient.bulksync_state = 0;
|
995
|
+
res = [sclient syncAll];
|
996
|
+
if ( res.error_code != RHO_ERR_NONE
|
997
|
+
|| NO == [@"complete" isEqualToString: res.status] ) {
|
998
|
+
return 0;
|
999
|
+
}
|
1000
|
+
if ( sclient.bulksync_state != 1 ) {
|
1001
|
+
return 0;
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
items2 = [product find_all:cond];
|
1005
|
+
if ( !items2 || 0 != [items2 count])
|
1006
|
+
return 0;
|
1007
|
+
|
1008
|
+
[item1 release];
|
1009
|
+
[cond release];
|
1010
|
+
return 1;
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
|
1014
|
+
|
1015
|
+
int runObjCClientBulkSyncTest()
|
1016
|
+
{
|
1017
|
+
product = [[RhomModel alloc] init];
|
1018
|
+
product.name = @"Product";
|
1019
|
+
|
1020
|
+
[RhoConnectClient initDatabase];
|
1021
|
+
sclient = [[RhoConnectClient alloc] init];
|
1022
|
+
NSMutableArray* models = [NSMutableArray arrayWithObjects:product, nil];
|
1023
|
+
|
1024
|
+
[sclient addModels:models];
|
1025
|
+
|
1026
|
+
//sclient.threaded_mode = FALSE;
|
1027
|
+
//sclient.poll_interval = 0;
|
1028
|
+
[sclient setLogSeverity:1];
|
1029
|
+
|
1030
|
+
// exception to throw on test failure
|
1031
|
+
NSException *e = [NSException
|
1032
|
+
exceptionWithName: @"NSException"
|
1033
|
+
reason: @"test faled"
|
1034
|
+
userInfo: nil];
|
1035
|
+
int result = 1;
|
1036
|
+
@try {
|
1037
|
+
if ( !ResetAndLogout() )
|
1038
|
+
@throw e;
|
1039
|
+
|
1040
|
+
sclient.sync_server = @"http://store-bulk.rhohub.com/application";
|
1041
|
+
//sclient.sync_server = @"http://192.168.0.103:9292/application";
|
1042
|
+
|
1043
|
+
sclient.bulksync_state = 0;
|
1044
|
+
|
1045
|
+
if ( !shouldPrepareSourceTypes() )
|
1046
|
+
@throw e;
|
1047
|
+
|
1048
|
+
if ( !shouldLogin() )
|
1049
|
+
@throw e;
|
1050
|
+
|
1051
|
+
if ( !shouldBulkSync() )
|
1052
|
+
@throw e;
|
1053
|
+
|
1054
|
+
[sclient updateModels:models];
|
1055
|
+
|
1056
|
+
if ( !shouldBulkSyncWithCreate() )
|
1057
|
+
@throw e;
|
1058
|
+
|
1059
|
+
if ( !shouldLogout() )
|
1060
|
+
@throw e;
|
1061
|
+
|
1062
|
+
if ( !shouldRestoreSourceTypes() )
|
1063
|
+
@throw e;
|
1064
|
+
|
1065
|
+
sclient.bulksync_state = 1;
|
1066
|
+
|
1067
|
+
} @catch( NSException* e) {
|
1068
|
+
result = 0;
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
[product release];
|
1072
|
+
[sclient release];
|
1073
|
+
|
1074
|
+
return result;
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
int main(int argc, char *argv[]) {
|
1078
|
+
|
1079
|
+
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
1080
|
+
fileManager = [NSFileManager defaultManager];
|
1081
|
+
|
1082
|
+
int retVal = runObjCClientTest();
|
1083
|
+
/*if (0 < retVal)
|
1084
|
+
retVal = runObjCClientBlobTest();
|
1085
|
+
if (0 < retVal)
|
1086
|
+
retVal = runObjCClientBulkSyncTest();
|
1087
|
+
*/
|
1088
|
+
if (retVal)
|
1089
|
+
NSLog(@"SUCCESS");
|
1090
|
+
else
|
1091
|
+
NSLog(@"FAILURE");
|
1092
|
+
|
1093
|
+
[pool drain];
|
1094
|
+
|
1095
|
+
return retVal;
|
1096
|
+
}
|