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
@@ -18,7 +18,7 @@ public class DBAdapter extends RubyBasic
|
|
18
18
|
|
19
19
|
private IDBStorage m_dbStorage;
|
20
20
|
private boolean m_bIsOpen = false;
|
21
|
-
private String m_strDBPath,
|
21
|
+
private String m_strDBPath, m_strDbVerPath;
|
22
22
|
private String m_strDbPartition;
|
23
23
|
private DBAttrManager m_attrMgr = new DBAttrManager();
|
24
24
|
static Hashtable/*Ptr<String,CDBAdapter*>*/ m_mapDBPartitions = new Hashtable();
|
@@ -259,7 +259,7 @@ public class DBAdapter extends RubyBasic
|
|
259
259
|
|
260
260
|
String strPath = RhoClassFactory.createFile().getDirPath(strDBDir);
|
261
261
|
m_strDBPath = strPath + strDBName.substring(nSlash+1);
|
262
|
-
|
262
|
+
m_strDbVerPath = strPath + getNameNoExt(strDBName.substring(nSlash+1)) + ".version";
|
263
263
|
}
|
264
264
|
|
265
265
|
private String getSqlScript()
|
@@ -306,88 +306,80 @@ public class DBAdapter extends RubyBasic
|
|
306
306
|
{
|
307
307
|
String m_strRhoVer = "";
|
308
308
|
String m_strAppVer = "";
|
309
|
+
boolean m_bEncrypted = false;
|
310
|
+
boolean m_bSqlite = false;
|
309
311
|
|
310
|
-
DBVersion
|
311
|
-
|
312
|
-
DBVersion( String strRhoVer, String strAppVer )
|
312
|
+
boolean isRhoVerChanged(DBVersion dbNewVer)
|
313
313
|
{
|
314
|
-
m_strRhoVer
|
315
|
-
m_strAppVer = strAppVer;
|
314
|
+
return m_strRhoVer.compareTo(dbNewVer.m_strRhoVer) != 0;
|
316
315
|
}
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
{
|
321
|
-
throw new net.rim.device.api.io.file.FileIOException(net.rim.device.api.io.file.FileIOException.FILESYSTEM_FULL);
|
322
|
-
}*/
|
323
|
-
DBVersion readDBVersion()throws Exception
|
324
|
-
{
|
325
|
-
String strFullVer = "";
|
326
|
-
IRAFile file = null;
|
327
|
-
try {
|
328
|
-
file = RhoClassFactory.createRAFile();
|
329
|
-
try{
|
330
|
-
file.open(m_strDBVerPath);
|
331
|
-
}catch(j2me.io.FileNotFoundException exc)
|
332
|
-
{
|
333
|
-
//file not exist
|
334
|
-
return new DBVersion();
|
335
|
-
}
|
336
|
-
|
337
|
-
byte buf[] = new byte[20];
|
338
|
-
// testError();
|
339
|
-
int len = file.read(buf, 0, buf.length);
|
340
|
-
if ( len > 0 )
|
341
|
-
strFullVer = new String(buf,0,len);
|
342
|
-
|
343
|
-
if ( strFullVer.length() == 0 )
|
344
|
-
return new DBVersion();
|
345
|
-
|
346
|
-
int nSep = strFullVer.indexOf(';');
|
347
|
-
if ( nSep == -1 )
|
348
|
-
return new DBVersion(strFullVer, "");
|
349
|
-
|
350
|
-
return new DBVersion(strFullVer.substring(0,nSep), strFullVer.substring(nSep+1) );
|
316
|
+
boolean isAppVerChanged(DBVersion dbNewVer)
|
317
|
+
{
|
318
|
+
return m_strAppVer.compareTo(dbNewVer.m_strAppVer) != 0;
|
351
319
|
}
|
352
|
-
|
353
|
-
|
354
|
-
throw e;
|
355
|
-
}finally
|
320
|
+
|
321
|
+
boolean isDbFormatChanged(DBVersion dbNewVer)
|
356
322
|
{
|
357
|
-
|
358
|
-
|
323
|
+
return m_bEncrypted != dbNewVer.m_bEncrypted ||
|
324
|
+
m_bSqlite != dbNewVer.m_bSqlite;
|
359
325
|
}
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
326
|
+
|
327
|
+
void fromFile(String strFilePath)throws Exception
|
328
|
+
{
|
329
|
+
String strData = RhoFile.readStringFromFile(strFilePath);
|
330
|
+
|
331
|
+
Tokenizer oTokenizer = new Tokenizer( strData, ";" );
|
332
|
+
int nPos = 0;
|
333
|
+
while (oTokenizer.hasMoreTokens())
|
334
|
+
{
|
335
|
+
String tok = oTokenizer.nextToken();
|
336
|
+
tok.trim();
|
337
|
+
|
338
|
+
switch(nPos)
|
339
|
+
{
|
340
|
+
case 0:
|
341
|
+
m_strRhoVer = tok;
|
342
|
+
break;
|
343
|
+
case 1:
|
344
|
+
m_strAppVer = tok;
|
345
|
+
break;
|
346
|
+
case 2:
|
347
|
+
m_bEncrypted = tok.compareTo("encrypted") == 0;
|
348
|
+
break;
|
349
|
+
case 3:
|
350
|
+
m_bSqlite = tok.compareTo("sqlite") == 0;
|
351
|
+
break;
|
352
|
+
}
|
353
|
+
nPos++;
|
354
|
+
}
|
355
|
+
}
|
356
|
+
|
357
|
+
void toFile(String strFilePath)throws Exception
|
358
|
+
{
|
359
|
+
String strFullVer = m_strRhoVer + ";" + m_strAppVer +
|
360
|
+
";" + (m_bEncrypted ? "encrypted":"") +
|
361
|
+
";" + (m_bSqlite ? "sqlite" : "");
|
362
|
+
|
363
|
+
try{
|
364
|
+
RhoClassFactory.createFile().delete(strFilePath);
|
365
|
+
RhoFile.writeStringToFile(strFilePath, strFullVer);
|
366
|
+
}catch (Exception e) {
|
367
|
+
LOG.ERROR("writeDBVersion failed.", e);
|
368
|
+
throw e;
|
369
|
+
}
|
370
|
+
}
|
371
|
+
};
|
380
372
|
|
381
|
-
boolean migrateDB(DBVersion dbVer,
|
373
|
+
boolean migrateDB(DBVersion dbVer, DBVersion dbNewVer )
|
382
374
|
{
|
383
|
-
LOG.INFO( "Try migrate database from " + (dbVer != null ? dbVer.m_strRhoVer:"") + " to " + (
|
384
|
-
if ( dbVer != null &&
|
385
|
-
(dbVer.m_strRhoVer.startsWith("1.4")||dbVer.m_strRhoVer.startsWith("1.4")) && (
|
375
|
+
LOG.INFO( "Try migrate database from " + (dbVer != null ? dbVer.m_strRhoVer:"") + " to " + (dbNewVer.m_strRhoVer !=null ? dbNewVer.m_strRhoVer:"") );
|
376
|
+
if ( dbVer != null && dbNewVer.m_strRhoVer != null &&
|
377
|
+
(dbVer.m_strRhoVer.startsWith("1.4")||dbVer.m_strRhoVer.startsWith("1.4")) && (dbNewVer.m_strRhoVer.startsWith("1.5")||dbNewVer.m_strRhoVer.startsWith("1.4")) )
|
386
378
|
{
|
387
|
-
LOG.INFO( "No migration required from " + (dbVer != null ? dbVer.m_strRhoVer:"") + " to " + (
|
379
|
+
LOG.INFO( "No migration required from " + (dbVer != null ? dbVer.m_strRhoVer:"") + " to " + (dbNewVer.m_strRhoVer !=null ? dbNewVer.m_strRhoVer:"") );
|
388
380
|
|
389
381
|
try{
|
390
|
-
|
382
|
+
dbNewVer.toFile(m_strDbVerPath);
|
391
383
|
}catch(Exception e)
|
392
384
|
{
|
393
385
|
LOG.ERROR("migrateDB failed.", e);
|
@@ -398,18 +390,18 @@ public class DBAdapter extends RubyBasic
|
|
398
390
|
}
|
399
391
|
|
400
392
|
//1.2.x -> 1.5.x,1.4.x
|
401
|
-
if ( dbVer != null &&
|
402
|
-
(dbVer.m_strRhoVer.startsWith("1.2")||dbVer.m_strRhoVer.startsWith("1.4")) && (
|
393
|
+
if ( dbVer != null && dbNewVer.m_strRhoVer != null &&
|
394
|
+
(dbVer.m_strRhoVer.startsWith("1.2")||dbVer.m_strRhoVer.startsWith("1.4")) && (dbNewVer.m_strRhoVer.startsWith("1.5")||dbNewVer.m_strRhoVer.startsWith("1.4")) )
|
403
395
|
{
|
404
396
|
//sources
|
405
397
|
//priority INTEGER, ADD
|
406
398
|
//backend_refresh_time int default 0, ADD
|
407
|
-
LOG.INFO("Migrate database from " + dbVer.m_strRhoVer + " to " +
|
399
|
+
LOG.INFO("Migrate database from " + dbVer.m_strRhoVer + " to " + dbNewVer.m_strRhoVer);
|
408
400
|
|
409
401
|
IDBStorage db = null;
|
410
402
|
try{
|
411
403
|
db = RhoClassFactory.createDBStorage();
|
412
|
-
db.open( m_strDBPath, getSqlScript() );
|
404
|
+
db.open( m_strDBPath, getSqlScript(), getEncryptionInfo() );
|
413
405
|
|
414
406
|
db.executeSQL( "ALTER TABLE sources ADD priority INTEGER", null, false);
|
415
407
|
db.executeSQL( "ALTER TABLE sources ADD backend_refresh_time int default 0", null, false);
|
@@ -429,7 +421,7 @@ public class DBAdapter extends RubyBasic
|
|
429
421
|
db.close();
|
430
422
|
db = null;
|
431
423
|
|
432
|
-
|
424
|
+
dbNewVer.toFile(m_strDbVerPath);
|
433
425
|
|
434
426
|
return true;
|
435
427
|
}catch(Exception e)
|
@@ -451,85 +443,100 @@ public class DBAdapter extends RubyBasic
|
|
451
443
|
return false;
|
452
444
|
}
|
453
445
|
|
454
|
-
|
446
|
+
String getEncryptionInfo()
|
455
447
|
{
|
456
|
-
|
457
|
-
|
448
|
+
boolean bEncrypted = AppBuildConfig.getItem("encrypt_database") != null &&
|
449
|
+
AppBuildConfig.getItem("encrypt_database").compareTo("1") == 0;
|
458
450
|
|
459
|
-
|
460
|
-
|
461
|
-
boolean bRhoReset = false;
|
462
|
-
boolean bAppReset = false;
|
451
|
+
String strRes = "";
|
463
452
|
|
464
|
-
if (
|
453
|
+
if (bEncrypted)
|
454
|
+
{
|
455
|
+
String strAppName = "rhodes";
|
456
|
+
try{
|
457
|
+
strAppName = RhoClassFactory.createRhoRubyHelper().getModuleName();
|
458
|
+
}catch(Exception e){}
|
459
|
+
|
460
|
+
strRes = m_strDbPartition + "_" + strAppName;
|
461
|
+
}
|
462
|
+
return strRes;
|
463
|
+
}
|
464
|
+
|
465
|
+
void checkDBVersion()throws Exception
|
466
|
+
{
|
467
|
+
DBVersion dbNewVer = new DBVersion();
|
468
|
+
dbNewVer.m_strRhoVer = RhoSupport.getRhoDBVersion();
|
469
|
+
dbNewVer.m_strAppVer = RhoConf.getInstance().getString("app_db_version");
|
470
|
+
String strEncryptionInfo = getEncryptionInfo();
|
471
|
+
dbNewVer.m_bEncrypted = strEncryptionInfo != null && strEncryptionInfo.length() > 0;
|
472
|
+
dbNewVer.m_bSqlite = Capabilities.USE_SQLITE;
|
473
|
+
|
474
|
+
DBVersion dbVer = new DBVersion();
|
475
|
+
dbVer.fromFile(m_strDbVerPath);
|
476
|
+
|
477
|
+
if (dbVer.m_strRhoVer.length() == 0 )
|
465
478
|
{
|
466
|
-
|
467
|
-
|
479
|
+
dbNewVer.toFile(m_strDbVerPath);
|
480
|
+
return;
|
468
481
|
}
|
469
|
-
|
482
|
+
|
483
|
+
boolean bRhoReset = dbVer.isRhoVerChanged(dbNewVer);
|
484
|
+
boolean bAppReset = dbVer.isAppVerChanged(dbNewVer);
|
485
|
+
|
486
|
+
boolean bDbFormatChanged = dbVer.isDbFormatChanged(dbNewVer);
|
487
|
+
if ( !bDbFormatChanged && dbVer.m_bEncrypted )
|
470
488
|
{
|
471
|
-
if (
|
472
|
-
|
489
|
+
if (!com.rho.RhoCrypto.isKeyExist(strEncryptionInfo) )
|
490
|
+
bDbFormatChanged = true;
|
473
491
|
}
|
474
492
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
String dbName = getNameNoExt(m_strDBPath);
|
481
|
-
String dbNameScript = dbName + ".script";
|
482
|
-
String dbNameData = dbName + ".data";
|
483
|
-
String dbNameJournal = dbName + ".journal";
|
484
|
-
String dbNameProperties = dbName + ".properties";
|
485
|
-
|
486
|
-
if ( fs.exists(dbNameScript) )
|
487
|
-
{
|
488
|
-
LOG.INFO("Remove hsqldb and use sqlite for Blackberry>=5.");
|
489
|
-
|
490
|
-
fs.delete(dbNameScript);
|
491
|
-
fs.delete(dbNameData);
|
492
|
-
fs.delete(dbNameJournal);
|
493
|
-
fs.delete(dbNameProperties);
|
494
|
-
bRhoReset = true;
|
495
|
-
}
|
496
|
-
}
|
493
|
+
if ( bDbFormatChanged )
|
494
|
+
LOG.INFO("Reset Database( format changed ):" + m_strDBPath);
|
495
|
+
|
496
|
+
if ( bRhoReset && !bAppReset && !bDbFormatChanged )
|
497
|
+
bRhoReset = !migrateDB(dbVer, dbNewVer);
|
497
498
|
|
498
|
-
if ( bRhoReset || bAppReset )
|
499
|
+
if ( bRhoReset || bAppReset || bDbFormatChanged)
|
499
500
|
{
|
500
|
-
|
501
|
-
try
|
501
|
+
if ( !bDbFormatChanged )
|
502
502
|
{
|
503
|
-
|
504
|
-
|
503
|
+
IDBStorage db = null;
|
504
|
+
try
|
505
505
|
{
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
506
|
+
db = RhoClassFactory.createDBStorage();
|
507
|
+
if ( db.isDbFileExists(m_strDBPath) )
|
508
|
+
{
|
509
|
+
db.open( m_strDBPath, "", strEncryptionInfo );
|
510
|
+
IDBResult res = db.executeSQL("SELECT * FROM client_info", null, false);
|
511
|
+
if ( !res.isOneEnd() )
|
512
|
+
{
|
513
|
+
m_strClientInfoInsert = createInsertStatement(res, "client_info");
|
514
|
+
m_dataClientInfo = res.getCurData();
|
515
|
+
}
|
516
|
+
}
|
517
|
+
}catch(Exception exc)
|
518
|
+
{
|
519
|
+
LOG.ERROR("Copy client_info table failed.", exc);
|
520
|
+
}catch(Throwable e)
|
521
|
+
{
|
522
|
+
LOG.ERROR("Copy client_info table crashed.", e);
|
523
|
+
}finally
|
524
|
+
{
|
525
|
+
if (db != null )
|
526
|
+
try{ db.close(); }catch(Exception e){}
|
513
527
|
}
|
514
|
-
}catch(Exception exc)
|
515
|
-
{
|
516
|
-
LOG.ERROR("Copy client_info table failed.", exc);
|
517
|
-
}catch(Throwable e)
|
518
|
-
{
|
519
|
-
LOG.ERROR("Copy client_info table crashed.", e);
|
520
|
-
}finally
|
521
|
-
{
|
522
|
-
if (db != null )
|
523
|
-
try{ db.close(); }catch(Exception e){}
|
524
528
|
}
|
525
|
-
|
529
|
+
|
526
530
|
m_dbStorage.deleteAllFiles(m_strDBPath);
|
527
531
|
|
528
|
-
|
529
|
-
|
530
|
-
|
532
|
+
if ( this.m_strDbPartition.compareTo("user") == 0 ) //do it only once
|
533
|
+
{
|
534
|
+
String fName = makeBlobFolderName();
|
535
|
+
RhoClassFactory.createFile().delete(fName);
|
536
|
+
DBAdapter.makeBlobFolderName(); //Create folder back
|
537
|
+
}
|
531
538
|
|
532
|
-
|
539
|
+
dbNewVer.toFile(m_strDbVerPath);
|
533
540
|
|
534
541
|
if ( RhoConf.getInstance().isExist("bulksync_state") && RhoConf.getInstance().getInt("bulksync_state") != 0)
|
535
542
|
RhoConf.getInstance().setInt("bulksync_state", 0, true);
|
@@ -579,7 +586,7 @@ public class DBAdapter extends RubyBasic
|
|
579
586
|
if ( !bTemp )
|
580
587
|
checkDBVersion();
|
581
588
|
|
582
|
-
m_dbStorage.open(m_strDBPath, getSqlScript() );
|
589
|
+
m_dbStorage.open(m_strDBPath, getSqlScript(), getEncryptionInfo() );
|
583
590
|
|
584
591
|
//executeSQL("CREATE INDEX by_src ON object_values (source_id)", null);
|
585
592
|
m_bIsOpen = true;
|
@@ -694,7 +701,7 @@ public class DBAdapter extends RubyBasic
|
|
694
701
|
LOG.TRACE("1. Size of " + dbNameData + ": " + fs.size(dbNameData));
|
695
702
|
|
696
703
|
db = RhoClassFactory.createDBStorage();
|
697
|
-
db.open( dbNewName, getSqlScript() );
|
704
|
+
db.open( dbNewName, getSqlScript(), getEncryptionInfo() );
|
698
705
|
|
699
706
|
String[] vecTables = m_dbStorage.getAllTableNames();
|
700
707
|
//IDBResult res;
|
@@ -734,7 +741,7 @@ public class DBAdapter extends RubyBasic
|
|
734
741
|
LOG.TRACE("3. Size of " + dbNameData + ": " + fs.size(dbNameData));
|
735
742
|
|
736
743
|
m_dbStorage = RhoClassFactory.createDBStorage();
|
737
|
-
m_dbStorage.open(m_strDBPath, getSqlScript() );
|
744
|
+
m_dbStorage.open(m_strDBPath, getSqlScript(), getEncryptionInfo() );
|
738
745
|
m_bIsOpen = true;
|
739
746
|
|
740
747
|
//getAttrMgr().load(this);
|
@@ -749,7 +756,7 @@ public class DBAdapter extends RubyBasic
|
|
749
756
|
{
|
750
757
|
LOG.ERROR("destroy_table error.Try to open old DB.");
|
751
758
|
try{
|
752
|
-
m_dbStorage.open(m_strDBPath, getSqlScript() );
|
759
|
+
m_dbStorage.open(m_strDBPath, getSqlScript(), getEncryptionInfo() );
|
753
760
|
m_bIsOpen = true;
|
754
761
|
}catch(Exception exc)
|
755
762
|
{
|
@@ -808,7 +815,7 @@ public class DBAdapter extends RubyBasic
|
|
808
815
|
IDBResult resSrc = executeSQL("SELECT name, schema FROM sources where source_id=?", arSrcID.elementAt(i) );
|
809
816
|
boolean bSchemaSource = false;
|
810
817
|
String strTableName = "object_values";
|
811
|
-
if ( !resSrc.
|
818
|
+
if ( !resSrc.isOneEnd() )
|
812
819
|
{
|
813
820
|
bSchemaSource = resSrc.getStringByIdx(1).length() > 0;
|
814
821
|
if ( bSchemaSource )
|
@@ -889,10 +896,10 @@ public class DBAdapter extends RubyBasic
|
|
889
896
|
{
|
890
897
|
DBAdapter db = null;
|
891
898
|
try{
|
892
|
-
db = (DBAdapter)alloc(null);
|
899
|
+
db = (DBAdapter)alloc(null);
|
900
|
+
db.setDbPartition(m_strDbPartition);
|
893
901
|
db.openDB(fDbName, true);
|
894
902
|
db.m_dbStorage.createTriggers();
|
895
|
-
db.setDbPartition(m_strDbPartition);
|
896
903
|
|
897
904
|
db.startTransaction();
|
898
905
|
|
@@ -951,7 +958,7 @@ public class DBAdapter extends RubyBasic
|
|
951
958
|
fs.renameOverwrite(fScriptName, dbNameScript);
|
952
959
|
|
953
960
|
m_dbStorage = RhoClassFactory.createDBStorage();
|
954
|
-
m_dbStorage.open(m_strDBPath, getSqlScript() );
|
961
|
+
m_dbStorage.open(m_strDBPath, getSqlScript(), getEncryptionInfo() );
|
955
962
|
m_bIsOpen = true;
|
956
963
|
|
957
964
|
//getAttrMgr().load(this);
|
@@ -966,7 +973,7 @@ public class DBAdapter extends RubyBasic
|
|
966
973
|
{
|
967
974
|
LOG.ERROR("destroy_table error.Try to open old DB.");
|
968
975
|
try{
|
969
|
-
m_dbStorage.open(m_strDBPath, getSqlScript() );
|
976
|
+
m_dbStorage.open(m_strDBPath, getSqlScript(), getEncryptionInfo() );
|
970
977
|
m_bIsOpen = true;
|
971
978
|
}catch(Exception exc)
|
972
979
|
{
|
@@ -1152,8 +1159,8 @@ public class DBAdapter extends RubyBasic
|
|
1152
1159
|
{
|
1153
1160
|
String szDbName = arg1.toStr();
|
1154
1161
|
String szDbPartition = arg2.toStr();
|
1162
|
+
((DBAdapter)receiver).setDbPartition(szDbPartition);
|
1155
1163
|
((DBAdapter)receiver).openDB(szDbName, false);
|
1156
|
-
((DBAdapter)receiver).setDbPartition(szDbPartition);
|
1157
1164
|
|
1158
1165
|
DBAdapter.getDBPartitions().put(szDbPartition, receiver);
|
1159
1166
|
|
@@ -2,7 +2,7 @@ package com.rho.db;
|
|
2
2
|
|
3
3
|
public interface IDBStorage {
|
4
4
|
|
5
|
-
public abstract void open(String strPath, String strSqlScript)throws DBException;
|
5
|
+
public abstract void open(String strPath, String strSqlScript, String strEncryptionInfo)throws DBException;
|
6
6
|
public abstract void close()throws DBException;
|
7
7
|
|
8
8
|
public abstract IDBResult executeSQL(String strStatement, Object[] values, boolean bReportNonUnique)throws DBException;
|
@@ -35,6 +35,21 @@ public class RhoFile
|
|
35
35
|
return strRes;
|
36
36
|
}
|
37
37
|
|
38
|
+
public static void writeStringToFile(String szFilePath, String strData)throws Exception
|
39
|
+
{
|
40
|
+
IRAFile file = null;
|
41
|
+
try{
|
42
|
+
file = RhoClassFactory.createRAFile();
|
43
|
+
file.open(szFilePath, "w");
|
44
|
+
byte[] buf = strData.getBytes();
|
45
|
+
file.write(buf, 0, buf.length);
|
46
|
+
}finally
|
47
|
+
{
|
48
|
+
if (file!=null)
|
49
|
+
try{ file.close(); }catch(Exception exc){}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
38
53
|
public static String readStringFromJarFile(String szFilePath, Object root)
|
39
54
|
{
|
40
55
|
java.io.InputStream fstream = null;
|
@@ -22,7 +22,6 @@ public class AsyncHttp extends ThreadQueue
|
|
22
22
|
private static RhodesApp RHODESAPP(){ return RhodesApp.getInstance(); }
|
23
23
|
|
24
24
|
static AsyncHttp m_pInstance;
|
25
|
-
HttpCommand m_pCurCmd;
|
26
25
|
|
27
26
|
static AsyncHttp Create()
|
28
27
|
{
|
@@ -37,7 +36,7 @@ public class AsyncHttp extends ThreadQueue
|
|
37
36
|
{
|
38
37
|
if ( m_pInstance != null )
|
39
38
|
{
|
40
|
-
m_pInstance.
|
39
|
+
m_pInstance.stop(-1);
|
41
40
|
LOG.INFO("Thread shutdown");
|
42
41
|
|
43
42
|
m_pInstance = null;
|
@@ -52,11 +51,9 @@ public class AsyncHttp extends ThreadQueue
|
|
52
51
|
ThreadQueue.setLogCategory(LOG.getLogCategory());
|
53
52
|
|
54
53
|
setPollInterval(QUEUE_POLL_INTERVAL_INFINITE);
|
55
|
-
|
56
|
-
m_pCurCmd = null;
|
57
54
|
}
|
58
55
|
|
59
|
-
void cancelRequest(String szCallback
|
56
|
+
void cancelRequest(String szCallback)
|
60
57
|
{
|
61
58
|
if (szCallback == null || szCallback.length() == 0 )
|
62
59
|
{
|
@@ -64,31 +61,48 @@ public class AsyncHttp extends ThreadQueue
|
|
64
61
|
return;
|
65
62
|
}
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
64
|
+
synchronized(getCommandLock())
|
65
|
+
{
|
66
|
+
HttpCommand pCmd = (HttpCommand)getCurCommand();
|
67
|
+
|
68
|
+
if ( pCmd != null && ( szCallback.compareTo("*") == 0 || pCmd.m_strCallback.compareTo(szCallback) == 0) )
|
69
|
+
pCmd.cancel();
|
70
|
+
|
71
|
+
if ( szCallback.compareTo("*") == 0 )
|
72
|
+
getCommands().clear();
|
73
|
+
else
|
74
|
+
{
|
75
|
+
for (int i = getCommands().size()-1; i >= 0; i--)
|
76
|
+
{
|
77
|
+
HttpCommand pCmd1 = (HttpCommand)getCommands().get(i);
|
78
|
+
|
79
|
+
if ( pCmd1 != null && pCmd1.m_strCallback.compareTo(szCallback) == 0 )
|
80
|
+
getCommands().remove(i);
|
81
|
+
}
|
82
|
+
|
83
|
+
}
|
84
|
+
}
|
74
85
|
}
|
75
86
|
|
76
|
-
public
|
87
|
+
public RubyValue addHttpCommand(IQueueCommand pCmd)
|
77
88
|
{
|
78
89
|
if ( ((HttpCommand)pCmd).m_strCallback.length()==0)
|
79
|
-
|
90
|
+
{
|
91
|
+
processCommandBase(pCmd);
|
92
|
+
return ((HttpCommand)pCmd).getRetValue();
|
93
|
+
}
|
80
94
|
else
|
81
95
|
{
|
82
96
|
super.addQueueCommand(pCmd);
|
83
97
|
start(epLow);
|
98
|
+
|
99
|
+
return ((HttpCommand)pCmd).getRetValue();
|
84
100
|
}
|
85
101
|
}
|
86
102
|
|
87
103
|
public void processCommand(IQueueCommand pCmd)
|
88
104
|
{
|
89
|
-
|
90
|
-
m_pCurCmd.execute();
|
91
|
-
m_pCurCmd = null;
|
105
|
+
((HttpCommand)pCmd).execute();
|
92
106
|
}
|
93
107
|
|
94
108
|
public final static int hcNone = 0, hcGet = 1, hcPost=2, hcDownload=3, hcUpload =4;
|
@@ -245,9 +259,9 @@ public class AsyncHttp extends ThreadQueue
|
|
245
259
|
}
|
246
260
|
}
|
247
261
|
|
248
|
-
void cancel()
|
262
|
+
public void cancel()
|
249
263
|
{
|
250
|
-
if (m_pNetRequest!=null
|
264
|
+
if (m_pNetRequest!=null )
|
251
265
|
m_pNetRequest.cancel();
|
252
266
|
}
|
253
267
|
|
@@ -355,9 +369,7 @@ public class AsyncHttp extends ThreadQueue
|
|
355
369
|
AsyncHttp.Create();
|
356
370
|
|
357
371
|
String command = arg1.toStr();
|
358
|
-
AsyncHttp.
|
359
|
-
AsyncHttp.getInstance().addQueueCommand(pHttp);
|
360
|
-
return pHttp.getRetValue();
|
372
|
+
return AsyncHttp.getInstance().addHttpCommand(new AsyncHttp.HttpCommand( command, arg2 ));
|
361
373
|
} catch(Exception e) {
|
362
374
|
LOG.ERROR("do_request failed", e);
|
363
375
|
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
@@ -371,7 +383,7 @@ public class AsyncHttp extends ThreadQueue
|
|
371
383
|
try {
|
372
384
|
String cancel_callback = arg.toStr();
|
373
385
|
if ( AsyncHttp.getInstance() != null )
|
374
|
-
AsyncHttp.getInstance().cancelRequest(cancel_callback
|
386
|
+
AsyncHttp.getInstance().cancelRequest(cancel_callback);
|
375
387
|
|
376
388
|
} catch(Exception e) {
|
377
389
|
LOG.ERROR("cancel failed", e);
|
@@ -181,13 +181,13 @@ public class NetRequest
|
|
181
181
|
writeHeaders(headers);
|
182
182
|
m_connection.setRequestMethod(strMethod);
|
183
183
|
}
|
184
|
+
|
185
|
+
is = m_connection.openInputStream();
|
186
|
+
LOG.INFO("openInputStream done");
|
184
187
|
|
185
188
|
code = m_connection.getResponseCode();
|
186
189
|
LOG.INFO("getResponseCode : " + code);
|
187
190
|
|
188
|
-
is = m_connection.openInputStream();
|
189
|
-
LOG.INFO("openInputStream done");
|
190
|
-
|
191
191
|
readHeaders(headers);
|
192
192
|
copyHashtable(m_OutHeaders, headers);
|
193
193
|
|
@@ -529,6 +529,8 @@ public class NetRequest
|
|
529
529
|
|
530
530
|
m_connection.setRequestMethod(IHttpConnection.GET);
|
531
531
|
|
532
|
+
is = m_connection.openInputStream();
|
533
|
+
|
532
534
|
code = m_connection.getResponseCode();
|
533
535
|
|
534
536
|
LOG.INFO("getResponseCode : " + code);
|
@@ -552,16 +554,11 @@ public class NetRequest
|
|
552
554
|
oSession.logout();
|
553
555
|
}
|
554
556
|
|
555
|
-
|
556
|
-
{
|
557
|
-
is = m_connection.openInputStream();
|
558
|
-
strRespBody = readFully(is, getResponseEncoding());
|
559
|
-
}
|
557
|
+
strRespBody = readFully(is, getResponseEncoding());
|
560
558
|
}else
|
561
559
|
{
|
562
560
|
int nRead = 0;
|
563
561
|
|
564
|
-
is = m_connection.openInputStream();
|
565
562
|
byte[] byteBuffer = new byte[1024*20];
|
566
563
|
|
567
564
|
do{
|