rhodes 5.5.2 → 5.5.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -1
- data/CREDITS +3 -3
- data/LICENSE +1 -1
- data/README.html +1 -1
- data/Rakefile +53 -14
- data/bin/get-rhodes-info +0 -0
- data/extensions/rhoconnect-push/ext/rhoconnect-push/platform/android/Rakefile +1 -1
- data/lib/build/jake.rb +11 -0
- data/lib/commonAPI/barcode/ext/platform/iphone/impl/BarcodeFactory.m +2 -1
- data/lib/commonAPI/coreapi/ext/NativeTabbar.xml +4 -0
- data/lib/commonAPI/coreapi/ext/platform/iphone/cpp_based_impl/SystemImpl.mm +1 -0
- data/lib/commonAPI/coreapi/ext/platform/iphone/impl/NativeTabbarSingleton.m +7 -2
- data/lib/commonAPI/coreapi/ext/platform/iphone/impl/NativeToolbarSingleton.m +6 -2
- data/lib/commonAPI/coreapi/ext/platform/iphone/impl/NavbarSingleton.m +8 -2
- data/lib/commonAPI/coreapi/ext/shared/ApplicationImpl.cpp +3 -0
- data/lib/commonAPI/coreapi/ext/shared/NetworkImpl.cpp +1 -0
- data/lib/commonAPI/coreapi/ext/shared/TimerImpl.cpp +36 -27
- data/lib/commonAPI/coreapi/public/api/rhoapi.js +6 -3
- data/lib/commonAPI/mediacapture/ext.yml +1 -2
- data/lib/commonAPI/mediacapture/ext/build.bat +8 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/MediaCapture.pro +82 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/Rakefile +35 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/resources/diaClosed.png +0 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/resources/diaOpened.png +0 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/resources/mediacapture.qrc +7 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/resources/photoSave.png +0 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/CCameraData.cpp +83 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/CCameraData.h +54 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/CameraDialogBuilder.h +36 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/CameraDialogController.h +31 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/CameraDialogView.h +73 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/Camera_impl.cpp +337 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/ImageFileNameGetter.h +40 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/ImageFilenameGetterResult.h +36 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/cameracrossthreadhalper.h +17 -0
- data/lib/commonAPI/mediacapture/ext/platform/qt/src/cameradialogview.cpp +178 -0
- data/lib/commonAPI/mediacapture/ext/shared/MediacaptureInit.cpp +8 -8
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/version.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml.erb +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +9 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +33 -0
- data/platform/android/build/android.rake +97 -43
- data/platform/android/build/android_studio_project_generator.rb +21 -0
- data/platform/android/build/android_tools.rb +8 -6
- data/platform/iphone/Classes/AppManager/AppManager.h +6 -0
- data/platform/iphone/Classes/AppManager/AppManager.m +76 -37
- data/platform/iphone/Classes/MapView/GoogleGeocoder.m +2 -3
- data/platform/iphone/Classes/MapView/MapViewController.m +3 -3
- data/platform/iphone/Classes/NativeBar.h +1 -0
- data/platform/iphone/Classes/NativeBar.m +15 -0
- data/platform/iphone/Classes/RhoViewController.m +8 -3
- data/platform/iphone/Classes/RhoWKWebView.m +1 -1
- data/platform/iphone/Classes/Rhodes.m +55 -38
- data/platform/iphone/Classes/SimpleMainView.m +3 -2
- data/platform/iphone/Classes/TabbedMainView.h +2 -0
- data/platform/iphone/Classes/TabbedMainView.m +15 -3
- data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.h +2 -0
- data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.m +185 -30
- data/platform/iphone/Classes/rho/net/IPhoneNetRequest.mm +105 -6
- data/platform/iphone/rbuild/iphone.rake +426 -267
- data/platform/iphone/rbuild/putsOverride.rake +8 -0
- data/platform/shared/api_generator/iphone/CJSConverter.mm +5 -3
- data/platform/shared/common/BundleManager.cpp +16 -6
- data/platform/shared/common/PosixThreadImpl.cpp +10 -4
- data/platform/shared/common/RhoTime.cpp +81 -40
- data/platform/shared/common/RhodesApp.cpp +2 -2
- data/platform/shared/common/RhodesApp.h +1 -1
- data/platform/shared/db/DBAdapter.cpp +33 -0
- data/platform/shared/db/DBAdapter.h +5 -0
- data/platform/shared/logging/RhoLogConf.cpp +17 -1
- data/platform/shared/logging/RhoLogConf.h +6 -0
- data/platform/shared/net/CURLNetRequest.cpp +6 -0
- data/platform/shared/net/HttpServer.cpp +27 -1
- data/platform/shared/net/INetRequest.cpp +33 -6
- data/platform/shared/net/INetRequest.h +2 -0
- data/platform/shared/qt/RhoSimulator_dev.pro +14 -10
- data/platform/shared/qt/rhodes/QtMainWindow.cpp +2 -2
- data/platform/shared/qt/rhodes/iexecutable.h +27 -0
- data/platform/shared/qt/rhodes/impl/MainWindowImpl.cpp +5 -0
- data/platform/shared/qt/rhodes/impl/MainWindowImpl.h +3 -0
- data/platform/shared/qt/rhodes/qkineticscroller.cpp +2 -2
- data/platform/shared/qt/rhodes/qkineticscroller_p.h +1 -1
- data/platform/shared/qt/rhodes/qtscrollerfilter.cpp +3 -3
- data/platform/shared/qt/rhodes/qtscrollevent.cpp +2 -2
- data/platform/shared/qt/rhodes/qwebviewkineticscroller.cpp +1 -1
- data/platform/shared/qt/rhodes/qwebviewkineticscroller.h +1 -1
- data/platform/shared/qt/rhodes/resources/rho.png +0 -0
- data/platform/shared/qt/rhodes/rhodes.pro +3 -2
- data/platform/wm/build/wm.rake +28 -9
- data/platform/wm/rhodes/browser/BrowserFactory.cpp +4 -6
- data/platform/wm/rhodes/browser/stubs.cpp +5 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.h +3 -0
- data/platform/wm/rhodes/rhodes.vcproj +31 -2
- data/rakefile.rb +53 -14
- data/res/build-tools/iphonesim/build/Release/iphonesim_8 +2 -2
- data/res/generators/rhogen.rb +6 -147
- data/res/generators/templates/api/platform/iphone/generated/base_impl/MontanaBase.m +7 -7
- data/res/generators/templates/api/platform/iphone/generated/javascript/montana_js_wrap.mm +2 -4
- data/res/generators/templates/application/AndroidManifest.erb +1 -1
- data/res/generators/templates/application/app/Settings/home.erb +1 -1
- data/res/generators/templates/application/build.yml +52 -6
- data/res/generators/templates/application/icon/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-hdpi/ic_notification.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-hdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-hdpi/loading.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-ldpi/ic_notification.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-ldpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-ldpi/loading.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-mdpi/ic_notification.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-mdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-mdpi/loading.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xhdpi/ic_notification.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xhdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xhdpi/loading.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xxhdpi/ic_notification.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xxhdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xxhdpi/loading.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xxxhdpi/ic_notification.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xxxhdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable-xxxhdpi/loading.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable/ic_notification.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/drawable/loading.png +0 -0
- data/res/generators/templates/application/resources/android/res/mipmap-hdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/mipmap-ldpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/mipmap-mdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/mipmap-xhdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/mipmap-xxhdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/mipmap-xxxhdpi/icon.png +0 -0
- data/res/generators/templates/application/resources/android/res/mipmap/icon.png +0 -0
- data/res/generators/templates/application/{app/loading-568h@2x.png → resources/ios/Default-568h@2x.png} +0 -0
- data/res/generators/templates/application/{app/loading-667h@2x.png → resources/ios/Default-667h@2x.png} +0 -0
- data/res/generators/templates/application/{app/loading-736h@3x.png → resources/ios/Default-736h@3x.png} +0 -0
- data/res/generators/templates/application/{app/loading-Landscape.png → resources/ios/Default-Landscape.png} +0 -0
- data/res/generators/templates/application/{app/loading-Landscape@2x.png → resources/ios/Default-Landscape@2x.png} +0 -0
- data/res/generators/templates/application/{app/loading-LandscapeLeft.png → resources/ios/Default-LandscapeLeft.png} +0 -0
- data/res/generators/templates/application/{app/loading-LandscapeLeft@2x.png → resources/ios/Default-LandscapeLeft@2x.png} +0 -0
- data/res/generators/templates/application/{app/loading-LandscapeRight.png → resources/ios/Default-LandscapeRight.png} +0 -0
- data/res/generators/templates/application/{app/loading-LandscapeRight@2x.png → resources/ios/Default-LandscapeRight@2x.png} +0 -0
- data/res/generators/templates/application/{app/loading-Portrait.png → resources/ios/Default-Portrait.png} +0 -0
- data/res/generators/templates/application/{app/loading-Portrait@2x.png → resources/ios/Default-Portrait@2x.png} +0 -0
- data/res/generators/templates/application/{app/loading-PortraitUpsideDown.png → resources/ios/Default-PortraitUpsideDown.png} +0 -0
- data/res/generators/templates/application/{app/loading-PortraitUpsideDown@2x.png → resources/ios/Default-PortraitUpsideDown@2x.png} +0 -0
- data/res/generators/templates/application/resources/ios/Default.png +0 -0
- data/res/generators/templates/application/{app/loading@2x.png → resources/ios/Default@2x.png} +0 -0
- data/res/generators/templates/application/resources/ios/iTunesArtwork.png +0 -0
- data/res/generators/templates/application/resources/ios/iTunesArtwork@2x.png +0 -0
- data/res/generators/templates/application/resources/ios/icon114.png +0 -0
- data/res/generators/templates/application/resources/ios/icon120.png +0 -0
- data/res/generators/templates/application/resources/ios/icon144.png +0 -0
- data/res/generators/templates/application/resources/ios/icon152.png +0 -0
- data/res/generators/templates/application/resources/ios/icon180.png +0 -0
- data/res/generators/templates/application/resources/ios/icon57.png +0 -0
- data/res/generators/templates/application/resources/ios/icon60.png +0 -0
- data/res/generators/templates/application/resources/ios/icon72.png +0 -0
- data/res/generators/templates/application/resources/ios/icon76.png +0 -0
- data/res/generators/templates/application/rhoconfig.txt +2 -1
- data/res/generators/templates/iphone_project/Bremen7.xcodeproj/project.pbxproj +44 -0
- data/res/generators/templates/iphone_project/Resources/back_btn.png +0 -0
- data/res/generators/templates/iphone_project/Resources/back_btn@2x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/back_btn@3x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/forward_btn.png +0 -0
- data/res/generators/templates/iphone_project/Resources/forward_btn@2x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/forward_btn@3x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/gears.png +0 -0
- data/res/generators/templates/iphone_project/Resources/gears@2x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/gears@3x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/home_btn.png +0 -0
- data/res/generators/templates/iphone_project/Resources/home_btn@2x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/home_btn@3x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/sync_btn.png +0 -0
- data/res/generators/templates/iphone_project/Resources/sync_btn@2x.png +0 -0
- data/res/generators/templates/iphone_project/Resources/sync_btn@3x.png +0 -0
- data/res/generators/templates/iphone_project/buildRhoBundle +23 -7
- data/res/generators/templates/iphone_project/root/Info.plist +0 -7
- data/res/generators/templates/iphone_project/root/iTunesArtwork +0 -0
- data/res/generators/templates/iphone_project/root/iTunesArtwork@2x +0 -0
- data/res/generators/templates/iphone_project/root/icon114.png +0 -0
- data/res/generators/templates/iphone_project/root/icon120.png +0 -0
- data/res/generators/templates/iphone_project/root/icon144.png +0 -0
- data/res/generators/templates/iphone_project/root/icon152.png +0 -0
- data/res/generators/templates/iphone_project/root/icon180.png +0 -0
- data/res/generators/templates/iphone_project/root/icon57.png +0 -0
- data/res/generators/templates/iphone_project/root/icon60.png +0 -0
- data/res/generators/templates/iphone_project/root/icon72.png +0 -0
- data/res/generators/templates/iphone_project/root/icon76.png +0 -0
- data/res/generators/templates/project/android_studio_project/app/build.gradle.erb +88 -0
- data/res/generators/templates/project/android_studio_project/build.gradle +23 -0
- data/res/generators/templates/project/android_studio_project/gradle.properties +17 -0
- data/res/generators/templates/project/android_studio_project/gradlew +160 -0
- data/res/generators/templates/project/android_studio_project/gradlew.bat +90 -0
- data/res/generators/templates/project/android_studio_project/settings.gradle +1 -0
- data/rhodes.gemspec +7 -6
- data/version +1 -1
- metadata +135 -42
- data/res/generators/templates/application/icon/icon.svg +0 -22
- data/res/generators/templates/application/icon/icon114.png +0 -0
- data/res/generators/templates/application/icon/icon120.png +0 -0
- data/res/generators/templates/application/icon/icon144.png +0 -0
- data/res/generators/templates/application/icon/icon152.png +0 -0
- data/res/generators/templates/application/icon/icon180.png +0 -0
- data/res/generators/templates/application/icon/icon57.png +0 -0
- data/res/generators/templates/application/icon/icon60.png +0 -0
- data/res/generators/templates/application/icon/icon72.png +0 -0
- data/res/generators/templates/application/icon/icon76.png +0 -0
- data/res/generators/templates/application/production/iTunesArtwork.png +0 -0
- data/res/generators/templates/application/production/iTunesArtwork@2x.png +0 -0
@@ -254,7 +254,7 @@
|
|
254
254
|
|
255
255
|
@implementation TabbedMainView
|
256
256
|
|
257
|
-
@synthesize tabbar, tabbarData, tabindex, on_change_tab_callback;
|
257
|
+
@synthesize tabbar, tabbarData, tabindex, on_change_tab_callback, invisible_tab_control;
|
258
258
|
|
259
259
|
- (UIImage*)recolorImageWithColor:(UIImage*)image color:(UIColor *)color shadowColor:(UIColor *)shadowColor shadowOffset:(CGSize)shadowOffset shadowBlur:(CGFloat)shadowBlur
|
260
260
|
{
|
@@ -344,21 +344,29 @@
|
|
344
344
|
frame.origin.x = 0;
|
345
345
|
frame.origin.y = 0;
|
346
346
|
|
347
|
+
invisible_tab_control = NO;
|
348
|
+
|
347
349
|
rootFrame = frame;
|
348
350
|
|
349
351
|
NSString *background_color = nil;
|
350
352
|
NSString *selected_color = nil;
|
353
|
+
NSString *invisibleTabControl = nil;
|
351
354
|
|
352
355
|
NSDictionary* global_properties = (NSDictionary*)[bar_info objectForKey:NATIVE_BAR_PROPERTIES];
|
353
356
|
if (global_properties != nil) {
|
354
357
|
background_color = (NSString*)[global_properties objectForKey:NATIVE_BAR_BACKGOUND_COLOR];
|
355
358
|
selected_color = (NSString*)[global_properties objectForKey:NATIVE_BAR_SELECTED_COLOR];
|
359
|
+
invisibleTabControl = (NSString*)[global_properties objectForKey:NATIVE_BAR_TABBAR_INVISIBLE];
|
356
360
|
|
357
361
|
self.on_change_tab_callback = (id<IMethodResult>)[global_properties objectForKey:NATIVE_BAR_ON_CHANGE_TAB_CALLBACK];
|
358
362
|
if (self.on_change_tab_callback != nil) {
|
359
363
|
//[self.on_change_tab_callback release];
|
360
364
|
}
|
361
365
|
}
|
366
|
+
|
367
|
+
if (invisibleTabControl != nil) {
|
368
|
+
invisible_tab_control = [invisibleTabControl isEqualToString:@"true"];
|
369
|
+
}
|
362
370
|
|
363
371
|
|
364
372
|
#ifdef __IPHONE_7_0
|
@@ -411,9 +419,11 @@
|
|
411
419
|
// First call of self.view (when self.view is nil) trigger loadView
|
412
420
|
// and viewDidLoad which add all our subviews to the root view
|
413
421
|
[self.view addSubview:tabbar.view];
|
414
|
-
|
422
|
+
|
415
423
|
//tabbar.tabBar.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
|
416
424
|
//tabbar.tabBar.autoresizesSubviews = YES;
|
425
|
+
|
426
|
+
tabbar.tabBar.hidden = invisible_tab_control;
|
417
427
|
|
418
428
|
CGRect childFrame = [[v view] bounds];
|
419
429
|
childFrame.origin.x = 0;
|
@@ -424,7 +434,9 @@
|
|
424
434
|
//childFrame.size.width -= tbFrame.size.height;
|
425
435
|
//}
|
426
436
|
//else {
|
437
|
+
if (!invisible_tab_control) {
|
427
438
|
childFrame.size.height -= tbFrame.size.height;
|
439
|
+
}
|
428
440
|
//}
|
429
441
|
|
430
442
|
NSArray *items = (NSArray*)[bar_info objectForKey:NATIVE_BAR_ITEMS];
|
@@ -624,7 +636,7 @@
|
|
624
636
|
}
|
625
637
|
if ((index < 0) || (index >= [tabbar.viewControllers count])) {
|
626
638
|
// error
|
627
|
-
|
639
|
+
RAWLOG_ERROR1("TabBar invalid tab index [%d] !!! ", (int)index);
|
628
640
|
return nil;
|
629
641
|
}
|
630
642
|
return (SimpleMainView*)[tabbar.viewControllers objectAtIndex:index];
|
@@ -6,10 +6,29 @@
|
|
6
6
|
|
7
7
|
#import "common/RhoConf.h"
|
8
8
|
|
9
|
+
|
10
|
+
#import "logging/RhoLog.h"
|
11
|
+
#undef DEFAULT_LOGCATEGORY
|
12
|
+
#define DEFAULT_LOGCATEGORY "RhoURLProtocol"
|
13
|
+
|
14
|
+
static bool is_net_trace() {
|
15
|
+
static int res = -1;
|
16
|
+
if (res == -1) {
|
17
|
+
if (rho_conf_getBool("net_trace") ) {
|
18
|
+
res = 1;
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
res = 0;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return res == 1;
|
25
|
+
}
|
26
|
+
|
27
|
+
|
9
28
|
extern int rho_http_started();
|
10
29
|
extern int rho_http_get_port();
|
11
30
|
|
12
|
-
const char* rho_http_direct_request( const char* method, const char* uri, const char* query, const void* headers, const char* body, int* responseLength );
|
31
|
+
const char* rho_http_direct_request( const char* method, const char* uri, const char* query, const void* headers, const char* body, int bodylen, int* responseLength );
|
13
32
|
void rho_http_free_response( const char* data );
|
14
33
|
|
15
34
|
void* rho_http_init_headers_list();
|
@@ -28,6 +47,7 @@ int on_http_data_cb(http_parser* parser, const char *at, size_t length) { return
|
|
28
47
|
int on_http_cb(http_parser* parser) { return 0; }
|
29
48
|
|
30
49
|
|
50
|
+
|
31
51
|
@interface CRhoURLResponse : NSHTTPURLResponse {
|
32
52
|
|
33
53
|
}
|
@@ -39,6 +59,16 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
39
59
|
|
40
60
|
@implementation CRhoURLProtocol
|
41
61
|
|
62
|
+
|
63
|
+
-(const char*)selfIDstring {
|
64
|
+
return [[NSString stringWithFormat:@"<%p>", self] UTF8String];
|
65
|
+
}
|
66
|
+
|
67
|
+
+ (const char*)requestInfo:(NSURLRequest*)req {
|
68
|
+
return [[NSString stringWithFormat:@"<NSURLRequest:<%p>, URL:[ %@ ], Headers:[ %@ ]", req, req.URL, req.allHTTPHeaderFields] UTF8String];
|
69
|
+
}
|
70
|
+
|
71
|
+
|
42
72
|
- (void)dealloc
|
43
73
|
{
|
44
74
|
[httpBody release];
|
@@ -59,17 +89,26 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
59
89
|
|
60
90
|
+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest
|
61
91
|
{
|
92
|
+
if (is_net_trace()) {
|
93
|
+
RAWTRACE1("$NetRequestProcess$ canInitWithRequest BEGIN: { %s }", [CRhoURLProtocol requestInfo:theRequest]);
|
94
|
+
}
|
95
|
+
|
62
96
|
NSURL* theUrl = [theRequest URL];
|
63
97
|
if ([[theUrl path] isEqualToString:@"/!__rhoNativeApi"]) {
|
64
98
|
|
65
99
|
NSString* jsonRequestTest = [theRequest valueForHTTPHeaderField:@"__rhoNativeApiCall"];
|
66
100
|
if (jsonRequestTest != nil) {
|
67
|
-
|
101
|
+
if (is_net_trace()) {
|
102
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return YES by !__rhoNativeApi prefix");
|
103
|
+
}
|
68
104
|
return YES;
|
69
105
|
}
|
70
106
|
}
|
71
107
|
#if defined(RHO_NO_RUBY_API) && defined(RHO_NO_HTTP_SERVER)
|
72
108
|
if ([theRequest.URL.scheme isEqualToString:@"file"]) {
|
109
|
+
if (is_net_trace()) {
|
110
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return YES by file scheme when no Ruby API server");
|
111
|
+
}
|
73
112
|
return YES;
|
74
113
|
}
|
75
114
|
#endif
|
@@ -79,10 +118,21 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
79
118
|
canHandle = rho_conf_getBool("ios_direct_local_requests")!=0;
|
80
119
|
}
|
81
120
|
|
82
|
-
if ( canHandle
|
83
|
-
|
121
|
+
if ( canHandle ) {
|
122
|
+
if (is_net_trace()) {
|
123
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest: ios_direct_local_requests = true !");
|
124
|
+
}
|
125
|
+
if ([CRhoURLProtocol isLocalURL:theUrl]) {
|
126
|
+
if (is_net_trace()) {
|
127
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return YES URL is local !");
|
128
|
+
}
|
129
|
+
return YES;
|
130
|
+
}
|
84
131
|
}
|
85
132
|
|
133
|
+
if (is_net_trace()) {
|
134
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return NO");
|
135
|
+
}
|
86
136
|
return NO;
|
87
137
|
}
|
88
138
|
|
@@ -91,19 +141,26 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
91
141
|
return request;
|
92
142
|
}
|
93
143
|
|
94
|
-
- (void)
|
144
|
+
- (void)startLoadingInThread
|
95
145
|
{
|
146
|
+
if (is_net_trace()) {
|
147
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoadingInThread BEGIN: { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:[self request]]);
|
148
|
+
}
|
96
149
|
NSURL* theUrl = [[self request] URL];
|
97
150
|
|
98
151
|
|
99
152
|
if ([[theUrl path] isEqualToString:@"/!__rhoNativeApi"]) {
|
100
|
-
|
153
|
+
if (is_net_trace()) {
|
154
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading URL has !__rhoNativeApi", [self selfIDstring]);
|
155
|
+
}
|
101
156
|
NSString* jsonRequestTest = [[self request] valueForHTTPHeaderField:@"__rhoNativeApiCall"];
|
102
157
|
if (jsonRequestTest != nil) {
|
103
158
|
NSString* responseStr = [CJSEntryPoint js_entry_point:jsonRequestTest];
|
104
159
|
if (responseStr != nil) {
|
105
|
-
//NSLog(@"$$$ send responce for[%@:%@] = [%@]", [theUrl absoluteString], jsonRequestTest, responseStr);
|
106
160
|
[self sendResponseWithResponseCode:200 data:[responseStr dataUsingEncoding:NSUTF8StringEncoding]];
|
161
|
+
if (is_net_trace()) {
|
162
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading END", [self selfIDstring]);
|
163
|
+
}
|
107
164
|
return;
|
108
165
|
}
|
109
166
|
}
|
@@ -133,12 +190,13 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
133
190
|
textEncodingName:@"UTF-8"];
|
134
191
|
response.statusCode = 200;
|
135
192
|
|
136
|
-
|
137
|
-
|
138
|
-
|
193
|
+
if (!self.isStopped) {
|
194
|
+
[[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
195
|
+
if (data != nil) {
|
196
|
+
[[self client] URLProtocol:self didLoadData:data];
|
197
|
+
}
|
198
|
+
[[self client] URLProtocolDidFinishLoading:self];
|
139
199
|
}
|
140
|
-
[[self client] URLProtocolDidFinishLoading:self];
|
141
|
-
|
142
200
|
|
143
201
|
return;
|
144
202
|
}
|
@@ -147,6 +205,9 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
147
205
|
|
148
206
|
if ( [CRhoURLProtocol isLocalURL:theUrl] )
|
149
207
|
{
|
208
|
+
if (is_net_trace()) {
|
209
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: URL is local !", [self selfIDstring]);
|
210
|
+
}
|
150
211
|
NSURL* url = theUrl;
|
151
212
|
CRhoURLResponse* resp = nil;
|
152
213
|
|
@@ -154,7 +215,14 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
154
215
|
|
155
216
|
if ( resp != nil )
|
156
217
|
{
|
218
|
+
if (is_net_trace()) {
|
219
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading has Responce from local server", [self selfIDstring]);
|
220
|
+
}
|
157
221
|
if ( ((self.httpStatusCode==301)||(self.httpStatusCode==302)) && ( [self.httpHeaders objectForKey:@"location"] != nil ) ) {
|
222
|
+
|
223
|
+
if (is_net_trace()) {
|
224
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading we have REDIRECT from local server !", [self selfIDstring]);
|
225
|
+
}
|
158
226
|
NSString* loc = [self.httpHeaders objectForKey:@"location"];
|
159
227
|
|
160
228
|
NSString* escaped = [loc stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
@@ -202,38 +270,92 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
202
270
|
}
|
203
271
|
|
204
272
|
|
205
|
-
|
206
|
-
|
273
|
+
NSMutableURLRequest* redirReq = [NSMutableURLRequest requestWithURL:url];
|
274
|
+
|
275
|
+
// clone headers from original request to redirect request
|
276
|
+
NSDictionary* headers = [[self request] allHTTPHeaderFields];
|
277
|
+
for (NSString* key in headers) {
|
278
|
+
NSString* value = [headers objectForKey:key];
|
279
|
+
[redirReq setValue:value forHTTPHeaderField:key];
|
280
|
+
}
|
281
|
+
|
282
|
+
if (is_net_trace()) {
|
283
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading wasRedirectedToRequest with Request { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:redirReq]);
|
284
|
+
}
|
285
|
+
if (!self.isStopped) {
|
286
|
+
|
287
|
+
[[self client] URLProtocol:self wasRedirectedToRequest:redirReq redirectResponse:resp];
|
288
|
+
}
|
289
|
+
if (is_net_trace()) {
|
290
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading END", [self selfIDstring]);
|
291
|
+
}
|
207
292
|
return;
|
208
293
|
}
|
294
|
+
else {
|
295
|
+
RAWLOG_ERROR2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading Redirect response has no URL ! Initial request: { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:[self request]]);
|
296
|
+
}
|
209
297
|
}
|
210
298
|
else
|
211
299
|
{
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
300
|
+
if (is_net_trace()) {
|
301
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading just request - no redirection", [self selfIDstring]);
|
302
|
+
}
|
303
|
+
if (!self.isStopped) {
|
304
|
+
|
305
|
+
[[self client] URLProtocol:self didReceiveResponse:resp cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
306
|
+
}
|
307
|
+
if (self.httpBody != nil) {
|
308
|
+
if (!self.isStopped) {
|
309
|
+
[[self client] URLProtocol:self didLoadData:self.httpBody];
|
310
|
+
}
|
311
|
+
}
|
312
|
+
if (!self.isStopped) {
|
313
|
+
[[self client] URLProtocolDidFinishLoading:self];
|
314
|
+
}
|
315
|
+
|
316
|
+
if (is_net_trace()) {
|
317
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading END", [self selfIDstring]);
|
216
318
|
}
|
217
|
-
|
218
|
-
[[self client] URLProtocolDidFinishLoading:self];
|
219
319
|
return;
|
220
320
|
}
|
221
321
|
}
|
322
|
+
else {
|
323
|
+
RAWLOG_ERROR2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading has NO Responce from local server !!! Initial request: { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:[self request]]);
|
324
|
+
}
|
222
325
|
}
|
223
326
|
|
224
|
-
//NSLog(@"$$$ responce ERROR: [%@]", [theUrl absoluteString]);
|
225
327
|
NSString* body = @"error";
|
226
328
|
[self sendResponseWithResponseCode:401 data:[body dataUsingEncoding:NSUTF8StringEncoding]];
|
227
|
-
|
329
|
+
if (is_net_trace()) {
|
330
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoadingInThread END", [self selfIDstring]);
|
331
|
+
}
|
228
332
|
}
|
229
333
|
|
334
|
+
- (void)startLoading
|
335
|
+
{
|
336
|
+
self.isStopped = NO;
|
337
|
+
if (is_net_trace()) {
|
338
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading()", [self selfIDstring]);
|
339
|
+
}
|
340
|
+
|
341
|
+
dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
|
342
|
+
[self startLoadingInThread];
|
343
|
+
});
|
344
|
+
}
|
345
|
+
|
346
|
+
|
230
347
|
- (CRhoURLResponse*) makeDirectHttpRequest:(NSURL*)theUrl
|
231
348
|
{
|
232
|
-
|
349
|
+
|
350
|
+
if (is_net_trace()) {
|
351
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: makeDirectHttpRequest : URL [ %s ]", [self selfIDstring], [[theUrl absoluteString] UTF8String]);
|
352
|
+
}
|
353
|
+
|
233
354
|
|
234
355
|
const char* uri = [[theUrl path] UTF8String];
|
235
356
|
const char* method = [[[self request] HTTPMethod] UTF8String];
|
236
357
|
const char* body = [[[self request] HTTPBody] bytes];
|
358
|
+
int bodylen = (int)[[self request] HTTPBody].length;
|
237
359
|
const char* query = [[theUrl query] UTF8String];
|
238
360
|
|
239
361
|
NSDictionary* headers = [[self request] allHTTPHeaderFields];
|
@@ -249,7 +371,7 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
249
371
|
|
250
372
|
int len = 0;
|
251
373
|
|
252
|
-
const char* response = rho_http_direct_request(method, uri, query, cHeaders, body, &len);
|
374
|
+
const char* response = rho_http_direct_request(method, uri, query, cHeaders, body, bodylen, &len);
|
253
375
|
|
254
376
|
rho_http_free_headers_list(cHeaders);
|
255
377
|
|
@@ -302,6 +424,10 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
302
424
|
|
303
425
|
- (void)stopLoading
|
304
426
|
{
|
427
|
+
self.isStopped = YES;
|
428
|
+
if (is_net_trace()) {
|
429
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: stopLoading()", [self selfIDstring]);
|
430
|
+
}
|
305
431
|
|
306
432
|
}
|
307
433
|
|
@@ -312,7 +438,13 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
312
438
|
|
313
439
|
- (void)sendResponseWithResponseCode:(NSInteger)statusCode data:(NSData*)data
|
314
440
|
{
|
441
|
+
if (is_net_trace()) {
|
442
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: sendResponseWithResponseCode : code: [ %d ] ", [self selfIDstring], (int)statusCode);
|
443
|
+
}
|
315
444
|
|
445
|
+
if (self.isStopped) {
|
446
|
+
return;
|
447
|
+
}
|
316
448
|
CRhoURLResponse* response =
|
317
449
|
[[CRhoURLResponse alloc] initWithURL:[[self request] URL]
|
318
450
|
MIMEType:@"text/plain"
|
@@ -320,25 +452,39 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
320
452
|
textEncodingName:@"UTF-8"];
|
321
453
|
response.statusCode = statusCode;
|
322
454
|
|
323
|
-
|
455
|
+
if (!self.isStopped) {
|
456
|
+
[[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
457
|
+
}
|
324
458
|
if (data != nil) {
|
325
|
-
|
459
|
+
if (!self.isStopped) {
|
460
|
+
[[self client] URLProtocol:self didLoadData:data];
|
461
|
+
}
|
462
|
+
}
|
463
|
+
if (!self.isStopped) {
|
464
|
+
[[self client] URLProtocolDidFinishLoading:self];
|
326
465
|
}
|
327
|
-
[[self client] URLProtocolDidFinishLoading:self];
|
328
|
-
|
329
466
|
[response release];
|
330
467
|
}
|
331
468
|
|
332
469
|
+ (BOOL) isLocalURL:(NSURL*)url
|
333
470
|
{
|
471
|
+
if (is_net_trace()) {
|
472
|
+
RAWTRACE1("$NetRequestProcess$ isLocalURL BEGIN : URL: [ %s ] ", [[url absoluteString] UTF8String]);
|
473
|
+
}
|
334
474
|
if ( [[url absoluteString] isEqualToString:@""] )
|
335
475
|
{
|
476
|
+
if (is_net_trace()) {
|
477
|
+
RAWTRACE("isLocalURL END : return NO");
|
478
|
+
}
|
336
479
|
return NO;
|
337
480
|
}
|
338
481
|
|
339
482
|
const char* scheme = [[url scheme] UTF8String];
|
340
483
|
if (scheme != 0) {
|
341
484
|
if ((strcmp(scheme, "http") !=0 ) && (strcmp(scheme, "https") !=0 )) {
|
485
|
+
if (is_net_trace()) {
|
486
|
+
RAWTRACE("$NetRequestProcess$ isLocalURL END : return NO");
|
487
|
+
}
|
342
488
|
return NO;
|
343
489
|
}
|
344
490
|
}
|
@@ -347,7 +493,10 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
347
493
|
|
348
494
|
if ( 0 == host )
|
349
495
|
{
|
350
|
-
|
496
|
+
if (is_net_trace()) {
|
497
|
+
RAWTRACE("$NetRequestProcess$ isLocalURL END : return YES");
|
498
|
+
}
|
499
|
+
return YES;
|
351
500
|
}
|
352
501
|
|
353
502
|
NSNumber* p = [url port];
|
@@ -355,10 +504,15 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
355
504
|
|
356
505
|
int rhoPort = rho_http_get_port();
|
357
506
|
|
358
|
-
|
507
|
+
BOOL ret = (
|
359
508
|
((port == rhoPort))
|
360
509
|
&& ( (strcmp(host,"127.0.0.1")==0) || (strcmp(host,"localhost")==0) )
|
361
510
|
);
|
511
|
+
if (is_net_trace()) {
|
512
|
+
RAWTRACE1("$NetRequestProcess$ isLocalURL END : return [%s]", [[[NSNumber numberWithBool:ret] stringValue] UTF8String]);
|
513
|
+
}
|
514
|
+
|
515
|
+
return ret;
|
362
516
|
}
|
363
517
|
|
364
518
|
|
@@ -366,6 +520,7 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
366
520
|
@synthesize httpHeaderName;
|
367
521
|
@synthesize httpHeaders;
|
368
522
|
@synthesize httpBody;
|
523
|
+
@synthesize isStopped;
|
369
524
|
|
370
525
|
|
371
526
|
@end
|