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
@@ -4,6 +4,7 @@
|
|
4
4
|
#include "common/map/MapEngine.h"
|
5
5
|
#include "common/RhoThread.h"
|
6
6
|
#include "common/ThreadQueue.h"
|
7
|
+
#include "net/INetRequest.h"
|
7
8
|
|
8
9
|
#include <list>
|
9
10
|
|
@@ -101,13 +102,19 @@ private:
|
|
101
102
|
|
102
103
|
void fetchTile(String const &baseUrl, int zoom, uint64 latitude, uint64 longitude);
|
103
104
|
|
105
|
+
virtual void cancel()
|
106
|
+
{
|
107
|
+
m_NetRequest.cancel();
|
108
|
+
}
|
109
|
+
|
104
110
|
private:
|
105
111
|
void processCommand(IQueueCommand *cmd);
|
106
112
|
bool fetchData(String const &url, void **data, size_t *datasize);
|
113
|
+
net::CNetRequestWrapper getNet(){ return getNetRequest(&m_NetRequest); }
|
107
114
|
|
108
115
|
private:
|
109
116
|
ESRIMapView *m_mapview;
|
110
|
-
|
117
|
+
NetRequest m_NetRequest;
|
111
118
|
};
|
112
119
|
|
113
120
|
friend class CacheUpdate;
|
@@ -179,6 +186,8 @@ public:
|
|
179
186
|
void setPinImage(IDrawingImage *pin, PIN_INFO pin_info);
|
180
187
|
void setPinCalloutImage(IDrawingImage *pinCallout, PIN_INFO pin_callout_info);
|
181
188
|
void setPinCalloutLinkImage(IDrawingImage *pinCallout, PIN_INFO pin_callout_info);
|
189
|
+
void setESRILogoImage(IDrawingImage *esriLogoImg);
|
190
|
+
|
182
191
|
|
183
192
|
private:
|
184
193
|
String const &getMapUrl();
|
@@ -239,6 +248,7 @@ private:
|
|
239
248
|
PIN_INFO m_pin_callout_info;
|
240
249
|
IDrawingImage *m_pinCalloutLink;
|
241
250
|
PIN_INFO m_pin_calloutlink_info;
|
251
|
+
IDrawingImage *m_esriLogo;
|
242
252
|
};
|
243
253
|
|
244
254
|
class ESRIMapEngine : public IMapEngine
|
@@ -23,8 +23,6 @@ String GoogleGeoCoding::Command::toString()
|
|
23
23
|
|
24
24
|
IMPLEMENT_LOGCLASS(GoogleGeoCoding,"GGeoCoding");
|
25
25
|
GoogleGeoCoding::GoogleGeoCoding()
|
26
|
-
:CThreadQueue(rho_impl_createClassFactory()),
|
27
|
-
m_net_request(getFactory()->createNetRequest())
|
28
26
|
{
|
29
27
|
CThreadQueue::setLogCategory(getLogCategory());
|
30
28
|
RHO_MAP_TRACE("GoogleGeoCoding: ctor start");
|
@@ -35,6 +33,8 @@ GoogleGeoCoding::GoogleGeoCoding()
|
|
35
33
|
GoogleGeoCoding::~GoogleGeoCoding()
|
36
34
|
{
|
37
35
|
RHO_MAP_TRACE("GoogleGeoCoding: dtor");
|
36
|
+
|
37
|
+
m_NetRequest.cancel();
|
38
38
|
CThreadQueue::stop(200);
|
39
39
|
}
|
40
40
|
/*
|
@@ -47,7 +47,7 @@ void GoogleGeoCoding::stop()
|
|
47
47
|
bool GoogleGeoCoding::fetchData(String const &url, void **data, size_t *datasize)
|
48
48
|
{
|
49
49
|
RHO_MAP_TRACE1("GoogleGeoCoding: fetchData: url=%s", url.c_str());
|
50
|
-
NetResponse
|
50
|
+
NetResponse resp = getNet().doRequest("GET", url, "", 0, 0);
|
51
51
|
if (!resp.isOK())
|
52
52
|
return false;
|
53
53
|
*datasize = resp.getDataSize();
|
@@ -40,9 +40,9 @@ private:
|
|
40
40
|
bool fetchData(String const &url, void **data, size_t *datasize);
|
41
41
|
|
42
42
|
void processCommand(IQueueCommand* cmd);
|
43
|
-
|
43
|
+
net::CNetRequestWrapper getNet(){ return getNetRequest(&m_NetRequest); }
|
44
44
|
private:
|
45
|
-
|
45
|
+
NetRequest m_NetRequest;
|
46
46
|
};
|
47
47
|
|
48
48
|
} // namespace map
|
@@ -45,6 +45,14 @@ void MapProvider::unregisterMapEngine(String const &id)
|
|
45
45
|
m_engines.remove(id);
|
46
46
|
}
|
47
47
|
|
48
|
+
bool MapProvider::isRegisteredMapEngine(String const &id) {
|
49
|
+
IMapEngine *engine = m_engines.get(id);
|
50
|
+
if (!engine)
|
51
|
+
return false;
|
52
|
+
return true;
|
53
|
+
}
|
54
|
+
|
55
|
+
|
48
56
|
IMapView *MapProvider::createMapView(String const &id, IDrawingDevice *device)
|
49
57
|
{
|
50
58
|
IMapEngine *engine = m_engines.get(id);
|
@@ -81,6 +89,35 @@ String Annotation::make_address(double latitude, double longitude)
|
|
81
89
|
|
82
90
|
namespace rhomap = rho::common::map;
|
83
91
|
|
92
|
+
|
93
|
+
bool rho_map_check_param(rho_param *p) {
|
94
|
+
if (!p || p->type != RHO_PARAM_HASH)
|
95
|
+
rho_ruby_raise_argerror("Wrong input parameter (expect Hash)");
|
96
|
+
|
97
|
+
rho_param *provider = NULL;
|
98
|
+
for (int i = 0, lim = p->v.hash->size; i < lim; ++i)
|
99
|
+
{
|
100
|
+
char *name = p->v.hash->name[i];
|
101
|
+
rho_param *value = p->v.hash->value[i];
|
102
|
+
if (!name || !value)
|
103
|
+
continue;
|
104
|
+
|
105
|
+
if (strcasecmp(name, "provider") == 0)
|
106
|
+
provider = value;
|
107
|
+
}
|
108
|
+
|
109
|
+
std::string providerId = "google";
|
110
|
+
if (provider)
|
111
|
+
{
|
112
|
+
if (provider->type != RHO_PARAM_STRING)
|
113
|
+
rho_ruby_raise_argerror("Wrong 'provider' value (expect String)");
|
114
|
+
providerId = provider->v.string;
|
115
|
+
}
|
116
|
+
std::transform(providerId.begin(), providerId.end(), providerId.begin(), &::tolower);
|
117
|
+
return RHOMAPPROVIDER().isRegisteredMapEngine(providerId);
|
118
|
+
}
|
119
|
+
|
120
|
+
|
84
121
|
rhomap::IMapView *rho_map_create(rho_param *p, rhomap::IDrawingDevice *device, int width, int height)
|
85
122
|
{
|
86
123
|
if (!p || p->type != RHO_PARAM_HASH)
|
@@ -155,6 +155,7 @@ public:
|
|
155
155
|
virtual void setPinImage(IDrawingImage *pin, PIN_INFO pin_info) = 0;
|
156
156
|
virtual void setPinCalloutImage(IDrawingImage *pinCallout, PIN_INFO pin_callout_info) = 0;
|
157
157
|
virtual void setPinCalloutLinkImage(IDrawingImage *pinCallout, PIN_INFO pin_callout_info) = 0;
|
158
|
+
virtual void setESRILogoImage(IDrawingImage *esriLogoImg) = 0;
|
158
159
|
|
159
160
|
};
|
160
161
|
|
@@ -193,6 +194,8 @@ public:
|
|
193
194
|
void registerMapEngine(String const &id, IMapEngine *engine);
|
194
195
|
void unregisterMapEngine(String const &id);
|
195
196
|
|
197
|
+
bool isRegisteredMapEngine(String const &id);
|
198
|
+
|
196
199
|
IMapView *createMapView(String const &id, IDrawingDevice *device);
|
197
200
|
void destroyMapView(IMapView *view);
|
198
201
|
|
@@ -209,6 +212,8 @@ inline rho::common::map::MapProvider &RHOMAPPROVIDER() {return rho::common::map:
|
|
209
212
|
|
210
213
|
rho::common::map::IMapView *rho_map_create(rho_param *p, rho::common::map::IDrawingDevice *device, int width, int height);
|
211
214
|
void rho_map_destroy(rho::common::map::IMapView *mapview);
|
215
|
+
// check param for valid - now check only :provider (must be supported)
|
216
|
+
bool rho_map_check_param(rho_param *p);
|
212
217
|
|
213
218
|
#endif
|
214
219
|
|
@@ -7,6 +7,7 @@
|
|
7
7
|
#include "common/RhoConf.h"
|
8
8
|
#include "common/RhodesApp.h"
|
9
9
|
#include "common/RhoAppAdapter.h"
|
10
|
+
#include "common/Tokenizer.h"
|
10
11
|
#ifndef RHO_NO_RUBY
|
11
12
|
#include "ruby/ext/rho/rhoruby.h"
|
12
13
|
#endif //RHO_NO_RUBY
|
@@ -131,8 +132,7 @@ void CDBAdapter::open (String strDbPath, String strVer, boolean bTemp)
|
|
131
132
|
const char* szEncrypt = get_app_build_config_item("encrypt_database");
|
132
133
|
if ( szEncrypt && strcmp(szEncrypt, "1") == 0 )
|
133
134
|
{
|
134
|
-
|
135
|
-
m_ptrCrypt = factory->createRhoCrypt();
|
135
|
+
m_ptrCrypt = rho_get_RhoClassFactory()->createRhoCrypt();
|
136
136
|
if ( m_strCryptKey.length() > 0 )
|
137
137
|
m_ptrCrypt->set_db_CryptKey( m_strDbPartition.c_str(), m_strCryptKey.c_str(), !bTemp );
|
138
138
|
|
@@ -168,7 +168,7 @@ void CDBAdapter::open (String strDbPath, String strVer, boolean bTemp)
|
|
168
168
|
db.open( strDbPath+"_oldver", m_strDbVer, true );
|
169
169
|
copyTable( "client_info", db, *this );
|
170
170
|
{
|
171
|
-
|
171
|
+
IDBResult res = executeSQL( "SELECT client_id FROM client_info" );
|
172
172
|
if ( !res.isEnd() && res.getStringByIdx(0).length() > 0 )
|
173
173
|
{
|
174
174
|
LOG(INFO) + "Set reset=1 in client_info";
|
@@ -183,26 +183,68 @@ void CDBAdapter::open (String strDbPath, String strVer, boolean bTemp)
|
|
183
183
|
|
184
184
|
}
|
185
185
|
|
186
|
-
|
186
|
+
void CDBAdapter::CDBVersion::fromFile(const String& strFilePath)//throws Exception
|
187
187
|
{
|
188
|
-
|
189
|
-
|
188
|
+
String strData;
|
189
|
+
CRhoFile::readStringFromFile(strFilePath.c_str(), strData);
|
190
|
+
|
191
|
+
CTokenizer oTokenizer( strData, ";" );
|
192
|
+
int nPos = 0;
|
193
|
+
while (oTokenizer.hasMoreTokens())
|
194
|
+
{
|
195
|
+
String tok = oTokenizer.nextToken();
|
196
|
+
tok = String_trim(tok);
|
197
|
+
|
198
|
+
switch(nPos)
|
199
|
+
{
|
200
|
+
case 0:
|
201
|
+
m_strRhoVer = tok;
|
202
|
+
break;
|
203
|
+
case 1:
|
204
|
+
m_strAppVer = tok;
|
205
|
+
break;
|
206
|
+
case 2:
|
207
|
+
m_bEncrypted = tok.compare("encrypted") == 0;
|
208
|
+
break;
|
209
|
+
}
|
210
|
+
nPos++;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
void CDBAdapter::CDBVersion::toFile(const String& strFilePath)const//throws Exception
|
215
|
+
{
|
216
|
+
String strFullVer = m_strRhoVer + ";" + m_strAppVer +
|
217
|
+
";" + (m_bEncrypted ? "encrypted":"");
|
218
|
+
|
219
|
+
//try{
|
220
|
+
CRhoFile::deleteFile( strFilePath.c_str() );
|
221
|
+
CRhoFile::writeStringToFile(strFilePath.c_str(), strFullVer);
|
222
|
+
//}catch (Exception e) {
|
223
|
+
// LOG.ERROR("writeDBVersion failed.", e);
|
224
|
+
// throw e;
|
225
|
+
//}
|
226
|
+
}
|
227
|
+
|
228
|
+
boolean CDBAdapter::migrateDB(const CDBVersion& dbVer, const CDBVersion& dbNewVer )
|
229
|
+
{
|
230
|
+
LOG(INFO) + "Try migrate database from " + dbVer.m_strRhoVer + " to " + dbNewVer.m_strRhoVer;
|
231
|
+
if ( (dbVer.m_strRhoVer.find("1.4") == 0)&& (dbNewVer.m_strRhoVer.find("1.5")==0||dbNewVer.m_strRhoVer.find("1.4")==0) )
|
190
232
|
{
|
191
|
-
LOG(INFO) + "No migration required from " + dbVer.m_strRhoVer + " to " +
|
192
|
-
|
233
|
+
LOG(INFO) + "No migration required from " + dbVer.m_strRhoVer + " to " + dbNewVer.m_strRhoVer;
|
234
|
+
dbNewVer.toFile(m_strDbVerPath);
|
193
235
|
return true;
|
194
236
|
}
|
195
237
|
|
196
238
|
if ( (dbVer.m_strRhoVer.find("2.0") == 0||dbVer.m_strRhoVer.find("2.1") == 0||dbVer.m_strRhoVer.find("2.2") == 0)&&
|
197
|
-
(
|
239
|
+
(dbNewVer.m_strRhoVer.find("2.0")==0||dbNewVer.m_strRhoVer.find("2.1")==0||dbNewVer.m_strRhoVer.find("2.2")==0) )
|
198
240
|
{
|
199
|
-
LOG(INFO) + "No migration required from " + dbVer.m_strRhoVer + " to " +
|
200
|
-
|
241
|
+
LOG(INFO) + "No migration required from " + dbVer.m_strRhoVer + " to " + dbNewVer.m_strRhoVer;
|
242
|
+
dbNewVer.toFile(m_strDbVerPath);
|
201
243
|
return true;
|
202
244
|
}
|
203
245
|
|
204
246
|
//1.2.x -> 1.5.x,1.4.x
|
205
|
-
if ( (dbVer.m_strRhoVer.find("1.2") == 0)&& (
|
247
|
+
if ( (dbVer.m_strRhoVer.find("1.2") == 0)&& (dbNewVer.m_strRhoVer.find("1.5")==0||dbNewVer.m_strRhoVer.find("1.4")==0) )
|
206
248
|
{
|
207
249
|
//sources
|
208
250
|
//priority INTEGER, ADD
|
@@ -211,28 +253,28 @@ boolean CDBAdapter::migrateDB(const CDBVersion& dbVer, const String& strRhoDBVer
|
|
211
253
|
|
212
254
|
//changed_values
|
213
255
|
//id INTEGER PRIMARY KEY, REMOVE
|
214
|
-
LOG(INFO) + "Migrate database from " + dbVer.m_strRhoVer + " to " +
|
256
|
+
LOG(INFO) + "Migrate database from " + dbVer.m_strRhoVer + " to " + dbNewVer.m_strRhoVer;
|
215
257
|
|
216
258
|
CDBAdapter db(m_strDbPartition.c_str(), true);
|
217
259
|
db.open( m_strDbPath, m_strDbVer, true );
|
218
|
-
|
219
|
-
|
260
|
+
IDBResult res = db.executeSQL( "ALTER TABLE sources ADD priority INTEGER" );
|
261
|
+
IDBResult res1 = db.executeSQL( "ALTER TABLE sources ADD backend_refresh_time int default 0" );
|
220
262
|
|
221
263
|
{
|
222
264
|
Vector<int> vecSrcIds;
|
223
|
-
|
265
|
+
IDBResult res2 = db.executeSQL( "SELECT source_id FROM sources" );
|
224
266
|
for ( ; !res2.isEnd(); res2.next() )
|
225
267
|
vecSrcIds.addElement(res2.getIntByIdx(0));
|
226
268
|
|
227
269
|
for( size_t i = 0; i < vecSrcIds.size(); i++)
|
228
270
|
{
|
229
|
-
|
230
|
-
vecSrcIds.elementAt(i), vecSrcIds.elementAt(i) )
|
271
|
+
IDBResult res3 = db.executeSQL( "UPDATE sources SET priority=? where source_id=?",
|
272
|
+
vecSrcIds.elementAt(i), vecSrcIds.elementAt(i) );
|
231
273
|
}
|
232
274
|
}
|
233
275
|
db.close();
|
234
276
|
|
235
|
-
|
277
|
+
dbNewVer.toFile(m_strDbVerPath);
|
236
278
|
|
237
279
|
return true;
|
238
280
|
}
|
@@ -242,76 +284,66 @@ boolean CDBAdapter::migrateDB(const CDBVersion& dbVer, const String& strRhoDBVer
|
|
242
284
|
|
243
285
|
void CDBAdapter::checkDBVersion(String& strRhoDBVer)
|
244
286
|
{
|
245
|
-
|
246
|
-
|
247
|
-
|
287
|
+
CDBVersion dbNewVer;
|
288
|
+
dbNewVer.m_strRhoVer = strRhoDBVer;
|
289
|
+
dbNewVer.m_strAppVer = RHOCONF().getString("app_db_version");
|
248
290
|
|
249
|
-
|
250
|
-
|
291
|
+
const char* szEncrypt = get_app_build_config_item("encrypt_database");
|
292
|
+
dbNewVer.m_bEncrypted = szEncrypt && strcmp(szEncrypt, "1") == 0;
|
293
|
+
|
294
|
+
CDBVersion dbVer;
|
295
|
+
dbVer.fromFile(m_strDbVerPath);
|
251
296
|
|
252
|
-
if (
|
297
|
+
if (dbVer.m_strRhoVer.length() == 0 )
|
253
298
|
{
|
254
|
-
|
255
|
-
|
299
|
+
dbNewVer.toFile(m_strDbVerPath);
|
300
|
+
return;
|
256
301
|
}
|
257
|
-
|
302
|
+
|
303
|
+
boolean bRhoReset = dbVer.isRhoVerChanged(dbNewVer);
|
304
|
+
boolean bAppReset = dbVer.isAppVerChanged(dbNewVer);
|
305
|
+
|
306
|
+
boolean bDbFormatChanged = dbVer.isDbFormatChanged(dbNewVer);
|
307
|
+
if ( !bDbFormatChanged && dbVer.m_bEncrypted )
|
258
308
|
{
|
259
|
-
if (
|
260
|
-
|
309
|
+
//if (!com.rho.RhoCrypto.isKeyExist(strEncryptionInfo) )
|
310
|
+
// bDbFormatChanged = true;
|
261
311
|
}
|
312
|
+
|
313
|
+
if ( bDbFormatChanged )
|
314
|
+
LOG(INFO) + "Reset Database( format changed ):" + m_strDbPath;
|
315
|
+
|
316
|
+
if ( bRhoReset && !bAppReset && !bDbFormatChanged )
|
317
|
+
bRhoReset = !migrateDB(dbVer, dbNewVer);
|
262
318
|
|
263
|
-
if ( bRhoReset
|
264
|
-
bRhoReset = !migrateDB(dbVer, strRhoDBVer, strAppDBVer);
|
265
|
-
|
266
|
-
if ( bRhoReset || bAppReset )
|
319
|
+
if ( bRhoReset || bAppReset || bDbFormatChanged)
|
267
320
|
{
|
268
321
|
LOG(INFO) + "Reset database because version is changed.";
|
269
322
|
|
270
323
|
CRhoFile::deleteFile( (m_strDbPath+"_oldver").c_str());
|
271
324
|
CRhoFile::deleteFile( (m_strDbPath+"_oldver-journal").c_str());
|
272
325
|
|
273
|
-
|
274
|
-
|
326
|
+
if ( bDbFormatChanged )
|
327
|
+
{
|
328
|
+
CRhoFile::deleteFile( m_strDbPath.c_str() );
|
329
|
+
CRhoFile::deleteFile((m_strDbPath+"-journal").c_str());
|
330
|
+
}else
|
331
|
+
{
|
332
|
+
CRhoFile::renameFile( m_strDbPath.c_str(), (m_strDbPath+"_oldver").c_str());
|
333
|
+
CRhoFile::renameFile((m_strDbPath+"-journal").c_str(), (m_strDbPath+"_oldver-journal").c_str());
|
334
|
+
}
|
275
335
|
|
276
|
-
|
336
|
+
if ( m_strDbPartition.compare("user") == 0 ) //do it only once
|
337
|
+
CRhoFile::deleteFilesInFolder(RHODESAPPBASE().getBlobsDirPath().c_str());
|
277
338
|
|
278
|
-
|
339
|
+
dbNewVer.toFile(m_strDbVerPath);
|
279
340
|
|
280
341
|
if ( RHOCONF().isExist("bulksync_state") && RHOCONF().getInt("bulksync_state") != 0)
|
281
342
|
RHOCONF().setInt("bulksync_state", 0, true);
|
282
|
-
|
283
|
-
}
|
284
|
-
|
285
|
-
CDBAdapter::CDBVersion CDBAdapter::readDBVersion()//throws Exception
|
286
|
-
{
|
287
|
-
String strFullVer;
|
288
|
-
CRhoFile oFile;
|
289
|
-
if ( !oFile.open(m_strDbVerPath.c_str(),CRhoFile::OpenReadOnly) )
|
290
|
-
return CDBVersion();
|
291
|
-
|
292
|
-
oFile.readString(strFullVer);
|
293
|
-
|
294
|
-
if ( strFullVer.length() == 0 )
|
295
|
-
return CDBVersion();
|
296
|
-
|
297
|
-
int nSep = strFullVer.find(';');
|
298
|
-
if ( nSep == -1 )
|
299
|
-
return CDBVersion(strFullVer, "");
|
300
|
-
|
301
|
-
return CDBVersion(strFullVer.substr(0,nSep), strFullVer.substr(nSep+1) );
|
302
|
-
}
|
303
|
-
|
304
|
-
void CDBAdapter::writeDBVersion(const CDBVersion& ver)//throws Exception
|
305
|
-
{
|
306
|
-
String strFullVer = ver.m_strRhoVer + ";" + ver.m_strAppVer;
|
307
|
-
CRhoFile oFile;
|
308
|
-
if ( !oFile.open(m_strDbVerPath.c_str(),CRhoFile::OpenForWrite) )
|
309
|
-
return;
|
310
|
-
|
311
|
-
oFile.write(strFullVer.c_str(), strFullVer.length() );
|
343
|
+
}
|
312
344
|
}
|
313
345
|
|
314
|
-
sqlite3_stmt* CDBAdapter::createInsertStatement(
|
346
|
+
sqlite3_stmt* CDBAdapter::createInsertStatement(IDBResult& res, const String& tableName, CDBAdapter& db, String& strInsert)
|
315
347
|
{
|
316
348
|
sqlite3_stmt* stInsert = 0;
|
317
349
|
int nColCount = sqlite3_data_count(res.getStatement());
|
@@ -399,7 +431,7 @@ boolean CDBAdapter::isTableExist(String strTableName)
|
|
399
431
|
{
|
400
432
|
Vector<String> vecTables;
|
401
433
|
|
402
|
-
|
434
|
+
IDBResult res = executeSQL( "SELECT name FROM sqlite_master WHERE type='table' AND name=?", strTableName.c_str() );
|
403
435
|
return !res.isEnd();
|
404
436
|
}
|
405
437
|
|
@@ -419,7 +451,7 @@ void CDBAdapter::destroy_tables(const rho::Vector<rho::String>& arIncludeTables,
|
|
419
451
|
//Copy all tables
|
420
452
|
|
421
453
|
Vector<String> vecTables;
|
422
|
-
|
454
|
+
IDBResult res = executeSQL( "SELECT name FROM sqlite_master WHERE type='table' " );
|
423
455
|
for ( ; !res.isEnd(); res.next() )
|
424
456
|
vecTables.addElement(res.getStringByIdx(0));
|
425
457
|
|
@@ -449,7 +481,7 @@ void CDBAdapter::destroy_tables(const rho::Vector<rho::String>& arIncludeTables,
|
|
449
481
|
void CDBAdapter::copyTable(String tableName, CDBAdapter& dbFrom, CDBAdapter& dbTo)
|
450
482
|
{
|
451
483
|
String strSelect = "SELECT * from " + tableName;
|
452
|
-
|
484
|
+
IDBResult res = dbFrom.executeSQL( strSelect.c_str() );
|
453
485
|
String strInsert = "";
|
454
486
|
int rc = 0;
|
455
487
|
for ( ; !res.isEnd(); res.next() )
|
@@ -468,8 +500,8 @@ void CDBAdapter::copyTable(String tableName, CDBAdapter& dbFrom, CDBAdapter& dbT
|
|
468
500
|
void CDBAdapter::updateAllAttribChanges()
|
469
501
|
{
|
470
502
|
//Check for attrib = object
|
471
|
-
|
472
|
-
"FROM changed_values where attrib = 'object' and sent=0")
|
503
|
+
IDBResult res = executeSQL("SELECT object, source_id, update_type "
|
504
|
+
"FROM changed_values where attrib = 'object' and sent=0");
|
473
505
|
|
474
506
|
if ( res.isEnd() )
|
475
507
|
return;
|
@@ -487,7 +519,7 @@ void CDBAdapter::updateAllAttribChanges()
|
|
487
519
|
|
488
520
|
for( int i = 0; i < (int)arObj.size(); i++ )
|
489
521
|
{
|
490
|
-
|
522
|
+
IDBResult resSrc = executeSQL("SELECT name, schema FROM sources where source_id=?", arSrcID.elementAt(i) );
|
491
523
|
boolean bSchemaSource = false;
|
492
524
|
String strTableName = "object_values";
|
493
525
|
if ( !resSrc.isEnd() )
|
@@ -499,7 +531,7 @@ void CDBAdapter::updateAllAttribChanges()
|
|
499
531
|
|
500
532
|
if (bSchemaSource)
|
501
533
|
{
|
502
|
-
|
534
|
+
IDBResult res2 = executeSQL((String("SELECT * FROM ") + strTableName + " where object=?").c_str(), arObj.elementAt(i) );
|
503
535
|
for( int j = 0; j < res2.getColCount(); j ++)
|
504
536
|
{
|
505
537
|
String strAttrib = res2.getColName(j);
|
@@ -511,8 +543,8 @@ void CDBAdapter::updateAllAttribChanges()
|
|
511
543
|
}
|
512
544
|
}else
|
513
545
|
{
|
514
|
-
|
515
|
-
arObj.elementAt(i), arSrcID.elementAt(i) )
|
546
|
+
IDBResult res2 = executeSQL((String("SELECT attrib, value FROM ") + strTableName + " where object=? and source_id=?").c_str(),
|
547
|
+
arObj.elementAt(i), arSrcID.elementAt(i) );
|
516
548
|
|
517
549
|
for( ; !res2.isEnd(); res2.next() )
|
518
550
|
{
|
@@ -539,7 +571,7 @@ void CDBAdapter::copyChangedValues(CDBAdapter& db)
|
|
539
571
|
{
|
540
572
|
Vector<int> arOldSrcs;
|
541
573
|
{
|
542
|
-
|
574
|
+
IDBResult resSrc = db.executeSQL( "SELECT DISTINCT(source_id) FROM changed_values" );
|
543
575
|
for ( ; !resSrc.isEnd(); resSrc.next() )
|
544
576
|
arOldSrcs.addElement( resSrc.getIntByIdx(0) );
|
545
577
|
}
|
@@ -547,12 +579,12 @@ void CDBAdapter::copyChangedValues(CDBAdapter& db)
|
|
547
579
|
{
|
548
580
|
int nOldSrcID = arOldSrcs.elementAt(i);
|
549
581
|
|
550
|
-
|
582
|
+
IDBResult res = executeSQL("SELECT name from sources WHERE source_id=?", nOldSrcID);
|
551
583
|
if ( !res.isEnd() )
|
552
584
|
{
|
553
585
|
String strSrcName = res.getStringByIdx(0);
|
554
586
|
|
555
|
-
|
587
|
+
IDBResult res2 = db.executeSQL("SELECT source_id from sources WHERE name=?", strSrcName);
|
556
588
|
if ( !res2.isEnd() )
|
557
589
|
{
|
558
590
|
if ( nOldSrcID != res2.getIntByIdx(0) )
|
@@ -44,8 +44,26 @@ class CDBAdapter
|
|
44
44
|
{
|
45
45
|
String m_strRhoVer;
|
46
46
|
String m_strAppVer;
|
47
|
+
boolean m_bEncrypted;
|
48
|
+
|
49
|
+
boolean isRhoVerChanged(CDBVersion& dbNewVer)
|
50
|
+
{
|
51
|
+
return m_strRhoVer.compare(dbNewVer.m_strRhoVer) != 0;
|
52
|
+
}
|
53
|
+
boolean isAppVerChanged(CDBVersion& dbNewVer)
|
54
|
+
{
|
55
|
+
return m_strAppVer.compare(dbNewVer.m_strAppVer) != 0;
|
56
|
+
}
|
47
57
|
|
48
|
-
|
58
|
+
boolean isDbFormatChanged(CDBVersion& dbNewVer)
|
59
|
+
{
|
60
|
+
return m_bEncrypted != dbNewVer.m_bEncrypted;// ||
|
61
|
+
//m_bSqlite != dbNewVer.m_bSqlite;
|
62
|
+
}
|
63
|
+
void fromFile(const String& strFilePath);//throws Exception
|
64
|
+
void toFile(const String& strFilePath)const;//throws Exception
|
65
|
+
|
66
|
+
CDBVersion() : m_bEncrypted(false){}
|
49
67
|
CDBVersion( String strRhoVer, String strAppVer )
|
50
68
|
{
|
51
69
|
m_strRhoVer = strRhoVer;
|
@@ -287,15 +305,13 @@ public:
|
|
287
305
|
private:
|
288
306
|
|
289
307
|
void checkDBVersion(String& strVer);
|
290
|
-
CDBVersion readDBVersion();//throws Exception
|
291
|
-
void writeDBVersion(const CDBVersion& ver);//throws Exception
|
292
308
|
void createSchema();
|
293
309
|
void createTriggers();
|
294
310
|
boolean checkDbError(int rc);
|
295
311
|
boolean checkDbErrorEx(int rc, rho::db::CDBResult& res);
|
296
|
-
sqlite3_stmt* createInsertStatement(
|
312
|
+
sqlite3_stmt* createInsertStatement(IDBResult& res, const String& tableName, CDBAdapter& db, String& strInsert);
|
297
313
|
|
298
|
-
boolean migrateDB(const CDBVersion& dbVer, const
|
314
|
+
boolean migrateDB(const CDBVersion& dbVer, const CDBVersion& dbNewVer);
|
299
315
|
void copyTable(String tableName, CDBAdapter& dbFrom, CDBAdapter& dbTo);
|
300
316
|
void copyChangedValues(CDBAdapter& db);
|
301
317
|
};
|
@@ -149,7 +149,7 @@ void CDBAttrManager::loadBlobAttrs(CDBAdapter& db)
|
|
149
149
|
{
|
150
150
|
int nSrcID = it->first;
|
151
151
|
|
152
|
-
|
152
|
+
IDBResult res = db.executeSQL("SELECT name FROM sources WHERE source_id=?", nSrcID);
|
153
153
|
if ( res.isEnd() )
|
154
154
|
continue;
|
155
155
|
|
@@ -167,7 +167,7 @@ void CDBAttrManager::loadBlobAttrs(CDBAdapter& db)
|
|
167
167
|
String strSql = "SELECT source_id,";
|
168
168
|
strSql += strDBAttr + " from sources";
|
169
169
|
|
170
|
-
|
170
|
+
IDBResult res = db.executeSQL(strSql.c_str());
|
171
171
|
for ( ; !res.isEnd(); res.next() )
|
172
172
|
{
|
173
173
|
int nSrcID = res.getIntByIdx(0);
|
@@ -50,6 +50,7 @@ public:
|
|
50
50
|
// void setErrorCode(int nError){ m_nErrorCode=nError; }
|
51
51
|
|
52
52
|
virtual bool isEnd(){ return m_dbStatement == null; }
|
53
|
+
virtual bool isOneEnd(){ return m_dbStatement == null; }
|
53
54
|
void next()
|
54
55
|
{
|
55
56
|
if ( sqlite3_step(m_dbStatement) != SQLITE_ROW )
|
@@ -90,9 +91,36 @@ public:
|
|
90
91
|
};
|
91
92
|
|
92
93
|
typedef rho::common::CAutoPtr<rho::db::CDBResult> DBResultPtr;
|
94
|
+
/*
|
93
95
|
#define DBResult(name, call)\
|
94
96
|
rho::db::DBResultPtr p##name = call;\
|
95
97
|
rho::db::CDBResult& name = *p##name;
|
98
|
+
*/
|
99
|
+
|
100
|
+
class CDBResultWrapper
|
101
|
+
{
|
102
|
+
DBResultPtr m_dbRes;
|
103
|
+
public:
|
104
|
+
CDBResultWrapper(const DBResultPtr& dbRes) : m_dbRes(dbRes){}
|
105
|
+
void operator=( const DBResultPtr& dbRes){ m_dbRes = dbRes; }
|
106
|
+
|
107
|
+
sqlite3_stmt* getStatement(){ return m_dbRes->getStatement(); }
|
108
|
+
boolean isNonUnique(){ return m_dbRes->isNonUnique(); }
|
109
|
+
bool isEnd(){ return m_dbRes->isEnd(); }
|
110
|
+
bool isOneEnd(){ return m_dbRes->isOneEnd(); }
|
111
|
+
void next(){ m_dbRes->next(); }
|
112
|
+
String getStringByIdx(int nCol){ return m_dbRes->getStringByIdx(nCol); }
|
113
|
+
int getIntByIdx(int nCol){ return m_dbRes->getIntByIdx(nCol); }
|
114
|
+
uint64 getUInt64ByIdx(int nCol){ return m_dbRes->getUInt64ByIdx(nCol); }
|
115
|
+
int getColCount(){ return m_dbRes->getColCount(); }
|
116
|
+
boolean isNullByIdx(int nCol){ return m_dbRes->isNullByIdx(nCol); }
|
117
|
+
String getColName(int nCol){ return m_dbRes->getColName(nCol); }
|
118
|
+
|
119
|
+
};
|
96
120
|
|
97
121
|
}
|
98
122
|
}
|
123
|
+
|
124
|
+
typedef rho::db::CDBResultWrapper IDBResult;
|
125
|
+
|
126
|
+
|