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
@@ -11,10 +11,18 @@ public class RhodesApp
|
|
11
11
|
RhoConf RHOCONF(){ return RhoConf.getInstance(); }
|
12
12
|
|
13
13
|
static RhodesApp m_pInstance;
|
14
|
-
|
14
|
+
|
15
|
+
private String m_strRhoRootPath, m_strBlobsDirPath, m_strDBDirPath;
|
16
|
+
|
15
17
|
Vector/*<unsigned long>*/ m_arCallbackObjects = new Vector();
|
16
18
|
private SplashScreen m_oSplashScreen = new SplashScreen();
|
19
|
+
|
20
|
+
Mutex m_mxPushCallback = new Mutex();
|
21
|
+
String m_strPushCallback = "", m_strPushCallbackParams = "";
|
17
22
|
|
23
|
+
Mutex m_mxScreenRotationCallback = new Mutex();
|
24
|
+
String m_strScreenRotationCallback = "", m_strScreenRotationCallbackParams = "";
|
25
|
+
|
18
26
|
NetRequest getNet() { return RhoClassFactory.createNetRequest();}
|
19
27
|
|
20
28
|
public static RhodesApp Create(String strRootPath)
|
@@ -34,13 +42,32 @@ public class RhodesApp
|
|
34
42
|
public static RhodesApp getInstance(){ return m_pInstance; }
|
35
43
|
public SplashScreen getSplashScreen(){return m_oSplashScreen;}
|
36
44
|
|
45
|
+
public String getBlobsDirPath(){return m_strBlobsDirPath; }
|
46
|
+
public String getDBDirPath(){return m_strDBDirPath; }
|
47
|
+
public String getRhoRootPath(){return m_strRhoRootPath;}
|
48
|
+
|
37
49
|
RhodesApp(String strRootPath)
|
38
50
|
{
|
39
51
|
m_strRhoRootPath = strRootPath;
|
40
52
|
|
41
53
|
getSplashScreen().init();
|
54
|
+
|
55
|
+
initAppUrls();
|
42
56
|
}
|
43
57
|
|
58
|
+
void initAppUrls()
|
59
|
+
{
|
60
|
+
m_strBlobsDirPath = getRhoRootPath() + "db/db-files";
|
61
|
+
m_strDBDirPath = getRhoRootPath() + "db";
|
62
|
+
}
|
63
|
+
|
64
|
+
public String resolveDBFilesPath(String strFilePath)
|
65
|
+
{
|
66
|
+
if ( strFilePath.startsWith(getRhoRootPath()) )
|
67
|
+
return strFilePath;
|
68
|
+
|
69
|
+
return FilePath.join(getRhoRootPath(), strFilePath);
|
70
|
+
}
|
44
71
|
|
45
72
|
public String addCallbackObject(RubyValue valObject, String strName)
|
46
73
|
{
|
@@ -71,12 +98,79 @@ public class RhodesApp
|
|
71
98
|
m_arCallbackObjects.setElementAt(null,nIndex);
|
72
99
|
return res;
|
73
100
|
}
|
74
|
-
|
101
|
+
|
75
102
|
String canonicalizeRhoUrl(String strUrl)throws Exception
|
76
103
|
{
|
77
104
|
return getNet().resolveUrl(strUrl);
|
78
105
|
}
|
106
|
+
|
107
|
+
public void setPushNotification(String strUrl, String strParams )throws Exception
|
108
|
+
{
|
109
|
+
synchronized(m_mxPushCallback)
|
110
|
+
{
|
111
|
+
m_strPushCallback = canonicalizeRhoUrl(strUrl);
|
112
|
+
m_strPushCallbackParams = strParams;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
public boolean callPushCallback(String strData)throws Exception
|
117
|
+
{
|
118
|
+
synchronized(m_mxPushCallback)
|
119
|
+
{
|
120
|
+
if ( m_strPushCallback.length() == 0 )
|
121
|
+
return false;
|
122
|
+
|
123
|
+
String strBody = "status=ok&message=";
|
124
|
+
strBody += URI.urlEncode(strData);
|
125
|
+
strBody += "&rho_callback=1";
|
126
|
+
if ( m_strPushCallbackParams.length() > 0 )
|
127
|
+
strBody += "&" + m_strPushCallbackParams;
|
128
|
+
|
129
|
+
NetResponse resp = getNet().pushData( m_strPushCallback, strBody, null );
|
130
|
+
if (!resp.isOK())
|
131
|
+
LOG.ERROR("Push notification failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData() );
|
132
|
+
else
|
133
|
+
{
|
134
|
+
String szData = resp.getCharData();
|
135
|
+
return !(szData != null && szData.equals("rho_push"));
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
return true;
|
140
|
+
}
|
79
141
|
|
142
|
+
public void setScreenRotationNotification(String strUrl, String strParams)throws Exception
|
143
|
+
{
|
144
|
+
synchronized(m_mxScreenRotationCallback)
|
145
|
+
{
|
146
|
+
m_strScreenRotationCallback = canonicalizeRhoUrl(strUrl);
|
147
|
+
m_strScreenRotationCallbackParams = strParams;
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
public void callScreenRotationCallback(int width, int height, int degrees)throws Exception
|
152
|
+
{
|
153
|
+
synchronized(m_mxScreenRotationCallback)
|
154
|
+
{
|
155
|
+
if (m_strScreenRotationCallback.length() == 0)
|
156
|
+
return;
|
157
|
+
|
158
|
+
String strBody = "rho_callback=1";
|
159
|
+
|
160
|
+
strBody += "&width="; strBody += width;
|
161
|
+
strBody += "&heigth="; strBody += height;
|
162
|
+
strBody += "°rees="; strBody += degrees;
|
163
|
+
|
164
|
+
if ( m_strScreenRotationCallbackParams.length() > 0 )
|
165
|
+
strBody += "&" + m_strPushCallbackParams;
|
166
|
+
|
167
|
+
NetResponse resp = getNet().pushData( m_strScreenRotationCallback, strBody, null );
|
168
|
+
if (!resp.isOK()) {
|
169
|
+
LOG.ERROR("Screen rotation notification failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData());
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
80
174
|
public void callPopupCallback(String strCallbackUrl, String id, String title)throws Exception
|
81
175
|
{
|
82
176
|
if ( strCallbackUrl == null || strCallbackUrl.length() == 0 )
|
@@ -86,5 +180,6 @@ public class RhodesApp
|
|
86
180
|
String strBody = "button_id=" + id + "&button_title=" + title;
|
87
181
|
strBody += "&rho_callback=1";
|
88
182
|
getNet().pushData( strCallbackUrl, strBody, null );
|
89
|
-
}
|
183
|
+
}
|
184
|
+
|
90
185
|
}
|
@@ -3,24 +3,32 @@ package com.rho.db;
|
|
3
3
|
import com.xruby.runtime.builtin.*;
|
4
4
|
import com.xruby.runtime.lang.*;
|
5
5
|
import com.rho.*;
|
6
|
+
import com.rho.file.*;
|
7
|
+
|
8
|
+
import java.util.Enumeration;
|
6
9
|
import java.util.Vector;
|
10
|
+
import java.util.Hashtable;
|
7
11
|
|
8
|
-
public class DBAdapter extends RubyBasic
|
12
|
+
public class DBAdapter extends RubyBasic
|
13
|
+
{
|
9
14
|
private static final RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
|
10
15
|
new RhoLogger("DbAdapter");
|
11
16
|
|
12
|
-
private static DBAdapter m_Instance;
|
17
|
+
//private static DBAdapter m_Instance;
|
13
18
|
|
14
19
|
private IDBStorage m_dbStorage;
|
15
20
|
private boolean m_bIsOpen = false;
|
16
21
|
private String m_strDBPath;
|
17
22
|
private String m_strDBVerPath;
|
18
23
|
private DBAttrManager m_attrMgr = new DBAttrManager();
|
24
|
+
static Hashtable/*Ptr<String,CDBAdapter*>*/ m_mapDBPartitions = new Hashtable();
|
19
25
|
|
20
26
|
Mutex m_mxDB = new Mutex();
|
21
27
|
int m_nTransactionCounter=0;
|
22
28
|
boolean m_bUIWaitDB = false;
|
23
29
|
|
30
|
+
static Hashtable/*Ptr<String,CDBAdapter*>&*/ getDBPartitions(){ return m_mapDBPartitions; }
|
31
|
+
|
24
32
|
DBAdapter(RubyClass c) {
|
25
33
|
super(c);
|
26
34
|
|
@@ -30,13 +38,13 @@ public class DBAdapter extends RubyBasic {
|
|
30
38
|
LOG.ERROR("createDBStorage failed.", exc);
|
31
39
|
}
|
32
40
|
}
|
33
|
-
|
41
|
+
/*
|
34
42
|
public static DBAdapter getInstance(){
|
35
43
|
if ( m_Instance == null )
|
36
44
|
m_Instance = new DBAdapter(RubyRuntime.DatabaseClass);
|
37
45
|
|
38
46
|
return m_Instance;
|
39
|
-
}
|
47
|
+
}*/
|
40
48
|
|
41
49
|
public void close()
|
42
50
|
{
|
@@ -53,15 +61,29 @@ public class DBAdapter extends RubyBasic {
|
|
53
61
|
{
|
54
62
|
return m_attrMgr;
|
55
63
|
}
|
64
|
+
|
65
|
+
public void executeBatchSQL(String strStatement)throws DBException{
|
66
|
+
LOG.TRACE("executeBatchSQL: " + strStatement);
|
67
|
+
|
68
|
+
m_dbStorage.executeBatchSQL(strStatement);
|
69
|
+
}
|
56
70
|
|
57
71
|
public IDBResult executeSQL(String strStatement, Object[] values)throws DBException{
|
58
72
|
LOG.TRACE("executeSQL: " + strStatement);
|
59
|
-
|
60
|
-
|
73
|
+
IDBResult res = null;
|
74
|
+
Lock();
|
75
|
+
try{
|
76
|
+
res = m_dbStorage.executeSQL(strStatement,values,false);
|
77
|
+
}finally
|
78
|
+
{
|
79
|
+
Unlock();
|
80
|
+
}
|
81
|
+
return res;
|
61
82
|
}
|
62
83
|
public IDBResult executeSQL(String strStatement)throws DBException{
|
63
84
|
return executeSQL(strStatement,null);
|
64
85
|
}
|
86
|
+
|
65
87
|
public IDBResult executeSQL(String strStatement, Object arg1)throws DBException{
|
66
88
|
Object[] values = {arg1};
|
67
89
|
return executeSQL(strStatement,values);
|
@@ -98,11 +120,47 @@ public class DBAdapter extends RubyBasic {
|
|
98
120
|
return executeSQL(strStatement,values);
|
99
121
|
}
|
100
122
|
|
101
|
-
public IDBResult executeSQLReportNonUnique(String strStatement, Object arg1, Object arg2, Object arg3, Object arg4
|
123
|
+
public IDBResult executeSQLReportNonUnique(String strStatement, Object arg1, Object arg2, Object arg3, Object arg4)throws DBException{
|
102
124
|
LOG.TRACE("executeSQLReportNonUnique: " + strStatement);
|
103
125
|
|
104
|
-
Object[] values = {arg1,arg2,arg3,arg4
|
105
|
-
|
126
|
+
Object[] values = {arg1,arg2,arg3,arg4};
|
127
|
+
IDBResult res = null;
|
128
|
+
Lock();
|
129
|
+
try{
|
130
|
+
res = m_dbStorage.executeSQL(strStatement,values, true);
|
131
|
+
}finally
|
132
|
+
{
|
133
|
+
Unlock();
|
134
|
+
}
|
135
|
+
|
136
|
+
return res;
|
137
|
+
}
|
138
|
+
|
139
|
+
public IDBResult executeSQLReportNonUniqueEx(String strStatement, Vector vecValues)throws DBException{
|
140
|
+
LOG.TRACE("executeSQLReportNonUnique: " + strStatement);
|
141
|
+
|
142
|
+
Object[] values = new Object[vecValues.size()];
|
143
|
+
for (int i = 0; i < vecValues.size(); i++ )
|
144
|
+
values[i] = vecValues.elementAt(i);
|
145
|
+
|
146
|
+
IDBResult res = null;
|
147
|
+
Lock();
|
148
|
+
try{
|
149
|
+
res = m_dbStorage.executeSQL(strStatement,values, true);
|
150
|
+
}finally
|
151
|
+
{
|
152
|
+
Unlock();
|
153
|
+
}
|
154
|
+
|
155
|
+
return res;
|
156
|
+
}
|
157
|
+
|
158
|
+
public IDBResult executeSQLEx(String strStatement, Vector vecValues)throws DBException{
|
159
|
+
Object[] values = new Object[vecValues.size()];
|
160
|
+
for (int i = 0; i < vecValues.size(); i++ )
|
161
|
+
values[i] = vecValues.elementAt(i);
|
162
|
+
|
163
|
+
return executeSQL(strStatement,values);
|
106
164
|
}
|
107
165
|
|
108
166
|
public IDBResult executeSQL(String strStatement, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)throws DBException{
|
@@ -111,25 +169,35 @@ public class DBAdapter extends RubyBasic {
|
|
111
169
|
}
|
112
170
|
|
113
171
|
public boolean isUIWaitDB(){ return m_bUIWaitDB; }
|
114
|
-
public void
|
115
|
-
|
172
|
+
public void Lock()
|
173
|
+
{
|
174
|
+
if ( RhoRuby.isMainRubyThread() )
|
175
|
+
m_bUIWaitDB = true;
|
176
|
+
|
177
|
+
m_mxDB.Lock();
|
178
|
+
|
179
|
+
if ( RhoRuby.isMainRubyThread() )
|
180
|
+
m_bUIWaitDB = false;
|
181
|
+
}
|
182
|
+
|
116
183
|
public void Unlock(){ m_mxDB.Unlock(); }
|
117
184
|
public boolean isInsideTransaction(){ return m_nTransactionCounter>0; }
|
118
185
|
|
119
|
-
public static IDBResult createResult(){
|
120
|
-
|
121
|
-
}
|
186
|
+
//public static IDBResult createResult(){
|
187
|
+
// return getInstance().m_dbStorage.createResult();
|
188
|
+
//}
|
122
189
|
|
123
190
|
public static String makeBlobFolderName()throws Exception{
|
124
|
-
String fName = RhoClassFactory.createFile().getDirPath("
|
191
|
+
String fName = RhoClassFactory.createFile().getDirPath("db/db-files");
|
192
|
+
|
125
193
|
return fName;
|
126
194
|
}
|
127
195
|
|
128
|
-
RubyString[]
|
196
|
+
RubyString[] getOrigColNames(IDBResult rows)
|
129
197
|
{
|
130
198
|
RubyString[] colNames = new RubyString[rows.getColCount()];
|
131
199
|
for ( int nCol = 0; nCol < rows.getColCount(); nCol ++ )
|
132
|
-
colNames[nCol] = ObjectFactory.createString(rows.
|
200
|
+
colNames[nCol] = ObjectFactory.createString(rows.getOrigColName(nCol));
|
133
201
|
|
134
202
|
return colNames;
|
135
203
|
}
|
@@ -174,15 +242,13 @@ public class DBAdapter extends RubyBasic {
|
|
174
242
|
{
|
175
243
|
Lock();
|
176
244
|
m_nTransactionCounter++;
|
177
|
-
|
178
245
|
if (m_nTransactionCounter == 1)
|
179
|
-
m_dbStorage.startTransaction();
|
246
|
+
m_dbStorage.startTransaction();
|
180
247
|
}
|
181
248
|
|
182
249
|
public void commit()throws DBException
|
183
250
|
{
|
184
251
|
m_nTransactionCounter--;
|
185
|
-
|
186
252
|
if (m_nTransactionCounter == 0)
|
187
253
|
{
|
188
254
|
getAttrMgr().save(this);
|
@@ -191,6 +257,16 @@ public class DBAdapter extends RubyBasic {
|
|
191
257
|
|
192
258
|
Unlock();
|
193
259
|
}
|
260
|
+
|
261
|
+
public void rollback()throws DBException
|
262
|
+
{
|
263
|
+
m_nTransactionCounter--;
|
264
|
+
if (m_nTransactionCounter == 0)
|
265
|
+
m_dbStorage.rollback();
|
266
|
+
|
267
|
+
Unlock();
|
268
|
+
}
|
269
|
+
|
194
270
|
public void endTransaction()throws DBException
|
195
271
|
{
|
196
272
|
commit();
|
@@ -382,6 +458,39 @@ public class DBAdapter extends RubyBasic {
|
|
382
458
|
|
383
459
|
}
|
384
460
|
|
461
|
+
static Vector m_dbAdapters = new Vector();
|
462
|
+
|
463
|
+
public static DBAdapter findDBAdapterByBaseName(String strBaseName)
|
464
|
+
{
|
465
|
+
for ( int i = 0; i < m_dbAdapters.size(); i++ )
|
466
|
+
{
|
467
|
+
DBAdapter item = (DBAdapter)m_dbAdapters.elementAt(i);
|
468
|
+
FilePath oPath = new FilePath(item.getDBPath());
|
469
|
+
|
470
|
+
if ( oPath.getBaseName().compareTo(strBaseName) == 0 )
|
471
|
+
return item;
|
472
|
+
}
|
473
|
+
return null;
|
474
|
+
}
|
475
|
+
|
476
|
+
public static void startAllDBTransaction()throws DBException
|
477
|
+
{
|
478
|
+
for ( int i = 0; i < m_dbAdapters.size(); i++ )
|
479
|
+
{
|
480
|
+
DBAdapter item = (DBAdapter)m_dbAdapters.elementAt(i);
|
481
|
+
item.startTransaction();
|
482
|
+
}
|
483
|
+
}
|
484
|
+
|
485
|
+
public static void commitAllDBTransaction()throws DBException
|
486
|
+
{
|
487
|
+
for ( int i = 0; i < m_dbAdapters.size(); i++ )
|
488
|
+
{
|
489
|
+
DBAdapter item = (DBAdapter)m_dbAdapters.elementAt(i);
|
490
|
+
item.commit();
|
491
|
+
}
|
492
|
+
}
|
493
|
+
|
385
494
|
private void openDB(String strDBName)throws Exception
|
386
495
|
{
|
387
496
|
if ( m_bIsOpen )
|
@@ -397,6 +506,8 @@ public class DBAdapter extends RubyBasic {
|
|
397
506
|
getAttrMgr().load(this);
|
398
507
|
|
399
508
|
m_dbStorage.setDbCallback(new DBCallback(this));
|
509
|
+
|
510
|
+
m_dbAdapters.addElement(this);
|
400
511
|
}
|
401
512
|
|
402
513
|
private String createInsertStatement(IDBResult res, String tableName)
|
@@ -422,7 +533,38 @@ public class DBAdapter extends RubyBasic {
|
|
422
533
|
return strInsert;
|
423
534
|
}
|
424
535
|
|
425
|
-
|
536
|
+
private boolean destroyTableName(String tableName, Vector arIncludeTables, Vector arExcludeTables )
|
537
|
+
{
|
538
|
+
int i;
|
539
|
+
for (i = 0; i < (int)arExcludeTables.size(); i++ )
|
540
|
+
{
|
541
|
+
if ( ((String)arExcludeTables.elementAt(i)).equalsIgnoreCase(tableName) )
|
542
|
+
return false;
|
543
|
+
}
|
544
|
+
|
545
|
+
for (i = 0; i < (int)arIncludeTables.size(); i++ )
|
546
|
+
{
|
547
|
+
if ( ((String)arIncludeTables.elementAt(i)).equalsIgnoreCase(tableName) )
|
548
|
+
return true;
|
549
|
+
}
|
550
|
+
|
551
|
+
return arIncludeTables.size()==0;
|
552
|
+
}
|
553
|
+
|
554
|
+
public boolean isTableExist(String strTableName)throws DBException
|
555
|
+
{
|
556
|
+
String[] vecTables = m_dbStorage.getAllTableNames();
|
557
|
+
for ( int i = 0; i< vecTables.length; i++ )
|
558
|
+
{
|
559
|
+
String tableName = vecTables[i];
|
560
|
+
if ( tableName.equalsIgnoreCase(strTableName) )
|
561
|
+
return true;
|
562
|
+
}
|
563
|
+
|
564
|
+
return false;
|
565
|
+
}
|
566
|
+
|
567
|
+
private RubyValue rb_destroy_tables(RubyValue vInclude, RubyValue vExclude)
|
426
568
|
{
|
427
569
|
if ( !m_bIsOpen )
|
428
570
|
return RubyConstant.QNIL;
|
@@ -431,7 +573,8 @@ public class DBAdapter extends RubyBasic {
|
|
431
573
|
try{
|
432
574
|
getAttrMgr().reset(this);
|
433
575
|
|
434
|
-
|
576
|
+
Vector vecIncludes = RhoRuby.makeVectorStringFromArray(vInclude);
|
577
|
+
Vector vecExcludes = RhoRuby.makeVectorStringFromArray(vExclude);
|
435
578
|
|
436
579
|
String dbName = getNameNoExt(m_strDBPath);
|
437
580
|
String dbNewName = dbName + "new";
|
@@ -467,7 +610,7 @@ public class DBAdapter extends RubyBasic {
|
|
467
610
|
for ( int i = 0; i< vecTables.length; i++ )
|
468
611
|
{
|
469
612
|
String tableName = vecTables[i];
|
470
|
-
if ( tableName
|
613
|
+
if ( destroyTableName( tableName, vecIncludes, vecExcludes ) )
|
471
614
|
continue;
|
472
615
|
|
473
616
|
res = executeSQL("SELECT * from " + tableName, null);
|
@@ -539,17 +682,7 @@ public class DBAdapter extends RubyBasic {
|
|
539
682
|
return RubyConstant.QNIL;
|
540
683
|
}
|
541
684
|
|
542
|
-
public void
|
543
|
-
{
|
544
|
-
m_nTransactionCounter--;
|
545
|
-
|
546
|
-
if (m_nTransactionCounter == 0)
|
547
|
-
m_dbStorage.rollback();
|
548
|
-
|
549
|
-
Unlock();
|
550
|
-
}
|
551
|
-
|
552
|
-
public void setInitialSyncDB(String fDbName, String fScriptName)
|
685
|
+
public void setBulkSyncDB(String fDbName, String fScriptName)
|
553
686
|
{
|
554
687
|
IDBStorage db = null;
|
555
688
|
try{
|
@@ -573,14 +706,32 @@ public class DBAdapter extends RubyBasic {
|
|
573
706
|
}
|
574
707
|
//copy sources
|
575
708
|
{
|
576
|
-
|
709
|
+
String tableName = "sources";
|
710
|
+
String strSelect = "SELECT * from " + tableName;
|
711
|
+
IDBResult res = executeSQL( strSelect );
|
712
|
+
String strInsert = "";
|
577
713
|
for ( ; !res.isEnd(); res.next() )
|
578
714
|
{
|
579
|
-
|
580
|
-
|
715
|
+
String strName = res.getStringByIdx(1);
|
716
|
+
Object[] values = {strName};
|
717
|
+
IDBResult res2 = db.executeSQL("SELECT name from sources where name=?", values, false);
|
718
|
+
if (!res2.isEnd())
|
719
|
+
continue;
|
720
|
+
|
721
|
+
if ( strInsert.length() == 0 )
|
722
|
+
strInsert = createInsertStatement(res, tableName);
|
581
723
|
|
582
|
-
|
724
|
+
db.executeSQL(strInsert, res.getCurData(), false );
|
583
725
|
}
|
726
|
+
/*
|
727
|
+
IDBResult res = executeSQL("SELECT name, sync_type, partition, priority from sources", null);
|
728
|
+
for ( ; !res.isEnd(); res.next() )
|
729
|
+
{
|
730
|
+
String strName = res.getStringByIdx(0);
|
731
|
+
Object[] values = {res.getStringByIdx(1), new Integer(res.getIntByIdx(2)),new Integer(res.getIntByIdx(3)),strName};
|
732
|
+
|
733
|
+
db.executeSQL("UPDATE sources SET sync_type=?, partition=?, priority=? where name=?",values, false);
|
734
|
+
}*/
|
584
735
|
}
|
585
736
|
|
586
737
|
db.commit();
|
@@ -668,36 +819,40 @@ public class DBAdapter extends RubyBasic {
|
|
668
819
|
return res;
|
669
820
|
}*/
|
670
821
|
|
671
|
-
public RubyValue rb_execute(RubyValue v, RubyValue arg)
|
822
|
+
public RubyValue rb_execute(RubyValue v, RubyValue batch, RubyValue arg)
|
672
823
|
{
|
673
824
|
RubyArray res = new RubyArray();
|
674
825
|
try{
|
675
|
-
|
676
|
-
if (
|
826
|
+
String strSql = v.toStr();
|
827
|
+
if ( batch == RubyConstant.QTRUE )
|
677
828
|
{
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
829
|
+
LOG.INFO("batch execute:" + strSql);
|
830
|
+
|
831
|
+
executeBatchSQL( strSql );
|
832
|
+
}
|
833
|
+
else
|
834
|
+
{
|
835
|
+
Object[] values = null;
|
836
|
+
if ( arg != null )
|
685
837
|
{
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
838
|
+
RubyArray args1 = arg.toAry();
|
839
|
+
RubyArray args = args1;
|
840
|
+
if ( args.size() > 0 && args.get(0) instanceof RubyArray )
|
841
|
+
args = (RubyArray)args.get(0);
|
842
|
+
|
843
|
+
values = new Object[args.size()];
|
844
|
+
for ( int i = 0; i < args.size(); i++ )
|
845
|
+
{
|
846
|
+
RubyValue val = args.get(i);
|
847
|
+
if ( val instanceof RubyFixnum )
|
848
|
+
values[i] = new Long( ((RubyFixnum)val).toLong() );
|
849
|
+
else
|
850
|
+
values[i] = val.toString();
|
851
|
+
}
|
691
852
|
}
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
Lock();
|
696
|
-
|
697
|
-
try{
|
698
|
-
IDBResult rows = executeSQL(v.toStr(), values);
|
699
|
-
|
700
|
-
RubyString[] colNames = getColNames(rows);
|
853
|
+
|
854
|
+
IDBResult rows = executeSQL( strSql, values);
|
855
|
+
RubyString[] colNames = getOrigColNames(rows);
|
701
856
|
|
702
857
|
for( ; !rows.isEnd(); rows.next() )
|
703
858
|
{
|
@@ -707,12 +862,7 @@ public class DBAdapter extends RubyBasic {
|
|
707
862
|
|
708
863
|
res.add( row );
|
709
864
|
}
|
710
|
-
|
711
|
-
{
|
712
|
-
setUIWaitDB(false);
|
713
|
-
Unlock();
|
714
|
-
}
|
715
|
-
|
865
|
+
}
|
716
866
|
}catch(Exception e)
|
717
867
|
{
|
718
868
|
LOG.ERROR("execute failed.", e);
|
@@ -724,71 +874,51 @@ public class DBAdapter extends RubyBasic {
|
|
724
874
|
|
725
875
|
//@RubyAllocMethod
|
726
876
|
private static RubyValue alloc(RubyValue receiver) {
|
727
|
-
return
|
877
|
+
return new DBAdapter(RubyRuntime.DatabaseClass);
|
728
878
|
}
|
729
879
|
|
730
|
-
|
880
|
+
public static void closeAll()
|
731
881
|
{
|
732
|
-
|
733
|
-
|
734
|
-
}catch(Exception e)
|
882
|
+
Enumeration enumDBs = m_mapDBPartitions.elements();
|
883
|
+
while (enumDBs.hasMoreElements())
|
735
884
|
{
|
736
|
-
|
737
|
-
|
885
|
+
DBAdapter db = (DBAdapter)enumDBs.nextElement();
|
886
|
+
db.close();
|
738
887
|
}
|
739
|
-
|
740
|
-
return this;
|
741
888
|
}
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
return ObjectFactory.createInteger(0);
|
889
|
+
|
890
|
+
public static void initAttrManager()throws DBException
|
891
|
+
{
|
892
|
+
Enumeration enumDBs = m_mapDBPartitions.elements();
|
893
|
+
while (enumDBs.hasMoreElements())
|
894
|
+
{
|
895
|
+
DBAdapter db = (DBAdapter)enumDBs.nextElement();
|
896
|
+
db.getAttrMgr().loadBlobAttrs(db);
|
897
|
+
}
|
753
898
|
}
|
754
899
|
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
}catch( Exception e ){
|
759
|
-
LOG.ERROR("commit failed.", e);
|
760
|
-
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
761
|
-
}
|
762
|
-
|
763
|
-
return ObjectFactory.createInteger(0);
|
900
|
+
public static DBAdapter getUserDB()
|
901
|
+
{
|
902
|
+
return (DBAdapter)getDBPartitions().get("user");
|
764
903
|
}
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
}catch( Exception e ){
|
770
|
-
LOG.ERROR("rollback failed.", e);
|
771
|
-
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
772
|
-
}
|
773
|
-
|
774
|
-
return ObjectFactory.createInteger(0);
|
904
|
+
|
905
|
+
public static DBAdapter getDB(String szPartition)
|
906
|
+
{
|
907
|
+
return (DBAdapter)getDBPartitions().get(szPartition);
|
775
908
|
}
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
}
|
790
|
-
|
791
|
-
return ObjectFactory.createInteger(0);
|
909
|
+
|
910
|
+
public static boolean isAnyInsideTransaction()
|
911
|
+
{
|
912
|
+
Enumeration enumDBs = m_mapDBPartitions.elements();
|
913
|
+
while (enumDBs.hasMoreElements())
|
914
|
+
{
|
915
|
+
DBAdapter db = (DBAdapter)enumDBs.nextElement();
|
916
|
+
|
917
|
+
if ( db.isInsideTransaction() )
|
918
|
+
return true;
|
919
|
+
}
|
920
|
+
|
921
|
+
return false;
|
792
922
|
}
|
793
923
|
|
794
924
|
public static void initMethods(RubyClass klass) {
|
@@ -798,49 +928,141 @@ public class DBAdapter extends RubyBasic {
|
|
798
928
|
return DBAdapter.alloc(receiver);}
|
799
929
|
});
|
800
930
|
|
801
|
-
klass.defineMethod( "initialize", new
|
802
|
-
|
803
|
-
|
931
|
+
klass.defineMethod( "initialize", new RubyTwoArgMethod()
|
932
|
+
{
|
933
|
+
protected RubyValue run(RubyValue receiver, RubyValue arg1, RubyValue arg2, RubyBlock block )
|
934
|
+
{
|
935
|
+
try
|
936
|
+
{
|
937
|
+
String szDbName = arg1.toStr();
|
938
|
+
String szDbPartition = arg2.toStr();
|
939
|
+
((DBAdapter)receiver).openDB(szDbName);
|
940
|
+
|
941
|
+
DBAdapter.getDBPartitions().put(szDbPartition, receiver);
|
942
|
+
|
943
|
+
return receiver;
|
944
|
+
}catch(Exception e)
|
945
|
+
{
|
946
|
+
LOG.ERROR("initialize failed.", e);
|
947
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
948
|
+
}
|
949
|
+
|
950
|
+
}
|
804
951
|
});
|
805
|
-
klass.defineMethod( "close", new RubyNoArgMethod(){
|
952
|
+
/*klass.defineMethod( "close", new RubyNoArgMethod(){
|
806
953
|
protected RubyValue run(RubyValue receiver, RubyBlock block ){
|
807
954
|
return ((DBAdapter)receiver).rb_close();}
|
808
|
-
})
|
955
|
+
});*/
|
809
956
|
klass.defineMethod( "execute", new RubyVarArgMethod(){
|
810
957
|
protected RubyValue run(RubyValue receiver, RubyArray args, RubyBlock block ){
|
811
|
-
return ((DBAdapter)receiver).rb_execute(args.get(0),
|
812
|
-
(args.size() >
|
958
|
+
return ((DBAdapter)receiver).rb_execute(args.get(0), args.get(1),
|
959
|
+
(args.size() > 2 ? args.get(2):null));}
|
813
960
|
});
|
814
961
|
|
815
962
|
klass.defineMethod( "start_transaction", new RubyNoArgMethod(){
|
816
|
-
protected RubyValue run(RubyValue receiver, RubyBlock block )
|
817
|
-
|
963
|
+
protected RubyValue run(RubyValue receiver, RubyBlock block )
|
964
|
+
{
|
965
|
+
try{
|
966
|
+
((DBAdapter)receiver).startTransaction();
|
967
|
+
return ObjectFactory.createInteger(0);
|
968
|
+
}catch( Exception e ){
|
969
|
+
LOG.ERROR("start_transaction failed.", e);
|
970
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
971
|
+
}
|
972
|
+
}
|
818
973
|
});
|
819
974
|
klass.defineMethod( "commit", new RubyNoArgMethod(){
|
820
|
-
protected RubyValue run(RubyValue receiver, RubyBlock block )
|
821
|
-
|
975
|
+
protected RubyValue run(RubyValue receiver, RubyBlock block )
|
976
|
+
{
|
977
|
+
try{
|
978
|
+
((DBAdapter)receiver).commit();
|
979
|
+
return ObjectFactory.createInteger(0);
|
980
|
+
}catch( Exception e ){
|
981
|
+
LOG.ERROR("commit failed.", e);
|
982
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
983
|
+
}
|
984
|
+
}
|
822
985
|
});
|
823
986
|
klass.defineMethod( "rollback", new RubyNoArgMethod(){
|
824
|
-
protected RubyValue run(RubyValue receiver, RubyBlock block ){
|
825
|
-
return ((DBAdapter)receiver).rb_rollback();}
|
826
|
-
});
|
827
|
-
klass.defineMethod( "destroy_table", new RubyOneArgMethod(){
|
828
|
-
protected RubyValue run(RubyValue receiver, RubyValue arg, RubyBlock block ){
|
829
|
-
return ((DBAdapter)receiver).rb_destroy_table(arg);}
|
830
|
-
});
|
831
|
-
klass.defineMethod( "is_ui_waitfordb", new RubyNoArgMethod(){
|
832
987
|
protected RubyValue run(RubyValue receiver, RubyBlock block )
|
833
988
|
{
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
return ObjectFactory.createBoolean(bRes);
|
989
|
+
try{
|
990
|
+
((DBAdapter)receiver).rollback();
|
991
|
+
return ObjectFactory.createInteger(0);
|
838
992
|
}catch( Exception e ){
|
839
|
-
LOG.ERROR("
|
993
|
+
LOG.ERROR("rollback failed.", e);
|
840
994
|
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
841
995
|
}
|
842
996
|
}
|
843
997
|
});
|
998
|
+
klass.defineMethod( "destroy_tables", new RubyTwoArgMethod(){
|
999
|
+
protected RubyValue run(RubyValue receiver, RubyValue arg, RubyValue arg1, RubyBlock block ){
|
1000
|
+
return ((DBAdapter)receiver).rb_destroy_tables(arg, arg1);}
|
1001
|
+
});
|
1002
|
+
|
1003
|
+
klass.defineMethod("is_ui_waitfordb", new RubyNoArgMethod() {
|
1004
|
+
protected RubyValue run(RubyValue receiver, RubyBlock block)
|
1005
|
+
{
|
1006
|
+
try{
|
1007
|
+
boolean bRes = ((DBAdapter)receiver).isUIWaitDB();
|
1008
|
+
return ObjectFactory.createBoolean(bRes);
|
1009
|
+
}catch(Exception e)
|
1010
|
+
{
|
1011
|
+
LOG.ERROR("is_ui_waitfordb failed", e);
|
1012
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
1013
|
+
}
|
1014
|
+
}
|
1015
|
+
});
|
1016
|
+
|
1017
|
+
/*
|
1018
|
+
klass.defineMethod("lock_db",
|
1019
|
+
new RubyNoArgMethod() {
|
1020
|
+
protected RubyValue run(RubyValue receiver, RubyBlock block) {
|
1021
|
+
try{
|
1022
|
+
DBAdapter db = (DBAdapter)receiver;
|
1023
|
+
db.setUnlockDB(true);
|
1024
|
+
db.Lock();
|
1025
|
+
}catch(Exception e)
|
1026
|
+
{
|
1027
|
+
LOG.ERROR("lock_db failed", e);
|
1028
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
return RubyConstant.QNIL;
|
1032
|
+
}
|
1033
|
+
});
|
1034
|
+
klass.defineMethod("unlock_db",
|
1035
|
+
new RubyNoArgMethod() {
|
1036
|
+
protected RubyValue run(RubyValue receiver, RubyBlock block) {
|
1037
|
+
try{
|
1038
|
+
DBAdapter db = (DBAdapter)receiver;
|
1039
|
+
db.Unlock();
|
1040
|
+
}catch(Exception e)
|
1041
|
+
{
|
1042
|
+
LOG.ERROR("unlock_db failed", e);
|
1043
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
return RubyConstant.QNIL;
|
1047
|
+
}
|
1048
|
+
});
|
1049
|
+
*/
|
1050
|
+
|
1051
|
+
klass.defineMethod( "table_exist?", new RubyOneArgMethod(){
|
1052
|
+
protected RubyValue run(RubyValue receiver, RubyValue arg, RubyBlock block )
|
1053
|
+
{
|
1054
|
+
try{
|
1055
|
+
DBAdapter db = (DBAdapter)receiver;
|
1056
|
+
boolean bExists = db.isTableExist(arg.toStr());
|
1057
|
+
|
1058
|
+
return ObjectFactory.createBoolean(bExists);
|
1059
|
+
}catch(Exception e)
|
1060
|
+
{
|
1061
|
+
LOG.ERROR("unlock_db failed", e);
|
1062
|
+
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
1063
|
+
}
|
1064
|
+
}
|
1065
|
+
});
|
844
1066
|
|
845
1067
|
}
|
846
1068
|
|
@@ -865,53 +1087,116 @@ public class DBAdapter extends RubyBasic {
|
|
865
1087
|
}
|
866
1088
|
}*/
|
867
1089
|
|
868
|
-
public void
|
1090
|
+
public void onAfterInsert(String tableName, IDBResult rows2Insert)
|
869
1091
|
{
|
870
1092
|
if ( !tableName.equalsIgnoreCase("object_values") )
|
871
1093
|
return;
|
872
1094
|
|
873
1095
|
for( ; !rows2Insert.isEnd(); rows2Insert.next() )
|
874
1096
|
{
|
875
|
-
|
876
|
-
|
877
|
-
|
1097
|
+
Object[] data = rows2Insert.getCurData();
|
1098
|
+
Integer nSrcID = new Integer(rows2Insert.getIntByIdx(0));
|
1099
|
+
String attrib = (String)data[1];
|
1100
|
+
m_db.getAttrMgr().add(nSrcID, attrib);
|
878
1101
|
}
|
879
1102
|
|
880
1103
|
}
|
881
1104
|
|
882
|
-
public void
|
1105
|
+
public void onBeforeUpdate(String tableName, IDBResult rows2Delete, int[] cols)
|
883
1106
|
{
|
884
|
-
|
1107
|
+
processDelete(tableName, rows2Delete, cols);
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
public void onBeforeDelete(String tableName, IDBResult rows2Delete)
|
1111
|
+
{
|
1112
|
+
processDelete(tableName, rows2Delete, null);
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
private boolean isChangedCol(int[] cols, int iCol)
|
1116
|
+
{
|
1117
|
+
if (cols==null)
|
1118
|
+
return true;
|
1119
|
+
|
1120
|
+
for ( int i = 0; i < cols.length; i++ )
|
1121
|
+
{
|
1122
|
+
if ( cols[i] == iCol )
|
1123
|
+
return true;
|
1124
|
+
}
|
1125
|
+
return false;
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
private void processDelete(String tableName, IDBResult rows2Delete, int[] cols)
|
1129
|
+
{
|
1130
|
+
if ( tableName.equalsIgnoreCase("changed_values") || tableName.equalsIgnoreCase("sources") ||
|
1131
|
+
tableName.equalsIgnoreCase("client_info"))
|
1132
|
+
return;
|
1133
|
+
|
1134
|
+
boolean bProcessTable = tableName.equalsIgnoreCase("object_values");
|
1135
|
+
boolean bSchemaSrc = false;
|
1136
|
+
Integer nSrcID = null;
|
1137
|
+
if ( !bProcessTable )
|
1138
|
+
{
|
1139
|
+
nSrcID = m_db.getAttrMgr().getSrcIDHasBlobsByName(tableName);
|
1140
|
+
bProcessTable = nSrcID != null;
|
1141
|
+
bSchemaSrc = bProcessTable;
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
if ( !bProcessTable)
|
1145
|
+
return;
|
1146
|
+
|
1147
|
+
if ( !bSchemaSrc && !isChangedCol(cols, 3))//value
|
885
1148
|
return;
|
886
1149
|
|
887
1150
|
for( ; !rows2Delete.isEnd(); rows2Delete.next() )
|
888
1151
|
{
|
889
|
-
|
890
|
-
String attrib = rows2Delete.getStringByIdx(2);
|
891
|
-
m_db.getAttrMgr().remove(nSrcID, attrib);
|
1152
|
+
Object[] data = rows2Delete.getCurData();
|
892
1153
|
|
893
|
-
|
894
|
-
|
895
|
-
|
1154
|
+
if ( !bSchemaSrc )
|
1155
|
+
{
|
1156
|
+
if ( nSrcID == null )
|
1157
|
+
nSrcID = new Integer(rows2Delete.getIntByIdx(0));
|
1158
|
+
|
1159
|
+
String attrib = (String)data[1];
|
1160
|
+
String value = (String)data[3];
|
896
1161
|
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
1162
|
+
if (cols == null) //delete
|
1163
|
+
m_db.getAttrMgr().remove(nSrcID, attrib);
|
1164
|
+
|
1165
|
+
if ( m_db.getAttrMgr().isBlobAttr(nSrcID, attrib) )
|
1166
|
+
processBlobDelete(nSrcID, attrib, value);
|
1167
|
+
}else
|
1168
|
+
{
|
1169
|
+
for ( int i = 0; i < rows2Delete.getColCount(); i++ )
|
1170
|
+
{
|
1171
|
+
if (!isChangedCol(cols, i))
|
1172
|
+
continue;
|
1173
|
+
|
1174
|
+
String attrib = rows2Delete.getColName(i);
|
1175
|
+
if ( !(data[i] instanceof String) )
|
1176
|
+
continue;
|
1177
|
+
|
1178
|
+
String value = (String)data[i];
|
1179
|
+
if ( m_db.getAttrMgr().isBlobAttr(nSrcID, attrib) )
|
1180
|
+
processBlobDelete(nSrcID, attrib, value);
|
1181
|
+
}
|
910
1182
|
}
|
911
|
-
|
1183
|
+
}
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
private void processBlobDelete(Integer nSrcID, String attrib, String value)
|
1187
|
+
{
|
1188
|
+
if ( value == null || value.length() == 0 )
|
1189
|
+
return;
|
1190
|
+
|
1191
|
+
try{
|
1192
|
+
String strFilePath = RhodesApp.getInstance().resolveDBFilesPath(value);
|
1193
|
+
|
1194
|
+
SimpleFile oFile = RhoClassFactory.createFile();
|
1195
|
+
oFile.delete(strFilePath);
|
1196
|
+
}catch(Exception exc){
|
1197
|
+
LOG.ERROR("DBCallback.OnDeleteFromTable: Error delete file: " + value, exc);
|
912
1198
|
}
|
913
1199
|
}
|
914
1200
|
|
915
1201
|
}
|
916
|
-
|
917
|
-
}
|
1202
|
+
}
|