rhodes 2.0.0.beta2 → 2.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -0
- data/Manifest.txt +27 -148
- data/Rakefile +49 -3
- data/lib/framework/builtinME.rb +6 -0
- data/lib/framework/rho/render.rb +13 -8
- data/lib/framework/rho/rho.rb +97 -43
- data/lib/framework/rho/rhoapplication.rb +8 -3
- data/lib/framework/rho/rhocontroller.rb +1 -1
- data/lib/framework/rhodes-framework.rb +1 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhoframework.rb +7 -22
- data/lib/framework/rhofsconnector.rb +1 -1
- data/lib/framework/rholang/localization_simplified.rb +2 -2
- data/lib/framework/rhom/rhom.rb +1 -0
- data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
- data/lib/framework/rhom/rhom_model.rb +98 -0
- data/lib/framework/rhom/rhom_object_factory.rb +13 -12
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/jni/include/{JNIRhodes.h → rhodes/JNIRhodes.h} +3 -54
- data/platform/android/Rhodes/jni/include/{RhoClassFactory.h → rhodes/RhoClassFactory.h} +0 -0
- data/platform/android/Rhodes/jni/include/{SystemInfoImpl.h → rhodes/SystemInfoImpl.h} +0 -0
- data/platform/android/Rhodes/jni/include/{details → rhodes/details}/rhojava.inc +1 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Logger.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoConf.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoLogConf.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoMenu.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Rhodes.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_SplashScreen.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_alert_Alert.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_camera_Camera.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_datetime_DateTimePicker.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_geolocation_GeoLocationImpl.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_RhoSocketImpl.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_SSLImpl.h +0 -0
- data/platform/android/Rhodes/jni/include/{sslimpl.h → rhodes/sslimpl.h} +0 -0
- data/platform/android/Rhodes/jni/include/rhodes.h +59 -0
- data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +3 -3
- data/platform/android/Rhodes/jni/src/alert.cpp +2 -2
- data/platform/android/Rhodes/jni/src/callbacks.cpp +4 -3
- data/platform/android/Rhodes/jni/src/camera.cpp +2 -2
- data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -2
- data/platform/android/Rhodes/jni/src/geolocation.cpp +2 -2
- data/platform/android/Rhodes/jni/src/logconf.cpp +2 -2
- data/platform/android/Rhodes/jni/src/logger.cpp +2 -2
- data/platform/android/Rhodes/jni/src/mapview.cpp +1 -1
- data/platform/android/Rhodes/jni/src/menu.cpp +2 -2
- data/platform/android/Rhodes/jni/src/nativebar.cpp +1 -1
- data/platform/android/Rhodes/jni/src/navbar.cpp +17 -3
- data/platform/android/Rhodes/jni/src/phonebook.cpp +1 -1
- data/platform/android/Rhodes/jni/src/rhoconf.cpp +2 -2
- data/platform/android/Rhodes/jni/src/rhodes.cpp +3 -3
- data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
- data/platform/android/Rhodes/jni/src/socketimpl.cpp +2 -2
- data/platform/android/Rhodes/jni/src/splashscreen.cpp +2 -2
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -3
- data/platform/android/Rhodes/jni/src/syncengine.cpp +2 -2
- data/platform/android/Rhodes/jni/src/webview.cpp +15 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeLibraries.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NavBar.java +52 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +8 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +26 -28
- data/platform/android/build/RhodesSRC_build.files +21 -20
- data/platform/android/build/android.rake +69 -24
- data/platform/android/build/androidcommon.rb +17 -12
- data/platform/bb/build/bb.rake +23 -21
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +5 -2
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +6 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +9 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +31 -2
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +17 -6
- data/platform/bb/rhodes/src/rhomobile/Utilities.java +6 -0
- data/platform/iphone/Classes/AppManager/AppManager.m +16 -4
- data/platform/iphone/Classes/DateTime.h +5 -6
- data/platform/iphone/Classes/DateTimePicker.m +4 -18
- data/platform/iphone/Classes/DateTimePickerDelegate.h +7 -9
- data/platform/iphone/Classes/DateTimePickerDelegate.m +141 -152
- data/platform/iphone/Classes/Rhodes.h +6 -1
- data/platform/iphone/Classes/Rhodes.m +17 -43
- data/platform/iphone/Classes/SimpleMainView.h +1 -1
- data/platform/iphone/Classes/SimpleMainView.m +54 -4
- data/platform/iphone/Classes/WebView.m +17 -0
- data/platform/iphone/rbuild/iphone.rake +1 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +0 -45
- data/platform/shared/common/PosixThreadImpl.cpp +8 -0
- data/platform/shared/common/PosixThreadImpl.h +1 -0
- data/platform/shared/common/RhoThread.cpp +1 -0
- data/platform/shared/common/RhoThread.h +4 -2
- data/platform/shared/curl/include/curl/curl.h +4 -0
- data/platform/shared/db/DBAdapter.cpp +47 -60
- data/platform/shared/db/DBAdapter.h +6 -2
- data/platform/shared/net/AsyncHttp.cpp +27 -11
- data/platform/shared/net/AsyncHttp.h +3 -1
- data/platform/shared/net/CURLNetRequest.cpp +11 -10
- data/platform/shared/net/CURLNetRequest.h +6 -4
- data/platform/shared/net/HttpServer.cpp +11 -6
- data/platform/shared/ruby/ext/asynchttp/asynchttp.i +2 -2
- data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +22 -11
- data/platform/shared/ruby/ext/rho/rhoruby.c +2 -2
- data/platform/shared/ruby/ext/rho/rhosupport.c +23 -3
- data/platform/shared/ruby/ext/webview/webview.i +4 -0
- data/platform/shared/ruby/ext/webview/webview_wrap.c +39 -0
- data/platform/shared/ruby/re.c +8 -0
- data/platform/shared/ruby/string.c +1 -1
- data/platform/shared/rubyJVM/src/com/rho/IRhoRubyHelper.java +1 -0
- data/platform/shared/rubyJVM/src/com/rho/RhoClassFactory.java +6 -1
- data/platform/shared/rubyJVM/src/com/rho/RhoThread.java +3 -0
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +34 -0
- data/platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java +40 -53
- data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +32 -15
- data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +31 -17
- data/platform/shared/rubyJVM/src/com/rho/net/RhoConnection.java +3 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/JSONArrayIterator.java +17 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +158 -137
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +18 -17
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +10 -2
- data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubyFile_Methods.java +6 -0
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyFile.java +18 -3
- data/platform/shared/rubyJVM/src/j2me/io/File.java +37 -9
- data/platform/shared/sqlite/sqlite3.c +14613 -13016
- data/platform/shared/sqlite/sqlite3.h +1461 -1499
- data/platform/shared/sqlite/sqlite3ext.h +0 -2
- data/platform/shared/sync/ClientRegister.cpp +3 -3
- data/platform/shared/sync/ClientRegister.h +2 -1
- data/platform/shared/sync/SyncEngine.cpp +20 -8
- data/platform/shared/sync/SyncSource.cpp +12 -12
- data/platform/shared/sync/SyncSource.h +4 -4
- data/platform/shared/sync/SyncThread.cpp +8 -1
- data/platform/shared/tcmalloc/rhomem.h +3 -0
- data/platform/shared/tcmalloc/tcmalloc_.cpp +11 -0
- data/platform/wm/rhodes/Alert.cpp +148 -101
- data/platform/wm/rhodes/Alert.h +4 -1
- data/platform/wm/rhodes/AppManager.cpp +212 -72
- data/platform/wm/rhodes/AppManager.h +24 -3
- data/platform/wm/rhodes/DateTimePicker.cpp +23 -11
- data/platform/wm/rhodes/DateTimePicker.h +16 -5
- data/platform/wm/rhodes/MainWindow.cpp +22 -7
- data/platform/wm/rhodes/OkCancelModalDialog.h +63 -0
- data/platform/wm/rhodes/Rhodes.cpp +29 -17
- data/platform/wm/rhodes/phonebook/NativeAddressBook.cpp +128 -4
- data/platform/wm/rhodes/phonebook/NativeAddressBook.h +33 -3
- data/platform/wm/rhodes/resource.h +1 -1
- data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +5 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +136 -102
- data/platform/wm/rhodes/rho/net/NetRequestImpl.h +12 -5
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +24 -10
- data/platform/wm/rhodes/rho/rubyext/WebView.cpp +6 -0
- data/platform/wm/rhodes/rhodes.vcproj +4 -0
- data/platform/wm/tools/detool/detool.cpp +17 -4
- data/rakefile.rb +49 -3
- data/res/build-tools/db/syncdb.schema +2 -2
- data/res/build-tools/detool.exe +0 -0
- data/res/generators/rhogen.rb +10 -10
- data/res/generators/templates/application/app/helpers/browser_helper.rb +9 -4
- data/res/generators/templates/application/app/index.bb.erb +5 -5
- data/res/generators/templates/application/build.yml +1 -0
- data/res/generators/templates/application/public/css/android.css +10 -8
- data/res/generators/templates/application/public/css/blackberry.css +40 -31
- data/res/generators/templates/application/public/css/iphone.css +4 -4
- data/res/generators/templates/application/public/css/webkit.css +7 -0
- data/res/generators/templates/application/public/css/windows_mobile.css +31 -27
- data/res/generators/templates/application/rhoconfig.txt +2 -2
- data/res/generators/templates/model/edit.bb.erb +2 -2
- data/res/generators/templates/model/index.bb.erb +6 -4
- data/res/generators/templates/model/model.rb +2 -1
- data/res/generators/templates/model/new.bb.erb +2 -2
- data/res/generators/templates/model/show.bb.erb +2 -2
- data/rhobuild.yml +37 -0
- data/rhodes.gemspec +1 -1
- data/spec/framework_spec/app/Account/account.rb +7 -0
- data/spec/framework_spec/app/Case/case.rb +6 -0
- data/spec/framework_spec/app/Customer/customer.rb +6 -0
- data/spec/framework_spec/app/Product/product.rb +9 -0
- data/spec/framework_spec/app/spec/rhom_object_spec.rb +1 -1
- data/spec/framework_spec/app/spec/syncengine_spec.rb +2 -1
- metadata +45 -151
- data/lib/build/manifest/createAppManifest.rb +0 -18
- data/lib/build/tasks/android.rake +0 -317
- data/lib/build/tasks/blackberry.rake +0 -355
- data/lib/build/tasks/common.rake +0 -62
- data/lib/build/tasks/iphone.rake +0 -108
- data/lib/build/tasks/linux.rake +0 -81
- data/lib/build/tasks/rhodes-build.rb +0 -11
- data/lib/build/tasks/rspec.rake +0 -20
- data/lib/build/tasks/symbian.rake +0 -202
- data/lib/build/tasks/wm.rake +0 -166
- data/lib/framework/ServeME.rb +0 -7
- data/platform/bb/build/MANIFEST.MF +0 -12
- data/platform/iphone/Classes/DateTimePicker.h +0 -17
- data/res/generators/templates/application/public/icons/Read me first - license.txt +0 -14
- 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 +0 -22
- 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/js/jquery-1.2.6.min.js +0 -32
- data/res/generators/templates/model/config.rb +0 -3
- data/res/generators/templates/spec/app/spec/webview_spec.rb +0 -5
- data/spec/framework_spec/app/Account/config.rb +0 -59
- data/spec/framework_spec/app/Case/config.rb +0 -3
- data/spec/framework_spec/app/Customer/config.rb +0 -3
- data/spec/framework_spec/app/Product/config.rb +0 -17
@@ -110,6 +110,14 @@ public class NetRequest
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
|
113
|
+
private String getResponseEncoding() throws Exception
|
114
|
+
{
|
115
|
+
if ( m_OutHeaders != null )
|
116
|
+
return (String)m_OutHeaders.get("content-type");
|
117
|
+
|
118
|
+
return "";
|
119
|
+
}
|
120
|
+
|
113
121
|
public NetResponse doRequest(String strMethod, String strUrl, String strBody, IRhoSession oSession, Hashtable headers ) throws Exception
|
114
122
|
{
|
115
123
|
String strRespBody = null;
|
@@ -159,6 +167,9 @@ public class NetRequest
|
|
159
167
|
|
160
168
|
is = m_connection.openInputStream();
|
161
169
|
LOG.INFO("openInputStream done");
|
170
|
+
|
171
|
+
readHeaders(headers);
|
172
|
+
copyHashtable(m_OutHeaders, headers);
|
162
173
|
|
163
174
|
if (code != IHttpConnection.HTTP_OK)
|
164
175
|
{
|
@@ -168,7 +179,7 @@ public class NetRequest
|
|
168
179
|
|
169
180
|
//if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
|
170
181
|
{
|
171
|
-
strRespBody = readFully(is);
|
182
|
+
strRespBody = readFully(is, getResponseEncoding());
|
172
183
|
|
173
184
|
if ( code == IHttpConnection.HTTP_MOVED_TEMPORARILY ||
|
174
185
|
code == IHttpConnection.HTTP_MOVED_PERMANENTLY )
|
@@ -181,13 +192,11 @@ public class NetRequest
|
|
181
192
|
long len = m_connection.getLength();
|
182
193
|
LOG.INFO("fetchRemoteData data size:" + len );
|
183
194
|
|
184
|
-
strRespBody = readFully(is);
|
195
|
+
strRespBody = readFully(is, getResponseEncoding());
|
185
196
|
|
186
197
|
LOG.INFO("fetchRemoteData data readFully.");
|
187
198
|
}
|
188
199
|
|
189
|
-
readHeaders(headers);
|
190
|
-
copyHashtable(m_OutHeaders, headers);
|
191
200
|
}finally
|
192
201
|
{
|
193
202
|
if ( is != null )
|
@@ -283,7 +292,7 @@ public class NetRequest
|
|
283
292
|
if (oItem.m_strFileName.length()>0)
|
284
293
|
oItem.m_strDataPrefix += "; filename=\"" + oItem.m_strFileName + "\"";
|
285
294
|
oItem.m_strDataPrefix += "\r\n";
|
286
|
-
if ( oItem.m_strContentType.length() > 0 )
|
295
|
+
if ( oItem.m_strContentType != null && oItem.m_strContentType.length() > 0 )
|
287
296
|
oItem.m_strDataPrefix += "Content-Type: " + oItem.m_strContentType + "\r\n";
|
288
297
|
|
289
298
|
long nContentSize = 0;
|
@@ -306,7 +315,7 @@ public class NetRequest
|
|
306
315
|
else
|
307
316
|
nContentSize = oItem.m_strBody.length();
|
308
317
|
|
309
|
-
if ( oItem.m_strContentType.length() > 0 )
|
318
|
+
if ( oItem.m_strContentType != null && oItem.m_strContentType.length() > 0 )
|
310
319
|
oItem.m_strDataPrefix += "Content-Length: " + nContentSize + "\r\n";
|
311
320
|
|
312
321
|
oItem.m_strDataPrefix += "\r\n";
|
@@ -392,6 +401,9 @@ public class NetRequest
|
|
392
401
|
code = m_connection.getResponseCode();
|
393
402
|
|
394
403
|
LOG.INFO("getResponseCode : " + code);
|
404
|
+
|
405
|
+
readHeaders(headers);
|
406
|
+
copyHashtable(m_OutHeaders, headers);
|
395
407
|
|
396
408
|
if (code != IHttpConnection.HTTP_OK)
|
397
409
|
{
|
@@ -400,19 +412,18 @@ public class NetRequest
|
|
400
412
|
oSession.logout();
|
401
413
|
|
402
414
|
if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
|
403
|
-
strRespBody = readFully(is);
|
415
|
+
strRespBody = readFully(is, getResponseEncoding());
|
404
416
|
|
405
417
|
}else
|
406
418
|
{
|
407
419
|
long len = m_connection.getLength();
|
408
420
|
LOG.INFO("fetchRemoteData data size:" + len );
|
409
421
|
|
410
|
-
strRespBody = readFully(is);
|
422
|
+
strRespBody = readFully(is, getResponseEncoding());
|
411
423
|
|
412
424
|
LOG.INFO("fetchRemoteData data readFully.");
|
413
425
|
}
|
414
426
|
|
415
|
-
readHeaders(headers);
|
416
427
|
}finally{
|
417
428
|
try{
|
418
429
|
if ( is != null )
|
@@ -425,7 +436,6 @@ public class NetRequest
|
|
425
436
|
}catch(IOException exc2){}
|
426
437
|
}
|
427
438
|
|
428
|
-
copyHashtable(m_OutHeaders, headers);
|
429
439
|
return makeResponse(strRespBody, code );
|
430
440
|
}
|
431
441
|
|
@@ -452,7 +462,7 @@ public class NetRequest
|
|
452
462
|
}
|
453
463
|
}
|
454
464
|
|
455
|
-
file = RhoClassFactory.
|
465
|
+
file = RhoClassFactory.createFSRAFile();
|
456
466
|
file.open(strFileName, "rw");
|
457
467
|
file.seek(file.size());
|
458
468
|
|
@@ -508,6 +518,7 @@ public class NetRequest
|
|
508
518
|
LOG.INFO("getResponseCode : " + code);
|
509
519
|
|
510
520
|
m_nCurDownloadSize = 0;
|
521
|
+
readHeaders(headers);
|
511
522
|
|
512
523
|
if ( code == IHttpConnection.HTTP_RANGENOTSATISFY )
|
513
524
|
code = IHttpConnection.HTTP_PARTIAL_CONTENT;
|
@@ -522,7 +533,7 @@ public class NetRequest
|
|
522
533
|
if ( code != IHttpConnection.HTTP_INTERNAL_ERROR )
|
523
534
|
{
|
524
535
|
is = m_connection.openInputStream();
|
525
|
-
strRespBody = readFully(is);
|
536
|
+
strRespBody = readFully(is, getResponseEncoding());
|
526
537
|
}
|
527
538
|
}else
|
528
539
|
{
|
@@ -549,8 +560,6 @@ public class NetRequest
|
|
549
560
|
}
|
550
561
|
|
551
562
|
}
|
552
|
-
|
553
|
-
readHeaders(headers);
|
554
563
|
}finally
|
555
564
|
{
|
556
565
|
if ( is != null )
|
@@ -644,17 +653,22 @@ public class NetRequest
|
|
644
653
|
return strRes;
|
645
654
|
}
|
646
655
|
|
647
|
-
private final String readFully(InputStream in) throws Exception
|
656
|
+
private final String readFully(InputStream in, String strContType) throws Exception
|
648
657
|
{
|
649
658
|
String strRes = "";
|
650
659
|
byte[] byteBuffer = new byte[1024*4];
|
651
|
-
|
660
|
+
boolean bUTF8 = strContType != null && strContType.indexOf("UTF-8")>=0;
|
661
|
+
|
652
662
|
int nRead = 0;
|
653
663
|
do{
|
654
664
|
nRead = in.read(byteBuffer);
|
655
665
|
if (nRead>0)
|
656
666
|
{
|
657
|
-
String strTemp
|
667
|
+
String strTemp;
|
668
|
+
if (bUTF8)
|
669
|
+
strTemp = new String(byteBuffer,0,nRead, "UTF-8");
|
670
|
+
else
|
671
|
+
strTemp = new String(byteBuffer,0,nRead);
|
658
672
|
strRes += strTemp;
|
659
673
|
}
|
660
674
|
}while( nRead > 0 );
|
@@ -635,6 +635,8 @@ public class RhoConnection implements IHttpConnection {
|
|
635
635
|
String url = uri.getPath();// + (nPos == 0 ? ".iseq" : "");
|
636
636
|
RubyValue res = RhoRuby.processIndexRequest(url);//erb-compiled should load from class
|
637
637
|
processResponse(res);
|
638
|
+
|
639
|
+
RhodesApp.getInstance().keepLastVisitedUrl(url_external);
|
638
640
|
return true;
|
639
641
|
}
|
640
642
|
|
@@ -762,6 +764,7 @@ public class RhoConnection implements IHttpConnection {
|
|
762
764
|
actionid.charAt(0)=='{' && actionid.charAt(actionid.length()-1)=='}' )
|
763
765
|
SyncThread.getInstance().addobjectnotify_bysrcname( model, actionid);
|
764
766
|
|
767
|
+
RhodesApp.getInstance().keepLastVisitedUrl(url_external);
|
765
768
|
LOG.INFO("dispatch end");
|
766
769
|
return true;
|
767
770
|
}
|
@@ -20,6 +20,12 @@ class JSONArrayIterator
|
|
20
20
|
m_array = (JSONArray)oEntry.m_object.get(strName);
|
21
21
|
m_nCurItem = 0;
|
22
22
|
}
|
23
|
+
|
24
|
+
private JSONArrayIterator()
|
25
|
+
{
|
26
|
+
m_array = null;
|
27
|
+
m_nCurItem = 0;
|
28
|
+
}
|
23
29
|
|
24
30
|
boolean isEnd()
|
25
31
|
{
|
@@ -42,4 +48,15 @@ class JSONArrayIterator
|
|
42
48
|
{
|
43
49
|
return new JSONEntry( isEnd() ? null : (JSONObject) m_array.get(m_nCurItem) );
|
44
50
|
}
|
51
|
+
|
52
|
+
JSONArrayIterator getCurArrayIter()throws JSONException
|
53
|
+
{
|
54
|
+
JSONArrayIterator res = new JSONArrayIterator();
|
55
|
+
if ( isEnd() )
|
56
|
+
return res;
|
57
|
+
|
58
|
+
res.m_array = (JSONArray)m_array.get(m_nCurItem);
|
59
|
+
return res;
|
60
|
+
}
|
61
|
+
|
45
62
|
}
|
@@ -25,6 +25,7 @@ import com.rho.RhoEmptyProfiler;
|
|
25
25
|
import com.rho.RhoLogger;
|
26
26
|
import com.rho.RhoProfiler;
|
27
27
|
import com.rho.RhoRuby;
|
28
|
+
import com.rho.TimeInterval;
|
28
29
|
import com.rho.db.*;
|
29
30
|
import com.rho.net.*;
|
30
31
|
import com.rho.*;
|
@@ -195,143 +196,160 @@ public class SyncEngine implements NetRequest.IRhoSession
|
|
195
196
|
|
196
197
|
void doSearch(Vector/*<rho::String>*/ arSources, String strParams, String strAction, boolean bSearchSyncChanges, int nProgressStep)
|
197
198
|
{
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
199
|
+
try
|
200
|
+
{
|
201
|
+
prepareSync(esSearch);
|
202
|
+
if ( !isContinueSync() )
|
203
|
+
{
|
204
|
+
if ( getState() != esExit )
|
205
|
+
setState(esNone);
|
206
|
+
|
207
|
+
return;
|
208
|
+
}
|
209
|
+
|
210
|
+
TimeInterval startTime = TimeInterval.getCurrentTime();
|
211
|
+
|
212
|
+
if ( bSearchSyncChanges )
|
213
|
+
{
|
214
|
+
for ( int i = 0; i < (int)arSources.size(); i++ )
|
215
|
+
{
|
216
|
+
SyncSource pSrc = findSourceByName((String)arSources.elementAt(i));
|
217
|
+
if ( pSrc != null )
|
218
|
+
pSrc.syncClientChanges();
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
int nErrCode = 0;
|
223
|
+
while( isContinueSync() )
|
224
|
+
{
|
225
|
+
int nSearchCount = 0;
|
226
|
+
String strUrl = getProtocol().getServerQueryUrl(strAction);
|
227
|
+
String strQuery = getProtocol().getServerQueryBody("", getClientID(), getSyncPageSize());
|
228
|
+
|
229
|
+
if ( strParams.length() > 0 )
|
230
|
+
strQuery += strParams;
|
231
|
+
|
232
|
+
for ( int i = 0; i < (int)arSources.size(); i++ )
|
233
|
+
{
|
234
|
+
SyncSource pSrc = findSourceByName((String)arSources.elementAt(i));
|
235
|
+
if ( pSrc != null )
|
236
|
+
{
|
237
|
+
strQuery += "&source[][name]=" + pSrc.getName();
|
238
|
+
|
239
|
+
if ( !pSrc.isTokenFromDB() && pSrc.getToken() > 1 )
|
240
|
+
strQuery += "&source[][token]=" + pSrc.getToken();
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
LOG.INFO("Call search on server. Url: " + (strUrl+strQuery) );
|
245
|
+
NetResponse resp = getNet().pullData(strUrl+strQuery, this);
|
246
|
+
|
247
|
+
if ( !resp.isOK() )
|
248
|
+
{
|
249
|
+
stopSync();
|
250
|
+
nErrCode = RhoRuby.getErrorFromResponse(resp);
|
251
|
+
continue;
|
252
|
+
}
|
253
|
+
|
254
|
+
String szData = resp.getCharData();
|
255
|
+
|
256
|
+
JSONArrayIterator oJsonArr = new JSONArrayIterator(szData);
|
257
|
+
|
258
|
+
for( ; !oJsonArr.isEnd() && isContinueSync(); oJsonArr.next() )
|
259
|
+
{
|
260
|
+
JSONArrayIterator oSrcArr = oJsonArr.getCurArrayIter();//new JSONArrayIterator(oJsonArr.getCurItem());
|
261
|
+
|
262
|
+
int nVersion = 0;
|
263
|
+
if ( !oSrcArr.isEnd() && oSrcArr.getCurItem().hasName("version") )
|
264
|
+
{
|
265
|
+
nVersion = oSrcArr.getCurItem().getInt("version");
|
266
|
+
oJsonArr.next();
|
267
|
+
}
|
268
|
+
|
269
|
+
if ( nVersion != getProtocol().getVersion() )
|
270
|
+
{
|
271
|
+
LOG.ERROR( "Sync server send search data with incompatible version. Client version: " + getProtocol().getVersion() +
|
272
|
+
"; Server response version: " + nVersion );
|
273
|
+
stopSync();
|
274
|
+
nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
|
275
|
+
continue;
|
276
|
+
}
|
277
|
+
|
278
|
+
if ( !oSrcArr.getCurItem().hasName("source") )
|
279
|
+
{
|
280
|
+
LOG.ERROR( "Sync server send search data without source name." );
|
281
|
+
stopSync();
|
282
|
+
nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
|
283
|
+
continue;
|
284
|
+
}
|
285
|
+
|
286
|
+
String strSrcName = oSrcArr.getCurItem().getString("source");
|
287
|
+
SyncSource pSrc = findSourceByName(strSrcName);
|
288
|
+
if ( pSrc == null )
|
289
|
+
{
|
290
|
+
LOG.ERROR("Sync server send search data for unknown source name:" + strSrcName);
|
291
|
+
stopSync();
|
292
|
+
nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
|
293
|
+
continue;
|
294
|
+
}
|
295
|
+
|
296
|
+
oSrcArr.reset(0);
|
297
|
+
pSrc.m_bIsSearch = true;
|
298
|
+
pSrc.setProgressStep(nProgressStep);
|
299
|
+
pSrc.processServerResponse_ver3(oSrcArr);
|
300
|
+
|
301
|
+
nSearchCount += pSrc.getCurPageCount();
|
302
|
+
}
|
303
|
+
|
304
|
+
if ( nSearchCount == 0 )
|
305
|
+
break;
|
306
|
+
}
|
307
|
+
|
308
|
+
if ( isContinueSync() )
|
309
|
+
{
|
310
|
+
SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
|
311
|
+
src.m_bIsSearch = true;
|
312
|
+
|
313
|
+
getNotify().fireSyncNotification(src, true, RhoRuby.ERR_NONE, RhoRuby.getMessageText("sync_completed"));
|
314
|
+
}
|
315
|
+
else if ( nErrCode != 0 )
|
316
|
+
{
|
317
|
+
SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
|
318
|
+
src.m_nErrCode = nErrCode;
|
319
|
+
src.m_bIsSearch = true;
|
320
|
+
getNotify().fireSyncNotification(src, true, src.m_nErrCode, "");
|
321
|
+
}
|
322
|
+
|
323
|
+
//update db info
|
324
|
+
TimeInterval endTime = TimeInterval.getCurrentTime();
|
325
|
+
//unsigned long timeUpdated = CLocalTime().toULong();
|
326
|
+
for ( int i = 0; i < (int)arSources.size(); i++ )
|
327
|
+
{
|
328
|
+
SyncSource oSrc = findSourceByName((String)arSources.elementAt(i));
|
329
|
+
if ( oSrc == null )
|
330
|
+
continue;
|
331
|
+
oSrc.getDB().executeSQL("UPDATE sources set last_updated=?,last_inserted_size=?,last_deleted_size=?, "+
|
332
|
+
"last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
|
333
|
+
new Long(endTime.toULong()/1000), new Integer(oSrc.getInsertedCount()), new Integer(oSrc.getDeletedCount()),
|
334
|
+
new Long((endTime.minus(startTime)).toULong()), new Integer(oSrc.getGetAtLeastOnePage()?1:0),
|
335
|
+
new Integer(oSrc.getRefreshTime()), oSrc.getID() );
|
336
|
+
}
|
337
|
+
//
|
338
|
+
|
339
|
+
getNotify().cleanCreateObjectErrors();
|
340
|
+
if ( getState() != esExit )
|
341
|
+
setState(esNone);
|
314
342
|
|
315
|
-
|
316
|
-
|
317
|
-
unsigned long timeUpdated = CLocalTime().toULong();
|
318
|
-
for ( int i = 0; i < (int)arSources.size(); i++ )
|
319
|
-
{
|
320
|
-
CSyncSource* pSrc = findSourceByName(arSources.elementAt(i));
|
321
|
-
if ( pSrc == null )
|
322
|
-
continue;
|
323
|
-
CSyncSource& oSrc = *pSrc;
|
324
|
-
oSrc.getDB().executeSQL("UPDATE sources set last_updated=?,last_inserted_size=?,last_deleted_size=?, \
|
325
|
-
last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
|
326
|
-
timeUpdated, oSrc.getInsertedCount(), oSrc.getDeletedCount(),
|
327
|
-
(endTime-startTime).toULong(), oSrc.getGetAtLeastOnePage(), oSrc.getRefreshTime(),
|
328
|
-
oSrc.getID() );
|
329
|
-
}
|
330
|
-
//
|
343
|
+
} catch(Exception exc) {
|
344
|
+
LOG.ERROR("Search failed.", exc);
|
331
345
|
|
332
|
-
|
333
|
-
|
334
|
-
|
346
|
+
SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
|
347
|
+
src.m_bIsSearch = true;
|
348
|
+
src.m_nErrCode = RhoRuby.ERR_RUNTIME;
|
349
|
+
|
350
|
+
getNotify().fireSyncNotification(src, true, src.m_nErrCode, "" );
|
351
|
+
}
|
352
|
+
|
335
353
|
}
|
336
354
|
|
337
355
|
void doSyncSource(SourceID oSrcID)
|
@@ -399,7 +417,7 @@ public class SyncEngine implements NetRequest.IRhoSession
|
|
399
417
|
{
|
400
418
|
m_sources.removeAllElements();
|
401
419
|
|
402
|
-
IDBResult res = getUserDB().executeSQL("SELECT source_id,sync_type,name, partition from sources ORDER BY
|
420
|
+
IDBResult res = getUserDB().executeSQL("SELECT source_id,sync_type,name, partition from sources ORDER BY sync_priority");
|
403
421
|
for ( ; !res.isEnd(); res.next() )
|
404
422
|
{
|
405
423
|
String strShouldSync = res.getStringByIdx(1);
|
@@ -473,7 +491,7 @@ public class SyncEngine implements NetRequest.IRhoSession
|
|
473
491
|
|
474
492
|
NetResponse resp = getNet().pullData(getProtocol().getClientResetUrl(strClientID), this);
|
475
493
|
/*
|
476
|
-
processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"
|
494
|
+
processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"sync_priority\":\"0\","+
|
477
495
|
"\"schema_version\":\"7.0\",\"schema\":{"+
|
478
496
|
"\"columns\":[\'brand\',\'created_at\',\'name\',\'price\',\'quantity\',\'sku\',\'updated_at\']"+
|
479
497
|
"}}]}");
|
@@ -521,6 +539,8 @@ public class SyncEngine implements NetRequest.IRhoSession
|
|
521
539
|
|
522
540
|
void doBulkSync()throws Exception
|
523
541
|
{
|
542
|
+
// processServerSources("{\"partition\":\"" + "application" + "\"}");
|
543
|
+
|
524
544
|
if ( !RhoConf.getInstance().isExist("bulksync_state") )
|
525
545
|
return;
|
526
546
|
|
@@ -628,6 +648,7 @@ public class SyncEngine implements NetRequest.IRhoSession
|
|
628
648
|
getNotify().fireBulkSyncNotification(false, "change_db", strPartition, RhoRuby.ERR_NONE);
|
629
649
|
|
630
650
|
dbPartition.setBulkSyncDB(fDataName, fScriptName);
|
651
|
+
processServerSources("{\"partition\":\"" + strPartition + "\"}");
|
631
652
|
|
632
653
|
LOG.INFO("Bulk sync: end change db");
|
633
654
|
getNotify().fireBulkSyncNotification(false, "", strPartition, RhoRuby.ERR_NONE);
|
@@ -85,7 +85,7 @@ class SyncSource
|
|
85
85
|
int m_nRefreshTime = 0;
|
86
86
|
int m_nProgressStep = -1;
|
87
87
|
boolean m_bSchemaSource;
|
88
|
-
Hashtable/*<String,String>*/
|
88
|
+
Hashtable/*<String,String>*/ m_hashAssociations = new Hashtable();
|
89
89
|
Vector/*Ptr<net::CMultipartItem*>*/ m_arMultipartItems = new Vector();
|
90
90
|
Vector/*<String>*/ m_arBlobAttrs = new Vector();
|
91
91
|
|
@@ -160,7 +160,7 @@ class SyncSource
|
|
160
160
|
m_nErrCode = RhoRuby.ERR_NONE;
|
161
161
|
m_bIsSearch = false;
|
162
162
|
|
163
|
-
IDBResult res = db.executeSQL("SELECT token,
|
163
|
+
IDBResult res = db.executeSQL("SELECT token,associations from sources WHERE source_id=?", m_nID);
|
164
164
|
if ( !res.isEnd() )
|
165
165
|
{
|
166
166
|
m_token = res.getLongByIdx(0);
|
@@ -172,15 +172,15 @@ class SyncSource
|
|
172
172
|
}
|
173
173
|
|
174
174
|
m_bSchemaSource = db.isTableExist(m_strName);
|
175
|
-
|
175
|
+
parseAssociations(res.getStringByIdx(1));
|
176
176
|
}
|
177
177
|
|
178
|
-
void
|
178
|
+
void parseAssociations(String strAssociations)
|
179
179
|
{
|
180
|
-
if (
|
180
|
+
if (strAssociations.length() == 0 )
|
181
181
|
return;
|
182
182
|
|
183
|
-
Tokenizer oTokenizer = new Tokenizer(
|
183
|
+
Tokenizer oTokenizer = new Tokenizer( strAssociations, "," );
|
184
184
|
|
185
185
|
String strSrcName = "";
|
186
186
|
while (oTokenizer.hasMoreTokens())
|
@@ -191,7 +191,7 @@ class SyncSource
|
|
191
191
|
|
192
192
|
if ( strSrcName.length() > 0 )
|
193
193
|
{
|
194
|
-
|
194
|
+
m_hashAssociations.put(strSrcName, tok);
|
195
195
|
strSrcName = "";
|
196
196
|
}else
|
197
197
|
strSrcName = tok;
|
@@ -220,9 +220,10 @@ class SyncSource
|
|
220
220
|
}finally{
|
221
221
|
TimeInterval endTime = TimeInterval.getCurrentTime();
|
222
222
|
getDB().executeSQL("UPDATE sources set last_updated=?,last_inserted_size=?,last_deleted_size=?, "+
|
223
|
-
|
224
|
-
|
225
|
-
|
223
|
+
"last_sync_duration=?,last_sync_success=?, backend_refresh_time=? WHERE source_id=?",
|
224
|
+
new Long(endTime.toULong()/1000), new Integer(getInsertedCount()), new Integer(getDeletedCount()),
|
225
|
+
new Long((endTime.minus(startTime)).toULong()),
|
226
|
+
new Integer(m_bGetAtLeastOnePage?1:0), new Integer(m_nRefreshTime), getID() );
|
226
227
|
}
|
227
228
|
}
|
228
229
|
|
@@ -622,19 +623,19 @@ class SyncSource
|
|
622
623
|
}
|
623
624
|
}
|
624
625
|
|
625
|
-
void
|
626
|
+
void processAssociations(String strOldObject, String strNewObject)throws Exception
|
626
627
|
{
|
627
|
-
Enumeration vals =
|
628
|
-
Enumeration keys =
|
628
|
+
Enumeration vals = m_hashAssociations.elements();
|
629
|
+
Enumeration keys = m_hashAssociations.keys();
|
629
630
|
while (vals.hasMoreElements())
|
630
631
|
{
|
631
632
|
SyncSource pSrc = getSync().findSourceByName((String)keys.nextElement());
|
632
633
|
if ( pSrc != null )
|
633
|
-
pSrc.
|
634
|
+
pSrc.updateAssociation(strOldObject, strNewObject, (String)vals.nextElement());
|
634
635
|
}
|
635
636
|
}
|
636
637
|
|
637
|
-
void
|
638
|
+
void updateAssociation(String strOldObject, String strNewObject, String strAttrib)throws Exception
|
638
639
|
{
|
639
640
|
if ( m_bSchemaSource )
|
640
641
|
{
|
@@ -767,7 +768,7 @@ class SyncSource
|
|
767
768
|
}else if ( strCmd.compareTo("links") == 0 )
|
768
769
|
{
|
769
770
|
String strValue = attrIter.getCurString();
|
770
|
-
|
771
|
+
processAssociations(strObject, strValue);
|
771
772
|
|
772
773
|
String strSqlUpdate = "UPDATE ";
|
773
774
|
strSqlUpdate += getName() + " SET object=? WHERE object=?";
|
@@ -871,7 +872,7 @@ class SyncSource
|
|
871
872
|
m_nDeleted++;
|
872
873
|
}else if ( strCmd.compareTo("links") == 0 )
|
873
874
|
{
|
874
|
-
|
875
|
+
processAssociations(strObject, oAttrValue.m_strValue);
|
875
876
|
|
876
877
|
getDB().executeSQL("UPDATE object_values SET object=? where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
|
877
878
|
getDB().executeSQL("UPDATE changed_values SET object=?,sent=3 where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
|
@@ -664,8 +664,16 @@ public class SyncThread extends RhoThread
|
|
664
664
|
new RubyOneArgMethod() {
|
665
665
|
protected RubyValue run(RubyValue receiver, RubyValue arg1, RubyBlock block) {
|
666
666
|
try{
|
667
|
-
String
|
668
|
-
|
667
|
+
String syncserver = arg1.toStr();
|
668
|
+
|
669
|
+
stopSync();
|
670
|
+
getSyncEngine().setSyncServer(syncserver);
|
671
|
+
|
672
|
+
if ( syncserver != null && syncserver.length() > 0 )
|
673
|
+
SyncThread.getInstance().start(SyncThread.epLow);
|
674
|
+
else
|
675
|
+
SyncThread.getInstance().stop(SYNC_WAIT_BEFOREKILL_SECONDS);
|
676
|
+
|
669
677
|
}catch(Exception e)
|
670
678
|
{
|
671
679
|
LOG.ERROR("set_syncserver failed", e);
|