rhodes 2.0.0.beta7 → 2.0.0.beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +20 -1
- data/bin/rhodes-setup +6 -2
- data/lib/extensions/digest/ext/Rakefile +2 -2
- data/lib/framework/rho/render.rb +2 -0
- data/lib/framework/rho/rho.rb +159 -95
- data/lib/framework/rho/rhoapplication.rb +24 -5
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhom/rhom_model.rb +32 -23
- data/lib/framework/rhom/rhom_object_factory.rb +2 -2
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/jni/src/callbacks.cpp +8 -1
- data/platform/android/Rhodes/jni/src/mapview.cpp +4 -1
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +5 -1
- data/platform/android/Rhodes/jni/src/webview.cpp +3 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +3 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeLibraries.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NavBar.java +1 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +3 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +0 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +4 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +24 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +7 -2
- data/platform/android/build/android.rake +11 -38
- data/platform/android/build/androidcommon.rb +50 -2
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/android/build/libsqlite_build.files +1 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +2 -1
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +1 -5
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +3 -6
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +4 -2
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +12 -35
- data/platform/bb/rhodes/src/rhomobile/Utilities.java +2 -1
- data/platform/iphone/Classes/DateTimePickerDelegate.m +4 -4
- data/platform/iphone/Classes/NativeBar.m +12 -6
- data/platform/iphone/Classes/NavBar.m +1 -1
- data/platform/iphone/Classes/RhoMainView.h +4 -1
- data/platform/iphone/Classes/Rhodes.h +6 -2
- data/platform/iphone/Classes/Rhodes.m +23 -3
- data/platform/iphone/Classes/SimpleMainView.h +3 -7
- data/platform/iphone/Classes/SimpleMainView.m +108 -54
- data/platform/iphone/Classes/TabbedMainView.h +3 -2
- data/platform/iphone/Classes/TabbedMainView.m +21 -10
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +8 -0
- data/platform/shared/common/IRhoClassFactory.h +1 -0
- data/platform/shared/common/RhodesApp.cpp +7 -2
- data/platform/shared/common/ThreadQueue.cpp +110 -0
- data/platform/shared/common/ThreadQueue.h +75 -0
- data/platform/shared/logging/RhoLogCat.h +4 -0
- data/platform/shared/net/AsyncHttp.cpp +134 -135
- data/platform/shared/net/AsyncHttp.h +74 -33
- data/platform/shared/net/HttpServer.cpp +7 -1
- data/platform/shared/ruby/thread.c +4 -0
- data/platform/shared/ruby/thread_win32.c +9 -8
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +26 -5
- data/platform/shared/rubyJVM/src/com/rho/net/INetworkAccess.java +0 -2
- data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +4 -13
- data/platform/shared/rubyJVM/src/com/rho/net/URI.java +2 -2
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +3 -3
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/ObjectFactory.java +12 -2
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyString.java +6 -3
- data/platform/shared/rubyJVM/src/javolution/util/FastTable.java +12 -2
- data/platform/shared/sync/SyncEngine.cpp +15 -3
- data/platform/shared/sync/SyncEngine.h +1 -1
- data/platform/shared/sync/SyncThread.cpp +18 -101
- data/platform/shared/sync/SyncThread.h +30 -22
- data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
- data/platform/wm/rhodes/Rhodes.cpp +143 -1
- data/platform/wm/rhodes/memory_helper.cpp +273 -0
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +1 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +46 -3
- data/platform/wm/rhodes/rho/rubyext/WebView.cpp +29 -1
- data/res/build-tools/db/syncdb.schema +1 -0
- data/res/generators/rhogen.rb +1 -1
- data/rhodes.gemspec +2 -2
- metadata +23 -6
- data/Manifest.txt +0 -5289
- data/rhobuild.yml +0 -37
|
@@ -361,10 +361,10 @@ void CSyncEngine::processServerSources(String strSources)
|
|
|
361
361
|
{
|
|
362
362
|
if ( strSources.length() > 0 )
|
|
363
363
|
{
|
|
364
|
-
NetResponse(resp,getNet().pushData( getNet().resolveUrl("/system/loadserversources"), strSources, null ));
|
|
364
|
+
/*NetResponse(resp,getNet().pushData( getNet().resolveUrl("/system/loadserversources"), strSources, null ));
|
|
365
365
|
loadAllSources();
|
|
366
366
|
|
|
367
|
-
rho_db_init_attr_manager();
|
|
367
|
+
rho_db_init_attr_manager(); */
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
|
|
@@ -377,6 +377,7 @@ boolean CSyncEngine::resetClientIDByNet(const String& strClientID)//throws Excep
|
|
|
377
377
|
|
|
378
378
|
NetResponse( resp, getNet().pullData(getProtocol().getClientResetUrl(strClientID), this) );
|
|
379
379
|
|
|
380
|
+
|
|
380
381
|
/* processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"sync_priority\":\"0\","
|
|
381
382
|
"\"schema_version\":\"7.0\",\"schema\":{"
|
|
382
383
|
"\"columns\":[\'brand\',\'created_at\',\'name\',\'price\',\'quantity\',\'sku\',\'updated_at\']"*/
|
|
@@ -428,7 +429,7 @@ String CSyncEngine::requestClientIDByNet()
|
|
|
428
429
|
|
|
429
430
|
CJSONEntry oJsonEntry(szData);
|
|
430
431
|
|
|
431
|
-
if (oJsonEntry.hasName("
|
|
432
|
+
if (oJsonEntry.hasName("sources") )
|
|
432
433
|
processServerSources(szData);
|
|
433
434
|
|
|
434
435
|
CJSONEntry oJsonObject = oJsonEntry.getEntry("client");
|
|
@@ -623,6 +624,17 @@ void CSyncEngine::syncAllSources()
|
|
|
623
624
|
|
|
624
625
|
void CSyncEngine::login(String name, String password, String callback)
|
|
625
626
|
{
|
|
627
|
+
/*
|
|
628
|
+
processServerSources(
|
|
629
|
+
"{\"sources\":[{ \"name\":\"ProductEx\", "
|
|
630
|
+
"\"sync_type\":\"incremental\", \"partition\":\"application\", \"source_id\":\"7\","
|
|
631
|
+
" \"sync_priority\":\"0\", \"model_type\":\"fixed_schema\", "
|
|
632
|
+
" \"schema\":{\"property\":{\"brand\":\"string\", \"price\":\"string\", \"quantity\":\"string\", \"name\":\"string\", "
|
|
633
|
+
" \"image_url\":\"blob\", \"image_url_ex\":{\"blob\":\"1\", \"server_overwrite\":\"1\"}}, "
|
|
634
|
+
" \"index\":[{\"by_brand_price1\":[\"brand\", \"price\"]}, {\"by_quantity1\":[\"quantity\"]}], \"unique_index\":[{\"by_name1\":[\"name\"]}]}, "
|
|
635
|
+
" \"belongs_to\":{\"brand\":\"Customer\"}, "
|
|
636
|
+
" \"schema_version\":\"1.0\"}]}");
|
|
637
|
+
*/
|
|
626
638
|
PROF_START("Login");
|
|
627
639
|
//try {
|
|
628
640
|
|
|
@@ -69,7 +69,7 @@ public:
|
|
|
69
69
|
ESyncState getState()const{ return m_syncState; }
|
|
70
70
|
boolean isContinueSync()const{ return m_syncState != esExit && m_syncState != esStop; }
|
|
71
71
|
boolean isSyncing()const{ return m_syncState == esSyncAllSources || m_syncState == esSyncSource; }
|
|
72
|
-
void stopSync(){ if (isContinueSync()){ setState(esStop); m_NetRequest->cancel();} }
|
|
72
|
+
void stopSync(){ if (isContinueSync()){ setState(esStop); if(m_NetRequest) m_NetRequest->cancel();} }
|
|
73
73
|
void stopSyncByUser(){ m_bStopByUser = true; stopSync(); }
|
|
74
74
|
void exitSync(){ setState(esExit); m_NetRequest->cancel(); }
|
|
75
75
|
boolean isStoppedByUser(){ return m_bStopByUser; }
|
|
@@ -31,13 +31,12 @@ CSyncThread* CSyncThread::m_pInstance = 0;
|
|
|
31
31
|
m_pInstance = 0;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
CSyncThread::CSyncThread(common::IRhoClassFactory* factory) :
|
|
34
|
+
CSyncThread::CSyncThread(common::IRhoClassFactory* factory) : CThreadQueue(factory)
|
|
35
35
|
{
|
|
36
|
-
|
|
37
|
-
if( RHOCONF().isExist("sync_poll_interval") )
|
|
38
|
-
m_nPollInterval = RHOCONF().getInt("sync_poll_interval");
|
|
36
|
+
CThreadQueue::setLogCategory(getLogCategory());
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
if( RHOCONF().isExist("sync_poll_interval") )
|
|
39
|
+
setPollInterval(RHOCONF().getInt("sync_poll_interval"));
|
|
41
40
|
|
|
42
41
|
m_oSyncEngine.setFactory(factory);
|
|
43
42
|
|
|
@@ -55,36 +54,7 @@ CSyncThread::~CSyncThread(void)
|
|
|
55
54
|
LOG(INFO) + "Sync engine thread shutdown";
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
if ( RHOCONF().getString("syncserver").length() == 0 )
|
|
61
|
-
return;
|
|
62
|
-
|
|
63
|
-
LOG(INFO) + "addSyncCommand: " + (*pSyncCmd).m_nCmdCode;
|
|
64
|
-
{
|
|
65
|
-
synchronized(m_mxStackCommands);
|
|
66
|
-
|
|
67
|
-
boolean bExist = false;
|
|
68
|
-
for ( int i = 0; i < (int)m_stackCommands.size(); i++ )
|
|
69
|
-
{
|
|
70
|
-
if ( m_stackCommands.get(i)->equals(*pSyncCmd) )
|
|
71
|
-
{
|
|
72
|
-
bExist = true;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if ( !bExist )
|
|
78
|
-
m_stackCommands.add(pSyncCmd);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if ( getSyncEngine().isNoThreadedMode() )
|
|
82
|
-
processCommands();
|
|
83
|
-
else
|
|
84
|
-
stopWait();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
int CSyncThread::getLastSyncInterval()
|
|
57
|
+
int CSyncThread::getLastPollInterval()
|
|
88
58
|
{
|
|
89
59
|
uint64 nowTime = CLocalTime().toULong();
|
|
90
60
|
|
|
@@ -100,63 +70,12 @@ int CSyncThread::getLastSyncInterval()
|
|
|
100
70
|
return latestTimeUpdated > 0 ? (int)(nowTime-latestTimeUpdated) : 0;
|
|
101
71
|
}
|
|
102
72
|
|
|
103
|
-
void CSyncThread::run()
|
|
104
|
-
{
|
|
105
|
-
LOG(INFO) + "Starting sync engine main routine...";
|
|
106
|
-
|
|
107
|
-
int nLastSyncInterval = getLastSyncInterval();
|
|
108
|
-
while( m_oSyncEngine.getState() != CSyncEngine::esExit )
|
|
109
|
-
{
|
|
110
|
-
unsigned int nWait = m_nPollInterval > 0 ? m_nPollInterval : SYNC_POLL_INTERVAL_INFINITE;
|
|
111
|
-
|
|
112
|
-
if ( m_nPollInterval > 0 && nLastSyncInterval > 0 )
|
|
113
|
-
{
|
|
114
|
-
int nWait2 = m_nPollInterval - nLastSyncInterval;
|
|
115
|
-
if ( nWait2 <= 0 )
|
|
116
|
-
nWait = SYNC_STARTUP_INTERVAL_SECONDS;
|
|
117
|
-
else
|
|
118
|
-
nWait = nWait2;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if ( nWait >= 0 && m_oSyncEngine.getState() != CSyncEngine::esExit &&
|
|
122
|
-
isNoCommands() )
|
|
123
|
-
{
|
|
124
|
-
LOG(INFO) + "Sync engine blocked for " + nWait + " seconds...";
|
|
125
|
-
wait(nWait);
|
|
126
|
-
}
|
|
127
|
-
nLastSyncInterval = 0;
|
|
128
|
-
|
|
129
|
-
if ( m_oSyncEngine.getState() != CSyncEngine::esExit )
|
|
130
|
-
processCommands();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
boolean CSyncThread::isNoCommands()
|
|
135
|
-
{
|
|
136
|
-
boolean bEmpty = false;
|
|
137
|
-
synchronized(m_mxStackCommands)
|
|
138
|
-
{
|
|
139
|
-
bEmpty = m_stackCommands.isEmpty();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return bEmpty;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
73
|
void CSyncThread::processCommands()//throws Exception
|
|
146
74
|
{
|
|
147
75
|
if ( isNoCommands() )
|
|
148
|
-
|
|
76
|
+
addQueueCommand(new CSyncCommand(scNone,false));
|
|
149
77
|
|
|
150
|
-
|
|
151
|
-
{
|
|
152
|
-
common::CAutoPtr<CSyncCommand> pSyncCmd = null;
|
|
153
|
-
{
|
|
154
|
-
synchronized(m_mxStackCommands);
|
|
155
|
-
pSyncCmd = (CSyncCommand*)m_stackCommands.removeFirst();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
processCommand(*pSyncCmd);
|
|
159
|
-
}
|
|
78
|
+
CThreadQueue::processCommands();
|
|
160
79
|
}
|
|
161
80
|
|
|
162
81
|
void CSyncThread::checkShowStatus(CSyncCommand& oSyncCmd)
|
|
@@ -167,12 +86,13 @@ void CSyncThread::checkShowStatus(CSyncCommand& oSyncCmd)
|
|
|
167
86
|
//m_statusListener.createStatusPopup(RhoRuby.getMessageText("syncronizing_data"));
|
|
168
87
|
}
|
|
169
88
|
|
|
170
|
-
void CSyncThread::processCommand(
|
|
89
|
+
void CSyncThread::processCommand(CQueueCommand* pCmd)
|
|
171
90
|
{
|
|
91
|
+
CSyncCommand& oSyncCmd = *((CSyncCommand*)pCmd);
|
|
172
92
|
switch(oSyncCmd.m_nCmdCode)
|
|
173
93
|
{
|
|
174
94
|
case scNone:
|
|
175
|
-
if (
|
|
95
|
+
if ( getPollInterval() )
|
|
176
96
|
{
|
|
177
97
|
checkShowStatus(oSyncCmd);
|
|
178
98
|
m_oSyncEngine.doSyncAllSources();
|
|
@@ -182,8 +102,6 @@ void CSyncThread::processCommand(CSyncCommand& oSyncCmd)
|
|
|
182
102
|
checkShowStatus(oSyncCmd);
|
|
183
103
|
m_oSyncEngine.doSyncAllSources();
|
|
184
104
|
break;
|
|
185
|
-
case scChangePollInterval:
|
|
186
|
-
break;
|
|
187
105
|
case scSyncOne:
|
|
188
106
|
{
|
|
189
107
|
checkShowStatus(oSyncCmd);
|
|
@@ -211,11 +129,10 @@ void CSyncThread::processCommand(CSyncCommand& oSyncCmd)
|
|
|
211
129
|
|
|
212
130
|
void CSyncThread::setPollInterval(int nInterval)
|
|
213
131
|
{
|
|
214
|
-
|
|
215
|
-
if ( m_nPollInterval == 0 )
|
|
132
|
+
if ( nInterval == 0 )
|
|
216
133
|
m_oSyncEngine.stopSync();
|
|
217
134
|
|
|
218
|
-
|
|
135
|
+
CThreadQueue::setPollInterval(nInterval);
|
|
219
136
|
}
|
|
220
137
|
|
|
221
138
|
};
|
|
@@ -232,14 +149,14 @@ void rho_sync_destroy()
|
|
|
232
149
|
|
|
233
150
|
void rho_sync_doSyncAllSources(int show_status_popup)
|
|
234
151
|
{
|
|
235
|
-
CSyncThread::getInstance()->
|
|
152
|
+
CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncCommand(CSyncThread::scSyncAll,show_status_popup!=0));
|
|
236
153
|
//rho_sync_doSyncSourceByUrl("http://dev.rhosync.rhohub.com/apps/SugarCRM/sources/SugarAccounts");
|
|
237
154
|
}
|
|
238
155
|
|
|
239
156
|
void rho_sync_doSyncSource(unsigned long nSrcID,int show_status_popup)
|
|
240
157
|
{
|
|
241
158
|
CRhoRubyStringOrInt oSrcID = rho_ruby_getstringorint(nSrcID);
|
|
242
|
-
CSyncThread::getInstance()->
|
|
159
|
+
CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncCommand(CSyncThread::scSyncOne, oSrcID.m_szStr, (int)oSrcID.m_nInt, show_status_popup!=0 ) );
|
|
243
160
|
}
|
|
244
161
|
|
|
245
162
|
void rho_sync_stop()
|
|
@@ -271,7 +188,7 @@ void rho_sync_doSearch(unsigned long ar_sources, const char *from, const char *p
|
|
|
271
188
|
rho::Vector<rho::String> arSources;
|
|
272
189
|
rho_ruby_enum_strary(ar_sources, source_iter, &arSources);
|
|
273
190
|
|
|
274
|
-
CSyncThread::getInstance()->
|
|
191
|
+
CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncSearchCommand(from,params,arSources,sync_changes,nProgressStep) );
|
|
275
192
|
}
|
|
276
193
|
|
|
277
194
|
void rho_sync_doSyncSourceByUrl(const char* szSrcUrl)
|
|
@@ -289,7 +206,7 @@ void rho_sync_doSyncSourceByUrl(const char* szSrcUrl)
|
|
|
289
206
|
strName = szLastSlash ? szLastSlash + 1 : szSrcUrl;
|
|
290
207
|
|
|
291
208
|
//TODO: save query params
|
|
292
|
-
CSyncThread::getInstance()->
|
|
209
|
+
CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncCommand(CSyncThread::scSyncOne, strName, (int)0, false ) );
|
|
293
210
|
}
|
|
294
211
|
|
|
295
212
|
void rho_sync_set_pollinterval(int nInterval)
|
|
@@ -306,13 +223,13 @@ void rho_sync_set_syncserver(char* syncserver)
|
|
|
306
223
|
if ( syncserver && *syncserver )
|
|
307
224
|
CSyncThread::getInstance()->start(CSyncThread::epLow);
|
|
308
225
|
else
|
|
309
|
-
CSyncThread::getInstance()->stop(SYNC_WAIT_BEFOREKILL_SECONDS);
|
|
226
|
+
CSyncThread::getInstance()->stop(CSyncThread::SYNC_WAIT_BEFOREKILL_SECONDS);
|
|
310
227
|
}
|
|
311
228
|
|
|
312
229
|
void rho_sync_login(const char *name, const char *password, const char* callback)
|
|
313
230
|
{
|
|
314
231
|
rho_sync_stop();
|
|
315
|
-
CSyncThread::getInstance()->
|
|
232
|
+
CSyncThread::getInstance()->addQueueCommand(new CSyncThread::CSyncLoginCommand(name, password, callback) );
|
|
316
233
|
}
|
|
317
234
|
|
|
318
235
|
int rho_sync_logged_in()
|
|
@@ -5,26 +5,24 @@
|
|
|
5
5
|
#include "logging/RhoLog.h"
|
|
6
6
|
#include "db/DBAdapter.h"
|
|
7
7
|
#include "sync/SyncEngine.h"
|
|
8
|
-
#include "common/
|
|
8
|
+
#include "common/ThreadQueue.h"
|
|
9
9
|
|
|
10
10
|
namespace rho {
|
|
11
11
|
namespace sync {
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
#define SYNC_POLL_INTERVAL_INFINITE (unsigned int)(-1)
|
|
15
|
-
#define SYNC_WAIT_BEFOREKILL_SECONDS 3
|
|
16
|
-
#define SYNC_STARTUP_INTERVAL_SECONDS 10
|
|
17
|
-
|
|
18
|
-
class CSyncThread : public common::CRhoThread
|
|
13
|
+
class CSyncThread : public common::CThreadQueue
|
|
19
14
|
{
|
|
20
15
|
public:
|
|
21
|
-
enum ESyncCommands{ scNone = 0, scSyncAll, scSyncOne,
|
|
16
|
+
enum ESyncCommands{ scNone = 0, scSyncAll, scSyncOne, scLogin, scSearchOne};
|
|
22
17
|
|
|
23
18
|
private:
|
|
24
19
|
|
|
25
20
|
DEFINE_LOGCLASS;
|
|
21
|
+
|
|
26
22
|
public:
|
|
27
|
-
|
|
23
|
+
static const unsigned int SYNC_WAIT_BEFOREKILL_SECONDS = 3;
|
|
24
|
+
|
|
25
|
+
class CSyncCommand : public CQueueCommand
|
|
28
26
|
{
|
|
29
27
|
public:
|
|
30
28
|
int m_nCmdCode;
|
|
@@ -59,12 +57,29 @@ public:
|
|
|
59
57
|
m_bShowStatus = bShowStatus;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
boolean equals(const
|
|
60
|
+
boolean equals(const CQueueCommand& cmd)
|
|
63
61
|
{
|
|
62
|
+
const CSyncCommand& oSyncCmd = (const CSyncCommand&)cmd;
|
|
64
63
|
return m_nCmdCode == oSyncCmd.m_nCmdCode && m_nCmdParam == oSyncCmd.m_nCmdParam &&
|
|
65
64
|
m_strCmdParam == oSyncCmd.m_strCmdParam;
|
|
66
65
|
}
|
|
67
66
|
|
|
67
|
+
String toString()
|
|
68
|
+
{
|
|
69
|
+
switch(m_nCmdCode)
|
|
70
|
+
{
|
|
71
|
+
case scSyncAll:
|
|
72
|
+
return "SyncAll";
|
|
73
|
+
case scSyncOne:
|
|
74
|
+
return "SyncOne";
|
|
75
|
+
case scLogin:
|
|
76
|
+
return "Login";
|
|
77
|
+
case scSearchOne:
|
|
78
|
+
return "Search";
|
|
79
|
+
}
|
|
80
|
+
return "Unknown";
|
|
81
|
+
}
|
|
82
|
+
|
|
68
83
|
};
|
|
69
84
|
|
|
70
85
|
class CSyncLoginCommand : public CSyncCommand
|
|
@@ -96,10 +111,6 @@ private:
|
|
|
96
111
|
static CSyncThread* m_pInstance;
|
|
97
112
|
|
|
98
113
|
CSyncEngine m_oSyncEngine;
|
|
99
|
-
common::CAutoPtr<common::IRhoClassFactory> m_ptrFactory;
|
|
100
|
-
int m_nPollInterval;
|
|
101
|
-
common::CMutex m_mxStackCommands;
|
|
102
|
-
LinkedListPtr<CSyncCommand*> m_stackCommands;
|
|
103
114
|
public:
|
|
104
115
|
~CSyncThread(void);
|
|
105
116
|
|
|
@@ -108,18 +119,15 @@ public:
|
|
|
108
119
|
static CSyncThread* getInstance(){ return m_pInstance; }
|
|
109
120
|
static CSyncEngine& getSyncEngine(){ return m_pInstance->m_oSyncEngine; }
|
|
110
121
|
|
|
111
|
-
void addSyncCommand(CSyncCommand* pSyncCmd);
|
|
112
|
-
|
|
113
|
-
virtual void run();
|
|
114
|
-
|
|
115
122
|
void setPollInterval(int nInterval);
|
|
116
123
|
private:
|
|
117
124
|
CSyncThread(common::IRhoClassFactory* factory);
|
|
118
|
-
int getLastSyncInterval();
|
|
119
125
|
|
|
120
|
-
|
|
121
|
-
void processCommand(
|
|
122
|
-
boolean
|
|
126
|
+
virtual int getLastPollInterval();
|
|
127
|
+
virtual void processCommand(CQueueCommand* pCmd);
|
|
128
|
+
virtual boolean isSkipDuplicateCmd() { return true; }
|
|
129
|
+
|
|
130
|
+
virtual void processCommands();
|
|
123
131
|
|
|
124
132
|
void checkShowStatus(CSyncCommand& oSyncCmd);
|
|
125
133
|
};
|
|
@@ -873,6 +873,14 @@
|
|
|
873
873
|
RelativePath="..\..\shared\common\StringConverter.h"
|
|
874
874
|
>
|
|
875
875
|
</File>
|
|
876
|
+
<File
|
|
877
|
+
RelativePath="..\..\shared\common\ThreadQueue.cpp"
|
|
878
|
+
>
|
|
879
|
+
</File>
|
|
880
|
+
<File
|
|
881
|
+
RelativePath="..\..\shared\common\ThreadQueue.h"
|
|
882
|
+
>
|
|
883
|
+
</File>
|
|
876
884
|
<File
|
|
877
885
|
RelativePath="..\..\shared\common\Tokenizer.cpp"
|
|
878
886
|
>
|
|
@@ -41,6 +41,10 @@ HREGNOTIFY g_hNotify = NULL;
|
|
|
41
41
|
|
|
42
42
|
#endif
|
|
43
43
|
|
|
44
|
+
#ifdef OS_WINDOWS
|
|
45
|
+
String httpProxy;
|
|
46
|
+
#endif
|
|
47
|
+
|
|
44
48
|
class CRhodesModule : public CAtlExeModuleT< CRhodesModule >
|
|
45
49
|
{
|
|
46
50
|
public :
|
|
@@ -49,13 +53,24 @@ public :
|
|
|
49
53
|
TCHAR szTokens[] = _T("-/");
|
|
50
54
|
LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
|
|
51
55
|
getRhoRootPath();
|
|
56
|
+
|
|
52
57
|
while (lpszToken != NULL)
|
|
53
58
|
{
|
|
54
59
|
if (WordCmpI(lpszToken, _T("Restarting"))==0) {
|
|
55
60
|
m_nRestarting = 10;
|
|
56
61
|
}
|
|
62
|
+
|
|
57
63
|
#if defined(OS_WINDOWS)
|
|
58
|
-
|
|
64
|
+
if (wcsncmp(lpszToken, _T("http_proxy"),10)==0) {
|
|
65
|
+
char *token = wce_wctomb(lpszToken);
|
|
66
|
+
char *proxy =parseToken(token,strlen(token));
|
|
67
|
+
|
|
68
|
+
httpProxy = proxy;
|
|
69
|
+
|
|
70
|
+
free(proxy);
|
|
71
|
+
free(token);
|
|
72
|
+
|
|
73
|
+
} else if (wcsncmp(lpszToken, _T("approot"),7)==0) {
|
|
59
74
|
char* token = wce_wctomb(lpszToken);
|
|
60
75
|
//parseToken will allocate extra byte at the end of the returned token value
|
|
61
76
|
char* path = parseToken( token, strlen(token) );
|
|
@@ -114,6 +129,12 @@ public :
|
|
|
114
129
|
rho_logconf_Init(m_strRootPath.c_str());
|
|
115
130
|
LOG(INFO) + "Rhodes started";
|
|
116
131
|
|
|
132
|
+
#ifdef OS_WINDOWS
|
|
133
|
+
if (httpProxy.length() > 0)
|
|
134
|
+
parseHttpProxyURI(httpProxy);
|
|
135
|
+
#endif
|
|
136
|
+
|
|
137
|
+
|
|
117
138
|
::SetThreadPriority(GetCurrentThread(),10);
|
|
118
139
|
|
|
119
140
|
//Check for bundle directory is exists.
|
|
@@ -239,6 +260,127 @@ public :
|
|
|
239
260
|
return m_strRootPath;
|
|
240
261
|
}
|
|
241
262
|
|
|
263
|
+
void parseHttpProxyURI(const rho::String &http_proxy)
|
|
264
|
+
{
|
|
265
|
+
// http://<login>:<passwod>@<host>:<port>
|
|
266
|
+
const char *default_port = "8080";
|
|
267
|
+
|
|
268
|
+
int index = http_proxy.find("http://", 0, 7);
|
|
269
|
+
if (index == string::npos) {
|
|
270
|
+
LOG(ERROR) + "http proxy url should starts with \"http://\"";
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
index = 7;
|
|
274
|
+
|
|
275
|
+
enum {
|
|
276
|
+
ST_START,
|
|
277
|
+
ST_LOGIN,
|
|
278
|
+
ST_PASSWORD,
|
|
279
|
+
ST_HOST,
|
|
280
|
+
ST_PORT,
|
|
281
|
+
ST_FINISH
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
String token, login, password, host, port;
|
|
285
|
+
char c, state = ST_START, prev_state = state;
|
|
286
|
+
int length = http_proxy.length();
|
|
287
|
+
|
|
288
|
+
for (int i = index; i < length; i++) {
|
|
289
|
+
c = http_proxy[i];
|
|
290
|
+
|
|
291
|
+
switch (state) {
|
|
292
|
+
case ST_START:
|
|
293
|
+
if (c == '@') {
|
|
294
|
+
prev_state = state; state = ST_HOST;
|
|
295
|
+
} else if (c == ':') {
|
|
296
|
+
prev_state = state; state = ST_PASSWORD;
|
|
297
|
+
} else {
|
|
298
|
+
token +=c;
|
|
299
|
+
state = ST_HOST;
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
case ST_HOST:
|
|
303
|
+
if (c == ':') {
|
|
304
|
+
host = token; token.clear();
|
|
305
|
+
prev_state = state; state = ST_PORT;
|
|
306
|
+
} else if (c == '@') {
|
|
307
|
+
host = token; token.clear();
|
|
308
|
+
prev_state = state; state = ST_LOGIN;
|
|
309
|
+
} else {
|
|
310
|
+
token += c;
|
|
311
|
+
if (i == (length - 1)) {
|
|
312
|
+
host = token; token.clear();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
break;
|
|
316
|
+
case ST_PORT:
|
|
317
|
+
if (c == '@') {
|
|
318
|
+
port = token; token.clear();
|
|
319
|
+
prev_state = state; state = ST_LOGIN;
|
|
320
|
+
} else {
|
|
321
|
+
token += c;
|
|
322
|
+
if (i == (length - 1)) {
|
|
323
|
+
port = token; token.clear();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
case ST_LOGIN:
|
|
328
|
+
if (prev_state == ST_PORT || prev_state == ST_HOST) {
|
|
329
|
+
login = host; host.clear();
|
|
330
|
+
password = port; port.clear();
|
|
331
|
+
prev_state = state; state = ST_HOST;
|
|
332
|
+
token += c;
|
|
333
|
+
} else {
|
|
334
|
+
token += c;
|
|
335
|
+
if (i == (length - 1)) {
|
|
336
|
+
login = token; token.clear();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
340
|
+
case ST_PASSWORD:
|
|
341
|
+
if (c == '@') {
|
|
342
|
+
password = token; token.clear();
|
|
343
|
+
prev_state = state; state = ST_HOST;
|
|
344
|
+
} else {
|
|
345
|
+
token += c;
|
|
346
|
+
if (i == (length - 1)) {
|
|
347
|
+
password = token; token.clear();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
default:
|
|
352
|
+
;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
LOG(INFO) + "Setting up HTTP proxy:";
|
|
357
|
+
LOG(INFO) + "URI: " + http_proxy;
|
|
358
|
+
LOG(INFO) + "HTTP proxy login = " + login;
|
|
359
|
+
LOG(INFO) + "HTTP proxy password = " + password;
|
|
360
|
+
LOG(INFO) + "HTTP proxy host = " + host;
|
|
361
|
+
LOG(INFO) + "HTTP proxy port = " + port;
|
|
362
|
+
|
|
363
|
+
if (host.length()) {
|
|
364
|
+
RHOCONF().setString ("http_proxy_host", host);
|
|
365
|
+
|
|
366
|
+
if (port.length()){
|
|
367
|
+
RHOCONF().setString ("http_proxy_port", port);
|
|
368
|
+
} else {
|
|
369
|
+
LOG(WARNING) + "there is no proxy port defined";
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (login.length())
|
|
373
|
+
RHOCONF().setString ("http_proxy_login", login);
|
|
374
|
+
|
|
375
|
+
if (password.length())
|
|
376
|
+
RHOCONF().setString ("http_proxy_password", password);
|
|
377
|
+
|
|
378
|
+
} else {
|
|
379
|
+
LOG(ERROR) + "empty host name in HTTP-proxy URL";
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
}
|
|
383
|
+
|
|
242
384
|
private:
|
|
243
385
|
CMainWindow m_appWindow;
|
|
244
386
|
rho::String m_strRootPath;
|