rhodes 3.0.0 → 3.0.1.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Rakefile +9 -2
- data/doc/application.txt +1 -1
- data/doc/build.txt +49 -70
- data/doc/device-caps.txt +22 -97
- data/doc/extensions.txt +1 -1
- data/doc/nfc.txt +542 -0
- data/doc/rhom.txt +7 -5
- data/doc/simulator.txt +116 -0
- data/doc/ui.txt +1 -1
- data/lib/build/jake.rb +5 -5
- data/lib/extensions/debugger/debugger.rb +63 -35
- data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +8 -6
- data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +1070 -249
- data/lib/extensions/nfc/ext/nfc/platform/android/res/xml/filter_nfc.xml +1 -5
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +894 -72
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java +82 -18
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessage.java +65 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcRecord.java +88 -24
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java +3 -0
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +204 -3
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +1047 -5
- data/lib/extensions/nfc/nfc.rb +635 -91
- data/lib/extensions/rhoxml/rexml/encodings/CP-1252.rb +103 -0
- data/lib/extensions/rhoxml/rexml/encodings/ISO-8859-1.rb +7 -0
- data/lib/framework/dateME.rb +26 -0
- data/lib/framework/rho/render.rb +21 -9
- data/lib/framework/rho/rho.rb +12 -0
- data/lib/framework/rho/rhoevent_bb.rb +3 -0
- data/lib/framework/rho/rhoevent_c.rb +3 -0
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhom/rhom_db_adapter.rb +9 -9
- data/lib/framework/rhosystem.rb +17 -0
- data/lib/framework/stringio.rb +18 -0
- 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/res/xml/filter_nfc.xml +1 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +0 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +10 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +29 -18
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +67 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivityListener.java +14 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +102 -28
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +35 -66
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +5 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +69 -41
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +7 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +68 -35
- data/platform/android/build/RhodesSRC_build.files +1 -0
- data/platform/android/build/android.rake +2 -2
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +1 -0
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +18 -6
- data/platform/bb/build/bb.rake +1 -1
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +5 -4
- data/platform/iphone/Classes/SimpleMainView.m +1 -1
- data/platform/iphone/Info.plist +1 -1
- data/platform/shared/common/RhodesApp.cpp +9 -3
- data/platform/shared/curl/lib/rhossl.c +5 -2
- data/platform/shared/db/DBAdapter.cpp +9 -0
- data/platform/shared/net/CURLNetRequest.cpp +8 -3
- data/platform/shared/net/iphone/sslimpl.cpp +3 -2
- data/platform/shared/net/ssl.cpp +8 -0
- data/platform/shared/ruby/ext/rho/rhoruby.c +10 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
- data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +3 -4
- data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
- data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
- data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
- data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
- data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
- data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
- data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
- data/platform/win32/RhoSimulator/libeay32.dll +0 -0
- data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
- data/platform/wm/build/wm.rake +27 -3
- data/platform/wm/rhodes/Rhodes.cpp +4 -0
- data/platform/wm/rhodes/emulator/MainWindowCallback.h +1 -0
- data/platform/wm/rhodes/emulator/MainWindowProxy.cpp +3 -1
- data/platform/wm/rhodes/emulator/MainWindowQt.cpp +23 -12
- data/platform/wm/rhodes/emulator/MainWindowQt.h +5 -1
- data/platform/wm/rhodes/emulator/QtMainWindow.cpp +39 -6
- data/platform/wm/rhodes/emulator/QtMainWindow.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +5 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.Libraries.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.dll +0 -0
- data/platform/wp7/IronRuby/bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.Core.dll +0 -0
- data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.dll +0 -0
- data/platform/wp7/RhoAppRunner/Program.cs +2 -2
- data/platform/wp7/RhoRubyLib/RhoRuby.cs +8 -0
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +29 -7
- data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +5 -2
- data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +12 -0
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +2 -0
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +1 -1
- data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +52 -7
- data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +85 -18
- data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +38 -3
- data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +27 -2
- data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +111 -15
- data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +330 -55
- data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +61 -4
- data/platform/wp7/build/wp.rake +89 -72
- data/platform/wp7/rhodes/App.xaml.cs +1 -1
- data/rakefile.rb +9 -2
- data/rhodes.gemspec +1 -3
- data/spec/phone_spec/app/spec/asynchttp_spec.rb +7 -9
- data/spec/phone_spec/app/spec/uri_spec.rb +75 -0
- data/spec/phone_spec/app/spec_runner.rb +4 -0
- metadata +21 -15
- data/Manifest.txt +0 -6403
- data/platform/win32/RhoSimulator/codecs/qcncodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qjpcodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qkrcodecs4.dll +0 -0
- data/platform/win32/RhoSimulator/codecs/qtwcodecs4.dll +0 -0
- data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
data/platform/iphone/Info.plist
CHANGED
@@ -296,8 +296,11 @@ void CRhodesApp::run()
|
|
296
296
|
LOG(INFO) + "RhodesApp thread shutdown";
|
297
297
|
|
298
298
|
rubyext::CGeoLocation::Destroy();
|
299
|
-
RhoRubyStop();
|
300
299
|
sync::CSyncThread::Destroy();
|
300
|
+
|
301
|
+
net::CAsyncHttp::Destroy();
|
302
|
+
|
303
|
+
RhoRubyStop();
|
301
304
|
}
|
302
305
|
|
303
306
|
CRhodesApp::~CRhodesApp(void)
|
@@ -341,7 +344,7 @@ void CRhodesApp::stopApp()
|
|
341
344
|
stop(2000);
|
342
345
|
}
|
343
346
|
|
344
|
-
net::CAsyncHttp::Destroy();
|
347
|
+
// net::CAsyncHttp::Destroy();
|
345
348
|
}
|
346
349
|
|
347
350
|
template <typename T>
|
@@ -958,7 +961,10 @@ boolean CRhodesApp::sendLog()
|
|
958
961
|
|
959
962
|
boolean bOldSaveToFile = LOGCONF().isLogToFile();
|
960
963
|
LOGCONF().setLogToFile(false);
|
961
|
-
|
964
|
+
NetRequest oNetRequest;
|
965
|
+
oNetRequest.setSslVerifyPeer(false);
|
966
|
+
|
967
|
+
NetResponse resp = getNetRequest(&oNetRequest).pushMultipartData( strQuery, oItem, &(rho::sync::CSyncThread::getSyncEngine()), null );
|
962
968
|
LOGCONF().setLogToFile(bOldSaveToFile);
|
963
969
|
|
964
970
|
if ( !resp.isOK() )
|
@@ -142,8 +142,11 @@ void Curl_rhossl_close(struct connectdata *conn, int sockindex)
|
|
142
142
|
int Curl_rhossl_shutdown(struct connectdata *conn, int sockindex)
|
143
143
|
{
|
144
144
|
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
|
145
|
-
|
146
|
-
|
145
|
+
if(connssl->storage != 0) {
|
146
|
+
rho_ssl_shutdown(connssl->storage);
|
147
|
+
rho_ssl_free_storage(connssl->storage);
|
148
|
+
connssl->storage = NULL;
|
149
|
+
}
|
147
150
|
return 0;
|
148
151
|
}
|
149
152
|
|
@@ -975,6 +975,15 @@ int rho_db_open(const char* szDBPath, const char* szDBPartition, void** ppDB)
|
|
975
975
|
return 0;
|
976
976
|
}
|
977
977
|
|
978
|
+
int rho_db_close(void* pDB)
|
979
|
+
{
|
980
|
+
rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
|
981
|
+
db.close();
|
982
|
+
|
983
|
+
//TODO: get error code from DBException
|
984
|
+
return 0;
|
985
|
+
}
|
986
|
+
|
978
987
|
int rho_db_startTransaction(void* pDB)
|
979
988
|
{
|
980
989
|
rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
|
@@ -171,7 +171,7 @@ INetResponse* CURLNetRequest::doRequest(const char *method, const String& strUrl
|
|
171
171
|
Hashtable<String,String>* pHeaders)
|
172
172
|
{
|
173
173
|
INetResponse* pResp = doPull(method, strUrl, strBody, null, oSession, pHeaders);
|
174
|
-
|
174
|
+
return pResp;
|
175
175
|
}
|
176
176
|
|
177
177
|
CURLcode CURLNetRequest::doCURLPerform(const String& strUrl)
|
@@ -198,8 +198,12 @@ INetResponse* CURLNetRequest::doPull(const char* method, const String& strUrl,
|
|
198
198
|
if (oFile)
|
199
199
|
nStartFrom = oFile->size();
|
200
200
|
|
201
|
-
if( !net::URI::isLocalHost(strUrl.c_str()) )
|
202
|
-
|
201
|
+
if( !net::URI::isLocalHost(strUrl.c_str()) )
|
202
|
+
{
|
203
|
+
//Log every non localhost requests
|
204
|
+
RAWLOG_INFO2("%s request (Pull): %s", method, strUrl.c_str());
|
205
|
+
rho_net_impl_network_indicator(1);
|
206
|
+
}
|
203
207
|
|
204
208
|
Hashtable<String,String> h;
|
205
209
|
if (pHeaders)
|
@@ -277,6 +281,7 @@ INetResponse* CURLNetRequest::pushMultipartData(const String& strUrl, VectorPtr<
|
|
277
281
|
int nRespCode = -1;
|
278
282
|
String strRespBody;
|
279
283
|
|
284
|
+
RAWLOG_INFO1("POST request (Push): %s", strUrl.c_str());
|
280
285
|
rho_net_impl_network_indicator(1);
|
281
286
|
|
282
287
|
curl_slist *hdrs = m_curl.set_options("POST", strUrl, String(), oSession, pHeaders);
|
@@ -39,12 +39,13 @@ static void report_error(const char *s, CFStreamError *e)
|
|
39
39
|
|
40
40
|
void * SSLImpl::createStorage()
|
41
41
|
{
|
42
|
-
return
|
42
|
+
return calloc(1, sizeof(ssl_data_t));
|
43
43
|
}
|
44
44
|
|
45
45
|
void SSLImpl::freeStorage(void *ptr)
|
46
46
|
{
|
47
|
-
|
47
|
+
if (ptr)
|
48
|
+
free(ptr);
|
48
49
|
}
|
49
50
|
|
50
51
|
CURLcode SSLImpl::connect(int sockfd, int nonblocking, int *done, int ssl_verify_peer, void *storage)
|
data/platform/shared/net/ssl.cpp
CHANGED
@@ -1,37 +1,45 @@
|
|
1
1
|
#include "net/ssl.h"
|
2
2
|
#include "common/IRhoClassFactory.h"
|
3
3
|
|
4
|
+
#include "logging/RhoLog.h"
|
5
|
+
|
4
6
|
extern "C" {
|
5
7
|
|
6
8
|
#define GETSSL rho_get_RhoClassFactory()->createSSLEngine()
|
7
9
|
|
8
10
|
void *rho_ssl_create_storage()
|
9
11
|
{
|
12
|
+
RAWTRACEC("rho_ssl", "rho_ssl_create_storage");
|
10
13
|
return GETSSL->createStorage();
|
11
14
|
}
|
12
15
|
|
13
16
|
void rho_ssl_free_storage(void *ptr)
|
14
17
|
{
|
18
|
+
RAWTRACEC("rho_ssl", "rho_ssl_free_storage");
|
15
19
|
return GETSSL->freeStorage(ptr);
|
16
20
|
}
|
17
21
|
|
18
22
|
CURLcode rho_ssl_connect(int sockfd, int nonblocking, int *done, int ssl_verify_peer, void *storage)
|
19
23
|
{
|
24
|
+
RAWTRACEC("rho_ssl", "rho_ssl_connect");
|
20
25
|
return GETSSL->connect(sockfd, nonblocking, done, ssl_verify_peer, storage);
|
21
26
|
}
|
22
27
|
|
23
28
|
void rho_ssl_shutdown(void *storage)
|
24
29
|
{
|
30
|
+
RAWTRACEC("rho_ssl", "rho_ssl_shutdown");
|
25
31
|
return GETSSL->shutdown(storage);
|
26
32
|
}
|
27
33
|
|
28
34
|
ssize_t rho_ssl_send(const void *mem, size_t len, void *storage)
|
29
35
|
{
|
36
|
+
RAWTRACEC("rho_ssl", "rho_ssl_send");
|
30
37
|
return GETSSL->send(mem, len, storage);
|
31
38
|
}
|
32
39
|
|
33
40
|
ssize_t rho_ssl_recv(char *buf, size_t size, int *wouldblock, void *storage)
|
34
41
|
{
|
42
|
+
RAWTRACEC("rho_ssl", "rho_ssl_recv");
|
35
43
|
return GETSSL->recv(buf, size, wouldblock, storage);
|
36
44
|
}
|
37
45
|
|
@@ -501,6 +501,16 @@ int rho_ruby_unpack_byte_array(VALUE array_value, unsigned char* buf, int max_le
|
|
501
501
|
return size;
|
502
502
|
}
|
503
503
|
|
504
|
+
int rho_ruby_array_get_size(VALUE ar) {
|
505
|
+
int size = 0;
|
506
|
+
if (TYPE(ar) != T_ARRAY) {
|
507
|
+
return -1;
|
508
|
+
}
|
509
|
+
size = RARRAY_LEN(ar);
|
510
|
+
return size;
|
511
|
+
}
|
512
|
+
|
513
|
+
|
504
514
|
|
505
515
|
|
506
516
|
VALUE rho_ruby_createHash() {
|
@@ -54,6 +54,7 @@ VALUE addStrToHashLen(VALUE hash, const char* key, const char* val, int len);
|
|
54
54
|
VALUE addHashToHash(VALUE hash, const char* key, VALUE val);
|
55
55
|
VALUE rho_ruby_hash_aref(VALUE hash, const char* key);
|
56
56
|
VALUE rho_ruby_array_get(VALUE ar, int nIndex);
|
57
|
+
int rho_ruby_array_get_size(VALUE ar);
|
57
58
|
|
58
59
|
char* getStringFromValue(VALUE val);
|
59
60
|
int getStringLenFromValue(VALUE val);
|
@@ -9,7 +9,7 @@ static VALUE mSqlite3;
|
|
9
9
|
static VALUE mDatabase;
|
10
10
|
|
11
11
|
extern int rho_db_open(const char* szDBPath, const char* szDBPartition, void** ppDB);
|
12
|
-
|
12
|
+
extern int rho_db_close(void* pDB);
|
13
13
|
extern int rho_db_startTransaction(void* pDB);
|
14
14
|
extern int rho_db_commitTransaction(void* pDB);
|
15
15
|
extern int rho_db_rollbackTransaction(void* pDB);
|
@@ -60,9 +60,8 @@ static VALUE db_close(int argc, VALUE *argv, VALUE self){
|
|
60
60
|
|
61
61
|
Data_Get_Struct(self, void *, ppDB);
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
rc = rho_db_close(*ppDB);
|
64
|
+
|
66
65
|
return INT2NUM(rc);
|
67
66
|
}
|
68
67
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/platform/wm/build/wm.rake
CHANGED
@@ -163,6 +163,12 @@ namespace "build" do
|
|
163
163
|
task :rhosimulator => ["config:set_win32_platform", "config:wm"] do
|
164
164
|
chdir $config["build"]["wmpath"]
|
165
165
|
|
166
|
+
qtdir = ENV['QTDIR']
|
167
|
+
unless (qtdir !~/^\s*$/) and File.directory?(qtdir)
|
168
|
+
puts "\nPlease, set QTDIR environment variable to Qt root directory path"
|
169
|
+
exit 1
|
170
|
+
end
|
171
|
+
|
166
172
|
args = ['/M4', 'rhodes.sln', '"EmulatorRelease|win32"']
|
167
173
|
puts "\nThe following step may take several minutes or more to complete depending on your processor speed\n\n"
|
168
174
|
puts Jake.run($vcbuild,args)
|
@@ -173,9 +179,27 @@ namespace "build" do
|
|
173
179
|
puts "Error building"
|
174
180
|
exit 1
|
175
181
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
182
|
+
|
183
|
+
target_path = File.join( $startdir, "platform/win32/RhoSimulator/")
|
184
|
+
if not File.directory?(target_path)
|
185
|
+
Dir.mkdir(target_path)
|
186
|
+
end
|
187
|
+
cp File.join($startdir, $vcbindir, "win32/rhodes/EmulatorRelease/rhosimulator.exe"), target_path
|
188
|
+
|
189
|
+
cp File.join(qtdir, "bin/QtCore4.dll"), target_path
|
190
|
+
cp File.join(qtdir, "bin/QtGui4.dll"), target_path
|
191
|
+
cp File.join(qtdir, "bin/QtNetwork4.dll"), target_path
|
192
|
+
cp File.join(qtdir, "bin/QtWebKit4.dll"), target_path
|
193
|
+
target_if_path = File.join(target_path, 'imageformats/')
|
194
|
+
if not File.directory?(target_if_path)
|
195
|
+
Dir.mkdir(target_if_path)
|
196
|
+
end
|
197
|
+
cp File.join(qtdir, "plugins/imageformats/qgif4.dll"), target_if_path
|
198
|
+
cp File.join(qtdir, "plugins/imageformats/qico4.dll"), target_if_path
|
199
|
+
cp File.join(qtdir, "plugins/imageformats/qjpeg4.dll"), target_if_path
|
200
|
+
cp File.join(qtdir, "plugins/imageformats/qmng4.dll"), target_if_path
|
201
|
+
cp File.join(qtdir, "plugins/imageformats/qsvg4.dll"), target_if_path
|
202
|
+
cp File.join(qtdir, "plugins/imageformats/qtiff4.dll"), target_if_path
|
179
203
|
end
|
180
204
|
|
181
205
|
end
|
@@ -11,6 +11,7 @@ public:
|
|
11
11
|
virtual void logEvent(const ::std::string& message) = 0;
|
12
12
|
virtual void createCustomMenu(void) = 0;
|
13
13
|
virtual void onCustomMenuItemCommand(int nItemPos) = 0;
|
14
|
+
virtual void onWindowClose(void) = 0;
|
14
15
|
protected:
|
15
16
|
virtual ~IMainWindowCallback() {};
|
16
17
|
};
|
@@ -33,7 +33,7 @@ CMainWindowProxy::~CMainWindowProxy(void)
|
|
33
33
|
void CMainWindowProxy::navigate(const wchar_t* url)
|
34
34
|
{
|
35
35
|
LOG(INFO) + "navigate: '"+url+"'";
|
36
|
-
((QtMainWindow*)qtMainWindow)->navigate(
|
36
|
+
((QtMainWindow*)qtMainWindow)->navigate(QString::fromWCharArray(url));
|
37
37
|
}
|
38
38
|
|
39
39
|
void CMainWindowProxy::setCallback(IMainWindowCallback* callback)
|
@@ -44,6 +44,8 @@ void CMainWindowProxy::setCallback(IMainWindowCallback* callback)
|
|
44
44
|
void* CMainWindowProxy::init(IMainWindowCallback* callback, const wchar_t* title)
|
45
45
|
{
|
46
46
|
int argc = 0;
|
47
|
+
QCoreApplication::setOrganizationName("Rhomobile");
|
48
|
+
QCoreApplication::setApplicationName("RhoSimulator");
|
47
49
|
qtApplication = (void*)new QApplication(argc, 0);
|
48
50
|
qtMainWindow = (void*)new QtMainWindow();
|
49
51
|
((QtMainWindow*)qtMainWindow)->setWindowTitle(QString::fromWCharArray(title));
|
@@ -20,6 +20,8 @@ extern "C" void rho_geoimpl_turngpsoff();
|
|
20
20
|
int CMainWindow::m_screenWidth;
|
21
21
|
int CMainWindow::m_screenHeight;
|
22
22
|
|
23
|
+
bool CMainWindow::mainWindowClosed = false;
|
24
|
+
|
23
25
|
CMainWindow::CMainWindow() { }
|
24
26
|
|
25
27
|
CMainWindow::~CMainWindow() { }
|
@@ -114,6 +116,15 @@ void CMainWindow::onCustomMenuItemCommand(int nItemPos)
|
|
114
116
|
oMenuItem.processCommand();
|
115
117
|
}
|
116
118
|
|
119
|
+
void CMainWindow::DestroyUi(void)
|
120
|
+
{
|
121
|
+
rho_rhodesapp_callUiDestroyedCallback();
|
122
|
+
}
|
123
|
+
|
124
|
+
void CMainWindow::onWindowClose(void)
|
125
|
+
{
|
126
|
+
mainWindowClosed = true;
|
127
|
+
}
|
117
128
|
|
118
129
|
// **************************************************************************
|
119
130
|
//
|
@@ -138,8 +149,6 @@ LRESULT CMainWindow::OnExecuteRunnable(UINT /*uMsg*/, WPARAM wParam, LPARAM lPar
|
|
138
149
|
|
139
150
|
LRESULT CMainWindow::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
|
140
151
|
{
|
141
|
-
rho_rhodesapp_callUiDestroyedCallback();
|
142
|
-
|
143
152
|
if(m_logView.IsWindow()) {
|
144
153
|
m_logView.DestroyWindow();
|
145
154
|
}
|
@@ -147,8 +156,8 @@ LRESULT CMainWindow::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam
|
|
147
156
|
|
148
157
|
if (m_alertDialog && m_alertDialog->IsWindow() )
|
149
158
|
m_alertDialog->DestroyWindow();
|
150
|
-
if (m_SyncStatusDlg
|
151
|
-
m_SyncStatusDlg
|
159
|
+
if (m_SyncStatusDlg && m_SyncStatusDlg->IsWindow() )
|
160
|
+
m_SyncStatusDlg->DestroyWindow();
|
152
161
|
|
153
162
|
PostQuitMessage(0);
|
154
163
|
|
@@ -256,18 +265,20 @@ LRESULT CMainWindow::OnAlertShowPopup (UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
|
|
256
265
|
StringW strAppName = RHODESAPP().getAppNameW();
|
257
266
|
CAlertDialog::Params *params = (CAlertDialog::Params *)lParam;
|
258
267
|
|
259
|
-
|
268
|
+
if (params->m_dlgType == CAlertDialog::Params::DLG_STATUS)
|
260
269
|
{
|
261
|
-
m_SyncStatusDlg
|
262
|
-
|
263
|
-
|
264
|
-
|
270
|
+
if (m_SyncStatusDlg == NULL)
|
271
|
+
m_SyncStatusDlg = new CSyncStatusDlg();
|
272
|
+
m_SyncStatusDlg->setStatusText(convertToStringW(params->m_message).c_str());
|
273
|
+
m_SyncStatusDlg->setTitle( convertToStringW(params->m_title).c_str() );
|
274
|
+
if ( !m_SyncStatusDlg->m_hWnd )
|
275
|
+
m_SyncStatusDlg->Create(m_hWnd, 0);
|
265
276
|
else
|
266
277
|
{
|
267
|
-
m_SyncStatusDlg
|
268
|
-
m_SyncStatusDlg
|
278
|
+
m_SyncStatusDlg->ShowWindow(SW_SHOW);
|
279
|
+
m_SyncStatusDlg->BringWindowToTop();
|
269
280
|
}
|
270
|
-
}else if (params->m_dlgType == CAlertDialog::Params::DLG_DEFAULT) {
|
281
|
+
} else if (params->m_dlgType == CAlertDialog::Params::DLG_DEFAULT) {
|
271
282
|
MessageBox(convertToStringW(params->m_message).c_str(), strAppName.c_str(), MB_ICONWARNING | MB_OK);
|
272
283
|
} else if (params->m_dlgType == CAlertDialog::Params::DLG_CUSTOM)
|
273
284
|
{
|
@@ -44,14 +44,18 @@ public:
|
|
44
44
|
virtual void logEvent(const ::std::string& message);
|
45
45
|
virtual void createCustomMenu(void);
|
46
46
|
virtual void onCustomMenuItemCommand(int nItemPos);
|
47
|
+
virtual void onWindowClose(void);
|
47
48
|
// public methods:
|
48
49
|
void Navigate2(BSTR URL);
|
49
50
|
HWND Initialize(const wchar_t* title);
|
50
51
|
void MessageLoop(void);
|
52
|
+
void DestroyUi(void);
|
51
53
|
void performOnUiThread(rho::common::IRhoRunnable* pTask);
|
52
54
|
CNativeToolbar& getToolbar(){ return m_toolbar; }
|
53
55
|
CMainWindowProxy &getProxy(){ return m_mainWindowProxy; }
|
54
56
|
HWND getWebViewHWND();
|
57
|
+
// for 'main_window_closed' System property
|
58
|
+
static bool mainWindowClosed;
|
55
59
|
|
56
60
|
BEGIN_MSG_MAP(CMainWindow)
|
57
61
|
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
@@ -110,7 +114,7 @@ public:
|
|
110
114
|
private:
|
111
115
|
rho::Vector<rho::common::CAppMenuItem> m_arAppMenuItems;
|
112
116
|
CAlertDialog *m_alertDialog;
|
113
|
-
CSyncStatusDlg m_SyncStatusDlg;
|
117
|
+
CSyncStatusDlg *m_SyncStatusDlg;
|
114
118
|
};
|
115
119
|
|
116
120
|
#if !defined(_WIN32_WCE)
|
@@ -3,11 +3,20 @@
|
|
3
3
|
#include "ui_QtMainWindow.h"
|
4
4
|
#include "ExternalWebView.h"
|
5
5
|
#include <QResizeEvent>
|
6
|
+
#include <QWebFrame>
|
7
|
+
#include <QWebSettings>
|
8
|
+
#include <QWebSecurityOrigin>
|
9
|
+
#include "ext/rho/rhoruby.h"
|
6
10
|
#include "common/RhoStd.h"
|
7
11
|
#include "common/RhodesApp.h"
|
8
12
|
#include "rubyext/WebView.h"
|
9
13
|
#undef null
|
10
14
|
|
15
|
+
extern "C" {
|
16
|
+
extern VALUE rb_thread_main(void);
|
17
|
+
extern VALUE rb_thread_wakeup(VALUE thread);
|
18
|
+
}
|
19
|
+
|
11
20
|
QtMainWindow::QtMainWindow(QWidget *parent) :
|
12
21
|
QMainWindow(parent),
|
13
22
|
ui(new Ui::QtMainWindow),
|
@@ -15,8 +24,22 @@ QtMainWindow::QtMainWindow(QWidget *parent) :
|
|
15
24
|
cb(NULL)
|
16
25
|
{
|
17
26
|
ui->setupUi(this);
|
18
|
-
|
27
|
+
|
28
|
+
QWebSettings* qs = QWebSettings::globalSettings(); //this->ui->webView->settings();
|
29
|
+
qs->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
|
30
|
+
qs->setAttribute(QWebSettings::LocalStorageEnabled, true);
|
31
|
+
qs->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
|
32
|
+
qs->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
|
33
|
+
qs->setOfflineStorageDefaultQuota(1024*1024*1024);
|
34
|
+
|
35
|
+
rho::String rs_dir = RHODESAPP().getRhoRootPath()+RHO_EMULATOR_DIR;
|
36
|
+
qs->setOfflineWebApplicationCachePath(rs_dir.c_str());
|
37
|
+
qs->setLocalStoragePath(rs_dir.c_str());
|
38
|
+
qs->setOfflineStoragePath(rs_dir.c_str());
|
39
|
+
|
19
40
|
this->ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
41
|
+
this->ui->webView->page()->mainFrame()->securityOrigin().setDatabaseQuota(1024*1024*1024);
|
42
|
+
|
20
43
|
this->move(0,0);
|
21
44
|
this->ui->toolBar->hide();
|
22
45
|
this->ui->toolBarRight->hide();
|
@@ -52,7 +75,9 @@ void QtMainWindow::showEvent(QShowEvent *)
|
|
52
75
|
|
53
76
|
void QtMainWindow::closeEvent(QCloseEvent *ce)
|
54
77
|
{
|
55
|
-
|
78
|
+
rb_thread_wakeup(rb_thread_main());
|
79
|
+
if (cb) cb->onWindowClose();
|
80
|
+
wi->close();
|
56
81
|
QMainWindow::closeEvent(ce);
|
57
82
|
}
|
58
83
|
|
@@ -76,8 +101,11 @@ void QtMainWindow::on_webView_linkClicked(const QUrl& url)
|
|
76
101
|
externalWebView->navigate(QUrl(sUrl.remove("rho_open_target=_blank")));
|
77
102
|
externalWebView->show();
|
78
103
|
externalWebView->activateWindow();
|
79
|
-
} else
|
80
|
-
|
104
|
+
} else {
|
105
|
+
sUrl.remove(QRegExp("#+$"));
|
106
|
+
if (sUrl.compare(ui->webView->url().toString())!=0)
|
107
|
+
ui->webView->load(QUrl(sUrl));
|
108
|
+
}
|
81
109
|
}
|
82
110
|
|
83
111
|
void QtMainWindow::on_webView_loadStarted()
|
@@ -100,9 +128,14 @@ void QtMainWindow::on_menuMain_aboutToShow()
|
|
100
128
|
if (cb) cb->createCustomMenu();
|
101
129
|
}
|
102
130
|
|
103
|
-
void QtMainWindow::navigate(
|
131
|
+
void QtMainWindow::navigate(QString url)
|
104
132
|
{
|
105
|
-
|
133
|
+
if (url.startsWith("javascript:", Qt::CaseInsensitive)) {
|
134
|
+
url.remove(0,11);
|
135
|
+
ui->webView->stop();
|
136
|
+
ui->webView->page()->mainFrame()->evaluateJavaScript(url);
|
137
|
+
} else
|
138
|
+
ui->webView->load(QUrl(url));
|
106
139
|
}
|
107
140
|
|
108
141
|
void QtMainWindow::GoBack(void)
|