rhodes 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -1
- data/Manifest.txt +5197 -0
- data/lib/framework/rho/rho.rb +20 -4
- data/lib/framework/rho/rhocontroller.rb +13 -9
- 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/android/build/android.rake +4 -2
- data/platform/android/build/androidcommon.rb +2 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +9 -1
- data/platform/iphone/Classes/RhoRunnerAppDelegate.m +9 -0
- data/platform/iphone/Classes/Server/ServerHost.h +2 -0
- data/platform/iphone/Classes/Server/ServerHost.m +29 -6
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +12 -0
- data/platform/shared/common/RhodesApp.cpp +2 -12
- data/platform/shared/common/RhodesApp.h +0 -1
- data/platform/shared/net/AsyncHttp.cpp +38 -49
- data/platform/shared/net/AsyncHttp.h +6 -7
- data/platform/shared/ruby/ext/asynchttp/asynchttp.i +8 -12
- data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +24 -101
- data/platform/shared/rubyJVM/src/com/rho/RhoRuby.java +5 -0
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +3 -10
- data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +45 -63
- metadata +3 -2
data/lib/framework/rho/rho.rb
CHANGED
@@ -391,17 +391,33 @@ module Rho
|
|
391
391
|
end # RhoConfig
|
392
392
|
|
393
393
|
module AsyncHttp
|
394
|
+
def self.process_result(res, callback)
|
395
|
+
return res if callback && callback.length() > 0
|
396
|
+
|
397
|
+
_params = ::Rho::RhoSupport::parse_query_parameters res
|
398
|
+
::Rho::RhoController.process_rho_object(_params)
|
399
|
+
_params
|
400
|
+
end
|
401
|
+
|
394
402
|
def self.get(args)
|
395
|
-
|
403
|
+
process_result(
|
404
|
+
AsyncHttp.do_get(args[:url], args[:headers], args[:callback], args[:callback_param] ),
|
405
|
+
args[:callback] )
|
396
406
|
end
|
397
407
|
def self.post(args)
|
398
|
-
|
408
|
+
process_result(
|
409
|
+
AsyncHttp.do_post(args[:url], args[:headers], args[:body], args[:callback], args[:callback_param] ),
|
410
|
+
args[:callback] )
|
399
411
|
end
|
400
412
|
def self.download_file(args)
|
401
|
-
|
413
|
+
process_result(
|
414
|
+
AsyncHttp.do_downloadfile(args[:url], args[:headers], args[:filename], args[:callback], args[:callback_param] ),
|
415
|
+
args[:callback] )
|
402
416
|
end
|
403
417
|
def self.upload_file(args)
|
404
|
-
|
418
|
+
process_result(
|
419
|
+
AsyncHttp.do_uploadfile(args[:url], args[:headers], args[:filename], args[:callback], args[:callback_param] ),
|
420
|
+
args[:callback] )
|
405
421
|
end
|
406
422
|
end
|
407
423
|
|
@@ -30,6 +30,18 @@ module Rho
|
|
30
30
|
return Hash['GET','index','POST','create'][@request['request-method']]
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.process_rho_object(params)
|
34
|
+
if params['rho_callback'] && params['__rho_object']
|
35
|
+
hashObjs = params['__rho_object']
|
36
|
+
|
37
|
+
hashObjs.each do |name,index|
|
38
|
+
params[name] = __rhoGetCallbackObject(index.to_i())
|
39
|
+
end
|
40
|
+
|
41
|
+
params.delete('__rho_object')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
33
45
|
def serve(application,object_mapping,req,res)
|
34
46
|
@request, @response = req, res
|
35
47
|
@object_mapping = object_mapping
|
@@ -37,15 +49,7 @@ module Rho
|
|
37
49
|
@rendered = false
|
38
50
|
@redirected = false
|
39
51
|
|
40
|
-
|
41
|
-
hashObjs = @params['__rho_object']
|
42
|
-
|
43
|
-
hashObjs.each do |name,index|
|
44
|
-
@params[name] = __rhoGetCallbackObject(index.to_i())
|
45
|
-
end
|
46
|
-
|
47
|
-
@params.delete('__rho_object')
|
48
|
-
end
|
52
|
+
RhoController.process_rho_object(@params)
|
49
53
|
|
50
54
|
act = req['action'].nil? ? default_action : req['action']
|
51
55
|
if self.respond_to?(act)
|
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="21"
|
5
|
+
android:versionName="1.5.2">
|
6
6
|
<uses-sdk android:minSdkVersion="3" />
|
7
7
|
<application android:icon="@drawable/icon"
|
8
8
|
android:multiprocess="true"
|
@@ -184,7 +184,8 @@ namespace "config" do
|
|
184
184
|
end
|
185
185
|
|
186
186
|
if $androidplatform.nil?
|
187
|
-
puts "+++ No required platform found"
|
187
|
+
puts "+++ No required platform (API level #{ANDROID_API_LEVEL}) found, can't proceed"
|
188
|
+
exit 1
|
188
189
|
else
|
189
190
|
puts "+++ Platform found: #{$androidplatform}" if USE_TRACES
|
190
191
|
end
|
@@ -262,7 +263,8 @@ namespace "config" do
|
|
262
263
|
$gapijar = File.join(dir, 'libs', 'maps.jar') if apilevel == ANDROID_API_LEVEL
|
263
264
|
end
|
264
265
|
if $gapijar.nil?
|
265
|
-
puts "+++ No Google APIs add-on found"
|
266
|
+
puts "+++ No Google APIs add-on found (which is required because 'mapping' enabled in build.yml)"
|
267
|
+
exit 1
|
266
268
|
else
|
267
269
|
puts "+++ Google APIs add-on found: #{$gapijar}" if USE_TRACES
|
268
270
|
end
|
@@ -117,7 +117,8 @@ def cc_run(command, args, chdir = nil)
|
|
117
117
|
end
|
118
118
|
ret = $?
|
119
119
|
FileUtils.cd save_cwd
|
120
|
-
ret
|
120
|
+
puts "FAIL: #{command} failed with status #{ret.inspect.to_s}" unless ret.success?
|
121
|
+
ret.success?
|
121
122
|
end
|
122
123
|
|
123
124
|
def cc_compile(filename, objdir, additional = nil)
|
@@ -1,9 +1,11 @@
|
|
1
1
|
package com.rho.rubyext;
|
2
2
|
|
3
|
+
import rhomobile.RhodesApplication;
|
3
4
|
import net.rim.blackberry.api.phone.Phone;
|
4
5
|
import net.rim.device.api.i18n.Locale;
|
5
6
|
import net.rim.device.api.system.Display;
|
6
7
|
|
8
|
+
import com.rho.BBVersionSpecific;
|
7
9
|
import com.rho.RhoEmptyLogger;
|
8
10
|
import com.rho.RhoLogger;
|
9
11
|
import com.xruby.runtime.builtin.ObjectFactory;
|
@@ -126,7 +128,13 @@ public class System {
|
|
126
128
|
if (CoverageInfo.isOutOfCoverage())
|
127
129
|
return false;
|
128
130
|
*/
|
129
|
-
|
131
|
+
int nStatus = net.rim.device.api.system.RadioInfo.getNetworkService();
|
132
|
+
boolean hasGPRS = ( nStatus & net.rim.device.api.system.RadioInfo.NETWORK_SERVICE_DATA) != 0;
|
133
|
+
|
134
|
+
boolean hasWifi = BBVersionSpecific.isWifiActive();
|
135
|
+
LOG.INFO("hasGPRS : " + hasGPRS + "; Wifi: " + hasWifi);
|
136
|
+
boolean bRes = hasGPRS || hasWifi;
|
137
|
+
return bRes;
|
130
138
|
}
|
131
139
|
|
132
140
|
public static int getScreenHeight() {
|
@@ -340,6 +340,14 @@
|
|
340
340
|
[self.player play];
|
341
341
|
}
|
342
342
|
|
343
|
+
- (void)onStopPlaying {
|
344
|
+
if (!self.player)
|
345
|
+
return;
|
346
|
+
|
347
|
+
[self.player stop];
|
348
|
+
self.player = nil;
|
349
|
+
}
|
350
|
+
|
343
351
|
- (void) audioPlayerDidFinishPlaying: (AVAudioPlayer *) player successfully: (BOOL) flag {
|
344
352
|
if (flag == YES) {
|
345
353
|
//[self.button setTitle: @"Play" forState: UIControlStateNormal];
|
@@ -505,6 +513,7 @@
|
|
505
513
|
serverHost->onShowPopup = @selector(onShowPopup:);
|
506
514
|
serverHost->onVibrate = @selector(onVibrate:);
|
507
515
|
serverHost->onPlayFile = @selector(onPlayFile:);
|
516
|
+
serverHost->onStopPlaying = @selector(onStopPlaying);
|
508
517
|
serverHost->onSysCall = @selector(onSysCall:);
|
509
518
|
serverHost->onMapLocation = @selector(onMapLocation:);
|
510
519
|
serverHost->onCreateMap = @selector(onCreateMap:);
|
@@ -35,6 +35,7 @@
|
|
35
35
|
SEL onShowPopup;
|
36
36
|
SEL onVibrate;
|
37
37
|
SEL onPlayFile;
|
38
|
+
SEL onStopPlaying;
|
38
39
|
SEL onSysCall;
|
39
40
|
SEL onMapLocation;
|
40
41
|
SEL onCreateMap;
|
@@ -60,6 +61,7 @@
|
|
60
61
|
@property (assign) SEL onShowPopup;
|
61
62
|
@property (assign) SEL onVibrate;
|
62
63
|
@property (assign) SEL onPlayFile;
|
64
|
+
@property (assign) SEL onStopPlaying;
|
63
65
|
@property (assign) SEL onSysCall;
|
64
66
|
@property (assign) SEL onMapLocation;
|
65
67
|
@property (assign) SEL onCreateMap;
|
@@ -78,7 +78,7 @@ static ServerHost* sharedSH = nil;
|
|
78
78
|
@synthesize actionTarget, /*onStartFailure,*/ onStartSuccess, onRefreshView, onNavigateTo, onExecuteJs;
|
79
79
|
@synthesize /*onSetViewHomeUrl, onSetViewOptionsUrl,*/ onTakePicture, onChoosePicture, onChooseDateTime;
|
80
80
|
@synthesize onCreateNativeBar, onRemoveNativeBar, onSwitchTab;
|
81
|
-
@synthesize onShowPopup, onVibrate, onPlayFile, onSysCall, onMapLocation, onCreateMap, onActiveTab, onShowLog;
|
81
|
+
@synthesize onShowPopup, onVibrate, onPlayFile, onStopPlaying, onSysCall, onMapLocation, onCreateMap, onActiveTab, onShowLog;
|
82
82
|
|
83
83
|
- (void)serverStarted:(NSString*)data {
|
84
84
|
if(actionTarget && [actionTarget respondsToSelector:onStartSuccess]) {
|
@@ -203,6 +203,12 @@ static ServerHost* sharedSH = nil;
|
|
203
203
|
}
|
204
204
|
}
|
205
205
|
|
206
|
+
- (void)stopPlaying {
|
207
|
+
if (actionTarget && [actionTarget respondsToSelector:onStopPlaying]) {
|
208
|
+
[actionTarget performSelectorOnMainThread:onStopPlaying withObject:nil waitUntilDone:NO];
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
206
212
|
- (void)mapLocation:(NSString*) query {
|
207
213
|
if(actionTarget && [actionTarget respondsToSelector:onMapLocation]) {
|
208
214
|
[actionTarget performSelectorOnMainThread:onMapLocation withObject:query waitUntilDone:NO];
|
@@ -450,11 +456,6 @@ void webview_set_menu_items(VALUE valMenu) {
|
|
450
456
|
rho_rhodesapp_setViewMenu(valMenu);
|
451
457
|
}
|
452
458
|
|
453
|
-
void Init_RingtoneManager()
|
454
|
-
{
|
455
|
-
//TODO: implement Ringtone
|
456
|
-
}
|
457
|
-
|
458
459
|
void alert_show_popup(char* message) {
|
459
460
|
if (message==NULL) {
|
460
461
|
RAWLOG_ERROR("Alert.show_popup - wrong arguments");
|
@@ -476,6 +477,28 @@ void alert_play_file(char* file_name, char* media_type) {
|
|
476
477
|
}
|
477
478
|
}
|
478
479
|
|
480
|
+
VALUE rho_ringtone_manager_get_all()
|
481
|
+
{
|
482
|
+
// No API to get ringtones
|
483
|
+
return rho_ruby_get_NIL();
|
484
|
+
}
|
485
|
+
|
486
|
+
void rho_ringtone_manager_play(char *file_name)
|
487
|
+
{
|
488
|
+
if (file_name == NULL) {
|
489
|
+
RAWLOG_ERROR("RingtoneManager.play - please specify file name to play");
|
490
|
+
return;
|
491
|
+
}
|
492
|
+
|
493
|
+
[[ServerHost sharedInstance] playFile:[NSString stringWithUTF8String:file_name]
|
494
|
+
mediaType:NULL];
|
495
|
+
}
|
496
|
+
|
497
|
+
void rho_ringtone_manager_stop()
|
498
|
+
{
|
499
|
+
[[ServerHost sharedInstance] stopPlaying];
|
500
|
+
}
|
501
|
+
|
479
502
|
void take_picture(char* callback_url) {
|
480
503
|
[[ServerHost sharedInstance] takePicture:[NSString stringWithUTF8String:callback_url]];
|
481
504
|
}
|
data/platform/iphone/Info.plist
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
5CF8DBC710B1D45C00247AB4 /* constants.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CF8DBC110B1D45C00247AB4 /* constants.h */; };
|
21
21
|
5CF8DBCA10B1D45C00247AB4 /* socket.c in Sources */ = {isa = PBXBuildFile; fileRef = 5CF8DBC410B1D45C00247AB4 /* socket.c */; };
|
22
22
|
5CF8DBCB10B1D45C00247AB4 /* sockport.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CF8DBC510B1D45C00247AB4 /* sockport.h */; };
|
23
|
+
BD28516111608C9A003DE4E9 /* ringtones_wrap.c in Sources */ = {isa = PBXBuildFile; fileRef = BD28516011608C9A003DE4E9 /* ringtones_wrap.c */; };
|
23
24
|
D38F7B5F110647510030B1F4 /* extensions.c in Sources */ = {isa = PBXBuildFile; fileRef = D38F7B5E110647510030B1F4 /* extensions.c */; };
|
24
25
|
F51668800FFD39D80079F023 /* alert_wrap.c in Sources */ = {isa = PBXBuildFile; fileRef = F516687F0FFD39D80079F023 /* alert_wrap.c */; };
|
25
26
|
F5177F180EE5B624000EA1A0 /* system_wrap.c in Sources */ = {isa = PBXBuildFile; fileRef = F5177F170EE5B624000EA1A0 /* system_wrap.c */; };
|
@@ -129,6 +130,7 @@
|
|
129
130
|
5CF8DBC110B1D45C00247AB4 /* constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = constants.h; path = ext/socket/constants.h; sourceTree = "<group>"; };
|
130
131
|
5CF8DBC410B1D45C00247AB4 /* socket.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = socket.c; path = ext/socket/socket.c; sourceTree = "<group>"; };
|
131
132
|
5CF8DBC510B1D45C00247AB4 /* sockport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sockport.h; path = ext/socket/sockport.h; sourceTree = "<group>"; };
|
133
|
+
BD28516011608C9A003DE4E9 /* ringtones_wrap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ringtones_wrap.c; path = ext/ringtones/ringtones_wrap.c; sourceTree = "<group>"; };
|
132
134
|
D2AAC046055464E500DB518D /* librhorubylib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = librhorubylib.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
133
135
|
D38F7B5E110647510030B1F4 /* extensions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = extensions.c; path = ext/rho/extensions.c; sourceTree = "<group>"; };
|
134
136
|
F516687F0FFD39D80079F023 /* alert_wrap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = alert_wrap.c; path = ../../shared/ruby/ext/alert/alert_wrap.c; sourceTree = SOURCE_ROOT; };
|
@@ -319,6 +321,14 @@
|
|
319
321
|
name = socket;
|
320
322
|
sourceTree = "<group>";
|
321
323
|
};
|
324
|
+
BD28515B11608C73003DE4E9 /* ringtones */ = {
|
325
|
+
isa = PBXGroup;
|
326
|
+
children = (
|
327
|
+
BD28516011608C9A003DE4E9 /* ringtones_wrap.c */,
|
328
|
+
);
|
329
|
+
name = ringtones;
|
330
|
+
sourceTree = "<group>";
|
331
|
+
};
|
322
332
|
C6A0FF2B0290797F04C91782 /* Documentation */ = {
|
323
333
|
isa = PBXGroup;
|
324
334
|
children = (
|
@@ -468,6 +478,7 @@
|
|
468
478
|
F5B8FACD0F44E8F900C9AF85 /* camera */,
|
469
479
|
F5C61CA60F3CFE5700207621 /* webview */,
|
470
480
|
F58E7FE50F008A8500E46829 /* phonebook */,
|
481
|
+
BD28515B11608C73003DE4E9 /* ringtones */,
|
471
482
|
5C043EB60EF7B7CF0014E5C6 /* rho */,
|
472
483
|
F5177F150EE5B5D9000EA1A0 /* system */,
|
473
484
|
F5E360C30EB6A76500226287 /* syncengine */,
|
@@ -720,6 +731,7 @@
|
|
720
731
|
D38F7B5F110647510030B1F4 /* extensions.c in Sources */,
|
721
732
|
5C8EE86511220ED30005C20D /* asynchttp_wrap.c in Sources */,
|
722
733
|
5C79894D113BD1D0005F8736 /* geolocation_wrap.c in Sources */,
|
734
|
+
BD28516111608C9A003DE4E9 /* ringtones_wrap.c in Sources */,
|
723
735
|
);
|
724
736
|
runOnlyForDeploymentPostprocessing = 0;
|
725
737
|
};
|
@@ -612,24 +612,14 @@ String CRhodesApp::addCallbackObject(ICallbackObject* pCallbackObject, String st
|
|
612
612
|
return strRes;
|
613
613
|
}
|
614
614
|
|
615
|
-
void CRhodesApp::delCallbackObject(ICallbackObject* pCallbackObject)
|
616
|
-
{
|
617
|
-
for (int i = 0; i < (int)m_arCallbackObjects.size(); i++)
|
618
|
-
{
|
619
|
-
if ( m_arCallbackObjects.elementAt(i) == pCallbackObject )
|
620
|
-
{
|
621
|
-
m_arCallbackObjects.setElementAt(0,i);
|
622
|
-
// rho_ruby_releaseValue(valObject);
|
623
|
-
}
|
624
|
-
}
|
625
|
-
}
|
626
|
-
|
627
615
|
unsigned long CRhodesApp::getCallbackObject(int nIndex)
|
628
616
|
{
|
629
617
|
if ( nIndex < 0 || nIndex > m_arCallbackObjects.size() )
|
630
618
|
return rho_ruby_get_NIL();
|
631
619
|
|
632
620
|
ICallbackObject* pCallbackObject = m_arCallbackObjects.elementAt(nIndex);
|
621
|
+
m_arCallbackObjects.setElementAt(0,nIndex);
|
622
|
+
|
633
623
|
if ( !pCallbackObject )
|
634
624
|
return rho_ruby_get_NIL();
|
635
625
|
|
@@ -91,7 +91,6 @@ public:
|
|
91
91
|
boolean sendLog();
|
92
92
|
|
93
93
|
String addCallbackObject(ICallbackObject* pCallbackObject, String strName);
|
94
|
-
void delCallbackObject(ICallbackObject* pCallbackObject);
|
95
94
|
unsigned long getCallbackObject(int nIndex);
|
96
95
|
|
97
96
|
const String& getRhoMessage(int nError, const char* szName);
|
@@ -11,7 +11,6 @@ namespace net
|
|
11
11
|
{
|
12
12
|
|
13
13
|
IMPLEMENT_LOGCLASS(CAsyncHttp, "AsyncHttp");
|
14
|
-
boolean CAsyncHttp::m_bNoThreaded = false;
|
15
14
|
common::CMutex CAsyncHttp::m_mxInstances;
|
16
15
|
VectorPtr<CAsyncHttp*> CAsyncHttp::m_arInstances;
|
17
16
|
|
@@ -35,7 +34,7 @@ CAsyncHttp::CAsyncHttp(common::IRhoClassFactory* factory, EHttpCommands eCmd,
|
|
35
34
|
|
36
35
|
addNewObject(this);
|
37
36
|
|
38
|
-
if (
|
37
|
+
if (m_strCallback.length()==0)
|
39
38
|
run();
|
40
39
|
else
|
41
40
|
start(epLow);
|
@@ -132,9 +131,9 @@ void CAsyncHttp::run()
|
|
132
131
|
break;
|
133
132
|
}
|
134
133
|
|
135
|
-
if ( !m_pNetRequest->isCancelled()
|
134
|
+
if ( !m_pNetRequest->isCancelled())
|
136
135
|
{
|
137
|
-
//processResponse(
|
136
|
+
//processResponse(m_pNetResponse);
|
138
137
|
callNotify(*m_pNetResponse,0);
|
139
138
|
}
|
140
139
|
|
@@ -184,67 +183,58 @@ unsigned long CAsyncHttp::getObjectValue()
|
|
184
183
|
return rho_ruby_create_string(resp.getCharData());
|
185
184
|
}
|
186
185
|
|
186
|
+
unsigned long CAsyncHttp::getRetValue()
|
187
|
+
{
|
188
|
+
if ( m_strCallback.length() == 0 )
|
189
|
+
return rho_ruby_create_string(m_strResBody.c_str());
|
190
|
+
|
191
|
+
return rho_ruby_get_NIL();
|
192
|
+
}
|
193
|
+
|
187
194
|
void CAsyncHttp::callNotify(rho::net::INetResponse& resp, int nError )
|
188
195
|
{
|
189
|
-
|
190
|
-
|
196
|
+
m_strResBody = "rho_callback=1";
|
197
|
+
m_strResBody += "&status=";
|
191
198
|
if ( nError > 0 )
|
192
199
|
{
|
193
|
-
|
200
|
+
m_strResBody += "error&error_code=" + nError;
|
194
201
|
}else
|
195
202
|
{
|
196
203
|
if ( resp.isOK() )
|
197
|
-
|
204
|
+
m_strResBody += "ok";
|
198
205
|
else
|
199
206
|
{
|
200
|
-
|
207
|
+
m_strResBody += "error&error_code=";
|
201
208
|
if ( !resp.isResponseRecieved())
|
202
|
-
|
209
|
+
m_strResBody += convertToStringA(1);//RhoRuby.ERR_NETWORK);
|
203
210
|
else if ( resp.isUnathorized() )
|
204
|
-
|
211
|
+
m_strResBody += convertToStringA(9);//RhoRuby.ERR_UNATHORIZED);
|
205
212
|
else
|
206
|
-
|
213
|
+
m_strResBody += convertToStringA(2);//RhoRuby.ERR_REMOTESERVER);
|
207
214
|
|
208
215
|
if ( resp.isResponseRecieved())
|
209
|
-
|
216
|
+
m_strResBody += "&http_error=" + convertToStringA(resp.getRespCode());
|
210
217
|
}
|
211
218
|
|
212
219
|
String cookies = resp.getCookies();
|
213
220
|
if (cookies.length()>0)
|
214
|
-
|
221
|
+
m_strResBody += "&cookies=" + URI::urlEncode(cookies);
|
215
222
|
|
216
|
-
|
217
|
-
|
223
|
+
m_strResBody += "&" + makeHeadersString();
|
224
|
+
m_strResBody += "&" + RHODESAPP().addCallbackObject(this, "body");
|
218
225
|
}
|
219
226
|
|
220
227
|
if ( m_strCallbackParams.length() > 0 )
|
221
|
-
|
222
|
-
|
223
|
-
if ( m_bNoThreaded )
|
224
|
-
{
|
225
|
-
const char* szName = strrchr(m_strCallback.c_str(), '/');
|
226
|
-
if (!szName)
|
227
|
-
szName = m_strCallback.c_str();
|
228
|
-
else
|
229
|
-
szName++;
|
228
|
+
m_strResBody += "&" + m_strCallbackParams;
|
230
229
|
|
231
|
-
|
232
|
-
strName += szName;
|
233
|
-
rho_ruby_set_const( strName.c_str(), strBody.c_str());
|
234
|
-
}else
|
230
|
+
if ( m_strCallback.length() > 0 )
|
235
231
|
{
|
236
|
-
// {
|
237
|
-
// synchronized(m_mxRequest)
|
238
|
-
// m_pNetRequest = m_ptrFactory->createNetRequest();
|
239
|
-
// }
|
240
232
|
common::CAutoPtr<INetRequest> pNetRequest = m_ptrFactory->createNetRequest();
|
241
233
|
String strFullUrl = pNetRequest->resolveUrl(m_strCallback);
|
242
|
-
NetResponse(resp1,pNetRequest->pushData( strFullUrl,
|
234
|
+
NetResponse(resp1,pNetRequest->pushData( strFullUrl, m_strResBody, null ));
|
243
235
|
if ( !resp1.isOK() )
|
244
236
|
LOG(ERROR) + "AsyncHttp notification failed. Code: " + resp1.getRespCode() + "; Error body: " + resp1.getCharData();
|
245
237
|
}
|
246
|
-
|
247
|
-
RHODESAPP().delCallbackObject(this);
|
248
238
|
}
|
249
239
|
|
250
240
|
} // namespace net
|
@@ -254,24 +244,28 @@ extern "C" {
|
|
254
244
|
|
255
245
|
using namespace rho::net;
|
256
246
|
|
257
|
-
|
247
|
+
unsigned long rho_asynchttp_get(const char* url, unsigned long headers, const char* callback, const char* callback_params)
|
258
248
|
{
|
259
|
-
new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcGet, url, headers, null, callback, callback_params );
|
249
|
+
CAsyncHttp* pHttp = new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcGet, url, headers, null, callback, callback_params );
|
250
|
+
return pHttp->getRetValue();
|
260
251
|
}
|
261
252
|
|
262
|
-
|
253
|
+
unsigned long rho_asynchttp_post(const char* url, unsigned long headers, const char* body, const char* callback, const char* callback_params)
|
263
254
|
{
|
264
|
-
new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcPost, url, headers, body!=null?body:"", callback, callback_params );
|
255
|
+
CAsyncHttp* pHttp = new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcPost, url, headers, body!=null?body:"", callback, callback_params );
|
256
|
+
return pHttp->getRetValue();
|
265
257
|
}
|
266
258
|
|
267
|
-
|
259
|
+
unsigned long rho_asynchttp_downloadfile(const char* url, unsigned long headers, const char* file_path, const char* callback, const char* callback_params)
|
268
260
|
{
|
269
|
-
new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcDownload, url, headers, file_path, callback, callback_params );
|
261
|
+
CAsyncHttp* pHttp = new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcDownload, url, headers, file_path, callback, callback_params );
|
262
|
+
return pHttp->getRetValue();
|
270
263
|
}
|
271
264
|
|
272
|
-
|
265
|
+
unsigned long rho_asynchttp_uploadfile(const char* url, unsigned long headers, const char* file_path, const char* callback, const char* callback_params)
|
273
266
|
{
|
274
|
-
new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcUpload, url, headers, file_path, callback, callback_params );
|
267
|
+
CAsyncHttp* pHttp = new CAsyncHttp(rho::common::createClassFactory(), CAsyncHttp::hcUpload, url, headers, file_path, callback, callback_params );
|
268
|
+
return pHttp->getRetValue();
|
275
269
|
}
|
276
270
|
|
277
271
|
void rho_asynchttp_cancel(const char* cancel_callback)
|
@@ -284,9 +278,4 @@ void rho_asynchttp_destroy()
|
|
284
278
|
CAsyncHttp::cancelRequest("*", true);
|
285
279
|
}
|
286
280
|
|
287
|
-
void rho_asynchttp_set_threaded_mode(int b)
|
288
|
-
{
|
289
|
-
CAsyncHttp::m_bNoThreaded = (b==0);
|
290
|
-
}
|
291
|
-
|
292
281
|
}
|