rhodes 2.3.0 → 2.3.1.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/Manifest.txt +5819 -0
- data/README.md +2 -2
- data/Rakefile +9 -5
- data/doc/build.txt +7 -13
- data/doc/configuration.txt +4 -0
- data/doc/connect-to-web-services.txt +0 -1
- data/doc/device-caps.txt +2 -2
- data/doc/extensions.txt +2 -0
- data/doc/linea.txt +699 -0
- data/doc/rhom.txt +2 -1
- data/doc/synchronization.txt +39 -2
- data/doc/ui.txt +1 -0
- data/installer/README.html +1 -1
- data/lib/build/jake.rb +3 -0
- data/lib/framework/res/esri.wm.png +0 -0
- data/lib/framework/rho/render.rb +2 -0
- data/lib/framework/rho/rho.rb +17 -10
- data/lib/framework/rho/rhoapplication.rb +13 -3
- data/lib/framework/rho/rhoevent_bb.rb +3 -1
- data/lib/framework/rho/rhoevent_c.rb +4 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhom/rhom.rb +10 -0
- data/lib/framework/rhom/rhom_object_factory.rb +45 -0
- data/lib/framework/rhom/rhom_source.rb +1 -1
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/jni/include/rhodes/RhoClassFactory.h +1 -1
- data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +1 -1
- data/platform/android/Rhodes/jni/src/callbacks.cpp +9 -11
- data/platform/android/Rhodes/jni/src/event.cpp +17 -9
- data/platform/android/Rhodes/jni/src/mapview.cpp +34 -4
- data/platform/android/Rhodes/jni/src/rhodes.cpp +1 -1
- data/platform/android/Rhodes/res/drawable/esri.png +0 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +3 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +8 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +80 -9
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +29 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +4 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +50 -10
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +3 -0
- data/platform/android/build/android.rake +45 -23
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +6 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/CachedDataRow.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/CachedRow.java +3 -2
- data/platform/bb/Hsqldb/src/org/hsqldb/Row.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/persist/CachedObject.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/persist/DataFileCache.java +66 -16
- data/platform/bb/Hsqldb/src/org/hsqldb/persist/HsqlDatabaseProperties.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/RhoCrypto.java +116 -0
- data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +39 -2
- data/platform/bb/RubyVM/src/com/rho/Tokenizer.java +11 -6
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +157 -150
- data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/file/RhoFile.java +15 -0
- data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +35 -23
- data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +6 -9
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +54 -16
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +18 -9
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +37 -59
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +3 -0
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +4 -5
- data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +4 -1
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +8 -3
- data/platform/bb/rhodes/resources/esri.png +0 -0
- data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +2 -0
- data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +8 -3
- data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +4 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +2 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapField.java +9 -0
- data/platform/iphone/Classes/Event/Event.m +12 -2
- data/platform/iphone/Classes/NativeBar.h +12 -11
- data/platform/iphone/Classes/NativeBar.m +13 -3
- data/platform/iphone/Classes/Rhodes.m +48 -10
- data/platform/iphone/Classes/SimpleMainView.h +1 -0
- data/platform/iphone/Classes/SimpleMainView.m +7 -1
- data/platform/iphone/Classes/SplitView/LeftViewController.m +3 -0
- data/platform/iphone/Classes/SplitView/RightViewController.m +11 -6
- data/platform/iphone/Classes/SplitView/SplittedMainView.m +8 -0
- data/platform/iphone/Classes/TabbedMainView.m +39 -3
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +4 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +3 -3
- data/platform/shared/SyncClient/SyncClient.cpp +23 -23
- data/platform/shared/common/IRhoClassFactory.h +6 -4
- data/platform/shared/common/RhoAppAdapter.h +1 -1
- data/platform/shared/common/RhoFile.cpp +10 -0
- data/platform/shared/common/RhoFile.h +1 -0
- data/platform/shared/common/RhoMutexLock.h +1 -1
- data/platform/shared/common/RhoStd.h +5 -0
- data/platform/shared/common/RhoThread.cpp +2 -2
- data/platform/shared/common/RhoThread.h +1 -2
- data/platform/shared/common/RhodesApp.cpp +33 -55
- data/platform/shared/common/RhodesApp.h +0 -5
- data/platform/shared/common/RhodesAppBase.cpp +1 -1
- data/platform/shared/common/SplashScreen.cpp +1 -2
- data/platform/shared/common/ThreadQueue.cpp +31 -4
- data/platform/shared/common/ThreadQueue.h +10 -3
- data/platform/shared/common/Tokenizer.cpp +12 -8
- data/platform/shared/common/iphone/RhoClassFactory.cpp +5 -8
- data/platform/shared/common/iphone/RhoClassfactory.h +1 -1
- data/platform/shared/common/map/ESRIMapEngine.cpp +17 -7
- data/platform/shared/common/map/ESRIMapEngine.h +11 -1
- data/platform/shared/common/map/GoogleMapEngine.cpp +3 -3
- data/platform/shared/common/map/GoogleMapEngine.h +2 -2
- data/platform/shared/common/map/MapEngine.cpp +37 -0
- data/platform/shared/common/map/MapEngine.h +5 -0
- data/platform/shared/db/DBAdapter.cpp +113 -81
- data/platform/shared/db/DBAdapter.h +21 -5
- data/platform/shared/db/DBAttrManager.cpp +2 -2
- data/platform/shared/db/DBResult.h +28 -0
- data/platform/shared/net/AsyncHttp.cpp +48 -48
- data/platform/shared/net/AsyncHttp.h +15 -12
- data/platform/shared/net/CURLNetRequest.cpp +27 -105
- data/platform/shared/net/CURLNetRequest.h +8 -15
- data/platform/shared/net/INetRequest.cpp +122 -0
- data/platform/shared/net/INetRequest.h +96 -23
- data/platform/shared/net/ssl.cpp +1 -1
- data/platform/shared/ruby/ext/calendar/calendar.i +2 -2
- data/platform/shared/ruby/ext/calendar/calendar_wrap.c +30 -3
- data/platform/shared/rubyext/GeoLocation.cpp +4 -5
- data/platform/shared/rubyext/GeoLocation.h +4 -4
- data/platform/shared/rubyext/RhoAppAdapter.cpp +1 -1
- data/platform/shared/rubyext/System.cpp +3 -0
- data/platform/shared/sync/ClientRegister.cpp +6 -9
- data/platform/shared/sync/ClientRegister.h +8 -6
- data/platform/shared/sync/SyncEngine.cpp +54 -30
- data/platform/shared/sync/SyncEngine.h +9 -11
- data/platform/shared/sync/SyncNotify.cpp +19 -14
- data/platform/shared/sync/SyncNotify.h +5 -12
- data/platform/shared/sync/SyncSource.cpp +53 -76
- data/platform/shared/sync/SyncSource.h +5 -4
- data/platform/shared/sync/SyncThread.cpp +5 -7
- data/platform/shared/sync/SyncThread.h +2 -2
- data/platform/wm/RhoLib/RhoLib.vcproj +43 -39
- data/platform/wm/build/wm.rake +19 -17
- data/platform/wm/rhodes/AppManager.cpp +4 -4
- data/platform/wm/rhodes/MainWindow.cpp +0 -1
- data/platform/wm/rhodes/MapView/MapViewManager.cpp +4 -0
- data/platform/wm/rhodes/Vibrate.cpp +2 -2
- data/platform/wm/rhodes/Vibrate.h +1 -1
- data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +7 -5
- data/platform/wm/rhodes/rho/common/RhoClassFactory.h +3 -3
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +24 -10
- data/platform/wm/rhodes/rho/net/NetRequestImpl.h +49 -25
- data/platform/wm/rhodes/rho/rubyext/calendar.cpp +16 -2
- data/platform/wm/rhodes/rhodes.vcproj +77 -85
- data/platform/wm/tools/detool/detool.cpp +16 -6
- data/rakefile.rb +9 -5
- data/res/build-tools/detool.exe +0 -0
- data/rhodes.gemspec +2 -2
- data/spec/phone_spec/app/spec/blobsync_spec.rb +1 -0
- data/spec/phone_spec/app/spec/events_spec.rb +13 -2
- data/spec/phone_spec/app/spec/mapview_spec.rb +2 -2
- data/spec/phone_spec/app/spec/nativebar_spec.rb +3 -3
- data/spec/phone_spec/app/spec/navbar_spec.rb +3 -3
- data/spec/phone_spec/app/spec/rho_spec.rb +1 -1
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +1 -1
- data/spec/phone_spec/app/spec/syncengine_spec.rb +219 -0
- data/spec/phone_spec/build.yml +1 -0
- metadata +15 -8
- data/platform/wm/rhodes/rho/net/NetRequest.cpp +0 -89
- data/platform/wm/rhodes/rho/net/NetRequest.h +0 -45
@@ -29,7 +29,7 @@ using namespace rho::common;
|
|
29
29
|
using namespace rho::json;
|
30
30
|
CSyncEngine::CSourceOptions CSyncEngine::m_oSourceOptions;
|
31
31
|
|
32
|
-
CSyncEngine::CSyncEngine():
|
32
|
+
CSyncEngine::CSyncEngine(): m_syncState(esNone), m_oSyncNotify(*this)
|
33
33
|
{
|
34
34
|
m_bNoThreaded = false;
|
35
35
|
m_bStopByUser = false;
|
@@ -43,6 +43,15 @@ void CSyncEngine::initProtocol()
|
|
43
43
|
m_SyncProtocol = new CSyncProtocol_3();
|
44
44
|
}
|
45
45
|
|
46
|
+
void CSyncEngine::setSslVerifyPeer(boolean b)
|
47
|
+
{
|
48
|
+
m_NetRequest.setSslVerifyPeer(b);
|
49
|
+
m_NetRequestClientID.setSslVerifyPeer(b);
|
50
|
+
|
51
|
+
if ( CClientRegister::getInstance() != null )
|
52
|
+
CClientRegister::getInstance()->setSslVerifyPeer(b);
|
53
|
+
}
|
54
|
+
|
46
55
|
void CSyncEngine::CSourceOptions::setProperty(int nSrcID, const char* szPropName, const char* szPropValue)
|
47
56
|
{
|
48
57
|
synchronized(m_mxSrcOptions)
|
@@ -89,6 +98,7 @@ void CSyncEngine::prepareSync(ESyncState eState, const CSourceID* oSrcID)
|
|
89
98
|
m_bStopByUser = false;
|
90
99
|
m_nErrCode = RhoAppAdapter.ERR_NONE;
|
91
100
|
m_strError = "";
|
101
|
+
m_strServerError = "";
|
92
102
|
m_bIsSchemaChanged = false;
|
93
103
|
|
94
104
|
loadAllSources();
|
@@ -118,7 +128,7 @@ void CSyncEngine::prepareSync(ESyncState eState, const CSourceID* oSrcID)
|
|
118
128
|
getNotify().fireSyncNotification(src, true, src->m_nErrCode, "");
|
119
129
|
}else
|
120
130
|
{
|
121
|
-
getNotify().fireAllSyncNotifications(true, m_nErrCode, m_strError );
|
131
|
+
getNotify().fireAllSyncNotifications(true, m_nErrCode, m_strError, "" );
|
122
132
|
}
|
123
133
|
|
124
134
|
stopSync();
|
@@ -188,6 +198,7 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
|
|
188
198
|
if ( strParams.length() > 0 )
|
189
199
|
strQuery += strParams.at(0) == '&' ? strParams : "&" + strParams;
|
190
200
|
|
201
|
+
String strTestResp = "";
|
191
202
|
for ( int i = 0; i < (int)arSources.size(); i++ )
|
192
203
|
{
|
193
204
|
CSyncSource* pSrc = findSourceByName(arSources.elementAt(i));
|
@@ -197,11 +208,13 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
|
|
197
208
|
|
198
209
|
if ( !pSrc->isTokenFromDB() && pSrc->getToken() > 1 )
|
199
210
|
strQuery += "&sources[][token]=" + convertToStringA(pSrc->getToken());
|
211
|
+
|
212
|
+
strTestResp = getSourceOptions().getProperty(pSrc->getID(), "rho_server_response");
|
200
213
|
}
|
201
214
|
}
|
202
215
|
|
203
|
-
|
204
|
-
NetResponse
|
216
|
+
LOG(INFO) + "Call search on server. Url: " + (strUrl+strQuery);
|
217
|
+
NetResponse resp = getNet().pullData(strUrl+strQuery, this);
|
205
218
|
|
206
219
|
if ( !resp.isOK() )
|
207
220
|
{
|
@@ -211,7 +224,11 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
|
|
211
224
|
continue;
|
212
225
|
}
|
213
226
|
|
214
|
-
const char* szData =
|
227
|
+
const char* szData = null;
|
228
|
+
if ( strTestResp.length() > 0 )
|
229
|
+
szData = strTestResp.c_str();
|
230
|
+
else
|
231
|
+
szData = resp.getCharData();
|
215
232
|
|
216
233
|
CJSONArrayIterator oJsonArr(szData);
|
217
234
|
|
@@ -233,8 +250,7 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
|
|
233
250
|
LOG(ERROR) + "Sync server send search data with incompatible version. Client version: " + convertToStringA(getProtocol().getVersion()) +
|
234
251
|
"; Server response version: " + convertToStringA(nVersion);
|
235
252
|
stopSync();
|
236
|
-
m_nErrCode = RhoAppAdapter.
|
237
|
-
m_strError = resp.getCharData();
|
253
|
+
m_nErrCode = RhoAppAdapter.ERR_SYNCVERSION;
|
238
254
|
continue;
|
239
255
|
}
|
240
256
|
|
@@ -248,7 +264,7 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
|
|
248
264
|
LOG(ERROR) + "Sync server send search data without source name.";
|
249
265
|
stopSync();
|
250
266
|
m_nErrCode = RhoAppAdapter.ERR_UNEXPECTEDSERVERRESPONSE;
|
251
|
-
m_strError =
|
267
|
+
m_strError = szData;
|
252
268
|
continue;
|
253
269
|
}
|
254
270
|
|
@@ -259,7 +275,7 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
|
|
259
275
|
LOG(ERROR) + "Sync server send search data for unknown source name:" + strSrcName;
|
260
276
|
stopSync();
|
261
277
|
m_nErrCode = RhoAppAdapter.ERR_UNEXPECTEDSERVERRESPONSE;
|
262
|
-
m_strError =
|
278
|
+
m_strError = szData;
|
263
279
|
continue;
|
264
280
|
}
|
265
281
|
|
@@ -268,13 +284,22 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
|
|
268
284
|
pSrc->processServerResponse_ver3(oSrcArr);
|
269
285
|
|
270
286
|
nSearchCount += pSrc->getCurPageCount();
|
287
|
+
|
288
|
+
if ( pSrc->getServerError().length() > 0 )
|
289
|
+
{
|
290
|
+
if ( m_strServerError.length() > 0 )
|
291
|
+
m_strServerError += "&";
|
292
|
+
|
293
|
+
m_strServerError += pSrc->getServerError();
|
294
|
+
m_nErrCode = pSrc->getErrorCode();
|
295
|
+
}
|
271
296
|
}
|
272
297
|
|
273
298
|
if ( nSearchCount == 0 )
|
274
299
|
break;
|
275
300
|
}
|
276
301
|
|
277
|
-
getNotify().fireAllSyncNotifications(true, m_nErrCode, m_strError);
|
302
|
+
getNotify().fireAllSyncNotifications(true, m_nErrCode, m_strError, m_strServerError);
|
278
303
|
|
279
304
|
//update db info
|
280
305
|
CTimeInterval endTime = CTimeInterval::getCurrentTime();
|
@@ -350,11 +375,11 @@ CSyncSource* CSyncEngine::findSourceByName(const String& strSrcName)
|
|
350
375
|
|
351
376
|
void CSyncEngine::applyChangedValues(db::CDBAdapter& db)
|
352
377
|
{
|
353
|
-
|
378
|
+
IDBResult resSrc = db.executeSQL( "SELECT DISTINCT(source_id) FROM changed_values" );
|
354
379
|
for ( ; !resSrc.isEnd(); resSrc.next() )
|
355
380
|
{
|
356
381
|
int nSrcID = resSrc.getIntByIdx(0);
|
357
|
-
|
382
|
+
IDBResult res = db.executeSQL("SELECT source_id,sync_type,name, partition from sources WHERE source_id=?", nSrcID);
|
358
383
|
if ( res.isEnd() )
|
359
384
|
continue;
|
360
385
|
|
@@ -370,7 +395,7 @@ void CSyncEngine::loadAllSources()
|
|
370
395
|
RhoAppAdapter.loadAllSyncSources();
|
371
396
|
else
|
372
397
|
{
|
373
|
-
NetResponse
|
398
|
+
NetResponse resp = getNet().pushData( getNet().resolveUrl("/system/loadallsyncsources"), "", null );
|
374
399
|
}
|
375
400
|
|
376
401
|
m_sources.removeAllElements();
|
@@ -380,7 +405,7 @@ void CSyncEngine::loadAllSources()
|
|
380
405
|
for( int i = 0; i < (int)arPartNames.size(); i++ )
|
381
406
|
{
|
382
407
|
db::CDBAdapter& dbPart = db::CDBAdapter::getDB(arPartNames.elementAt(i).c_str());
|
383
|
-
|
408
|
+
IDBResult res = dbPart.executeSQL("SELECT source_id,sync_type,name from sources ORDER BY sync_priority");
|
384
409
|
for ( ; !res.isEnd(); res.next() )
|
385
410
|
{
|
386
411
|
String strShouldSync = res.getStringByIdx(1);
|
@@ -442,7 +467,7 @@ String CSyncEngine::readClientID()
|
|
442
467
|
String clientID = "";
|
443
468
|
synchronized(m_mxLoadClientID)
|
444
469
|
{
|
445
|
-
|
470
|
+
IDBResult res = getUserDB().executeSQL("SELECT client_id,reset from client_info limit 1");
|
446
471
|
if ( !res.isEnd() )
|
447
472
|
clientID = res.getStringByIdx(0);
|
448
473
|
}
|
@@ -457,7 +482,7 @@ String CSyncEngine::loadClientID()
|
|
457
482
|
{
|
458
483
|
boolean bResetClient = false;
|
459
484
|
{
|
460
|
-
|
485
|
+
IDBResult res = getUserDB().executeSQL("SELECT client_id,reset from client_info limit 1");
|
461
486
|
if ( !res.isEnd() )
|
462
487
|
{
|
463
488
|
clientID = res.getStringByIdx(0);
|
@@ -469,7 +494,7 @@ String CSyncEngine::loadClientID()
|
|
469
494
|
{
|
470
495
|
clientID = requestClientIDByNet();
|
471
496
|
|
472
|
-
|
497
|
+
IDBResult res = getUserDB().executeSQL("SELECT * FROM client_info");
|
473
498
|
if ( !res.isEnd() )
|
474
499
|
getUserDB().executeSQL("UPDATE client_info SET client_id=?", clientID);
|
475
500
|
else
|
@@ -498,7 +523,7 @@ void CSyncEngine::processServerSources(String strSources)
|
|
498
523
|
RhoAppAdapter.loadServerSources(strSources);
|
499
524
|
else
|
500
525
|
{
|
501
|
-
NetResponse
|
526
|
+
NetResponse resp = getNet().pushData( getNet().resolveUrl("/system/loadserversources"), strSources, null );
|
502
527
|
}
|
503
528
|
|
504
529
|
loadAllSources();
|
@@ -514,7 +539,7 @@ boolean CSyncEngine::resetClientIDByNet(const String& strClientID)//throws Excep
|
|
514
539
|
//if ( CClientRegister::getInstance() != null )
|
515
540
|
// strBody += CClientRegister::getInstance()->getRegisterBody();
|
516
541
|
|
517
|
-
NetResponse
|
542
|
+
NetResponse resp = getNetClientID().pullData(getProtocol().getClientResetUrl(strClientID), this);
|
518
543
|
|
519
544
|
|
520
545
|
/* processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"sync_priority\":\"0\","
|
@@ -552,7 +577,7 @@ String CSyncEngine::requestClientIDByNet()
|
|
552
577
|
//if ( CClientRegister::getInstance() != null )
|
553
578
|
// strBody += CClientRegister::getInstance()->getRegisterBody();
|
554
579
|
|
555
|
-
NetResponse(
|
580
|
+
NetResponse resp = getNetClientID().pullData(getProtocol().getClientCreateUrl(), this);
|
556
581
|
if ( resp.isOK() && resp.getCharData() != null )
|
557
582
|
{
|
558
583
|
const char* szData = resp.getCharData();
|
@@ -631,7 +656,7 @@ void CSyncEngine::loadBulkPartition(const String& strPartition )
|
|
631
656
|
|
632
657
|
while(strCmd.length() == 0&&isContinueSync())
|
633
658
|
{
|
634
|
-
NetResponse
|
659
|
+
NetResponse resp = getNet().pullData(strUrl+strQuery, this);
|
635
660
|
const char* szData = resp.getCharData();
|
636
661
|
if ( !resp.isOK() || szData == null || *szData == 0)
|
637
662
|
{
|
@@ -677,7 +702,7 @@ void CSyncEngine::loadBulkPartition(const String& strPartition )
|
|
677
702
|
String strSqlDataUrl = CFilePath::join(getHostFromUrl(serverUrl), strDataUrl) +strZip;
|
678
703
|
LOG(INFO) + "Bulk sync: download data from server: " + strSqlDataUrl;
|
679
704
|
{
|
680
|
-
NetResponse
|
705
|
+
NetResponse resp1 = getNet().pullFile(strSqlDataUrl, fDataName+strZip, this, null);
|
681
706
|
if ( !resp1.isOK() )
|
682
707
|
{
|
683
708
|
LOG(ERROR) + "Bulk sync failed: cannot download database file.";
|
@@ -795,7 +820,7 @@ void CSyncEngine::login(String name, String password, const CSyncNotification& o
|
|
795
820
|
m_bStopByUser = false;
|
796
821
|
//try {
|
797
822
|
|
798
|
-
NetResponse
|
823
|
+
NetResponse resp = getNet().pullCookies( getProtocol().getLoginUrl(), getProtocol().getLoginBody(name, password), this );
|
799
824
|
int nErrCode = RhoAppAdapter.getErrorFromResponse(resp);
|
800
825
|
if ( nErrCode != RhoAppAdapter.ERR_NONE )
|
801
826
|
{
|
@@ -818,7 +843,7 @@ void CSyncEngine::login(String name, String password, const CSyncNotification& o
|
|
818
843
|
}
|
819
844
|
|
820
845
|
{
|
821
|
-
|
846
|
+
IDBResult res = getUserDB().executeSQL("SELECT * FROM client_info");
|
822
847
|
if ( !res.isEnd() )
|
823
848
|
getUserDB().executeSQL( "UPDATE client_info SET session=?", strSession );
|
824
849
|
else
|
@@ -834,7 +859,7 @@ void CSyncEngine::login(String name, String password, const CSyncNotification& o
|
|
834
859
|
RhoAppAdapter.resetDBOnSyncUserChanged();
|
835
860
|
else
|
836
861
|
{
|
837
|
-
NetResponse
|
862
|
+
NetResponse resp = getNet().pushData( getNet().resolveUrl("/system/resetDBOnSyncUserChanged"), "", null );
|
838
863
|
}
|
839
864
|
}
|
840
865
|
}
|
@@ -857,8 +882,8 @@ void CSyncEngine::login(String name, String password, const CSyncNotification& o
|
|
857
882
|
boolean CSyncEngine::isLoggedIn()
|
858
883
|
{
|
859
884
|
String strRes = "";
|
860
|
-
|
861
|
-
if ( !res.
|
885
|
+
IDBResult res = getUserDB().executeSQL("SELECT session FROM client_info");
|
886
|
+
if ( !res.isOneEnd() )
|
862
887
|
strRes = res.getStringByIdx(0);
|
863
888
|
|
864
889
|
return strRes.length() > 0;
|
@@ -867,7 +892,7 @@ boolean CSyncEngine::isLoggedIn()
|
|
867
892
|
String CSyncEngine::loadSession()
|
868
893
|
{
|
869
894
|
m_strSession = "";
|
870
|
-
|
895
|
+
IDBResult res = getUserDB().executeSQL("SELECT session FROM client_info");
|
871
896
|
|
872
897
|
if ( !res.isEnd() )
|
873
898
|
m_strSession = res.getStringByIdx(0);
|
@@ -877,8 +902,7 @@ String CSyncEngine::loadSession()
|
|
877
902
|
|
878
903
|
void CSyncEngine::logout()
|
879
904
|
{
|
880
|
-
|
881
|
-
m_NetRequest->cancel();
|
905
|
+
m_NetRequest.cancel();
|
882
906
|
|
883
907
|
getUserDB().executeSQL( "UPDATE client_info SET session=NULL" );
|
884
908
|
m_strSession = "";
|
@@ -44,7 +44,7 @@ public:
|
|
44
44
|
|
45
45
|
private:
|
46
46
|
VectorPtr<CSyncSource*> m_sources;
|
47
|
-
|
47
|
+
NetRequest m_NetRequest, m_NetRequestClientID;
|
48
48
|
common::CAutoPtr<ISyncProtocol> m_SyncProtocol;
|
49
49
|
ESyncState m_syncState;
|
50
50
|
String m_clientID;
|
@@ -55,21 +55,18 @@ private:
|
|
55
55
|
int m_nSyncPageSize;
|
56
56
|
boolean m_bNoThreaded;
|
57
57
|
int m_nErrCode;
|
58
|
-
String m_strError;
|
58
|
+
String m_strError, m_strServerError;
|
59
59
|
boolean m_bIsSearch, m_bIsSchemaChanged;
|
60
60
|
static CSourceOptions m_oSourceOptions;
|
61
61
|
|
62
|
+
net::CNetRequestWrapper getNetClientID(){ return getNetRequest(&m_NetRequestClientID); }
|
63
|
+
|
62
64
|
public:
|
63
65
|
CSyncEngine();
|
64
66
|
~CSyncEngine(void){}
|
65
67
|
|
66
|
-
void setFactory(common::IRhoClassFactory* factory){
|
67
|
-
m_NetRequest = factory->createNetRequest();
|
68
|
-
//clientID may be requested by ClientRegister thread
|
69
|
-
m_NetRequestClientID = factory->createNetRequest();
|
70
|
-
m_oSyncNotify.setFactory(factory);
|
71
|
-
}
|
72
68
|
static CSourceOptions& getSourceOptions(){ return m_oSourceOptions; }
|
69
|
+
net::CNetRequestWrapper getNet(){ return getNetRequest(&m_NetRequest); }
|
73
70
|
|
74
71
|
void doSyncAllSources();
|
75
72
|
void doSyncSource(const CSourceID& oSrcID);
|
@@ -86,10 +83,12 @@ public:
|
|
86
83
|
boolean isSearch()const{ return m_bIsSearch; }
|
87
84
|
boolean isContinueSync()const{ return m_syncState != esExit && m_syncState != esStop; }
|
88
85
|
boolean isSyncing()const{ return m_syncState == esSyncAllSources || m_syncState == esSyncSource; }
|
89
|
-
void stopSync(){ if (isContinueSync()){ setState(esStop);
|
86
|
+
void stopSync(){ if (isContinueSync()){ setState(esStop); m_NetRequest.cancel();m_NetRequestClientID.cancel();} }
|
90
87
|
void stopSyncByUser(){ m_bStopByUser = true; stopSync(); }
|
91
|
-
void exitSync(){ setState(esExit); m_NetRequest
|
88
|
+
void exitSync(){ setState(esExit); m_NetRequest.cancel(); m_NetRequestClientID.cancel();}
|
92
89
|
boolean isStoppedByUser(){ return m_bStopByUser; }
|
90
|
+
void setSslVerifyPeer(boolean b);
|
91
|
+
|
93
92
|
//private:
|
94
93
|
String getClientID()const{ return m_clientID; }
|
95
94
|
void setSession(String strSession){m_strSession=strSession;}
|
@@ -113,7 +112,6 @@ public:
|
|
113
112
|
void doBulkSync();//throws Exception
|
114
113
|
|
115
114
|
CSyncNotify& getNotify(){ return m_oSyncNotify; }
|
116
|
-
net::INetRequest& getNet(){ return *m_NetRequest; }
|
117
115
|
ISyncProtocol& getProtocol(){ return *m_SyncProtocol; }
|
118
116
|
|
119
117
|
CSyncSource* findSourceByName(const String& strSrcName);
|
@@ -101,7 +101,7 @@ void CSyncNotify::fireObjectsNotification()
|
|
101
101
|
if ( nNotifyType == enDelete )
|
102
102
|
{
|
103
103
|
//TODO: get db for source
|
104
|
-
|
104
|
+
IDBResult res = getDB().executeSQL("SELECT object FROM object_values where object=? LIMIT 1 OFFSET 0", itObject->first );
|
105
105
|
if ( !res.isEnd() )
|
106
106
|
nNotifyType = enUpdate;
|
107
107
|
}
|
@@ -217,7 +217,7 @@ void CSyncNotify::onSyncSourceEnd( int nSrc, VectorPtr<CSyncSource*>& sources )
|
|
217
217
|
if ( pSN != null )
|
218
218
|
fireSyncNotification(&src, true, src.m_nErrCode, "");
|
219
219
|
else
|
220
|
-
fireAllSyncNotifications(true, src.m_nErrCode, src.m_strError );
|
220
|
+
fireAllSyncNotifications(true, src.m_nErrCode, src.m_strError, "" );
|
221
221
|
}
|
222
222
|
else
|
223
223
|
fireSyncNotification(&src, true, src.m_nErrCode, "");
|
@@ -329,10 +329,10 @@ void CSyncNotify::fireBulkSyncNotification( boolean bFinish, String status, Stri
|
|
329
329
|
strParams += "&bulk_status="+status;
|
330
330
|
strParams += "&sync_type=bulk";
|
331
331
|
|
332
|
-
doFireSyncNotification( null, bFinish, nErrCode, "", strParams );
|
332
|
+
doFireSyncNotification( null, bFinish, nErrCode, "", strParams, "" );
|
333
333
|
}
|
334
334
|
|
335
|
-
void CSyncNotify::fireAllSyncNotifications( boolean bFinish, int nErrCode, String strError )
|
335
|
+
void CSyncNotify::fireAllSyncNotifications( boolean bFinish, int nErrCode, String strError, String strServerError )
|
336
336
|
{
|
337
337
|
if ( getSync().getState() == CSyncEngine::esExit )
|
338
338
|
return;
|
@@ -341,7 +341,7 @@ void CSyncNotify::fireAllSyncNotifications( boolean bFinish, int nErrCode, Strin
|
|
341
341
|
{
|
342
342
|
CSyncNotification* pSN = getSyncNotifyBySrc(null);
|
343
343
|
if ( pSN != null )
|
344
|
-
doFireSyncNotification( null, bFinish, nErrCode, strError, "" );
|
344
|
+
doFireSyncNotification( null, bFinish, nErrCode, strError, "", strServerError );
|
345
345
|
}
|
346
346
|
}
|
347
347
|
|
@@ -361,7 +361,7 @@ void CSyncNotify::fireSyncNotification( CSyncSource* src, boolean bFinish, int n
|
|
361
361
|
}
|
362
362
|
}
|
363
363
|
|
364
|
-
doFireSyncNotification(src, bFinish, nErrCode, "", "" );
|
364
|
+
doFireSyncNotification(src, bFinish, nErrCode, "", "", "" );
|
365
365
|
}
|
366
366
|
|
367
367
|
CSyncNotification* CSyncNotify::getSyncNotifyBySrc(CSyncSource* src)
|
@@ -384,7 +384,7 @@ CSyncNotification* CSyncNotify::getSyncNotifyBySrc(CSyncSource* src)
|
|
384
384
|
return pSN != null ? pSN : &m_emptyNotify;
|
385
385
|
}
|
386
386
|
|
387
|
-
void CSyncNotify::doFireSyncNotification( CSyncSource* src, boolean bFinish, int nErrCode, String strError, String strParams)
|
387
|
+
void CSyncNotify::doFireSyncNotification( CSyncSource* src, boolean bFinish, int nErrCode, String strError, String strParams, String strServerError)
|
388
388
|
{
|
389
389
|
if ( getSync().isStoppedByUser() )
|
390
390
|
return;
|
@@ -432,13 +432,17 @@ void CSyncNotify::doFireSyncNotification( CSyncSource* src, boolean bFinish, int
|
|
432
432
|
|
433
433
|
strBody += "error";
|
434
434
|
strBody += "&error_code=" + convertToStringA(nErrCode);
|
435
|
-
strBody += "&error_type=" + (src != null ? (*src).m_strErrorType : String());
|
436
435
|
strBody += "&error_message=";
|
437
436
|
|
438
437
|
if ( strError.length() > 0 )
|
439
438
|
URI::urlEncode(strError,strBody);
|
440
439
|
else if ( src != null )
|
441
440
|
URI::urlEncode( (*src).m_strError,strBody);
|
441
|
+
|
442
|
+
if ( strServerError.length() > 0 )
|
443
|
+
strBody += "&" + strServerError;
|
444
|
+
else if ( src != null && (*src).m_strServerError.length() > 0 )
|
445
|
+
strBody += "&" + (*src).m_strServerError;
|
442
446
|
}
|
443
447
|
|
444
448
|
if ( src != null )
|
@@ -449,7 +453,12 @@ void CSyncNotify::doFireSyncNotification( CSyncSource* src, boolean bFinish, int
|
|
449
453
|
|
450
454
|
strBody += "&rho_callback=1";
|
451
455
|
if ( pSN->m_strParams.length() > 0 )
|
452
|
-
|
456
|
+
{
|
457
|
+
if ( !String_startsWith( pSN->m_strParams, "&" ) )
|
458
|
+
strBody += "&";
|
459
|
+
|
460
|
+
strBody += pSN->m_strParams;
|
461
|
+
}
|
453
462
|
|
454
463
|
bRemoveAfterFire = bRemoveAfterFire && pSN->m_bRemoveAfterFire;
|
455
464
|
}
|
@@ -476,7 +485,7 @@ boolean CSyncNotify::callNotify(const CSyncNotification& oNotify, const String&
|
|
476
485
|
if ( strUrl.length() == 0 )
|
477
486
|
return true;
|
478
487
|
|
479
|
-
NetResponse
|
488
|
+
NetResponse resp = getNet().pushData( strUrl, strBody, null );
|
480
489
|
if ( !resp.isOK() )
|
481
490
|
LOG(ERROR) + "Fire notification failed. Code: " + resp.getRespCode() + "; Error body: " + resp.getCharData();
|
482
491
|
else
|
@@ -548,11 +557,7 @@ int CSyncNotify::getLastSyncObjectCount(int nSrcID)
|
|
548
557
|
void CSyncNotify::callLoginCallback(const CSyncNotification& oNotify, int nErrCode, String strMessage)
|
549
558
|
{
|
550
559
|
if ( getSync().isStoppedByUser() )
|
551
|
-
{
|
552
|
-
LOG(INFO) + "Login was stopped by application.";
|
553
|
-
|
554
560
|
return;
|
555
|
-
}
|
556
561
|
|
557
562
|
//try{
|
558
563
|
String strBody = "error_code=" + convertToStringA(nErrCode);
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#include "logging/RhoLog.h"
|
5
5
|
#include "common/AutoPointer.h"
|
6
6
|
#include "common/IRhoClassFactory.h"
|
7
|
+
#include "net/INetRequest.h"
|
7
8
|
|
8
9
|
typedef int (*RHOC_CALLBACK)(const char* szNotify, void* callback_data);
|
9
10
|
|
@@ -12,10 +13,6 @@ namespace db {
|
|
12
13
|
class CDBAdapter;
|
13
14
|
}
|
14
15
|
|
15
|
-
namespace net {
|
16
|
-
struct INetRequest;
|
17
|
-
}
|
18
|
-
|
19
16
|
namespace sync {
|
20
17
|
class CSyncEngine;
|
21
18
|
class CSyncSource;
|
@@ -67,18 +64,14 @@ private:
|
|
67
64
|
String m_strNotifyBody;
|
68
65
|
String m_strStatusHide;
|
69
66
|
|
70
|
-
|
67
|
+
NetRequest m_NetRequest;
|
71
68
|
|
72
|
-
net::
|
69
|
+
net::CNetRequestWrapper getNet(){ return getNetRequest(&m_NetRequest); }
|
73
70
|
CSyncEngine& getSync(){ return m_syncEngine; }
|
74
71
|
public:
|
75
72
|
CSyncNotify( CSyncEngine& syncEngine ) : m_syncEngine(syncEngine), m_bEnableReporting(false),
|
76
73
|
m_bEnableReportingGlobal(false){}
|
77
74
|
|
78
|
-
void setFactory(common::IRhoClassFactory* factory){
|
79
|
-
m_NetRequest = factory->createNetRequest();
|
80
|
-
}
|
81
|
-
|
82
75
|
//Object notifications
|
83
76
|
void fireObjectsNotification();
|
84
77
|
void onObjectChanged(int nSrcID, const String& strObject, int nType);
|
@@ -115,7 +108,7 @@ public:
|
|
115
108
|
const String& getNotifyBody(){ return m_strNotifyBody; }
|
116
109
|
void cleanNotifyBody(){ m_strNotifyBody = ""; }
|
117
110
|
|
118
|
-
void fireAllSyncNotifications( boolean bFinish, int nErrCode, String strError );
|
111
|
+
void fireAllSyncNotifications( boolean bFinish, int nErrCode, String strError, String strServerError );
|
119
112
|
void reportSyncStatus(String status, int error, String strDetails);
|
120
113
|
void showStatusPopup(const String& status);
|
121
114
|
private:
|
@@ -124,7 +117,7 @@ private:
|
|
124
117
|
String makeCreateObjectErrorBody(int nSrcID);
|
125
118
|
void processSingleObject();
|
126
119
|
|
127
|
-
void doFireSyncNotification( CSyncSource* src, boolean bFinish, int nErrCode, String strError, String strParams);
|
120
|
+
void doFireSyncNotification( CSyncSource* src, boolean bFinish, int nErrCode, String strError, String strParams, String strServerError);
|
128
121
|
|
129
122
|
boolean callNotify(const CSyncNotification& oNotify, const String& strBody );
|
130
123
|
|