rhodes 1.5.5 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Manifest.txt +214 -32
- data/Rakefile +33 -10
- data/bin/upgrade-rhodes-app +0 -1
- data/lib/build/compileERB/bb.rb +2 -2
- data/lib/build/compileERB/default.rb +7 -5
- data/lib/build/jake.rb +1 -1
- data/lib/extensions/digest-md5/ext.yml +1 -1
- data/lib/extensions/digest-md5/ext/Rakefile +35 -36
- data/lib/extensions/digest-md5/ext/build.bat +1 -0
- data/lib/extensions/digest-md5/ext/digest-md5.vcproj +203 -0
- data/lib/extensions/digest-sha1/ext.yml +1 -1
- data/lib/extensions/digest/ext.yml +1 -1
- data/lib/extensions/digest/ext/Rakefile +35 -39
- data/lib/extensions/digest/ext/build.bat +1 -2
- data/lib/extensions/digest/ext/digest.vcproj +203 -0
- data/lib/framework/rho/render.rb +79 -22
- data/lib/framework/rho/rho.rb +294 -56
- data/lib/framework/rho/rhoapplication.rb +10 -0
- data/lib/framework/rho/rhofsconnector.rb +2 -6
- data/lib/framework/rho/rhoutils.rb +56 -14
- data/lib/framework/rho/rhoviewhelpers.rb +2 -0
- data/lib/framework/rhodes.rb +2 -2
- data/lib/framework/rhom/rhom.rb +42 -15
- data/lib/framework/rhom/rhom_db_adapter.rb +165 -159
- data/lib/framework/rhom/rhom_object.rb +0 -1
- data/lib/framework/rhom/rhom_object_factory.rb +343 -166
- data/lib/framework/rhom/rhom_source.rb +28 -15
- data/lib/framework/version.rb +2 -2
- data/lib/rhodes.rb +2 -2
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +39 -44
- data/platform/android/Rhodes/jni/include/JNIRhodes.h +1 -1
- data/platform/android/Rhodes/jni/include/details/rhojava.inc +23 -20
- data/platform/android/Rhodes/jni/include/jni/com_rhomobile_rhodes_RhoMenu.h +61 -0
- data/platform/android/Rhodes/jni/include/jni/com_rhomobile_rhodes_Rhodes.h +16 -0
- data/platform/android/Rhodes/jni/include/jni/com_rhomobile_rhodes_alert_Alert.h +21 -0
- data/platform/android/Rhodes/jni/include/sslimpl.h +1 -1
- data/platform/android/Rhodes/jni/src/alert.cpp +32 -5
- data/platform/android/Rhodes/jni/src/callbacks.cpp +51 -21
- data/platform/android/Rhodes/jni/src/mapview.cpp +3 -8
- data/platform/android/Rhodes/jni/src/menu.cpp +70 -0
- data/platform/android/Rhodes/jni/src/navbar.cpp +16 -0
- data/platform/android/Rhodes/jni/src/rhodes.cpp +37 -0
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -3
- data/platform/android/Rhodes/jni/src/webview.cpp +21 -7
- data/platform/android/Rhodes/res/drawable/alert_alert.png +0 -0
- data/platform/android/Rhodes/res/drawable/alert_info.png +0 -0
- data/platform/android/Rhodes/res/drawable/alert_question.png +0 -0
- data/platform/android/Rhodes/res/drawable/camera.png +0 -0
- data/platform/android/Rhodes/res/layout/camera.xml +18 -3
- data/platform/android/Rhodes/res/menu/options.xml +0 -10
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +5 -10
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +12 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +105 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +157 -122
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +7 -58
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +16 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +220 -17
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +22 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +44 -25
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +10 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +3 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +10 -21
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +15 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +44 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/socket/SSLImpl.java +47 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +13 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/TelUriHandler.java +11 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/UriHandler.java +1 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/VideoUriHandler.java +61 -0
- data/platform/android/build/RhodesSRC_build.files +3 -0
- data/platform/android/build/android.rake +173 -60
- data/platform/android/build/androidcommon.rb +1 -2
- data/platform/android/build/librhocommon_build.files +5 -0
- data/platform/android/build/librhodes_build.files +2 -0
- data/platform/android/build/libruby_build.files +2 -1
- data/platform/bb/Hsqldb/Hsqldb.jdp +0 -3
- data/platform/bb/Hsqldb/src/com/rho/db/FileUtilBB.java +1 -1
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +16 -1
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBRowResult.java +5 -0
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +25 -4
- data/platform/bb/Hsqldb/src/com/rho/db/Journal.java +1 -1
- data/platform/bb/Hsqldb/src/com/rho/file/FileAccessBB.java +0 -1
- data/platform/bb/Hsqldb/src/j2me/math/Number.java +6 -3
- data/platform/bb/Hsqldb/src/org/hsqldb/CompiledStatementExecutor.java +2 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +1 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Parser.java +1 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Result.java +2 -0
- data/platform/bb/Hsqldb/src/org/hsqldb/Select.java +12 -6
- data/platform/bb/Hsqldb/src/org/hsqldb/Session.java +19 -12
- data/platform/bb/Hsqldb/src/org/hsqldb/Table.java +10 -4
- data/platform/bb/Hsqldb/src/org/hsqldb/Token.java +10 -2
- data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +3 -3
- data/platform/bb/Hsqldb/src/org/hsqldb/lib/java/JavaSystem.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/persist/HsqlProperties.java +2 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/persist/ScaledRAFile.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/scriptio/ScriptReaderText.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/scriptio/ScriptWriterBase.java +1 -1
- data/platform/bb/RubyVM/RubyVM.jdp +9 -10
- data/platform/bb/build/RubyVM_build.files +9 -7
- data/platform/bb/build/bb.rake +13 -3
- data/platform/bb/build/hsqldb_build.files +0 -2
- data/platform/bb/build/rhodes_build.files +5 -2
- data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +8 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +154 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/RhoMainScreen.java +8 -0
- data/platform/bb/rhodes/platform/common/com/rho/BrowserAdapter5.java +28 -0
- data/platform/bb/rhodes/rhodes.jdp +12 -7
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +331 -0
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +28 -0
- data/platform/bb/rhodes/src/com/rho/IBrowserAdapter.java +10 -0
- data/platform/bb/rhodes/src/com/rho/RhoMainScreen.java +4 -0
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +2 -4
- data/platform/bb/rhodes/src/com/rho/{Jsr75File.java → file/Jsr75File.java} +83 -36
- data/platform/bb/{Hsqldb → rhodes}/src/com/rho/file/Jsr75RAFileImpl.java +0 -1
- data/platform/bb/{Hsqldb → rhodes}/src/com/rho/file/PersistRAFileImpl.java +0 -2
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +8 -10
- data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +1 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/GeoLocation.java +39 -0
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +63 -2
- data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +100 -0
- data/platform/bb/rhodes/src/rhomobile/LogScreen.java +1 -1
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +13 -1
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +138 -492
- data/platform/bb/rhodes/src/rhomobile/SecondaryResourceFetchThread.java +11 -2
- data/platform/bb/rhodes/src/rhomobile/Utilities.java +14 -10
- data/platform/bb/rhodes/src/rhomobile/camera/CameraScreen.java +5 -14
- data/platform/bb/rhodes/src/rhomobile/camera/ImageBrowserScreen.java +1 -1
- data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +2 -2
- data/platform/iphone/Classes/AppManager/AppManager.m +37 -14
- data/platform/iphone/Classes/Camera/PickImageDelegate.h +15 -4
- data/platform/iphone/Classes/Camera/PickImageDelegate.m +53 -50
- data/platform/iphone/Classes/DateTimePicker.h +17 -0
- data/platform/iphone/Classes/DateTimePicker.m +35 -0
- data/platform/iphone/Classes/GeoLocation/LocationController.m +2 -3
- data/platform/iphone/Classes/LogOptionsController.m +3 -2
- data/platform/iphone/Classes/LogViewController.m +4 -2
- data/platform/iphone/Classes/MapView/GoogleGeocoder.m +12 -20
- data/platform/iphone/Classes/MapView/MapAnnotation.h +9 -13
- data/platform/iphone/Classes/MapView/MapAnnotation.m +17 -65
- data/platform/iphone/Classes/MapView/MapViewController.h +1 -7
- data/platform/iphone/Classes/MapView/MapViewController.m +51 -25
- data/platform/iphone/Classes/NativeBar.h +0 -12
- data/platform/iphone/Classes/NativeBar.m +121 -2
- data/platform/iphone/Classes/NavBar.h +16 -0
- data/platform/iphone/Classes/NavBar.m +115 -0
- data/platform/iphone/Classes/RhoAlert.h +19 -0
- data/platform/iphone/Classes/RhoAlert.m +258 -0
- data/platform/iphone/Classes/RhoDelegate.m +1 -0
- data/platform/iphone/Classes/RhoMainView.h +33 -0
- data/platform/iphone/Classes/Rhodes.h +56 -0
- data/platform/iphone/Classes/Rhodes.m +533 -0
- data/platform/iphone/Classes/RingtoneManager.h +17 -0
- data/platform/iphone/Classes/RingtoneManager.m +73 -0
- data/platform/iphone/Classes/SimpleMainView.h +30 -0
- data/platform/iphone/Classes/SimpleMainView.m +380 -0
- data/platform/iphone/Classes/TabbedMainView.h +24 -0
- data/platform/iphone/Classes/TabbedMainView.m +202 -0
- data/platform/iphone/Classes/WebView.m +123 -0
- data/platform/iphone/Classes/rho/net/NetRequestImpl.m +2 -2
- data/platform/iphone/Classes/rho/net/sslimpl.cpp +13 -1
- data/platform/iphone/Classes/rho/net/sslimpl.h +1 -1
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +44 -0
- data/platform/iphone/main.m +1 -2
- data/platform/iphone/rbuild/iphone.rake +8 -16
- data/platform/iphone/rhoextlib/dosyscall.c +1 -1
- data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +6 -4
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +12 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +97 -62
- data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +12 -0
- data/platform/osx/Rhodes Launcher/launch.rb +14 -21
- data/platform/shared/common/AppMenu.cpp +122 -0
- data/platform/shared/common/AppMenu.h +46 -0
- data/platform/shared/common/PosixThreadImpl.cpp +1 -1
- data/platform/shared/common/RhoConf.cpp +27 -2
- data/platform/shared/common/RhoConf.h +5 -0
- data/platform/shared/common/RhoFilePath.h +21 -0
- data/platform/shared/common/RhoStd.h +44 -5
- data/platform/shared/common/RhoTime.h +20 -7
- data/platform/shared/common/RhodesApp.cpp +236 -177
- data/platform/shared/common/RhodesApp.h +36 -13
- data/platform/shared/common/SplashScreen.cpp +2 -2
- data/platform/shared/common/StringConverter.h +10 -11
- data/platform/shared/common/rhoparams.c +0 -6
- data/platform/shared/curl/lib/rhossl.c +3 -2
- data/platform/shared/curl/lib/url.c +0 -5
- data/platform/shared/db/DBAdapter.cpp +304 -81
- data/platform/shared/db/DBAdapter.h +24 -7
- data/platform/shared/db/DBAttrManager.cpp +83 -30
- data/platform/shared/db/DBAttrManager.h +6 -0
- data/platform/shared/db/DBResult.h +15 -4
- data/platform/shared/json/JSONIterator.cpp +100 -3
- data/platform/shared/json/JSONIterator.h +28 -3
- data/platform/shared/net/AsyncHttp.cpp +25 -22
- data/platform/shared/net/AsyncHttp.h +10 -6
- data/platform/shared/net/CURLNetRequest.cpp +115 -36
- data/platform/shared/net/CURLNetRequest.h +6 -0
- data/platform/shared/net/HttpServer.cpp +6 -4
- data/platform/shared/net/HttpServer.h +0 -1
- data/platform/shared/net/INetRequest.h +19 -3
- data/platform/shared/net/URI.cpp +2 -2
- data/platform/shared/net/ssl.cpp +2 -2
- data/platform/shared/net/ssl.h +2 -2
- data/platform/shared/ruby/ext/alert/alert.i +14 -2
- data/platform/shared/ruby/ext/alert/alert_wrap.c +40 -20
- data/platform/shared/ruby/ext/asynchttp/asynchttp.i +8 -8
- data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +112 -16
- data/platform/shared/ruby/ext/geolocation/geolocation.i +16 -12
- data/platform/shared/ruby/ext/geolocation/geolocation_wrap.c +481 -125
- data/platform/shared/ruby/ext/navbar/navbar.i +20 -0
- data/platform/shared/ruby/ext/navbar/navbar_wrap.c +1859 -0
- data/platform/shared/ruby/ext/rho/extensions.c +1 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +32 -2
- data/platform/shared/ruby/ext/rho/rhoruby.h +7 -2
- data/platform/shared/ruby/ext/rhoconf/rhoconf.i +4 -0
- data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +31 -0
- data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +188 -3226
- data/platform/shared/ruby/ext/syncengine/syncengine.i +14 -25
- data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +96 -104
- data/platform/shared/ruby/ext/system/system.i +12 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +101 -7
- data/platform/shared/ruby/ext/webview/webview.i +20 -15
- data/platform/shared/ruby/ext/webview/webview_wrap.c +42 -16
- data/platform/shared/ruby/thread_pthread.c +4 -4
- data/platform/shared/ruby/thread_win32.c +4 -4
- data/platform/shared/ruby/wince/io_wce.c +0 -1
- data/platform/shared/rubyJVM/src/com/rho/FilePath.java +18 -2
- data/platform/shared/rubyJVM/src/com/rho/IRhoRubyHelper.java +1 -0
- data/platform/shared/rubyJVM/src/com/rho/Properties.java +9 -0
- data/platform/shared/rubyJVM/src/com/rho/RhoClassFactory.java +2 -3
- data/platform/shared/rubyJVM/src/com/rho/RhoConf.java +47 -8
- data/platform/shared/rubyJVM/src/com/rho/RhoLogConf.java +1 -0
- data/platform/shared/rubyJVM/src/com/rho/RhoLogFileSink.java +1 -0
- data/platform/shared/rubyJVM/src/com/rho/RhoRuby.java +43 -5
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +98 -3
- data/platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java +460 -175
- data/platform/shared/rubyJVM/src/com/rho/db/DBAttrManager.java +81 -33
- data/platform/shared/rubyJVM/src/com/rho/db/IDBCallback.java +3 -5
- data/platform/shared/rubyJVM/src/com/rho/db/IDBResult.java +2 -0
- data/platform/shared/rubyJVM/src/com/rho/db/IDBStorage.java +2 -0
- data/platform/shared/rubyJVM/src/com/rho/{IFile.java → file/IFile.java} +1 -1
- data/platform/shared/rubyJVM/src/com/rho/{IFileAccess.java → file/IFileAccess.java} +1 -1
- data/platform/shared/rubyJVM/src/com/rho/{IRAFile.java → file/IRAFile.java} +1 -1
- data/platform/{bb/Hsqldb/src/com/rho/db → shared/rubyJVM/src/com/rho/file}/RandomAccessFile.java +1 -2
- data/platform/shared/rubyJVM/src/com/rho/{SimpleFile.java → file/SimpleFile.java} +5 -1
- data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +23 -18
- data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +167 -250
- data/platform/shared/rubyJVM/src/com/rho/net/RhoConnection.java +100 -30
- data/platform/shared/rubyJVM/src/com/rho/net/URI.java +0 -1
- data/platform/shared/rubyJVM/src/com/rho/sync/ClientRegister.java +30 -33
- data/platform/shared/rubyJVM/src/com/rho/sync/ISyncProtocol.java +20 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/JSONEntry.java +5 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/JSONStructIterator.java +74 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +486 -257
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncNotify.java +89 -58
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncProtocol_3.java +79 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +634 -495
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +74 -90
- data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubySymbol_Methods.java +1 -0
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyThread.java +6 -0
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyRuntime.java +6 -2
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubySymbol.java +17 -1
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyValue.java +1 -0
- data/platform/shared/rubyJVM/src/org/json/me/JSONObject.java +3 -0
- data/platform/shared/rubyext/GeoLocation.cpp +23 -0
- data/platform/shared/rubyext/GeoLocation.h +2 -0
- data/platform/shared/rubyext/RhoRuby.cpp +31 -0
- data/platform/shared/rubyext/RhoRuby.h +32 -0
- data/platform/shared/rubyext/System.cpp +14 -3
- data/platform/shared/rubyext/WebView.h +21 -0
- data/platform/shared/sync/ClientRegister.cpp +23 -28
- data/platform/shared/sync/ClientRegister.h +6 -2
- data/platform/shared/sync/ISyncProtocol.h +29 -0
- data/platform/shared/sync/SyncEngine.cpp +450 -190
- data/platform/shared/sync/SyncEngine.h +28 -38
- data/platform/shared/sync/SyncNotify.cpp +43 -41
- data/platform/shared/sync/SyncNotify.h +7 -7
- data/platform/shared/sync/SyncProtocol_3.h +86 -0
- data/platform/shared/sync/SyncSource.cpp +535 -371
- data/platform/shared/sync/SyncSource.h +48 -55
- data/platform/shared/sync/SyncThread.cpp +59 -103
- data/platform/shared/sync/SyncThread.h +10 -23
- data/platform/shared/unzip/unzip.cpp +3 -2
- data/platform/shared/unzip/unzip.h +5 -1
- data/platform/shared/wtl80/include/atlapp.h +10 -10
- data/platform/wm/RhoLib/RhoLib.vcproj +32 -0
- data/platform/wm/build/build_inf.js +40 -3
- data/platform/wm/build/wm.rake +95 -9
- data/platform/wm/rhodes/Alert.cpp +4 -0
- data/platform/wm/rhodes/DateTimePicker.cpp +183 -0
- data/platform/wm/rhodes/DateTimePicker.h +100 -0
- data/platform/wm/rhodes/MainWindow.cpp +222 -209
- data/platform/wm/rhodes/MainWindow.h +28 -35
- data/platform/wm/rhodes/Rhodes.cpp +20 -60
- data/platform/wm/rhodes/Rhodes.rc +41 -7
- data/platform/wm/rhodes/Utils.cpp +65 -0
- data/platform/wm/rhodes/Utils.h +9 -0
- data/platform/wm/rhodes/camera/Camera.cpp +2 -2
- data/platform/wm/rhodes/menubar.cpp +2 -33
- data/platform/wm/rhodes/menubar.h +0 -14
- data/platform/wm/rhodes/resource.h +13 -11
- data/platform/wm/rhodes/rho/net/NetRequest.cpp +16 -35
- data/platform/wm/rhodes/rho/net/NetRequest.h +8 -2
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +264 -46
- data/platform/wm/rhodes/rho/net/NetRequestImpl.h +14 -4
- data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.cpp +1 -1
- data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +77 -4
- data/platform/wm/rhodes/rho/rubyext/WebView.cpp +63 -0
- data/platform/wm/rhodes/rhodes.vcproj +20 -66
- data/platform/wm/rhodes/stdafx.h +22 -0
- data/platform/wm/rubylib/rubylib.vcproj +4 -0
- data/platform/wm/syncengine/syncengine.vcproj +8 -0
- data/platform/wm/tools/detool.sln +66 -0
- data/platform/wm/tools/detool/DEMComInterface.tlb +0 -0
- data/platform/wm/tools/detool/ReadMe.txt +33 -0
- data/platform/wm/tools/detool/detool.cpp +559 -0
- data/platform/wm/tools/detool/detool.h +5 -0
- data/platform/wm/tools/detool/detool.vcproj +233 -0
- data/platform/wm/tools/detool/stdafx.cpp +8 -0
- data/platform/wm/tools/detool/stdafx.h +15 -0
- data/platform/wm/tools/detool/targetver.h +24 -0
- data/platform/wm/tools/rhosetup/ReadMe.txt +41 -0
- data/platform/wm/tools/rhosetup/rhosetup.cpp +52 -0
- data/platform/wm/tools/rhosetup/rhosetup.vcproj +641 -0
- data/platform/wm/tools/rhosetup/stdafx.cpp +8 -0
- data/platform/wm/tools/rhosetup/stdafx.h +59 -0
- data/rakefile.rb +33 -10
- data/res/build-tools/db/syncdb.schema +25 -23
- data/res/build-tools/db/syncdb.triggers +1 -1
- data/res/build-tools/detool.exe +0 -0
- data/res/build-tools/rhosetup.dll +0 -0
- data/res/generators/rhogen.rb +27 -22
- data/res/generators/templates/application/app/Settings/controller.rb +3 -1
- data/res/generators/templates/application/app/Settings/home.bb.erb +17 -0
- data/res/generators/templates/application/app/Settings/home.erb +21 -12
- data/res/generators/templates/application/app/Settings/index.bb.erb +32 -0
- data/res/generators/templates/application/app/Settings/index.erb +44 -15
- data/res/generators/templates/application/app/Settings/login.bb.erb +35 -0
- data/res/generators/templates/application/app/Settings/login.erb +29 -30
- data/res/generators/templates/application/app/Settings/reset.bb.erb +15 -0
- data/res/generators/templates/application/app/Settings/reset.erb +16 -13
- data/res/generators/templates/application/app/Settings/wait.bb.erb +3 -0
- data/res/generators/templates/application/app/Settings/wait.erb +4 -4
- data/res/generators/templates/application/app/application.rb +8 -0
- data/res/generators/templates/application/app/helpers/browser_helper.rb +13 -0
- data/res/generators/templates/application/app/index.bb.erb +26 -0
- data/res/generators/templates/application/app/index.erb +21 -12
- data/res/generators/templates/application/app/layout.erb +9 -11
- data/res/generators/templates/application/public/css/android.css +285 -0
- data/res/generators/templates/application/public/css/blackberry.css +85 -78
- data/res/generators/templates/application/public/css/iphone.css +286 -296
- data/res/generators/templates/application/public/css/webkit.css +34 -0
- data/res/generators/templates/application/public/css/windows_mobile.css +208 -0
- data/res/generators/templates/application/public/icons/Read me first - license.txt +14 -0
- data/res/generators/templates/application/public/icons/about.png +0 -0
- data/res/generators/templates/application/public/icons/airplane.png +0 -0
- data/res/generators/templates/application/public/icons/baby.png +0 -0
- data/res/generators/templates/application/public/icons/badge.png +0 -0
- data/res/generators/templates/application/public/icons/bandaid.png +0 -0
- data/res/generators/templates/application/public/icons/bar-chart.png +0 -0
- data/res/generators/templates/application/public/icons/battery.png +0 -0
- data/res/generators/templates/application/public/icons/beaker.png +0 -0
- data/res/generators/templates/application/public/icons/beaker2.png +0 -0
- data/res/generators/templates/application/public/icons/beermug.png +0 -0
- data/res/generators/templates/application/public/icons/bird.png +0 -0
- data/res/generators/templates/application/public/icons/book.png +0 -0
- data/res/generators/templates/application/public/icons/bookmark.png +0 -0
- data/res/generators/templates/application/public/icons/brightness.png +0 -0
- data/res/generators/templates/application/public/icons/bug.png +0 -0
- data/res/generators/templates/application/public/icons/cabinet.png +0 -0
- data/res/generators/templates/application/public/icons/calendar.png +0 -0
- data/res/generators/templates/application/public/icons/camera.png +0 -0
- data/res/generators/templates/application/public/icons/changeName.rb +22 -0
- data/res/generators/templates/application/public/icons/chat2.png +0 -0
- data/res/generators/templates/application/public/icons/chicken.png +0 -0
- data/res/generators/templates/application/public/icons/clock.png +0 -0
- data/res/generators/templates/application/public/icons/cloud.png +0 -0
- data/res/generators/templates/application/public/icons/coffee.png +0 -0
- data/res/generators/templates/application/public/icons/compass.png +0 -0
- data/res/generators/templates/application/public/icons/contrast.png +0 -0
- data/res/generators/templates/application/public/icons/dashboard.png +0 -0
- data/res/generators/templates/application/public/icons/display.png +0 -0
- data/res/generators/templates/application/public/icons/dogpaw.png +0 -0
- data/res/generators/templates/application/public/icons/download.png +0 -0
- data/res/generators/templates/application/public/icons/dumbbell.png +0 -0
- data/res/generators/templates/application/public/icons/ekg.png +0 -0
- data/res/generators/templates/application/public/icons/envelope.png +0 -0
- data/res/generators/templates/application/public/icons/equalizer.png +0 -0
- data/res/generators/templates/application/public/icons/eye.png +0 -0
- data/res/generators/templates/application/public/icons/film-roll.png +0 -0
- data/res/generators/templates/application/public/icons/flag.png +0 -0
- data/res/generators/templates/application/public/icons/fork-and-knife.png +0 -0
- data/res/generators/templates/application/public/icons/fuel.png +0 -0
- data/res/generators/templates/application/public/icons/gameplan.png +0 -0
- data/res/generators/templates/application/public/icons/gear.png +0 -0
- data/res/generators/templates/application/public/icons/gear2.png +0 -0
- data/res/generators/templates/application/public/icons/gift.png +0 -0
- data/res/generators/templates/application/public/icons/heart.png +0 -0
- data/res/generators/templates/application/public/icons/house.png +0 -0
- data/res/generators/templates/application/public/icons/inbox.png +0 -0
- data/res/generators/templates/application/public/icons/index-cards.png +0 -0
- data/res/generators/templates/application/public/icons/iphone.png +0 -0
- data/res/generators/templates/application/public/icons/ipod.png +0 -0
- data/res/generators/templates/application/public/icons/key.png +0 -0
- data/res/generators/templates/application/public/icons/lifebuoy.png +0 -0
- data/res/generators/templates/application/public/icons/lightbulb.png +0 -0
- data/res/generators/templates/application/public/icons/line-chart.png +0 -0
- data/res/generators/templates/application/public/icons/location.png +0 -0
- data/res/generators/templates/application/public/icons/lock.png +0 -0
- data/res/generators/templates/application/public/icons/loopback.png +0 -0
- data/res/generators/templates/application/public/icons/magnifying-glass.png +0 -0
- data/res/generators/templates/application/public/icons/map-marker.png +0 -0
- data/res/generators/templates/application/public/icons/map.png +0 -0
- data/res/generators/templates/application/public/icons/medical-bag.png +0 -0
- data/res/generators/templates/application/public/icons/medical.png +0 -0
- data/res/generators/templates/application/public/icons/microphone.png +0 -0
- data/res/generators/templates/application/public/icons/movie1.png +0 -0
- data/res/generators/templates/application/public/icons/movie2.png +0 -0
- data/res/generators/templates/application/public/icons/network.png +0 -0
- data/res/generators/templates/application/public/icons/note.png +0 -0
- data/res/generators/templates/application/public/icons/outlet.png +0 -0
- data/res/generators/templates/application/public/icons/palette.png +0 -0
- data/res/generators/templates/application/public/icons/paperclip.png +0 -0
- data/res/generators/templates/application/public/icons/phone.png +0 -0
- data/res/generators/templates/application/public/icons/photos.png +0 -0
- data/res/generators/templates/application/public/icons/piano.png +0 -0
- data/res/generators/templates/application/public/icons/picture-frame.png +0 -0
- data/res/generators/templates/application/public/icons/pill.png +0 -0
- data/res/generators/templates/application/public/icons/pin.png +0 -0
- data/res/generators/templates/application/public/icons/pinetree.png +0 -0
- data/res/generators/templates/application/public/icons/planet.png +0 -0
- data/res/generators/templates/application/public/icons/puzzle.png +0 -0
- data/res/generators/templates/application/public/icons/radar.png +0 -0
- data/res/generators/templates/application/public/icons/redo.png +0 -0
- data/res/generators/templates/application/public/icons/refresh.png +0 -0
- data/res/generators/templates/application/public/icons/runner.png +0 -0
- data/res/generators/templates/application/public/icons/shoebox.png +0 -0
- data/res/generators/templates/application/public/icons/shopping-bag.png +0 -0
- data/res/generators/templates/application/public/icons/shopping-cart.png +0 -0
- data/res/generators/templates/application/public/icons/shuffle.png +0 -0
- data/res/generators/templates/application/public/icons/signpost.png +0 -0
- data/res/generators/templates/application/public/icons/skull-n-crossbones.png +0 -0
- data/res/generators/templates/application/public/icons/skull.png +0 -0
- data/res/generators/templates/application/public/icons/sliders.png +0 -0
- data/res/generators/templates/application/public/icons/spraycan.png +0 -0
- data/res/generators/templates/application/public/icons/squiggle.png +0 -0
- data/res/generators/templates/application/public/icons/star.png +0 -0
- data/res/generators/templates/application/public/icons/stopwatch.png +0 -0
- data/res/generators/templates/application/public/icons/suitcase.png +0 -0
- data/res/generators/templates/application/public/icons/tag.png +0 -0
- data/res/generators/templates/application/public/icons/tags.png +0 -0
- data/res/generators/templates/application/public/icons/target.png +0 -0
- data/res/generators/templates/application/public/icons/testtube.png +0 -0
- data/res/generators/templates/application/public/icons/thermometer.png +0 -0
- data/res/generators/templates/application/public/icons/toolbox.png +0 -0
- data/res/generators/templates/application/public/icons/trophy.png +0 -0
- data/res/generators/templates/application/public/icons/tshirt.png +0 -0
- data/res/generators/templates/application/public/icons/tv.png +0 -0
- data/res/generators/templates/application/public/icons/umbrella.png +0 -0
- data/res/generators/templates/application/public/icons/walk.png +0 -0
- data/res/generators/templates/application/public/icons/weather.png +0 -0
- data/res/generators/templates/application/public/icons/widescreen.png +0 -0
- data/res/generators/templates/application/public/icons/wineglass.png +0 -0
- data/res/generators/templates/application/public/icons/zap.png +0 -0
- data/res/generators/templates/application/public/images/android/btn_check_off.png +0 -0
- data/res/generators/templates/application/public/images/android/btn_check_on.png +0 -0
- data/res/generators/templates/application/public/images/android/btn_radio_off.png +0 -0
- data/res/generators/templates/application/public/images/android/btn_radio_on.png +0 -0
- data/res/generators/templates/application/public/images/android/ic_menu_more.png +0 -0
- data/res/generators/templates/application/public/images/iphone/disclosure.png +0 -0
- data/res/generators/templates/application/public/images/iphone/disclosure_detail.png +0 -0
- data/res/generators/templates/application/public/images/iphone/radiobutton.png +0 -0
- data/res/generators/templates/application/public/images/iphone/select.png +0 -0
- data/res/generators/templates/application/public/images/iphone/switch.png +0 -0
- data/res/generators/templates/application/public/images/listArrow.png +0 -0
- data/res/generators/templates/application/public/images/listArrowDown.png +0 -0
- data/res/generators/templates/model/controller.rb +2 -0
- data/res/generators/templates/model/edit.bb.erb +24 -0
- data/res/generators/templates/model/edit.erb +21 -25
- data/res/generators/templates/model/index.bb.erb +21 -0
- data/res/generators/templates/model/index.erb +28 -14
- data/res/generators/templates/model/new.bb.erb +24 -0
- data/res/generators/templates/model/new.erb +20 -20
- data/res/generators/templates/model/show.bb.erb +21 -0
- data/res/generators/templates/model/show.erb +15 -15
- data/rhobuild.yml +37 -0
- data/rhodes.gemspec +1 -1
- data/spec/framework_spec/app/Account/config.rb +57 -1
- data/spec/framework_spec/app/Case/config.rb +1 -1
- data/spec/framework_spec/app/Customer/config.rb +1 -1
- data/spec/framework_spec/app/Product/config.rb +15 -1
- data/spec/framework_spec/app/spec/fixtures/object_values.txt +90 -90
- data/spec/framework_spec/app/spec/pagination/fixtures/object_values.txt +91 -91
- data/spec/framework_spec/app/spec/rho_spec.rb +1 -1
- data/spec/framework_spec/app/spec/rhom_object_spec.rb +47 -28
- data/spec/framework_spec/app/spec/rhom_spec.rb +8 -8
- data/spec/framework_spec/app/spec/spec_helper.rb +13 -5
- data/spec/framework_spec/app/spec_runner.rb +5 -4
- data/spec/framework_spec/public/css/base.css +0 -1
- data/spec/framework_spec/public/css/iphone.css +0 -1
- data/spec/framework_spec/rhoconfig.txt +3 -1
- metadata +220 -37
- data/platform/bb/rhodes/src/rhomobile/WebView.java +0 -90
- data/platform/iphone/Classes/BarItem.h +0 -27
- data/platform/iphone/Classes/BarItem.m +0 -32
- data/platform/iphone/Classes/JSString.h +0 -12
- data/platform/iphone/Classes/JSString.m +0 -7
- data/platform/iphone/Classes/RhoRunnerAppDelegate.h +0 -48
- data/platform/iphone/Classes/RhoRunnerAppDelegate.m +0 -617
- data/platform/iphone/Classes/Server/ServerHost.h +0 -81
- data/platform/iphone/Classes/Server/ServerHost.m +0 -597
- data/platform/iphone/Classes/Server/WebViewUrl.h +0 -13
- data/platform/iphone/Classes/Server/WebViewUrl.m +0 -8
- data/platform/iphone/Classes/TabBarDelegate.h +0 -39
- data/platform/iphone/Classes/TabBarDelegate.m +0 -151
- data/platform/iphone/Classes/Utils/unzip.cpp +0 -4328
- data/platform/iphone/Classes/Utils/unzip.h +0 -234
- data/platform/iphone/Classes/WebViewController.h +0 -59
- data/platform/iphone/Classes/WebViewController.m +0 -472
- data/platform/wm/rhodes/GetURLDialog.cpp +0 -64
- data/platform/wm/rhodes/GetURLDialog.h +0 -39
- data/res/generators/templates/application/public/css/base.css +0 -39
- data/res/generators/templates/application/public/css/rho.css +0 -3
- data/res/generators/templates/application/public/css/xhtml.css +0 -114
- data/spec/framework_spec/app/Question/config.rb +0 -3
- data/spec/generator_spec/source_generator_spec.rb +0 -27
@@ -38,16 +38,14 @@ public class SyncNotify {
|
|
38
38
|
static Mutex m_mxObjectNotify = new Mutex();
|
39
39
|
|
40
40
|
Hashtable/*<int,SyncNotification>*/ m_mapSyncNotifications = new Hashtable();
|
41
|
-
|
42
|
-
|
43
|
-
SyncNotification m_initialSyncNotify;
|
41
|
+
SyncNotification m_pSearchNotification;
|
42
|
+
SyncNotification m_bulkSyncNotify;
|
44
43
|
|
45
44
|
Mutex m_mxSyncNotifications = new Mutex();
|
46
45
|
ISyncStatusListener m_syncStatusListener = null;
|
47
46
|
boolean m_bEnableReporting = false;
|
48
47
|
|
49
48
|
SyncEngine getSync(){ return m_syncEngine; }
|
50
|
-
DBAdapter getDB(){ return getSync().getDB(); }
|
51
49
|
NetRequest getNet(){ return getSync().getNet(); }
|
52
50
|
|
53
51
|
SyncNotify( SyncEngine syncEngine )
|
@@ -142,13 +140,15 @@ public class SyncNotify {
|
|
142
140
|
if (nNotifyType == enNone.intValue())
|
143
141
|
continue;
|
144
142
|
|
143
|
+
//This is slow operation
|
144
|
+
/*
|
145
145
|
if ( nNotifyType == enDelete.intValue() )
|
146
146
|
{
|
147
147
|
IDBResult res = getDB().executeSQL("SELECT object FROM object_values where object=? LIMIT 1 OFFSET 0", strObject );
|
148
148
|
if ( !res.isEnd() )
|
149
149
|
nNotifyType = enUpdate.intValue();
|
150
150
|
}
|
151
|
-
|
151
|
+
*/
|
152
152
|
if ( strBody.length() > 0 )
|
153
153
|
strBody += "&rho_callback=1&";
|
154
154
|
|
@@ -174,10 +174,7 @@ public class SyncNotify {
|
|
174
174
|
return;
|
175
175
|
}
|
176
176
|
|
177
|
-
|
178
|
-
if ( !resp.isOK() )
|
179
|
-
LOG.ERROR( "Fire object notification failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData() );
|
180
|
-
|
177
|
+
callNotify(strUrl, strBody);
|
181
178
|
}
|
182
179
|
|
183
180
|
void onObjectChanged(Integer nSrcID, String strObject, Integer nType)
|
@@ -275,7 +272,7 @@ public class SyncNotify {
|
|
275
272
|
|
276
273
|
if ( strFullUrl.length() > 0 )
|
277
274
|
{
|
278
|
-
IDBResult res =
|
275
|
+
IDBResult res = DBAdapter.getUserDB().executeSQL("SELECT source_id from sources order by source_id");
|
279
276
|
for ( ; !res.isEnd(); res.next() )
|
280
277
|
m_mapSyncNotifications.put( new Integer(res.getIntByIdx(0)), new SyncNotification( strFullUrl, strParams, false ) );
|
281
278
|
}
|
@@ -294,25 +291,25 @@ public class SyncNotify {
|
|
294
291
|
}
|
295
292
|
}
|
296
293
|
|
297
|
-
void setSearchNotification(
|
294
|
+
void setSearchNotification(String strUrl, String strParams )throws Exception
|
298
295
|
{
|
299
|
-
LOG.INFO( "Set search notification.
|
296
|
+
LOG.INFO( "Set search notification. Url :" + strUrl + "; Params: " + strParams );
|
300
297
|
String strFullUrl = getNet().resolveUrl(strUrl);
|
301
298
|
|
302
299
|
if ( strFullUrl.length() > 0 )
|
303
300
|
{
|
304
301
|
synchronized(m_mxSyncNotifications){
|
305
|
-
|
302
|
+
m_pSearchNotification = new SyncNotification( strFullUrl, strParams, true );
|
306
303
|
}
|
307
|
-
LOG.INFO( " Done Set search notification.
|
304
|
+
LOG.INFO( " Done Set search notification. Url :" + strFullUrl + "; Params: " + strParams );
|
308
305
|
}
|
309
306
|
}
|
310
307
|
|
311
|
-
void
|
308
|
+
void setBulkSyncNotification(String strUrl, String strParams )throws Exception
|
312
309
|
{
|
313
310
|
String strFullUrl = getNet().resolveUrl(strUrl);
|
314
311
|
|
315
|
-
|
312
|
+
m_bulkSyncNotify = new SyncNotification( strFullUrl, strParams, false );
|
316
313
|
}
|
317
314
|
|
318
315
|
public void setSyncStatusListener(ISyncStatusListener listener)
|
@@ -357,7 +354,7 @@ public class SyncNotify {
|
|
357
354
|
}
|
358
355
|
}
|
359
356
|
|
360
|
-
void
|
357
|
+
void fireBulkSyncNotification( boolean bFinish, String status, String partition, int nErrCode )
|
361
358
|
{
|
362
359
|
if ( getSync().getState() == SyncEngine.esExit )
|
363
360
|
return;
|
@@ -365,7 +362,7 @@ public class SyncNotify {
|
|
365
362
|
//TODO: show report
|
366
363
|
if( nErrCode != RhoRuby.ERR_NONE)
|
367
364
|
{
|
368
|
-
String strMessage = RhoRuby.getMessageText("sync_failed_for") + "
|
365
|
+
String strMessage = RhoRuby.getMessageText("sync_failed_for") + "bulk.";
|
369
366
|
reportSyncStatus(strMessage,nErrCode,"");
|
370
367
|
}
|
371
368
|
|
@@ -374,11 +371,13 @@ public class SyncNotify {
|
|
374
371
|
String strBody = "", strUrl;
|
375
372
|
synchronized(m_mxSyncNotifications)
|
376
373
|
{
|
377
|
-
if (
|
374
|
+
if ( m_bulkSyncNotify == null )
|
378
375
|
return;
|
379
376
|
|
380
|
-
strUrl =
|
377
|
+
strUrl = m_bulkSyncNotify.m_strUrl;
|
381
378
|
strBody = "rho_callback=1";
|
379
|
+
strBody += "&partition=" + partition;
|
380
|
+
strBody += "&bulk_status="+status;
|
382
381
|
strBody += "&status=";
|
383
382
|
if ( bFinish )
|
384
383
|
{
|
@@ -396,32 +395,22 @@ public class SyncNotify {
|
|
396
395
|
else
|
397
396
|
strBody += "in_progress";
|
398
397
|
|
399
|
-
if (
|
400
|
-
strBody += "&" +
|
398
|
+
if ( m_bulkSyncNotify.m_strParams.length() > 0 )
|
399
|
+
strBody += "&" + m_bulkSyncNotify.m_strParams;
|
401
400
|
|
402
|
-
bRemoveAfterFire = bRemoveAfterFire &&
|
401
|
+
bRemoveAfterFire = bRemoveAfterFire && m_bulkSyncNotify.m_bRemoveAfterFire;
|
403
402
|
}
|
404
403
|
|
405
404
|
if ( bRemoveAfterFire )
|
406
|
-
|
405
|
+
clearBulkSyncNotification();
|
407
406
|
|
408
|
-
LOG.INFO( "Fire
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
LOG.ERROR( "Fire intial notification failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData() );
|
413
|
-
else
|
414
|
-
{
|
415
|
-
String szData = resp.getCharData();
|
416
|
-
if ( szData != null && szData.equals("stop") )
|
417
|
-
{
|
418
|
-
clearInitialSyncNotification();
|
419
|
-
}
|
420
|
-
}
|
421
|
-
|
407
|
+
LOG.INFO( "Fire bulk notification.Url :" + strUrl + "; Body: " + strBody );
|
408
|
+
|
409
|
+
if ( callNotify(strUrl, strBody) )
|
410
|
+
clearBulkSyncNotification();
|
422
411
|
}catch(Exception exc)
|
423
412
|
{
|
424
|
-
LOG.ERROR("Fire
|
413
|
+
LOG.ERROR("Fire bulk notification failed.", exc);
|
425
414
|
}
|
426
415
|
|
427
416
|
}
|
@@ -433,7 +422,7 @@ public class SyncNotify {
|
|
433
422
|
|
434
423
|
if( strMessage.length() > 0 || nErrCode != RhoRuby.ERR_NONE)
|
435
424
|
{
|
436
|
-
if ( !( src != null && src.
|
425
|
+
if ( !( src != null && src.isSearch()) )
|
437
426
|
{
|
438
427
|
if ( src != null && (strMessage==null || strMessage.length() == 0) )
|
439
428
|
strMessage = RhoRuby.getMessageText("sync_failed_for") + src.getName() + ".";
|
@@ -455,7 +444,12 @@ public class SyncNotify {
|
|
455
444
|
boolean bRemoveAfterFire = bFinish;
|
456
445
|
{
|
457
446
|
synchronized(m_mxSyncNotifications){
|
458
|
-
SyncNotification sn =
|
447
|
+
SyncNotification sn = null;
|
448
|
+
if ( src.isSearch() )
|
449
|
+
sn = m_pSearchNotification;
|
450
|
+
else
|
451
|
+
sn = (SyncNotification)m_mapSyncNotifications.get(src.getID());
|
452
|
+
|
459
453
|
if ( sn == null )
|
460
454
|
return;
|
461
455
|
|
@@ -496,25 +490,43 @@ public class SyncNotify {
|
|
496
490
|
clearNotification(src);
|
497
491
|
|
498
492
|
LOG.INFO( "Fire notification. Source ID: " + src.getID() + "; Url :" + strUrl + "; Body: " + strBody );
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
LOG.ERROR( "Fire notification failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData() );
|
503
|
-
else
|
504
|
-
{
|
505
|
-
String szData = resp.getCharData();
|
506
|
-
if ( szData != null && szData.equals("stop") )
|
507
|
-
{
|
508
|
-
clearNotification(src);
|
509
|
-
}
|
510
|
-
}
|
511
|
-
|
493
|
+
|
494
|
+
if ( callNotify(strUrl, strBody) )
|
495
|
+
clearNotification(src);
|
512
496
|
}catch(Exception exc)
|
513
497
|
{
|
514
498
|
LOG.ERROR("Fire notification failed.", exc);
|
515
499
|
}
|
516
500
|
}
|
517
501
|
|
502
|
+
boolean callNotify(String strUrl, String strBody )throws Exception
|
503
|
+
{
|
504
|
+
/* if ( getSync().isNoThreadedMode() )
|
505
|
+
{
|
506
|
+
const char* szName = strrchr(strUrl.c_str(), '/');
|
507
|
+
if (!szName)
|
508
|
+
szName = strUrl.c_str();
|
509
|
+
else
|
510
|
+
szName++;
|
511
|
+
|
512
|
+
String strName = "C_";
|
513
|
+
strName += szName;
|
514
|
+
rho_ruby_set_const( strName.c_str(), strBody.c_str());
|
515
|
+
return false;
|
516
|
+
}*/
|
517
|
+
|
518
|
+
NetResponse resp = getNet().pushData( strUrl, strBody, null );
|
519
|
+
if ( !resp.isOK() )
|
520
|
+
LOG.ERROR( "Fire object notification failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData() );
|
521
|
+
else
|
522
|
+
{
|
523
|
+
String szData = resp.getCharData();
|
524
|
+
return szData != null && szData.equals("stop");
|
525
|
+
}
|
526
|
+
|
527
|
+
return false;
|
528
|
+
}
|
529
|
+
|
518
530
|
void clearNotification(SyncSource src)
|
519
531
|
{
|
520
532
|
LOG.INFO( "Clear notification. Source : " + src.getName());
|
@@ -522,7 +534,7 @@ public class SyncNotify {
|
|
522
534
|
synchronized(m_mxSyncNotifications)
|
523
535
|
{
|
524
536
|
if ( src.isSearch() )
|
525
|
-
|
537
|
+
m_pSearchNotification = null;
|
526
538
|
else
|
527
539
|
m_mapSyncNotifications.remove(src.getID());
|
528
540
|
}
|
@@ -540,12 +552,12 @@ public class SyncNotify {
|
|
540
552
|
}
|
541
553
|
}
|
542
554
|
|
543
|
-
void
|
555
|
+
void clearBulkSyncNotification()
|
544
556
|
{
|
545
|
-
LOG.INFO( "Clear
|
557
|
+
LOG.INFO( "Clear bulk notification." );
|
546
558
|
|
547
559
|
synchronized(m_mxSyncNotifications){
|
548
|
-
|
560
|
+
m_bulkSyncNotify = null;
|
549
561
|
}
|
550
562
|
}
|
551
563
|
|
@@ -586,5 +598,24 @@ public class SyncNotify {
|
|
586
598
|
|
587
599
|
return nCount;
|
588
600
|
}
|
601
|
+
|
602
|
+
void callLoginCallback(String callback, int nErrCode, String strMessage)
|
603
|
+
{
|
604
|
+
try{
|
605
|
+
String strBody = "error_code=" + nErrCode;
|
606
|
+
strBody += "&error_message=" + URI.urlEncode(strMessage != null? strMessage : "");
|
607
|
+
strBody += "&rho_callback=1";
|
608
|
+
|
609
|
+
String strUrl = getNet().resolveUrl(callback);
|
610
|
+
|
611
|
+
LOG.INFO( "Login callback: " + callback + ". Body: "+ strBody );
|
612
|
+
|
613
|
+
callNotify(strUrl, strBody);
|
614
|
+
}catch(Exception exc)
|
615
|
+
{
|
616
|
+
LOG.ERROR("Call Login callback failed.", exc);
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
589
620
|
|
590
621
|
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
package com.rho.sync;
|
2
|
+
|
3
|
+
import com.rho.RhoConf;
|
4
|
+
import com.rho.FilePath;
|
5
|
+
|
6
|
+
public class SyncProtocol_3 implements ISyncProtocol
|
7
|
+
{
|
8
|
+
String m_strContentType;
|
9
|
+
|
10
|
+
public SyncProtocol_3()
|
11
|
+
{
|
12
|
+
m_strContentType = "application/json";
|
13
|
+
}
|
14
|
+
|
15
|
+
public String getContentType(){ return m_strContentType; }
|
16
|
+
public int getVersion(){ return 3; }
|
17
|
+
|
18
|
+
public String getLoginUrl()
|
19
|
+
{
|
20
|
+
return RhoConf.getInstance().getPath("syncserver") + "clientlogin";
|
21
|
+
}
|
22
|
+
|
23
|
+
public String getLoginBody( String name, String password)
|
24
|
+
{
|
25
|
+
return "{\"login\":\"" + name + "\",\"password\":\"" + password + "\",\"remember_me\":1}";
|
26
|
+
}
|
27
|
+
|
28
|
+
public String getClientCreateUrl()
|
29
|
+
{
|
30
|
+
return RhoConf.getInstance().getPath("syncserver") + "clientcreate";
|
31
|
+
}
|
32
|
+
|
33
|
+
public String getClientRegisterUrl()
|
34
|
+
{
|
35
|
+
return RhoConf.getInstance().getPath("syncserver") + "clientregister";
|
36
|
+
}
|
37
|
+
|
38
|
+
public String getClientRegisterBody( String strClientID, String strPin, int nPort, String strType )
|
39
|
+
{
|
40
|
+
return "{\"client_id\":\"" + strClientID +
|
41
|
+
"\",\"device_pin\":\"" + strPin +
|
42
|
+
"\",\"device_port\":\"" + nPort +
|
43
|
+
"\",\"device_type\":\"" + strType + "\"}";
|
44
|
+
}
|
45
|
+
|
46
|
+
public String getClientResetUrl(String strClientID)
|
47
|
+
{
|
48
|
+
return RhoConf.getInstance().getPath("syncserver") + "clientreset?client_id=" + strClientID;
|
49
|
+
}
|
50
|
+
|
51
|
+
public String getClientChangesUrl()
|
52
|
+
{
|
53
|
+
String strUrl = RhoConf.getInstance().getPath("syncserver");
|
54
|
+
return strUrl.substring(0,strUrl.length()-1);
|
55
|
+
}
|
56
|
+
|
57
|
+
public String getServerQueryUrl(String strAction )
|
58
|
+
{
|
59
|
+
String strUrl = RhoConf.getInstance().getPath("syncserver");
|
60
|
+
if ( strAction.length() > 0 )
|
61
|
+
strUrl = FilePath.join(strUrl, strAction);
|
62
|
+
else
|
63
|
+
strUrl = strUrl.substring(0,strUrl.length()-1);
|
64
|
+
|
65
|
+
return strUrl;
|
66
|
+
}
|
67
|
+
|
68
|
+
public String getServerQueryBody(String strSrcName, String strClientID, int nPageSize )
|
69
|
+
{
|
70
|
+
String strQuery = "?client_id=" + strClientID +
|
71
|
+
"&p_size=" + nPageSize + "&version=3";
|
72
|
+
|
73
|
+
if ( strSrcName.length() > 0 )
|
74
|
+
strQuery += "&source_name=" + strSrcName;
|
75
|
+
|
76
|
+
return strQuery;
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
@@ -23,15 +23,19 @@ import com.rho.RhoEmptyLogger;
|
|
23
23
|
import com.rho.RhoEmptyProfiler;
|
24
24
|
import com.rho.RhoLogger;
|
25
25
|
import com.rho.RhoProfiler;
|
26
|
+
import com.rho.RhodesApp;
|
27
|
+
import com.rho.Tokenizer;
|
26
28
|
import com.rho.net.*;
|
27
29
|
import com.rho.db.*;
|
28
|
-
import java.util.Vector;
|
29
30
|
|
30
|
-
import
|
31
|
+
import java.util.Enumeration;
|
32
|
+
import java.util.Vector;
|
33
|
+
import java.util.Hashtable;
|
31
34
|
|
32
35
|
import com.rho.FilePath;
|
33
36
|
import com.rho.TimeInterval;
|
34
37
|
import com.rho.RhoRuby;
|
38
|
+
import com.rho.net.NetRequest.MultipartItem;
|
35
39
|
|
36
40
|
class SyncSource
|
37
41
|
{
|
@@ -41,104 +45,157 @@ class SyncSource
|
|
41
45
|
private static final RhoProfiler PROF = RhoProfiler.RHO_STRIP_PROFILER ? new RhoEmptyProfiler() :
|
42
46
|
new RhoProfiler();
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
static class SyncBlob
|
48
|
+
static class CAttrValue
|
47
49
|
{
|
48
|
-
|
49
|
-
|
50
|
+
String m_strAttrib = "";
|
51
|
+
String m_strValue = "";
|
52
|
+
String m_strBlobSuffix = "";
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
CAttrValue(String strAttrib, String strValue)
|
55
|
+
{
|
56
|
+
m_strAttrib = strAttrib;
|
57
|
+
m_strValue = strValue;
|
54
58
|
|
55
|
-
|
56
|
-
|
59
|
+
if ( m_strAttrib.endsWith("-rhoblob") )
|
60
|
+
{
|
61
|
+
m_strBlobSuffix = "-rhoblob";
|
62
|
+
m_strAttrib = m_strAttrib.substring(0,m_strAttrib.length()-m_strBlobSuffix.length());
|
63
|
+
}
|
64
|
+
}
|
57
65
|
};
|
58
66
|
|
59
67
|
SyncEngine m_syncEngine;
|
60
|
-
|
68
|
+
DBAdapter m_dbAdapter;
|
69
|
+
|
61
70
|
Integer m_nID;
|
62
|
-
String m_strName;
|
63
|
-
String m_strUrl;
|
71
|
+
String m_strName = "";
|
64
72
|
long m_token = 0;
|
73
|
+
String m_strSyncType = "";
|
65
74
|
boolean m_bTokenFromDB;
|
66
75
|
|
67
76
|
int m_nCurPageCount, m_nInserted, m_nDeleted, m_nTotalCount, m_nAttribCounter=0;
|
68
77
|
boolean m_bGetAtLeastOnePage = false;
|
69
|
-
int m_eSyncServerDataPass = edpNone;
|
70
78
|
int m_nErrCode = RhoRuby.ERR_NONE;
|
71
79
|
String m_strError = "";
|
72
|
-
|
73
|
-
String m_strAction = "";
|
74
|
-
boolean m_bSearchSyncChanges = false;
|
75
|
-
int m_nProgressStep = -1;
|
76
|
-
String m_strUrlParams = "";
|
80
|
+
public boolean m_bIsSearch = false;
|
77
81
|
|
78
|
-
String m_strPushBody = "";
|
82
|
+
//String m_strPushBody = "";
|
79
83
|
Vector/*Ptr<CSyncBlob*>*/ m_arSyncBlobs = new Vector();
|
80
84
|
|
81
|
-
String m_strAskParams = "";
|
82
85
|
int m_nRefreshTime = 0;
|
86
|
+
int m_nProgressStep = -1;
|
87
|
+
boolean m_bSchemaSource;
|
88
|
+
Hashtable/*<String,String>*/ m_hashLinks = new Hashtable();
|
89
|
+
Vector/*Ptr<net::CMultipartItem*>*/ m_arMultipartItems = new Vector();
|
90
|
+
Vector/*<String>*/ m_arBlobAttrs = new Vector();
|
83
91
|
|
84
|
-
String getUrl() { return m_strUrl; }
|
85
92
|
Integer getID() { return m_nID; }
|
86
93
|
String getName() { return m_strName; }
|
94
|
+
String getSyncType(){ return m_strSyncType; }
|
87
95
|
int getServerObjectsCount(){ return m_nInserted+m_nDeleted; }
|
88
|
-
boolean isSearch(){ return
|
96
|
+
boolean isSearch(){ return m_bIsSearch;}
|
89
97
|
|
90
98
|
long getToken(){ return m_token; }
|
99
|
+
boolean isTokenFromDB(){ return m_bTokenFromDB; }
|
91
100
|
void setToken(long token){ m_token = token; m_bTokenFromDB = false; }
|
92
101
|
boolean isEmptyToken()
|
93
102
|
{
|
94
103
|
return m_token == 0;
|
95
104
|
}
|
96
|
-
|
97
|
-
|
105
|
+
|
106
|
+
int getProgressStep(){ return m_nProgressStep; }
|
107
|
+
void setProgressStep(int nProgressStep){ m_nProgressStep = nProgressStep; }
|
108
|
+
|
109
|
+
boolean getGetAtLeastOnePage(){ return m_bGetAtLeastOnePage; }
|
110
|
+
int getRefreshTime(){ return m_nRefreshTime; }
|
111
|
+
|
98
112
|
int getInsertedCount() { return m_nInserted; }
|
99
113
|
int getDeletedCount() { return m_nDeleted; }
|
100
114
|
void setCurPageCount(int nCurPageCount){m_nCurPageCount = nCurPageCount;}
|
101
115
|
void setTotalCount(int nTotalCount){m_nTotalCount = nTotalCount;}
|
102
116
|
int getCurPageCount(){return m_nCurPageCount;}
|
103
117
|
int getTotalCount(){return m_nTotalCount;}
|
104
|
-
int getProgressStep(){ return m_nProgressStep; }
|
105
118
|
|
106
|
-
void setSyncServerDataPass(int ePass){m_eSyncServerDataPass = ePass;}
|
107
|
-
boolean isDeleteObjectsPass(){ return m_eSyncServerDataPass == edpDeleteObjects; }
|
108
|
-
|
109
119
|
SyncEngine getSync(){ return m_syncEngine; }
|
110
120
|
SyncNotify getNotify(){ return getSync().getNotify(); }
|
111
|
-
DBAdapter getDB(){ return getSync().getDB(); }
|
112
121
|
NetRequest getNet(){ return getSync().getNet(); }
|
122
|
+
ISyncProtocol getProtocol(){ return getSync().getProtocol(); }
|
113
123
|
void setRefreshTime( int nRefreshTime ){ m_nRefreshTime = nRefreshTime;}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
SyncSource(int id, String strUrl, String name, long token, SyncEngine syncEngine )
|
124
|
+
DBAdapter getDB(){ return m_dbAdapter; }
|
125
|
+
|
126
|
+
SyncSource(SyncEngine syncEngine, DBAdapter db)throws DBException
|
118
127
|
{
|
119
128
|
m_syncEngine = syncEngine;
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
m_token = token;
|
124
|
-
m_bTokenFromDB = true;
|
129
|
+
m_dbAdapter = db;
|
130
|
+
|
131
|
+
m_nID = new Integer(0);
|
125
132
|
|
133
|
+
m_bTokenFromDB = true;
|
134
|
+
|
126
135
|
m_nCurPageCount = 0;
|
127
136
|
m_nInserted = 0;
|
128
137
|
m_nDeleted = 0;
|
138
|
+
m_nTotalCount = 0;
|
139
|
+
m_bGetAtLeastOnePage = false;
|
140
|
+
|
141
|
+
m_nErrCode = RhoRuby.ERR_NONE;
|
142
|
+
m_bIsSearch = false;
|
143
|
+
m_bSchemaSource = db.isTableExist(m_strName);
|
129
144
|
}
|
130
145
|
|
131
|
-
SyncSource(SyncEngine syncEngine)
|
146
|
+
SyncSource(int id, String name, String strSyncType, DBAdapter db, SyncEngine syncEngine )throws DBException
|
132
147
|
{
|
133
148
|
m_syncEngine = syncEngine;
|
134
|
-
|
135
|
-
|
136
|
-
m_strName =
|
137
|
-
|
149
|
+
m_dbAdapter = db;
|
150
|
+
m_nID = new Integer(id);
|
151
|
+
m_strName = name;
|
152
|
+
m_strSyncType = strSyncType;
|
138
153
|
|
139
154
|
m_nCurPageCount = 0;
|
140
155
|
m_nInserted = 0;
|
141
156
|
m_nDeleted = 0;
|
157
|
+
m_nTotalCount = 0;
|
158
|
+
m_bGetAtLeastOnePage = false;
|
159
|
+
|
160
|
+
m_nErrCode = RhoRuby.ERR_NONE;
|
161
|
+
m_bIsSearch = false;
|
162
|
+
|
163
|
+
IDBResult res = db.executeSQL("SELECT token,links from sources WHERE source_id=?", m_nID);
|
164
|
+
if ( !res.isEnd() )
|
165
|
+
{
|
166
|
+
m_token = res.getLongByIdx(0);
|
167
|
+
m_bTokenFromDB = true;
|
168
|
+
}else
|
169
|
+
{
|
170
|
+
m_token = 0;
|
171
|
+
m_bTokenFromDB = true;
|
172
|
+
}
|
173
|
+
|
174
|
+
m_bSchemaSource = db.isTableExist(m_strName);
|
175
|
+
parseLinks(res.getStringByIdx(1));
|
176
|
+
}
|
177
|
+
|
178
|
+
void parseLinks(String strLinks)
|
179
|
+
{
|
180
|
+
if (strLinks.length() == 0 )
|
181
|
+
return;
|
182
|
+
|
183
|
+
Tokenizer oTokenizer = new Tokenizer( strLinks, "," );
|
184
|
+
|
185
|
+
String strSrcName = "";
|
186
|
+
while (oTokenizer.hasMoreTokens())
|
187
|
+
{
|
188
|
+
String tok = oTokenizer.nextToken();
|
189
|
+
if (tok.length() == 0)
|
190
|
+
continue;
|
191
|
+
|
192
|
+
if ( strSrcName.length() > 0 )
|
193
|
+
{
|
194
|
+
m_hashLinks.put(strSrcName, tok);
|
195
|
+
strSrcName = "";
|
196
|
+
}else
|
197
|
+
strSrcName = tok;
|
198
|
+
}
|
142
199
|
}
|
143
200
|
|
144
201
|
void sync() throws Exception
|
@@ -146,44 +203,13 @@ class SyncSource
|
|
146
203
|
getNotify().fireSyncNotification(null, false, RhoRuby.ERR_NONE, RhoRuby.getMessageText("syncronizing") + getName() + "...");
|
147
204
|
|
148
205
|
TimeInterval startTime = TimeInterval.getCurrentTime();
|
206
|
+
m_bIsSearch = false;
|
149
207
|
|
150
208
|
try{
|
151
|
-
PROF.START("Pull");
|
152
209
|
if ( isEmptyToken() )
|
153
210
|
processToken(1);
|
154
211
|
|
155
|
-
boolean bSyncedServer =
|
156
|
-
if ( m_strParams.length() == 0 || m_bSearchSyncChanges )
|
157
|
-
{
|
158
|
-
if ( isPendingClientChanges() )
|
159
|
-
{
|
160
|
-
LOG.INFO("Client has unconfirmed items in database. Sync server first.");
|
161
|
-
syncServerChanges();
|
162
|
-
bSyncedServer = true;
|
163
|
-
}
|
164
|
-
|
165
|
-
if ( bSyncedServer && isPendingClientChanges() )
|
166
|
-
{
|
167
|
-
LOG.ERROR("Client still has unconfirmed items in database. Sync is stopped.");
|
168
|
-
getSync().setState(SyncEngine.esStop);
|
169
|
-
}
|
170
|
-
else
|
171
|
-
{
|
172
|
-
boolean bSyncClient = false;
|
173
|
-
{
|
174
|
-
IDBResult res = getDB().executeSQL("SELECT object FROM changed_values WHERE source_id=? and sent<=1 LIMIT 1 OFFSET 0", getID());
|
175
|
-
bSyncClient = !res.isEnd();
|
176
|
-
}
|
177
|
-
if ( bSyncClient )
|
178
|
-
{
|
179
|
-
syncClientChanges();
|
180
|
-
getAndremoveAsk();
|
181
|
-
bSyncedServer = false;
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
PROF.STOP("Pull");
|
186
|
-
|
212
|
+
boolean bSyncedServer = syncClientChanges();
|
187
213
|
if ( !bSyncedServer )
|
188
214
|
syncServerChanges();
|
189
215
|
|
@@ -193,193 +219,215 @@ class SyncSource
|
|
193
219
|
throw exc;
|
194
220
|
}finally{
|
195
221
|
TimeInterval endTime = TimeInterval.getCurrentTime();
|
196
|
-
|
222
|
+
getDB().executeSQL("UPDATE sources set last_updated=?,last_inserted_size=?,last_deleted_size=?, "+
|
197
223
|
"last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
|
198
224
|
new Long(endTime.toULong()/1000), new Integer(getInsertedCount()), new Integer(getDeletedCount()), new Long((endTime.minus(startTime)).toULong()),
|
199
225
|
new Integer(m_bGetAtLeastOnePage?1:0), new Integer(m_nRefreshTime), getID() );
|
200
226
|
}
|
201
227
|
}
|
202
228
|
|
229
|
+
boolean syncClientChanges()throws Exception
|
230
|
+
{
|
231
|
+
boolean bSyncedServer = false;
|
232
|
+
if ( isPendingClientChanges() )
|
233
|
+
{
|
234
|
+
syncServerChanges();
|
235
|
+
bSyncedServer = true;
|
236
|
+
}
|
237
|
+
|
238
|
+
if ( bSyncedServer && isPendingClientChanges() )
|
239
|
+
getSync().setState(SyncEngine.esStop);
|
240
|
+
else
|
241
|
+
{
|
242
|
+
PROF.START("Pull");
|
243
|
+
|
244
|
+
boolean bSyncClient = false;
|
245
|
+
{
|
246
|
+
IDBResult res = getDB().executeSQL("SELECT object FROM changed_values WHERE source_id=? LIMIT 1 OFFSET 0", getID());
|
247
|
+
bSyncClient = !res.isEnd();
|
248
|
+
}
|
249
|
+
if ( bSyncClient )
|
250
|
+
{
|
251
|
+
doSyncClientChanges();
|
252
|
+
bSyncedServer = false;
|
253
|
+
}
|
254
|
+
|
255
|
+
PROF.STOP("Pull");
|
256
|
+
}
|
257
|
+
|
258
|
+
return bSyncedServer;
|
259
|
+
}
|
260
|
+
|
203
261
|
boolean isPendingClientChanges()throws DBException
|
204
262
|
{
|
205
263
|
IDBResult res = getDB().executeSQL("SELECT object FROM changed_values WHERE source_id=? and update_type='create' and sent>1 LIMIT 1 OFFSET 0", getID());
|
206
264
|
return !res.isEnd();
|
207
265
|
}
|
208
|
-
|
209
|
-
void
|
266
|
+
|
267
|
+
void doSyncClientChanges()throws Exception
|
210
268
|
{
|
211
|
-
String
|
212
|
-
|
269
|
+
String arUpdateTypes[] = {"create", "update", "delete"};
|
270
|
+
boolean arUpdateSent[] = {false, false, false};
|
271
|
+
|
272
|
+
m_arMultipartItems.removeAllElements();
|
273
|
+
m_arBlobAttrs.removeAllElements();
|
274
|
+
String strBody = "{\"source_name\":\"" + getName() + "\",\"client_id\":\"" + getSync().getClientID() + "\"";
|
275
|
+
boolean bSend = false;
|
276
|
+
int i = 0;
|
277
|
+
for( i = 0; i < 3 && getSync().isContinueSync(); i++ )
|
213
278
|
{
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
strBlobPath = strBlobPath.substring(1);
|
220
|
-
|
221
|
-
strFilePath += strBlobPath;
|
222
|
-
|
223
|
-
strQuery = strBaseQuery + "&" + blob.getBody();
|
224
|
-
try{
|
225
|
-
NetResponse resp = getNet().pushFile(strQuery, strFilePath, getSync(), null );
|
226
|
-
if ( !resp.isOK() )
|
227
|
-
{
|
228
|
-
getSync().setState(SyncEngine.esStop);
|
229
|
-
m_nErrCode = RhoRuby.ERR_REMOTESERVER;
|
230
|
-
//m_strError = resp.getCharData();
|
231
|
-
return;
|
232
|
-
}
|
233
|
-
}catch(Exception exc)
|
234
|
-
{
|
235
|
-
m_nErrCode = RhoRuby.getNetErrorCode(exc);
|
236
|
-
throw exc;
|
237
|
-
}
|
279
|
+
String strBody1;
|
280
|
+
strBody1 = makePushBody_Ver3(arUpdateTypes[i]);
|
281
|
+
if (strBody1.length() > 0)
|
282
|
+
{
|
283
|
+
strBody += "," + strBody1;
|
238
284
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
285
|
+
String strBlobAttrs = "";
|
286
|
+
for ( int j = 0; j < (int)m_arBlobAttrs.size(); j++)
|
287
|
+
{
|
288
|
+
if ( strBlobAttrs.length() > 0 )
|
289
|
+
strBlobAttrs += ",";
|
290
|
+
|
291
|
+
strBlobAttrs += "\"" + m_arBlobAttrs.elementAt(j) + "\"";
|
292
|
+
}
|
293
|
+
|
294
|
+
if ( strBlobAttrs.length() > 0 )
|
295
|
+
strBody += ",\"blob_fields\":[" + strBlobAttrs + "]";
|
296
|
+
|
297
|
+
arUpdateSent[i] = true;
|
298
|
+
bSend = true;
|
299
|
+
}
|
243
300
|
}
|
244
|
-
|
245
|
-
m_arSyncBlobs.removeAllElements();
|
246
|
-
}
|
301
|
+
strBody += "}";
|
247
302
|
|
248
|
-
|
249
|
-
{
|
250
|
-
String[] arUpdateTypes = {"create", "update", "delete"};
|
251
|
-
for( int i = 0; i < 3 && getSync().isContinueSync(); i++ )
|
303
|
+
if ( bSend )
|
252
304
|
{
|
253
|
-
|
254
|
-
|
255
|
-
String strQuery = SyncEngine.SYNC_SOURCE_FORMAT() + "&client_id=" + getSync().getClientID();
|
305
|
+
LOG.INFO( "Push client changes to server. Source: " + getName() + "Size :" + strBody.length() );
|
306
|
+
LOG.TRACE("Push body: " + strBody);
|
256
307
|
|
257
|
-
|
258
|
-
String strBody = makePushBody(arUpdateTypes[i]);
|
259
|
-
if ( strBody.length() > 0 )
|
308
|
+
if ( m_arMultipartItems.size() > 0 )
|
260
309
|
{
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
310
|
+
MultipartItem oItem = new MultipartItem();
|
311
|
+
oItem.m_strBody = strBody;
|
312
|
+
//oItem.m_strContentType = getProtocol().getContentType();
|
313
|
+
oItem.m_strName = "cud";
|
314
|
+
m_arMultipartItems.addElement(oItem);
|
315
|
+
|
316
|
+
NetResponse resp = getNet().pushMultipartData( getProtocol().getClientChangesUrl(), m_arMultipartItems, getSync(), null );
|
265
317
|
if ( !resp.isOK() )
|
266
318
|
{
|
267
319
|
getSync().setState(SyncEngine.esStop);
|
268
320
|
m_nErrCode = RhoRuby.ERR_REMOTESERVER;
|
269
|
-
continue;
|
270
321
|
}
|
271
|
-
}
|
272
|
-
|
273
|
-
if ( m_arSyncBlobs.size()>0 )
|
322
|
+
}else
|
274
323
|
{
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
324
|
+
NetResponse resp = getNet().pushData( getProtocol().getClientChangesUrl(), strBody, getSync());
|
325
|
+
if ( !resp.isOK() )
|
326
|
+
{
|
327
|
+
getSync().setState(SyncEngine.esStop);
|
328
|
+
m_nErrCode = RhoRuby.ERR_REMOTESERVER;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
for( i = 0; i < 3 && getSync().isContinueSync(); i++ )
|
334
|
+
{
|
335
|
+
if ( arUpdateSent[i] )
|
287
336
|
{
|
288
337
|
//oo conflicts
|
289
338
|
if ( i < 1 ) //create
|
290
339
|
getDB().executeSQL("UPDATE changed_values SET sent=2 WHERE source_id=? and update_type=? and sent=1", getID(), arUpdateTypes[i] );
|
291
340
|
else
|
292
341
|
//
|
293
|
-
|
342
|
+
getDB().executeSQL("DELETE FROM changed_values WHERE source_id=? and update_type=? and sent=1", getID(), arUpdateTypes[i] );
|
294
343
|
}
|
295
344
|
}
|
345
|
+
|
346
|
+
m_arMultipartItems.removeAllElements();
|
347
|
+
m_arBlobAttrs.removeAllElements();
|
296
348
|
}
|
297
349
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
* update: attrvals[][attrib]=<name|industry>&attrvals[][object]=<remoteid>&attrvals[][value]=<some new value>
|
304
|
-
* delete: attrvals[][attrib]=<name|industry>&attrvals[][object]=<remoteid>
|
305
|
-
*/
|
306
|
-
|
307
|
-
String makePushBody( String szUpdateType)throws DBException
|
350
|
+
//{"source_name":"SampleAdapter","client_id":1,"create":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}}}
|
351
|
+
//{"source_name":"SampleAdapter","client_id":1,"update":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}}}
|
352
|
+
//{"source_name":"SampleAdapter","client_id":1,"delete":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}}}
|
353
|
+
//{"source_name":"SampleAdapter","client_id":1,"delete":{"3":{"brand":"HTC","name":"Fuze","price":"299.99"}},"create":{"1":{"brand":"Apple","name":"iPhone","price":"199.99"}},"update":{"2":{"brand":"Android","name":"G2","price":"99.99"}}}
|
354
|
+
String makePushBody_Ver3( String strUpdateType)throws DBException
|
308
355
|
{
|
309
356
|
String strBody = "";
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
357
|
+
getDB().Lock();
|
358
|
+
IDBResult res = getDB().executeSQL("SELECT attrib, object, value, attrib_type "+
|
359
|
+
"FROM changed_values where source_id=? and update_type =? and sent<=1 ORDER BY object", getID(), strUpdateType );
|
360
|
+
|
314
361
|
if ( res.isEnd() )
|
315
362
|
{
|
316
|
-
|
317
|
-
|
363
|
+
getDB().Unlock();
|
364
|
+
return strBody;
|
318
365
|
}
|
319
|
-
|
366
|
+
|
367
|
+
String strCurObject = "";
|
368
|
+
boolean bFirst = true;
|
320
369
|
for( ; !res.isEnd(); res.next() )
|
321
370
|
{
|
322
|
-
String
|
323
|
-
|
324
|
-
if ( res.getStringByIdx(1).length() > 0 )
|
325
|
-
strSrcBody += "&attrvals[][object]=" + res.getStringByIdx(1);
|
326
|
-
|
327
|
-
long main_id = res.getLongByIdx(4);
|
328
|
-
if ( main_id != 0 )
|
329
|
-
strSrcBody += "&attrvals[][id]=" + main_id;
|
330
|
-
|
371
|
+
String strAttrib = res.getStringByIdx(0);
|
372
|
+
String strObject = res.getStringByIdx(1);
|
331
373
|
String value = res.getStringByIdx(2);
|
332
374
|
String attribType = res.getStringByIdx(3);
|
333
|
-
|
334
|
-
|
335
|
-
//if ( value.length() > 0 )
|
375
|
+
|
376
|
+
if ( attribType.compareTo("blob.file") == 0 )
|
336
377
|
{
|
337
|
-
|
378
|
+
MultipartItem oItem = new MultipartItem();
|
379
|
+
oItem.m_strFilePath = RhodesApp.getInstance().resolveDBFilesPath(value);
|
380
|
+
oItem.m_strContentType = "application/octet-stream";
|
381
|
+
oItem.m_strName = strAttrib + "-" + strObject;
|
382
|
+
|
383
|
+
m_arBlobAttrs.addElement(strAttrib);
|
384
|
+
m_arMultipartItems.addElement(oItem);
|
385
|
+
}
|
386
|
+
|
387
|
+
if ( strBody.length() == 0 )
|
388
|
+
strBody += "\"" + strUpdateType + "\":{";
|
389
|
+
|
390
|
+
if ( strObject.compareTo(strCurObject) != 0 )
|
391
|
+
{
|
392
|
+
if ( strCurObject.length() > 0 )
|
338
393
|
{
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
}else
|
348
|
-
strSrcBody += "&attrvals[][value]=" + value;
|
394
|
+
if ( !bFirst )
|
395
|
+
strBody += "}";
|
396
|
+
strBody += ",";
|
397
|
+
}
|
398
|
+
|
399
|
+
bFirst = true;
|
400
|
+
strBody += "\"" + strObject + "\"";
|
401
|
+
strCurObject = strObject;
|
349
402
|
}
|
350
|
-
|
351
|
-
if (
|
352
|
-
strBody += "
|
353
|
-
|
354
|
-
strBody += strSrcBody;
|
355
|
-
}
|
356
|
-
|
357
|
-
getDB().executeSQL("UPDATE changed_values SET sent=1 WHERE source_id=? and update_type=? and sent=0", getID(), szUpdateType );
|
358
|
-
getDB().Unlock();
|
359
|
-
|
360
|
-
return strBody;
|
361
|
-
}
|
403
|
+
|
404
|
+
if (!bFirst)
|
405
|
+
strBody += ",";
|
362
406
|
|
363
|
-
|
364
|
-
{
|
365
|
-
String askParams = "";
|
366
|
-
{
|
367
|
-
IDBResult res = getDB().executeSQL("SELECT object, attrib, value "+
|
368
|
-
"FROM changed_values WHERE source_id=? and update_type =?", getID(), "ask" );
|
369
|
-
if ( !res.isEnd() )
|
407
|
+
if ( strAttrib.length() > 0 )
|
370
408
|
{
|
371
|
-
|
409
|
+
if ( bFirst )
|
410
|
+
strBody += ":{";
|
372
411
|
|
373
|
-
|
374
|
-
|
412
|
+
strBody += "\"" + strAttrib + "\":\"" + value + "\"";
|
413
|
+
bFirst = false;
|
375
414
|
}
|
376
|
-
|
377
|
-
getDB().executeSQL("DELETE FROM changed_values WHERE source_id=? and update_type=?", getID(), "ask" );
|
378
415
|
}
|
379
416
|
|
380
|
-
|
417
|
+
if ( strBody.length() > 0 )
|
418
|
+
{
|
419
|
+
if ( !bFirst )
|
420
|
+
strBody += "}";
|
421
|
+
|
422
|
+
strBody += "}";
|
423
|
+
}
|
424
|
+
|
425
|
+
getDB().executeSQL("UPDATE changed_values SET sent=1 WHERE source_id=? and update_type=? and sent=0", getID(), strUpdateType );
|
426
|
+
getDB().Unlock();
|
427
|
+
|
428
|
+
return strBody;
|
381
429
|
}
|
382
|
-
|
430
|
+
|
383
431
|
void syncServerChanges()throws Exception
|
384
432
|
{
|
385
433
|
LOG.INFO("Sync server changes source ID :" + getID() );
|
@@ -387,42 +435,24 @@ class SyncSource
|
|
387
435
|
while( getSync().isContinueSync() )
|
388
436
|
{
|
389
437
|
setCurPageCount(0);
|
390
|
-
String strUrl =
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
String strQuery = SyncEngine.SYNC_SOURCE_FORMAT() + "&client_id=" + getSync().getClientID() +
|
395
|
-
"&p_size=" + getSync().SYNC_PAGE_SIZE() + "&version=" + getSync().SYNC_VERSION();
|
396
|
-
if ( m_strParams.length() > 0 )
|
397
|
-
strQuery += m_strParams;
|
398
|
-
|
399
|
-
if( m_strUrlParams.length() > 0 )
|
400
|
-
strQuery += "&" + m_strUrlParams;
|
401
|
-
|
402
|
-
if ( getAskParams().length() > 0 )
|
403
|
-
{
|
404
|
-
getSync();
|
405
|
-
strUrl += SyncEngine.SYNC_ASK_ACTION();
|
406
|
-
strQuery += "&question=" + getAskParams();
|
407
|
-
}
|
408
|
-
|
438
|
+
String strUrl = getProtocol().getServerQueryUrl("");
|
439
|
+
String strQuery = getProtocol().getServerQueryBody(getName(), getSync().getClientID(), getSync().getSyncPageSize());
|
440
|
+
|
409
441
|
if ( !m_bTokenFromDB && getToken() > 1 )
|
410
|
-
strQuery += "&
|
411
|
-
|
442
|
+
strQuery += "&token=" + getToken();
|
443
|
+
|
412
444
|
LOG.INFO( "Pull changes from server. Url: " + (strUrl+strQuery) );
|
413
445
|
|
414
446
|
NetResponse resp = null;
|
415
447
|
try{
|
416
|
-
|
417
|
-
|
448
|
+
PROF.START("Net");
|
449
|
+
resp = getNet().pullData(strUrl+strQuery, getSync());
|
418
450
|
PROF.STOP("Net");
|
419
|
-
|
451
|
+
|
420
452
|
if ( !resp.isOK() )
|
421
453
|
{
|
422
454
|
getSync().stopSync();
|
423
|
-
|
424
|
-
//m_strError = resp.getCharData();
|
425
|
-
|
455
|
+
m_nErrCode = RhoRuby.getErrorFromResponse(resp);
|
426
456
|
continue;
|
427
457
|
}
|
428
458
|
}catch(Exception exc)
|
@@ -430,312 +460,429 @@ class SyncSource
|
|
430
460
|
m_nErrCode = RhoRuby.getNetErrorCode(exc);
|
431
461
|
throw exc;
|
432
462
|
}
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
"{a:\"second_name\",i:55555,v:\"Burgess\"}]},"
|
444
|
-
"{oo:\"456\", e:\"Something went wrong creating this record on the backend: code 7\"}"
|
445
|
-
"]}]"; */
|
446
|
-
/*"[{count: 1},{version: 1},{total_count: 1},{token: 123},"
|
447
|
-
"{s:\"Product\",ol:["
|
448
|
-
"{oo:\"94\", e:\"Something went wrong creating this record on the backend: code 7\"}"
|
449
|
-
"]}]";*/
|
450
|
-
/*"[{count: 1},{version: 1},{total_count: 1},{token: 123},"
|
451
|
-
"{s:\"Product\",ol:["
|
452
|
-
"{o:\"94\", av:["
|
453
|
-
"{a:\"TEST\",i:55555,v:\"Geny\"}]},"
|
454
|
-
"]}]";
|
455
|
-
|
456
|
-
//u:\"query\",
|
457
|
-
*/
|
458
|
-
//processServerData(strData);
|
459
|
-
|
460
|
-
if ( getAskParams().length() > 0 || getCurPageCount() == 0 )
|
463
|
+
|
464
|
+
String szData = resp.getCharData();
|
465
|
+
|
466
|
+
PROF.START("Parse");
|
467
|
+
JSONArrayIterator oJsonArr = new JSONArrayIterator(szData);
|
468
|
+
PROF.STOP("Parse");
|
469
|
+
|
470
|
+
processServerResponse_ver3(oJsonArr);
|
471
|
+
|
472
|
+
if ( getToken() == 0 )
|
461
473
|
break;
|
462
474
|
}
|
463
475
|
}
|
464
476
|
|
465
|
-
void
|
477
|
+
void processServerResponse_ver3(JSONArrayIterator oJsonArr)throws Exception
|
466
478
|
{
|
467
|
-
LOG.TRACE("Server data: " + szData);
|
468
|
-
PROF.START("Parse");
|
469
|
-
JSONArrayIterator oJsonArr = new JSONArrayIterator(szData);
|
470
|
-
PROF.STOP("Parse");
|
471
|
-
|
472
479
|
PROF.START("Data1");
|
473
|
-
|
480
|
+
|
481
|
+
int nVersion = 0;
|
482
|
+
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("version") )
|
474
483
|
{
|
475
|
-
|
476
|
-
|
484
|
+
nVersion = oJsonArr.getCurItem().getInt("version");
|
485
|
+
oJsonArr.next();
|
486
|
+
}
|
487
|
+
|
488
|
+
if ( nVersion != getProtocol().getVersion() )
|
489
|
+
{
|
490
|
+
LOG.ERROR("Sync server send data with incompatible version. Client version: " + getProtocol().getVersion() +
|
491
|
+
"; Server response version: " + nVersion + ". Source name: " + getName() );
|
477
492
|
getSync().stopSync();
|
493
|
+
m_nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
|
478
494
|
return;
|
479
495
|
}
|
480
|
-
|
481
|
-
if ( !oJsonArr.isEnd() )
|
496
|
+
|
497
|
+
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("source") )
|
482
498
|
{
|
483
|
-
|
499
|
+
//skip it. it uses in search only
|
484
500
|
oJsonArr.next();
|
485
501
|
}
|
486
|
-
|
487
|
-
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("
|
502
|
+
|
503
|
+
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("token"))
|
488
504
|
{
|
489
|
-
|
505
|
+
processToken(oJsonArr.getCurItem().getUInt64("token"));
|
490
506
|
oJsonArr.next();
|
491
507
|
}
|
492
|
-
|
493
|
-
if (
|
508
|
+
|
509
|
+
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("count") )
|
494
510
|
{
|
495
|
-
|
496
|
-
|
497
|
-
getSync().stopSync();
|
498
|
-
m_nErrCode = RhoRuby.ERR_SYNCVERSION;
|
499
|
-
return;
|
511
|
+
setCurPageCount(oJsonArr.getCurItem().getInt("count"));
|
512
|
+
oJsonArr.next();
|
500
513
|
}
|
501
|
-
|
502
|
-
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("
|
514
|
+
|
515
|
+
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("refresh_time") )
|
503
516
|
{
|
504
|
-
setRefreshTime(oJsonArr.getCurItem().getInt("
|
517
|
+
setRefreshTime(oJsonArr.getCurItem().getInt("refresh_time"));
|
505
518
|
oJsonArr.next();
|
506
519
|
}
|
507
|
-
|
520
|
+
|
521
|
+
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("progress_count") )
|
522
|
+
{
|
523
|
+
//TODO: progress_count
|
524
|
+
//setTotalCount(oJsonArr.getCurItem().getInt("progress_count"));
|
525
|
+
oJsonArr.next();
|
526
|
+
}
|
527
|
+
|
508
528
|
if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("total_count") )
|
509
529
|
{
|
510
530
|
setTotalCount(oJsonArr.getCurItem().getInt("total_count"));
|
511
531
|
oJsonArr.next();
|
512
532
|
}
|
513
|
-
|
514
|
-
// if ( getServerObjectsCount() == 0 )
|
515
|
-
// getNotify().fireSyncNotification(this, false, RhoRuby.ERR_NONE, "");
|
516
|
-
|
517
|
-
if ( !oJsonArr.isEnd() )
|
533
|
+
/* if ( !oJsonArr.isEnd() && oJsonArr.getCurItem().hasName("source-error") )
|
518
534
|
{
|
519
|
-
|
520
|
-
|
521
|
-
|
535
|
+
CJSONEntry oJsonErr = oJsonArr.getCurItem().getEntry("source-error");
|
536
|
+
m_strError = oJsonErr.getString("message");
|
537
|
+
m_nErrCode = RhoRuby.ERR_CUSTOMSYNCSERVER;
|
538
|
+
getSync().stopSync();
|
539
|
+
return;
|
540
|
+
}*/
|
541
|
+
|
542
|
+
//if ( getServerObjectsCount() == 0 )
|
543
|
+
// getNotify().fireSyncNotification(this, false, RhoRuby.ERR_NONE, "");
|
544
|
+
|
545
|
+
if ( getToken() == 0 )
|
522
546
|
{
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
547
|
+
//oo conflicts
|
548
|
+
getDB().executeSQL("DELETE FROM changed_values where source_id=? and sent>=3", getID() );
|
549
|
+
//
|
550
|
+
|
527
551
|
}
|
528
|
-
|
529
|
-
LOG.INFO(
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
}
|
561
|
-
|
552
|
+
|
553
|
+
LOG.INFO("Got " + getCurPageCount() + "(Processed: " + getServerObjectsCount() + ") records of " + getTotalCount() + " from server. Source: " + getName()
|
554
|
+
+ ". Version: " + nVersion );
|
555
|
+
|
556
|
+
PROF.STOP("Data1");
|
557
|
+
if ( !oJsonArr.isEnd() && getSync().isContinueSync() )
|
558
|
+
{
|
559
|
+
JSONEntry oCmds = oJsonArr.getCurItem();
|
560
|
+
PROF.START("Data");
|
561
|
+
|
562
|
+
getDB().startTransaction();
|
563
|
+
if ( oCmds.hasName("metadata") && getSync().isContinueSync() )
|
564
|
+
{
|
565
|
+
String strMetadata = oCmds.getString("metadata");
|
566
|
+
getDB().executeSQL("UPDATE sources SET metadata=? WHERE source_id=?", strMetadata, getID() );
|
567
|
+
}
|
568
|
+
if ( oCmds.hasName("links") && getSync().isContinueSync() )
|
569
|
+
processSyncCommand("links", oCmds.getEntry("links") );
|
570
|
+
if ( oCmds.hasName("delete") && getSync().isContinueSync() )
|
571
|
+
processSyncCommand("delete", oCmds.getEntry("delete") );
|
572
|
+
if ( oCmds.hasName("insert") && getSync().isContinueSync() )
|
573
|
+
processSyncCommand("insert", oCmds.getEntry("insert") );
|
574
|
+
|
575
|
+
PROF.STOP("Data");
|
576
|
+
|
577
|
+
PROF.START("DB");
|
578
|
+
getDB().endTransaction();
|
579
|
+
PROF.STOP("DB");
|
580
|
+
|
581
|
+
getNotify().fireObjectsNotification();
|
582
|
+
}
|
583
|
+
|
562
584
|
PROF.START("Data1");
|
563
|
-
|
564
|
-
|
585
|
+
if ( getCurPageCount() > 0 )
|
586
|
+
getNotify().fireSyncNotification(this, false, RhoRuby.ERR_NONE, "");
|
565
587
|
PROF.STOP("Data1");
|
566
588
|
}
|
589
|
+
|
590
|
+
void processSyncCommand(String strCmd, JSONEntry oCmdEntry)throws Exception
|
591
|
+
{
|
592
|
+
JSONStructIterator objIter = new JSONStructIterator(oCmdEntry);
|
593
|
+
|
594
|
+
for( ; !objIter.isEnd() && getSync().isContinueSync(); objIter.next() )
|
595
|
+
{
|
596
|
+
String strObject = objIter.getCurKey();
|
597
|
+
JSONStructIterator attrIter = new JSONStructIterator( objIter.getCurValue() );
|
598
|
+
if ( m_bSchemaSource )
|
599
|
+
processServerCmd_Ver3_Schema(strCmd,strObject,attrIter);
|
600
|
+
else
|
601
|
+
{
|
602
|
+
for( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next() )
|
603
|
+
{
|
604
|
+
String strAttrib = attrIter.getCurKey();
|
605
|
+
String strValue = attrIter.getCurString();
|
606
|
+
|
607
|
+
processServerCmd_Ver3(strCmd,strObject,strAttrib,strValue);
|
608
|
+
}
|
609
|
+
}
|
567
610
|
|
568
|
-
|
611
|
+
int nSyncObjectCount = getNotify().incLastSyncObjectCount(getID());
|
612
|
+
if ( getProgressStep() > 0 && (nSyncObjectCount%getProgressStep() == 0) )
|
613
|
+
getNotify().fireSyncNotification(this, false, RhoRuby.ERR_NONE, "");
|
614
|
+
|
615
|
+
if ( getDB().isUIWaitDB() )
|
616
|
+
{
|
617
|
+
LOG.INFO("Commit transaction because of UI request.");
|
618
|
+
getDB().endTransaction();
|
619
|
+
SyncThread.getInstance().sleep(1000);
|
620
|
+
getDB().startTransaction();
|
621
|
+
}
|
622
|
+
}
|
623
|
+
}
|
624
|
+
|
625
|
+
void processLinks(String strOldObject, String strNewObject)throws Exception
|
569
626
|
{
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
627
|
+
Enumeration vals = m_hashLinks.elements();
|
628
|
+
Enumeration keys = m_hashLinks.keys();
|
629
|
+
while (vals.hasMoreElements())
|
630
|
+
{
|
631
|
+
SyncSource pSrc = getSync().findSourceByName((String)keys.nextElement());
|
632
|
+
if ( pSrc != null )
|
633
|
+
pSrc.updateLink(strOldObject, strNewObject, (String)vals.nextElement());
|
634
|
+
}
|
635
|
+
}
|
636
|
+
|
637
|
+
void updateLink(String strOldObject, String strNewObject, String strAttrib)throws Exception
|
638
|
+
{
|
639
|
+
if ( m_bSchemaSource )
|
575
640
|
{
|
576
|
-
|
577
|
-
|
578
|
-
|
641
|
+
String strSqlUpdate = "UPDATE ";
|
642
|
+
strSqlUpdate += getName() + " SET " + strAttrib + "=? where " + strAttrib + "=?";
|
643
|
+
|
644
|
+
getDB().executeSQL(strSqlUpdate, strNewObject, strOldObject );
|
579
645
|
}
|
646
|
+
else
|
647
|
+
getDB().executeSQL("UPDATE object_values SET value=? where attrib=? and source_id=? and value=?",
|
648
|
+
strNewObject, strAttrib, getID(), strOldObject );
|
580
649
|
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
650
|
+
getDB().executeSQL("UPDATE changed_values SET value=? where attrib=? and source_id=? and value=?",
|
651
|
+
strNewObject, strAttrib, getID(), strOldObject );
|
652
|
+
}
|
653
|
+
|
654
|
+
void processServerCmd_Ver3_Schema(String strCmd, String strObject, JSONStructIterator attrIter)throws Exception
|
655
|
+
{
|
656
|
+
if ( strCmd.compareTo("insert") == 0 )
|
657
|
+
{
|
658
|
+
Vector/*<String>*/ vecValues = new Vector(), vecAttrs = new Vector();
|
659
|
+
String strCols = "", strQuest = "", strSet = "";
|
660
|
+
for( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next() )
|
661
|
+
{
|
662
|
+
CAttrValue oAttrValue = new CAttrValue(attrIter.getCurKey(),attrIter.getCurString());
|
663
|
+
if ( !processBlob(strCmd,strObject,oAttrValue) )
|
664
|
+
continue;
|
665
|
+
|
666
|
+
if ( strCols.length() > 0 )
|
667
|
+
strCols += ",";
|
668
|
+
if ( strQuest.length() > 0)
|
669
|
+
strQuest += ",";
|
670
|
+
if ( strSet.length() > 0)
|
671
|
+
strSet += ",";
|
672
|
+
|
673
|
+
strCols += oAttrValue.m_strAttrib;
|
674
|
+
strQuest += "?";
|
675
|
+
strSet += oAttrValue.m_strAttrib + "=?";
|
676
|
+
vecAttrs.addElement(oAttrValue.m_strAttrib);
|
677
|
+
vecValues.addElement(oAttrValue.m_strValue);
|
678
|
+
}
|
679
|
+
vecValues.addElement(strObject);
|
680
|
+
if ( strCols.length() > 0 )
|
681
|
+
strCols += ",";
|
682
|
+
if ( strQuest.length() > 0)
|
683
|
+
strQuest += ",";
|
591
684
|
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
685
|
+
strCols += "object";
|
686
|
+
strQuest += "?";
|
687
|
+
|
688
|
+
String strSqlInsert = "INSERT INTO ";
|
689
|
+
strSqlInsert += getName() + " (";
|
690
|
+
strSqlInsert += strCols + ") VALUES(" + strQuest + ")";
|
691
|
+
|
692
|
+
if ( !getSync().isContinueSync() )
|
693
|
+
return;
|
694
|
+
|
695
|
+
IDBResult resInsert = getDB().executeSQLReportNonUniqueEx(strSqlInsert, vecValues );
|
696
|
+
if ( resInsert.isNonUnique() )
|
697
|
+
{
|
698
|
+
String strSqlUpdate = "UPDATE ";
|
699
|
+
strSqlUpdate += getName() + " SET " + strSet + " WHERE object=?";
|
700
|
+
getDB().executeSQLEx(strSqlUpdate, vecValues);
|
701
|
+
|
702
|
+
// oo conflicts
|
703
|
+
for( int i = 0; i < (int)vecAttrs.size(); i++ )
|
601
704
|
{
|
602
|
-
|
603
|
-
|
705
|
+
getDB().executeSQL("UPDATE changed_values SET sent=4 where object=? and attrib=? and source_id=? and sent>1",
|
706
|
+
strObject, vecAttrs.elementAt(i), getID() );
|
707
|
+
}
|
708
|
+
//
|
709
|
+
}
|
710
|
+
|
711
|
+
getNotify().onObjectChanged(getID(),strObject, SyncNotify.enUpdate);
|
712
|
+
m_nInserted++;
|
713
|
+
}else if (strCmd.compareTo("delete") == 0)
|
714
|
+
{
|
715
|
+
Vector/*<String>*/ vecAttrs = new Vector();
|
716
|
+
String strSet = "";
|
717
|
+
for( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next() )
|
718
|
+
{
|
719
|
+
CAttrValue oAttrValue = new CAttrValue(attrIter.getCurKey(),attrIter.getCurString());
|
720
|
+
|
721
|
+
if ( strSet.length() > 0 )
|
722
|
+
strSet += ",";
|
604
723
|
|
605
|
-
|
724
|
+
vecAttrs.addElement(oAttrValue.m_strAttrib);
|
725
|
+
strSet += oAttrValue.m_strAttrib + "=NULL";
|
726
|
+
}
|
606
727
|
|
607
|
-
|
728
|
+
String strSqlUpdate = "UPDATE ";
|
729
|
+
strSqlUpdate += getName() + " SET " + strSet + " WHERE object=?";
|
730
|
+
|
731
|
+
if ( strSet.length() == 0 || !getSync().isContinueSync() )
|
732
|
+
return;
|
733
|
+
|
734
|
+
getDB().executeSQL(strSqlUpdate, strObject);
|
735
|
+
//Remove item if all nulls
|
736
|
+
String strSelect = "SELECT * FROM " + getName() + " WHERE object=?";
|
737
|
+
IDBResult res = getDB().executeSQL( strSelect, strObject );
|
738
|
+
if ( !res.isEnd() )
|
739
|
+
{
|
740
|
+
boolean bAllNulls = true;
|
741
|
+
for( int i = 0; i < res.getColCount(); i ++)
|
742
|
+
{
|
743
|
+
if ( !res.isNullByIdx(i) && res.getColName(i).compareTo("object")!=0 )
|
744
|
+
{
|
745
|
+
bAllNulls = false;
|
746
|
+
break;
|
747
|
+
}
|
608
748
|
}
|
609
|
-
|
610
|
-
|
611
|
-
"(id, attrib, source_id, object, value, attrib_type) VALUES(?,?,?,?,?,?)",
|
612
|
-
value.m_nID, strAttrib, nSrcID, strObject,
|
613
|
-
value.m_strValue, value.m_strAttrType );
|
614
|
-
if ( resInsert.isNonUnique() )
|
615
|
-
{
|
616
|
-
getDB().executeSQL("UPDATE object_values "+
|
617
|
-
"SET id=?, value=?, attrib_type=? WHERE object=? and attrib=? and source_id=?",
|
618
|
-
value.m_nID, value.m_strValue, value.m_strAttrType,
|
619
|
-
strObject, strAttrib, nSrcID );
|
620
|
-
|
621
|
-
// oo conflicts
|
622
|
-
getDB().executeSQL("UPDATE changed_values SET main_id=? where object=? and attrib=? and source_id=? and sent<=1", value.m_nID, strObject, strAttrib, nSrcID );
|
623
|
-
getDB().executeSQL("UPDATE changed_values SET sent=4 where object=? and attrib=? and source_id=? and sent>1", strObject, strAttrib, nSrcID );
|
624
|
-
//
|
625
|
-
}
|
626
|
-
|
627
|
-
getNotify().onObjectChanged(nSrcID,strObject, SyncNotify.enUpdate);
|
628
|
-
|
629
|
-
m_nInserted++;
|
630
|
-
}else
|
631
|
-
{
|
632
|
-
long id = oJsonEntry.getLong("i");
|
633
|
-
|
634
|
-
IDBResult res = getDB().executeSQL("SELECT source_id, object FROM object_values where id=?", id );
|
635
|
-
if ( !res.isEnd() )
|
749
|
+
|
750
|
+
if (bAllNulls)
|
636
751
|
{
|
637
|
-
|
638
|
-
|
639
|
-
String strDelObject = res.getStringByIdx(1);
|
640
|
-
getDB().executeSQL("DELETE FROM object_values where id=?", id );
|
641
|
-
getNotify().onObjectChanged(nDelSrcID, strDelObject, SyncNotify.enDelete);
|
752
|
+
String strDelete = "DELETE FROM " + getName() + " WHERE object=?";
|
753
|
+
getDB().executeSQL( strDelete, strObject);
|
642
754
|
}
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
755
|
+
}
|
756
|
+
|
757
|
+
getNotify().onObjectChanged(getID(), strObject, SyncNotify.enDelete);
|
758
|
+
// oo conflicts
|
759
|
+
for( int i = 0; i < (int)vecAttrs.size(); i++ )
|
760
|
+
{
|
761
|
+
getDB().executeSQL("UPDATE changed_values SET sent=3 where object=? and attrib=? and source_id=?",
|
762
|
+
strObject, vecAttrs.elementAt(i), getID() );
|
763
|
+
}
|
764
|
+
//
|
765
|
+
|
766
|
+
m_nDeleted++;
|
767
|
+
}else if ( strCmd.compareTo("links") == 0 )
|
768
|
+
{
|
769
|
+
String strValue = attrIter.getCurString();
|
770
|
+
processLinks(strObject, strValue);
|
771
|
+
|
772
|
+
String strSqlUpdate = "UPDATE ";
|
773
|
+
strSqlUpdate += getName() + " SET object=? WHERE object=?";
|
774
|
+
getDB().executeSQL(strSqlUpdate, strValue, strObject);
|
775
|
+
|
776
|
+
getDB().executeSQL("UPDATE changed_values SET object=?,sent=3 where object=? and source_id=?", strValue, strObject, getID() );
|
777
|
+
getNotify().onObjectChanged(getID(), strObject, SyncNotify.enCreate);
|
778
|
+
}
|
779
|
+
|
652
780
|
}
|
653
781
|
|
654
|
-
|
782
|
+
boolean processBlob( String strCmd, String strObject, CAttrValue oAttrValue )throws Exception
|
655
783
|
{
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
784
|
+
//TODO: when server return delete with rhoblob postfix - delete isBlobAttr
|
785
|
+
if ( !(oAttrValue.m_strBlobSuffix.length() > 0 || getDB().getAttrMgr().isBlobAttr(getID(), oAttrValue.m_strAttrib)) )
|
786
|
+
return true;
|
787
|
+
|
788
|
+
boolean bDownload = true;
|
789
|
+
String strDbValue = "";
|
790
|
+
if ( !getDB().getAttrMgr().isOverwriteBlobFromServer(getID(), oAttrValue.m_strAttrib) )
|
791
|
+
{
|
792
|
+
if ( m_bSchemaSource )
|
664
793
|
{
|
665
|
-
|
666
|
-
|
794
|
+
String strSelect = "SELECT " + oAttrValue.m_strAttrib + " FROM " + getName() + " WHERE object=?";
|
795
|
+
IDBResult res = getDB().executeSQL( strSelect, strObject);
|
796
|
+
if (!res.isEnd())
|
667
797
|
{
|
668
|
-
|
669
|
-
|
670
|
-
m_nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
|
671
|
-
break;
|
798
|
+
strDbValue = res.getStringByIdx(0);
|
799
|
+
bDownload = strDbValue == null || strDbValue.length() == 0;
|
672
800
|
}
|
673
|
-
|
674
|
-
}
|
675
|
-
|
676
|
-
JSONArrayIterator oJsonObjList = new JSONArrayIterator(oJsonSource, "ol");
|
677
|
-
m_nAttribCounter = 0;
|
678
|
-
for( ; !oJsonObjList.isEnd() && getSync().isContinueSync(); oJsonObjList.next() )
|
801
|
+
}else
|
679
802
|
{
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
getDB().endTransaction();
|
686
|
-
getDB().startTransaction();
|
687
|
-
|
688
|
-
m_nAttribCounter = 0;
|
689
|
-
}
|
690
|
-
|
691
|
-
JSONEntry oJsonObject = oJsonObjList.getCurItem();
|
692
|
-
if( !processSyncObject_ver1(oJsonObject,nSrcID))
|
803
|
+
IDBResult res = getDB().executeSQL(
|
804
|
+
"SELECT value FROM object_values WHERE object=? and attrib=? and source_id=?",
|
805
|
+
strObject, oAttrValue.m_strAttrib, getID() );
|
806
|
+
if (!res.isEnd())
|
693
807
|
{
|
694
|
-
|
695
|
-
|
808
|
+
strDbValue = res.getStringByIdx(0);
|
809
|
+
bDownload = strDbValue == null || strDbValue.length() == 0;
|
696
810
|
}
|
697
|
-
|
698
|
-
|
699
|
-
{
|
700
|
-
int nSyncObjectCount = getNotify().incLastSyncObjectCount(nSrcID);
|
811
|
+
}
|
812
|
+
}
|
701
813
|
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
814
|
+
if ( bDownload )
|
815
|
+
{
|
816
|
+
boolean bRes = false;
|
817
|
+
getDB().endTransaction();
|
818
|
+
try{
|
819
|
+
bRes = downloadBlob(oAttrValue);
|
820
|
+
}finally
|
821
|
+
{
|
822
|
+
getDB().startTransaction();
|
707
823
|
}
|
824
|
+
|
825
|
+
return bRes;
|
708
826
|
}
|
827
|
+
|
828
|
+
String fName = makeFileName( oAttrValue );
|
829
|
+
String fOldName = RhodesApp.getInstance().resolveDBFilesPath(strDbValue);
|
830
|
+
RhoClassFactory.createFile().renameOverwrite(fOldName, fName);
|
831
|
+
|
832
|
+
oAttrValue.m_strValue = FilePath.getRelativePath( fName, RhodesApp.getInstance().getRhoRootPath());
|
833
|
+
return true;
|
709
834
|
}
|
710
835
|
|
711
|
-
|
836
|
+
void processServerCmd_Ver3(String strCmd, String strObject, String strAttriba, String strValuea)throws Exception
|
712
837
|
{
|
713
|
-
|
714
|
-
String m_strAttrType;
|
715
|
-
Long m_nID;
|
716
|
-
|
717
|
-
CValue(JSONEntry oJsonEntry)throws JSONException
|
718
|
-
{
|
719
|
-
m_strValue = oJsonEntry.getString("value");
|
720
|
-
m_strAttrType = oJsonEntry.getString("attrib_type");
|
721
|
-
m_nID = new Long(oJsonEntry.getLong("id"));
|
722
|
-
}
|
723
|
-
CValue(JSONEntry oJsonEntry, int nVer)throws JSONException
|
724
|
-
{
|
725
|
-
if ( nVer == 1 )
|
726
|
-
{
|
727
|
-
m_strValue = oJsonEntry.getString("v");
|
728
|
-
m_strAttrType = oJsonEntry.getString("t");
|
729
|
-
m_nID = new Long(oJsonEntry.getLong("i"));
|
730
|
-
}
|
731
|
-
}
|
838
|
+
CAttrValue oAttrValue = new CAttrValue(strAttriba,strValuea);
|
732
839
|
|
840
|
+
if ( strCmd.compareTo("insert") == 0 )
|
841
|
+
{
|
842
|
+
if ( !processBlob(strCmd,strObject,oAttrValue) )
|
843
|
+
return;
|
844
|
+
|
845
|
+
IDBResult resInsert = getDB().executeSQLReportNonUnique("INSERT INTO object_values "+
|
846
|
+
"(attrib, source_id, object, value) VALUES(?,?,?,?)",
|
847
|
+
oAttrValue.m_strAttrib, getID(), strObject, oAttrValue.m_strValue );
|
848
|
+
|
849
|
+
if ( resInsert.isNonUnique() )
|
850
|
+
{
|
851
|
+
getDB().executeSQL("UPDATE object_values " +
|
852
|
+
"SET value=? WHERE object=? and attrib=? and source_id=?",
|
853
|
+
oAttrValue.m_strValue, strObject, oAttrValue.m_strAttrib, getID() );
|
854
|
+
|
855
|
+
// oo conflicts
|
856
|
+
getDB().executeSQL("UPDATE changed_values SET sent=4 where object=? and attrib=? and source_id=? and sent>1",
|
857
|
+
strObject, oAttrValue.m_strAttrib, getID() );
|
858
|
+
//
|
859
|
+
}
|
860
|
+
|
861
|
+
getNotify().onObjectChanged(getID(),strObject, SyncNotify.enUpdate);
|
862
|
+
m_nInserted++;
|
863
|
+
}else if (strCmd.compareTo("delete") == 0)
|
864
|
+
{
|
865
|
+
getDB().executeSQL("DELETE FROM object_values where object=? and attrib=? and source_id=?", strObject, oAttrValue.m_strAttrib, getID() );
|
866
|
+
getNotify().onObjectChanged(getID(), strObject, SyncNotify.enDelete);
|
867
|
+
// oo conflicts
|
868
|
+
getDB().executeSQL("UPDATE changed_values SET sent=3 where object=? and attrib=? and source_id=?", strObject, oAttrValue.m_strAttrib, getID() );
|
869
|
+
//
|
870
|
+
|
871
|
+
m_nDeleted++;
|
872
|
+
}else if ( strCmd.compareTo("links") == 0 )
|
873
|
+
{
|
874
|
+
processLinks(strObject, oAttrValue.m_strValue);
|
875
|
+
|
876
|
+
getDB().executeSQL("UPDATE object_values SET object=? where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
|
877
|
+
getDB().executeSQL("UPDATE changed_values SET object=?,sent=3 where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
|
878
|
+
|
879
|
+
getNotify().onObjectChanged(getID(), strObject, SyncNotify.enCreate);
|
880
|
+
}
|
881
|
+
|
733
882
|
}
|
734
883
|
|
735
|
-
private String makeFileName(
|
884
|
+
private String makeFileName(CAttrValue value)throws Exception
|
736
885
|
{
|
737
|
-
String fName = DBAdapter.makeBlobFolderName();
|
738
|
-
|
739
886
|
String strExt = ".bin";
|
740
887
|
URI uri = new URI(value.m_strValue);
|
741
888
|
int nDot = uri.getPath().lastIndexOf('.');
|
@@ -752,17 +899,13 @@ class SyncSource
|
|
752
899
|
}
|
753
900
|
}
|
754
901
|
|
755
|
-
|
756
|
-
fName += "id_" + value.m_nID.toString() + strExt;
|
902
|
+
String fName = RhodesApp.getInstance().getBlobsDirPath() + "/id_" + TimeInterval.getCurrentTime().toULong() + strExt;
|
757
903
|
|
758
904
|
return fName;
|
759
905
|
}
|
760
906
|
|
761
|
-
boolean downloadBlob(
|
907
|
+
boolean downloadBlob(CAttrValue value)throws Exception
|
762
908
|
{
|
763
|
-
if ( value.m_strAttrType == null || !value.m_strAttrType.equals("blob.url") )
|
764
|
-
return true;
|
765
|
-
|
766
909
|
String fName = makeFileName( value );
|
767
910
|
String url = value.m_strValue;
|
768
911
|
int nQuest = url.lastIndexOf('?');
|
@@ -776,8 +919,8 @@ class SyncSource
|
|
776
919
|
NetResponse resp = getNet().pullFile(url, fName, getSync(), null);
|
777
920
|
if ( !resp.isOK() )
|
778
921
|
{
|
779
|
-
|
780
|
-
|
922
|
+
getSync().stopSync();
|
923
|
+
m_nErrCode = RhoRuby.getErrorFromResponse(resp);
|
781
924
|
return false;
|
782
925
|
}
|
783
926
|
}catch(Exception exc)
|
@@ -786,11 +929,7 @@ class SyncSource
|
|
786
929
|
throw exc;
|
787
930
|
}
|
788
931
|
|
789
|
-
|
790
|
-
|
791
|
-
String root = RhoClassFactory.createFile().getDirPath("");
|
792
|
-
|
793
|
-
value.m_strValue = "/" + fName.substring(root.length());
|
932
|
+
value.m_strValue = FilePath.getRelativePath( fName, RhodesApp.getInstance().getRhoRootPath());
|
794
933
|
|
795
934
|
return true;
|
796
935
|
}
|