rhodes 1.5.0 → 1.5.1
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 +5 -0
- data/bin/rhogen +3 -3
- data/lib/build/jake.rb +31 -22
- data/lib/framework/rhodes.rb +2 -2
- data/lib/framework/version.rb +2 -2
- data/lib/rhodes.rb +2 -2
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/bb/build/bb.rake +2 -21
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +3 -0
- data/platform/iphone/Classes/WebViewController.m +5 -3
- data/platform/iphone/Info.plist +1 -1
- data/platform/shared/common/RhoStd.h +5 -0
- data/platform/shared/common/RhodesApp.cpp +4 -3
- data/platform/shared/net/AsyncHttp.cpp +54 -24
- data/platform/shared/net/AsyncHttp.h +7 -5
- data/platform/shared/ruby/wince/io_wce.c +2 -2
- data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +50 -19
- data/platform/shared/sync/SyncNotify.cpp +2 -1
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +11 -0
- metadata +51 -24
data/CHANGELOG
CHANGED
data/bin/rhogen
CHANGED
|
@@ -21,10 +21,10 @@ class String
|
|
|
21
21
|
return self
|
|
22
22
|
end
|
|
23
23
|
def encoding
|
|
24
|
-
if Encoding.responds_to?('new')
|
|
25
|
-
Encoding.new
|
|
24
|
+
if RUBY_VERSION =~ /1\.8/ and Encoding.responds_to?('new')
|
|
25
|
+
Encoding.new
|
|
26
26
|
else
|
|
27
|
-
Encoding.default_external
|
|
27
|
+
Encoding.default_external
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
data/lib/build/jake.rb
CHANGED
|
@@ -93,53 +93,62 @@ class Jake
|
|
|
93
93
|
|
|
94
94
|
conf
|
|
95
95
|
end
|
|
96
|
-
|
|
97
|
-
def self.run(command, args, wd=nil,system = false, hideerrors = false)
|
|
98
|
-
argv = []
|
|
99
|
-
currentdir = ""
|
|
100
|
-
retval = ""
|
|
101
|
-
argv << command
|
|
102
|
-
argv += args
|
|
103
|
-
argv.map! { |x| x.to_s }.map! { |x| x =~ /^".*"$/ ? x[1..-2] : x }
|
|
104
96
|
|
|
105
|
-
|
|
97
|
+
def self.run2(command, args, options = {})
|
|
98
|
+
argv = []
|
|
99
|
+
currentdir = ""
|
|
100
|
+
retval = ""
|
|
101
|
+
argv << command
|
|
102
|
+
argv += args
|
|
103
|
+
argv.map! { |x| x.to_s }.map! { |x| x =~ /^".*"$/ ? x[1..-2] : x }
|
|
104
|
+
|
|
105
|
+
wd = options[:directory]
|
|
106
|
+
if not wd.nil?
|
|
106
107
|
currentdir = pwd()
|
|
107
|
-
chdir wd
|
|
108
|
+
chdir wd
|
|
108
109
|
end
|
|
109
|
-
|
|
110
|
+
|
|
110
111
|
cmdstr = argv.map { |x| x =~ / |\|/ ? '"' + x + '"' : x }.join(' ')
|
|
111
112
|
|
|
112
113
|
puts "PWD: " + pwd
|
|
113
114
|
puts "CMD: " + cmdstr
|
|
114
115
|
$stdout.flush
|
|
115
|
-
|
|
116
|
+
|
|
117
|
+
hideerrors = options[:hideerrors]
|
|
116
118
|
if hideerrors
|
|
117
119
|
if RUBY_PLATFORM =~ /(win|w)32$/
|
|
118
120
|
nul = "nul"
|
|
119
121
|
else
|
|
120
122
|
nul = "/dev/null"
|
|
121
123
|
end
|
|
122
|
-
argv << "2>" + nul
|
|
123
124
|
end
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if system
|
|
125
|
+
|
|
126
|
+
if options[:system]
|
|
127
127
|
system(cmdstr)
|
|
128
128
|
retval = ""
|
|
129
129
|
else
|
|
130
130
|
argv = cmdstr if RUBY_VERSION =~ /^1\.8/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
if options[:nowait]
|
|
132
|
+
IO.popen(argv)
|
|
133
|
+
else
|
|
134
|
+
IO.popen(argv) do |f|
|
|
135
|
+
while line = f.gets
|
|
136
|
+
puts line
|
|
137
|
+
$stdout.flush
|
|
138
|
+
end
|
|
134
139
|
end
|
|
135
|
-
|
|
140
|
+
end
|
|
136
141
|
end
|
|
142
|
+
|
|
137
143
|
if not wd.nil?
|
|
138
144
|
chdir currentdir
|
|
139
145
|
end
|
|
140
|
-
|
|
141
|
-
|
|
146
|
+
|
|
147
|
+
retval
|
|
148
|
+
end
|
|
142
149
|
|
|
150
|
+
def self.run(command, args, wd=nil,system = false, hideerrors = false)
|
|
151
|
+
self.run2(command, args, {:directory => wd, :system => system, :hiderrors => hideerrors})
|
|
143
152
|
end
|
|
144
153
|
|
|
145
154
|
def self.unjar(src,targetdir)
|
data/lib/framework/rhodes.rb
CHANGED
data/lib/framework/version.rb
CHANGED
data/lib/rhodes.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
3
|
package="com.rhomobile.rhodes"
|
|
4
|
-
android:versionCode="
|
|
5
|
-
android:versionName="1.5.
|
|
4
|
+
android:versionCode="20"
|
|
5
|
+
android:versionName="1.5.1">
|
|
6
6
|
<uses-sdk android:minSdkVersion="3" />
|
|
7
7
|
<application android:icon="@drawable/icon"
|
|
8
8
|
android:multiprocess="true"
|
data/platform/bb/build/bb.rake
CHANGED
|
@@ -58,15 +58,7 @@ def startsim
|
|
|
58
58
|
|
|
59
59
|
args << "/app-param=JvmDebugFile:"+Jake.get_absolute($app_config["applog"])
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
rd, wr = IO.pipe
|
|
63
|
-
Thread.new {
|
|
64
|
-
wr.putc 0
|
|
65
|
-
Jake.run(command,args,jde + "/simulator",true)
|
|
66
|
-
$stdout.flush
|
|
67
|
-
}
|
|
68
|
-
rd.getc
|
|
69
|
-
sleep 1
|
|
61
|
+
Jake.run2 command, args, {:directory => jde + "/simulator", :nowait => true}
|
|
70
62
|
end
|
|
71
63
|
|
|
72
64
|
def stopsim
|
|
@@ -77,19 +69,8 @@ def stopsim
|
|
|
77
69
|
args = []
|
|
78
70
|
args << "/session="+sim
|
|
79
71
|
args << "/execute=Exit(true)"
|
|
80
|
-
#Jake.run(command,args, jde + "/simulator")
|
|
81
|
-
#Thread.new { Jake.run(command,args, nil, true,true) }
|
|
82
|
-
|
|
83
|
-
# Wait until thread will start
|
|
84
|
-
rd, wr = IO.pipe
|
|
85
|
-
Thread.new {
|
|
86
|
-
wr.putc 0
|
|
87
|
-
Jake.run(command,args, nil, true,true)
|
|
88
|
-
$stdout.flush
|
|
89
|
-
}
|
|
90
|
-
rd.getc
|
|
91
|
-
sleep 1
|
|
92
72
|
|
|
73
|
+
Jake.run2 command, args, {:directory => jde + "/simulator", :nowait => true}
|
|
93
74
|
end
|
|
94
75
|
|
|
95
76
|
def manualsign
|
|
@@ -1715,6 +1715,9 @@ final public class RhodesApplication extends UiApplication implements RenderingA
|
|
|
1715
1715
|
}catch(IOException exc)
|
|
1716
1716
|
{
|
|
1717
1717
|
LOG.ERROR("Callback failed: " + _url, exc);
|
|
1718
|
+
|
|
1719
|
+
if ( m_netCallback != null )
|
|
1720
|
+
m_netCallback.setResponse( new NetResponse("", 500) );
|
|
1718
1721
|
}
|
|
1719
1722
|
}
|
|
1720
1723
|
else
|
|
@@ -35,6 +35,8 @@ char* get_current_location() {
|
|
|
35
35
|
//UNLOCK(current_location);
|
|
36
36
|
}*/
|
|
37
37
|
|
|
38
|
+
extern int webview_active_tab();
|
|
39
|
+
|
|
38
40
|
@interface UIBarButtonItemAction : NSObject
|
|
39
41
|
{
|
|
40
42
|
WebViewController *wc;
|
|
@@ -379,9 +381,9 @@ char* get_current_location() {
|
|
|
379
381
|
}
|
|
380
382
|
|
|
381
383
|
-(void)refresh {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
384
|
+
//[webView reload];
|
|
385
|
+
const char *appUrl = rho_rhodesapp_getcurrenturl(webview_active_tab());
|
|
386
|
+
[self navigate:[NSString stringWithUTF8String:appUrl]];
|
|
385
387
|
}
|
|
386
388
|
|
|
387
389
|
-(void)onRefresh:(id)sender {
|
data/platform/iphone/Info.plist
CHANGED
|
@@ -156,7 +156,7 @@ void CRhodesApp::stopApp()
|
|
|
156
156
|
stop(2000);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
rho_asynchttp_destroy();
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
class CRhoCallbackCall : public common::CRhoThread
|
|
@@ -559,8 +559,9 @@ menu_iter(const char* szLabel, const char* szLink, void* pThis)
|
|
|
559
559
|
|
|
560
560
|
void CRhodesApp::setViewMenu(unsigned long valMenu)
|
|
561
561
|
{
|
|
562
|
-
synchronized(m_mxViewMenuItems)
|
|
563
562
|
{
|
|
563
|
+
synchronized(m_mxViewMenuItems)
|
|
564
|
+
|
|
564
565
|
m_hashViewMenuItems.clear();
|
|
565
566
|
m_strAppBackUrl="";
|
|
566
567
|
}
|
|
@@ -878,7 +879,7 @@ const char* rho_ruby_getMessageText(const char* szName)
|
|
|
878
879
|
|
|
879
880
|
int rho_rhodesapp_isrubycompiler()
|
|
880
881
|
{
|
|
881
|
-
return
|
|
882
|
+
return 0;
|
|
882
883
|
}
|
|
883
884
|
|
|
884
885
|
int rho_conf_send_log()
|
|
@@ -13,7 +13,7 @@ namespace net
|
|
|
13
13
|
IMPLEMENT_LOGCLASS(CAsyncHttp, "AsyncHttp");
|
|
14
14
|
boolean CAsyncHttp::m_bNoThreaded = false;
|
|
15
15
|
common::CMutex CAsyncHttp::m_mxInstances;
|
|
16
|
-
|
|
16
|
+
VectorPtr<CAsyncHttp*> CAsyncHttp::m_arInstances;
|
|
17
17
|
|
|
18
18
|
extern "C" void header_iter(const char* szName, const char* szValue, void* pHash)
|
|
19
19
|
{
|
|
@@ -23,6 +23,7 @@ extern "C" void header_iter(const char* szName, const char* szValue, void* pHash
|
|
|
23
23
|
CAsyncHttp::CAsyncHttp(common::IRhoClassFactory* factory, EHttpCommands eCmd,
|
|
24
24
|
const char* url, unsigned long headers, const char* body, const char* callback, const char* callback_params) : CRhoThread(factory)
|
|
25
25
|
{
|
|
26
|
+
m_bFinished = false;
|
|
26
27
|
m_ptrFactory = factory;
|
|
27
28
|
m_strUrl = url != null ? url : "";
|
|
28
29
|
m_strBody = body != null ? body : "";
|
|
@@ -32,10 +33,7 @@ CAsyncHttp::CAsyncHttp(common::IRhoClassFactory* factory, EHttpCommands eCmd,
|
|
|
32
33
|
|
|
33
34
|
rho_ruby_enum_strhash(headers, &header_iter, &m_mapHeaders);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
synchronized(m_mxInstances);
|
|
37
|
-
m_arInstances.addElement(this);
|
|
38
|
-
}
|
|
36
|
+
addNewObject(this);
|
|
39
37
|
|
|
40
38
|
if (m_bNoThreaded)
|
|
41
39
|
run();
|
|
@@ -43,24 +41,46 @@ CAsyncHttp::CAsyncHttp(common::IRhoClassFactory* factory, EHttpCommands eCmd,
|
|
|
43
41
|
start(epLow);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
CAsyncHttp
|
|
44
|
+
void CAsyncHttp::cancel(boolean bWait)
|
|
47
45
|
{
|
|
48
|
-
synchronized(m_mxInstances)
|
|
49
46
|
{
|
|
50
|
-
|
|
47
|
+
synchronized(m_mxRequest)
|
|
48
|
+
|
|
49
|
+
if (m_pNetRequest!=null && !m_pNetRequest->isCancelled() )
|
|
50
|
+
m_pNetRequest->cancel();
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
if ( bWait )
|
|
54
|
+
stop(-1);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
void CAsyncHttp::
|
|
57
|
+
/*static*/ void CAsyncHttp::addNewObject(CAsyncHttp* pObj)
|
|
55
58
|
{
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
synchronized(m_mxInstances)
|
|
60
|
+
{
|
|
61
|
+
while(1)
|
|
62
|
+
{
|
|
63
|
+
int nToDelete = -1;
|
|
64
|
+
for (int i = 0; i < (int)m_arInstances.size(); i++ )
|
|
65
|
+
{
|
|
66
|
+
if ( m_arInstances.elementAt(i)->m_bFinished )
|
|
67
|
+
{
|
|
68
|
+
nToDelete = i;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (nToDelete==-1)
|
|
74
|
+
break;
|
|
58
75
|
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
m_arInstances.removeElementAt(nToDelete);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
m_arInstances.addElement(pObj);
|
|
80
|
+
}
|
|
61
81
|
}
|
|
62
82
|
|
|
63
|
-
/*static*/ void CAsyncHttp::cancelRequest(const char* szCallback)
|
|
83
|
+
/*static*/ void CAsyncHttp::cancelRequest(const char* szCallback, boolean bWait)
|
|
64
84
|
{
|
|
65
85
|
if (!szCallback || !*szCallback )
|
|
66
86
|
{
|
|
@@ -73,13 +93,13 @@ void CAsyncHttp::cancel()
|
|
|
73
93
|
if ( *szCallback == '*')
|
|
74
94
|
{
|
|
75
95
|
for (int i = 0; i < (int)m_arInstances.size(); i++ )
|
|
76
|
-
m_arInstances.elementAt(i)->cancel();
|
|
96
|
+
m_arInstances.elementAt(i)->cancel(bWait);
|
|
77
97
|
}else
|
|
78
98
|
{
|
|
79
99
|
for (int i = 0; i < (int)m_arInstances.size(); i++ )
|
|
80
100
|
{
|
|
81
101
|
if ( m_arInstances.elementAt(i)->m_strCallback.compare(szCallback) == 0 )
|
|
82
|
-
m_arInstances.elementAt(i)->cancel();
|
|
102
|
+
m_arInstances.elementAt(i)->cancel(bWait);
|
|
83
103
|
}
|
|
84
104
|
}
|
|
85
105
|
}
|
|
@@ -89,7 +109,10 @@ void CAsyncHttp::run()
|
|
|
89
109
|
{
|
|
90
110
|
LOG(INFO) + "RhoHttp thread start.";
|
|
91
111
|
|
|
92
|
-
|
|
112
|
+
{
|
|
113
|
+
synchronized(m_mxRequest)
|
|
114
|
+
m_pNetRequest = m_ptrFactory->createNetRequest();
|
|
115
|
+
}
|
|
93
116
|
|
|
94
117
|
switch( m_eCmd )
|
|
95
118
|
{
|
|
@@ -117,8 +140,7 @@ void CAsyncHttp::run()
|
|
|
117
140
|
|
|
118
141
|
LOG(INFO) + "RhoHttp thread end.";
|
|
119
142
|
|
|
120
|
-
|
|
121
|
-
delete this;
|
|
143
|
+
m_bFinished = true;
|
|
122
144
|
}
|
|
123
145
|
|
|
124
146
|
String CAsyncHttp::makeHeadersString()
|
|
@@ -211,10 +233,13 @@ void CAsyncHttp::callNotify(rho::net::INetResponse& resp, int nError )
|
|
|
211
233
|
rho_ruby_set_const( strName.c_str(), strBody.c_str());
|
|
212
234
|
}else
|
|
213
235
|
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
236
|
+
// {
|
|
237
|
+
// synchronized(m_mxRequest)
|
|
238
|
+
// m_pNetRequest = m_ptrFactory->createNetRequest();
|
|
239
|
+
// }
|
|
240
|
+
common::CAutoPtr<INetRequest> pNetRequest = m_ptrFactory->createNetRequest();
|
|
241
|
+
String strFullUrl = pNetRequest->resolveUrl(m_strCallback);
|
|
242
|
+
NetResponse(resp1,pNetRequest->pushData( strFullUrl, strBody, null ));
|
|
218
243
|
if ( !resp1.isOK() )
|
|
219
244
|
LOG(ERROR) + "AsyncHttp notification failed. Code: " + resp1.getRespCode() + "; Error body: " + resp1.getCharData();
|
|
220
245
|
}
|
|
@@ -251,7 +276,12 @@ void rho_asynchttp_uploadfile(const char* url, unsigned long headers, const char
|
|
|
251
276
|
|
|
252
277
|
void rho_asynchttp_cancel(const char* cancel_callback)
|
|
253
278
|
{
|
|
254
|
-
CAsyncHttp::cancelRequest(cancel_callback);
|
|
279
|
+
CAsyncHttp::cancelRequest(cancel_callback, false);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
void rho_asynchttp_destroy()
|
|
283
|
+
{
|
|
284
|
+
CAsyncHttp::cancelRequest("*", true);
|
|
255
285
|
}
|
|
256
286
|
|
|
257
287
|
void rho_asynchttp_set_threaded_mode(int b)
|
|
@@ -17,14 +17,16 @@ class CAsyncHttp : public common::CRhoThread, rho::ICallbackObject
|
|
|
17
17
|
DEFINE_LOGCLASS;
|
|
18
18
|
|
|
19
19
|
static common::CMutex m_mxInstances;
|
|
20
|
-
static
|
|
20
|
+
static VectorPtr<CAsyncHttp*> m_arInstances;
|
|
21
21
|
common::CAutoPtr<common::IRhoClassFactory> m_ptrFactory;
|
|
22
|
+
common::CMutex m_mxRequest;
|
|
22
23
|
|
|
23
24
|
common::CAutoPtr<INetRequest> m_pNetRequest;
|
|
24
25
|
common::CAutoPtr<INetResponse> m_pNetResponse;
|
|
25
26
|
Hashtable<String,String> m_mapHeaders;
|
|
26
27
|
|
|
27
28
|
String m_strUrl, m_strBody, m_strCallback, m_strCallbackParams;
|
|
29
|
+
boolean m_bFinished;
|
|
28
30
|
public:
|
|
29
31
|
enum EHttpCommands{ hcGet = 0, hcPost, hcDownload, hcUpload };
|
|
30
32
|
private:
|
|
@@ -35,11 +37,10 @@ public:
|
|
|
35
37
|
|
|
36
38
|
CAsyncHttp(common::IRhoClassFactory* factory, EHttpCommands eCmd,
|
|
37
39
|
const char* url, unsigned long headers, const char* body, const char* callback, const char* callback_params);
|
|
38
|
-
~CAsyncHttp();
|
|
39
40
|
|
|
40
|
-
void cancel();
|
|
41
|
+
void cancel(boolean bWait);
|
|
41
42
|
|
|
42
|
-
static void cancelRequest(const char* szCallback);
|
|
43
|
+
static void cancelRequest(const char* szCallback, boolean bWait);
|
|
43
44
|
|
|
44
45
|
//rho::ICallbackObject
|
|
45
46
|
virtual unsigned long getObjectValue();
|
|
@@ -50,7 +51,7 @@ private:
|
|
|
50
51
|
void callNotify(INetResponse& resp, int nError );
|
|
51
52
|
|
|
52
53
|
String makeHeadersString();
|
|
53
|
-
|
|
54
|
+
static void addNewObject(CAsyncHttp* pObj);
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
} // namespace net
|
|
@@ -67,6 +68,7 @@ void rho_asynchttp_post(const char* url, unsigned long headers, const char* body
|
|
|
67
68
|
void rho_asynchttp_downloadfile(const char* url, unsigned long headers, const char* filename, const char* callback, const char* callback_params);
|
|
68
69
|
void rho_asynchttp_uploadfile(const char* url, unsigned long headers, const char* filename, const char* callback, const char* callback_params);
|
|
69
70
|
void rho_asynchttp_cancel(const char* cancel_callback);
|
|
71
|
+
void rho_asynchttp_destroy();
|
|
70
72
|
void rho_asynchttp_set_threaded_mode(int b);
|
|
71
73
|
|
|
72
74
|
#ifdef __cplusplus
|
|
@@ -202,7 +202,7 @@ int _open(const char *path, int oflag, va_list arg)
|
|
|
202
202
|
|
|
203
203
|
fNumber = get_NewFileNumber();
|
|
204
204
|
if ( fNumber == 0 )
|
|
205
|
-
return -
|
|
205
|
+
return -1;
|
|
206
206
|
|
|
207
207
|
wfile = wce_mbtowc(path);
|
|
208
208
|
if ( (osfh = CreateFileW( wfile,
|
|
@@ -235,7 +235,7 @@ int _open(const char *path, int oflag, va_list arg)
|
|
|
235
235
|
return fNumber;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
return -
|
|
238
|
+
return -1;
|
|
239
239
|
}
|
|
240
240
|
/*
|
|
241
241
|
wchar_t *wfile;
|
|
@@ -20,12 +20,15 @@ public class AsyncHttp extends RhoThread
|
|
|
20
20
|
private static Object m_mxInstances = new Object();
|
|
21
21
|
private static Vector/*<CAsyncHttp*>*/ m_arInstances = new Vector();
|
|
22
22
|
private RhoClassFactory m_ptrFactory;
|
|
23
|
-
|
|
23
|
+
private Object m_mxRequest = new Object();
|
|
24
|
+
|
|
24
25
|
private NetRequest m_pNetRequest;
|
|
25
26
|
private NetResponse m_pNetResponse;
|
|
26
27
|
private Hashtable/*<String,String>*/ m_mapHeaders = new Hashtable();
|
|
27
28
|
|
|
28
29
|
private String m_strUrl, m_strBody, m_strCallback, m_strCallbackParams;
|
|
30
|
+
boolean m_bFinished = false;
|
|
31
|
+
|
|
29
32
|
private RubyValue m_valBody;
|
|
30
33
|
public final static int hcGet = 0, hcPost=1, hcDownload=2, hcUpload =3;
|
|
31
34
|
private int m_eCmd;
|
|
@@ -47,10 +50,7 @@ public class AsyncHttp extends RhoThread
|
|
|
47
50
|
|
|
48
51
|
m_mapHeaders = RhoRuby.enum_strhash(headers);
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
m_arInstances.addElement(this);
|
|
53
|
-
}
|
|
53
|
+
addNewObject(this);
|
|
54
54
|
|
|
55
55
|
if (m_bNoThreaded)
|
|
56
56
|
run();
|
|
@@ -58,16 +58,46 @@ public class AsyncHttp extends RhoThread
|
|
|
58
58
|
start(epLow);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
void cancel()
|
|
61
|
+
void cancel(boolean bWait)
|
|
62
62
|
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
synchronized(m_mxRequest)
|
|
64
|
+
{
|
|
65
|
+
if (m_pNetRequest!=null && !m_pNetRequest.isCancelled())
|
|
66
|
+
m_pNetRequest.cancel();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if ( bWait )
|
|
70
|
+
stop(10000);
|
|
67
71
|
//delete this;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
static void
|
|
74
|
+
static void addNewObject(AsyncHttp pObj)
|
|
75
|
+
{
|
|
76
|
+
synchronized(m_mxInstances)
|
|
77
|
+
{
|
|
78
|
+
while(true)
|
|
79
|
+
{
|
|
80
|
+
int nToDelete = -1;
|
|
81
|
+
for (int i = 0; i < (int)m_arInstances.size(); i++ )
|
|
82
|
+
{
|
|
83
|
+
if ( ((AsyncHttp)m_arInstances.elementAt(i)).m_bFinished )
|
|
84
|
+
{
|
|
85
|
+
nToDelete = i;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (nToDelete==-1)
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
m_arInstances.removeElementAt(nToDelete);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
m_arInstances.addElement(pObj);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static void cancelRequest(String szCallback, boolean bWait)
|
|
71
101
|
{
|
|
72
102
|
if (szCallback == null|| szCallback.length() ==0 )
|
|
73
103
|
{
|
|
@@ -80,13 +110,13 @@ public class AsyncHttp extends RhoThread
|
|
|
80
110
|
if ( szCallback.compareTo("*") ==0 )
|
|
81
111
|
{
|
|
82
112
|
for (int i = 0; i < (int)m_arInstances.size(); i++ )
|
|
83
|
-
((AsyncHttp)m_arInstances.elementAt(i)).cancel();
|
|
113
|
+
((AsyncHttp)m_arInstances.elementAt(i)).cancel(bWait);
|
|
84
114
|
}else
|
|
85
115
|
{
|
|
86
116
|
for (int i = 0; i < (int)m_arInstances.size(); i++ )
|
|
87
117
|
{
|
|
88
118
|
if ( ((AsyncHttp)m_arInstances.elementAt(i)).m_strCallback.compareTo(szCallback) == 0 )
|
|
89
|
-
((AsyncHttp)m_arInstances.elementAt(i)).cancel();
|
|
119
|
+
((AsyncHttp)m_arInstances.elementAt(i)).cancel(bWait);
|
|
90
120
|
}
|
|
91
121
|
}
|
|
92
122
|
}
|
|
@@ -96,8 +126,11 @@ public class AsyncHttp extends RhoThread
|
|
|
96
126
|
{
|
|
97
127
|
LOG.INFO("RhoHttp thread start.");
|
|
98
128
|
|
|
99
|
-
|
|
100
|
-
|
|
129
|
+
synchronized(m_mxRequest)
|
|
130
|
+
{
|
|
131
|
+
m_pNetRequest = m_ptrFactory.createNetRequest();
|
|
132
|
+
}
|
|
133
|
+
|
|
101
134
|
try{
|
|
102
135
|
switch( m_eCmd )
|
|
103
136
|
{
|
|
@@ -135,10 +168,8 @@ public class AsyncHttp extends RhoThread
|
|
|
135
168
|
}finally
|
|
136
169
|
{
|
|
137
170
|
LOG.INFO("RhoHttp thread end.");
|
|
171
|
+
m_bFinished = true;
|
|
138
172
|
}
|
|
139
|
-
|
|
140
|
-
//if ( !m_pNetRequest.isCancelled() )
|
|
141
|
-
// delete this;
|
|
142
173
|
}
|
|
143
174
|
|
|
144
175
|
String makeHeadersString()
|
|
@@ -338,7 +369,7 @@ public class AsyncHttp extends RhoThread
|
|
|
338
369
|
{
|
|
339
370
|
try {
|
|
340
371
|
String cancel_callback = arg.toStr();
|
|
341
|
-
AsyncHttp.cancelRequest(cancel_callback);
|
|
372
|
+
AsyncHttp.cancelRequest(cancel_callback, false);
|
|
342
373
|
} catch(Exception e) {
|
|
343
374
|
LOG.ERROR("cancel failed", e);
|
|
344
375
|
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
|
|
@@ -319,8 +319,9 @@ void CSyncNotify::fireInitialSyncNotification( boolean bFinish, int nErrCode )
|
|
|
319
319
|
|
|
320
320
|
boolean bRemoveAfterFire = bFinish;
|
|
321
321
|
String strBody = "", strUrl;
|
|
322
|
-
synchronized(m_mxSyncNotifications)
|
|
323
322
|
{
|
|
323
|
+
synchronized(m_mxSyncNotifications)
|
|
324
|
+
|
|
324
325
|
if ( m_initialSyncNotify.m_strUrl.length() == 0 )
|
|
325
326
|
return;
|
|
326
327
|
|
|
@@ -392,6 +392,17 @@ CNetResponseImpl* CNetRequestImpl::sendStream(common::InputStream* bodyStream)
|
|
|
392
392
|
void CNetRequestImpl::cancel()
|
|
393
393
|
{
|
|
394
394
|
m_bCancel = true;
|
|
395
|
+
|
|
396
|
+
if ( hRequest )
|
|
397
|
+
InternetCloseHandle(hRequest);
|
|
398
|
+
/* if ( hConnection )
|
|
399
|
+
InternetCloseHandle(hConnection);
|
|
400
|
+
if ( hInet )
|
|
401
|
+
InternetCloseHandle(hInet); */
|
|
402
|
+
/*
|
|
403
|
+
hRequest = 0;
|
|
404
|
+
hConnection = 0;
|
|
405
|
+
hInet = 0;*/
|
|
395
406
|
}
|
|
396
407
|
|
|
397
408
|
void CNetRequestImpl::close()
|
metadata
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rhodes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 1
|
|
7
|
+
- 5
|
|
8
|
+
- 1
|
|
9
|
+
version: 1.5.1
|
|
5
10
|
platform: ruby
|
|
6
11
|
authors:
|
|
7
12
|
- Rhomobile
|
|
@@ -14,54 +19,74 @@ default_executable:
|
|
|
14
19
|
dependencies:
|
|
15
20
|
- !ruby/object:Gem::Dependency
|
|
16
21
|
name: templater
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
20
24
|
requirements:
|
|
21
25
|
- - ">="
|
|
22
26
|
- !ruby/object:Gem::Version
|
|
27
|
+
segments:
|
|
28
|
+
- 0
|
|
29
|
+
- 5
|
|
30
|
+
- 0
|
|
23
31
|
version: 0.5.0
|
|
24
|
-
|
|
32
|
+
type: :runtime
|
|
33
|
+
version_requirements: *id001
|
|
25
34
|
- !ruby/object:Gem::Dependency
|
|
26
35
|
name: rake
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
prerelease: false
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
30
38
|
requirements:
|
|
31
39
|
- - ">="
|
|
32
40
|
- !ruby/object:Gem::Version
|
|
41
|
+
segments:
|
|
42
|
+
- 0
|
|
43
|
+
- 8
|
|
44
|
+
- 7
|
|
33
45
|
version: 0.8.7
|
|
34
|
-
|
|
46
|
+
type: :runtime
|
|
47
|
+
version_requirements: *id002
|
|
35
48
|
- !ruby/object:Gem::Dependency
|
|
36
49
|
name: activesupport
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
prerelease: false
|
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
40
52
|
requirements:
|
|
41
53
|
- - ">="
|
|
42
54
|
- !ruby/object:Gem::Version
|
|
55
|
+
segments:
|
|
56
|
+
- 2
|
|
57
|
+
- 3
|
|
58
|
+
- 5
|
|
43
59
|
version: 2.3.5
|
|
44
|
-
|
|
60
|
+
type: :runtime
|
|
61
|
+
version_requirements: *id003
|
|
45
62
|
- !ruby/object:Gem::Dependency
|
|
46
63
|
name: rdoc
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
prerelease: false
|
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
50
66
|
requirements:
|
|
51
67
|
- - ">="
|
|
52
68
|
- !ruby/object:Gem::Version
|
|
69
|
+
segments:
|
|
70
|
+
- 2
|
|
71
|
+
- 4
|
|
72
|
+
- 3
|
|
53
73
|
version: 2.4.3
|
|
54
|
-
|
|
74
|
+
type: :development
|
|
75
|
+
version_requirements: *id004
|
|
55
76
|
- !ruby/object:Gem::Dependency
|
|
56
77
|
name: diff-lcs
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
prerelease: false
|
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
60
80
|
requirements:
|
|
61
81
|
- - ">="
|
|
62
82
|
- !ruby/object:Gem::Version
|
|
83
|
+
segments:
|
|
84
|
+
- 1
|
|
85
|
+
- 1
|
|
86
|
+
- 2
|
|
63
87
|
version: 1.1.2
|
|
64
|
-
|
|
88
|
+
type: :runtime
|
|
89
|
+
version_requirements: *id005
|
|
65
90
|
description: Rhodes mobile framework
|
|
66
91
|
email: dev@rhomobile.com
|
|
67
92
|
executables:
|
|
@@ -5285,18 +5310,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
5285
5310
|
requirements:
|
|
5286
5311
|
- - ">="
|
|
5287
5312
|
- !ruby/object:Gem::Version
|
|
5313
|
+
segments:
|
|
5314
|
+
- 0
|
|
5288
5315
|
version: "0"
|
|
5289
|
-
version:
|
|
5290
5316
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
5291
5317
|
requirements:
|
|
5292
5318
|
- - ">="
|
|
5293
5319
|
- !ruby/object:Gem::Version
|
|
5320
|
+
segments:
|
|
5321
|
+
- 0
|
|
5294
5322
|
version: "0"
|
|
5295
|
-
version:
|
|
5296
5323
|
requirements: []
|
|
5297
5324
|
|
|
5298
5325
|
rubyforge_project: rhodes
|
|
5299
|
-
rubygems_version: 1.3.
|
|
5326
|
+
rubygems_version: 1.3.6
|
|
5300
5327
|
signing_key:
|
|
5301
5328
|
specification_version: 2
|
|
5302
5329
|
summary: The Rhodes framework is the easiest way to develop NATIVE apps with full device capabilities (GPS, PIM, camera, etc.) for any smartphone.
|