rhodes 5.5.0.7 → 5.5.0.22
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/Rakefile +24 -0
- data/extensions/instrumentation/ext/platform/android/src/com/rho/instrumentation/Instrumentation.java +5 -0
- data/extensions/rhoconnect-push/ext/rhoconnect-push/platform/android/Rakefile +1 -1
- data/lib/build/jake.rb +5 -0
- data/lib/commonAPI/clipboard/ext.yml +17 -0
- data/lib/commonAPI/clipboard/ext/Clipboard.xml +49 -0
- data/lib/commonAPI/clipboard/ext/build +19 -0
- data/lib/commonAPI/clipboard/ext/build.bat +29 -0
- data/lib/commonAPI/clipboard/ext/platform/android/Rakefile +141 -0
- data/lib/commonAPI/clipboard/ext/platform/android/ext_java.files +9 -0
- data/lib/commonAPI/clipboard/ext/platform/android/ext_native.files +7 -0
- data/lib/commonAPI/clipboard/ext/platform/android/jni/Clipboard_impl.cpp +61 -0
- data/lib/commonAPI/clipboard/ext/platform/android/src/com/rho/clipboard/Clipboard.java +15 -0
- data/lib/commonAPI/clipboard/ext/platform/android/src/com/rho/clipboard/ClipboardFactory.java +18 -0
- data/lib/commonAPI/clipboard/ext/platform/android/src/com/rho/clipboard/ClipboardSingleton.java +146 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/Clipboard.xcodeproj/project.pbxproj +368 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/Clipboard_Prefix.pch +7 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/Rakefile +73 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/impl/Clipboard.h +11 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/impl/Clipboard.m +12 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/impl/ClipboardFactorySingleton.m +16 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/impl/ClipboardSetup.m +9 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/impl/ClipboardSingleton.h +18 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/impl/ClipboardSingleton.m +43 -0
- data/lib/commonAPI/clipboard/ext/platform/iphone/impl/readme.txt +7 -0
- data/lib/commonAPI/coreapi/ext/NativeTabbar.xml +3 -3
- data/lib/commonAPI/coreapi/ext/shared/TimerImpl.cpp +36 -27
- data/lib/commonAPI/coreapi/public/api/rhoapi-force.ajax.js +3 -1
- data/lib/commonAPI/coreapi/public/api/rhoapi.js +2 -1
- data/lib/commonAPI/devicesecurity/ext.yml +11 -0
- data/lib/commonAPI/devicesecurity/ext/DeviceSecurity.xml +91 -0
- data/lib/commonAPI/devicesecurity/ext/build +19 -0
- data/lib/commonAPI/devicesecurity/ext/build.bat +29 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/InbuiltValues.erb +16 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/Rakefile +166 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/ext_java.files +10 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/ext_native.files +7 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/jni/DeviceSecurity_impl.cpp +61 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/src/com/rho/devicesecurity/DeviceSecurity.java +14 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/src/com/rho/devicesecurity/DeviceSecurityFactory.java +18 -0
- data/lib/commonAPI/devicesecurity/ext/platform/android/src/com/rho/devicesecurity/DeviceSecuritySingleton.java +412 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/DeviceSecurity.xcodeproj/project.pbxproj +368 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/DeviceSecurity_Prefix.pch +7 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/Rakefile +73 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/impl/DeviceSecurity.h +11 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/impl/DeviceSecurity.m +12 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/impl/DeviceSecurityFactorySingleton.m +16 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/impl/DeviceSecuritySetup.m +9 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/impl/DeviceSecuritySingleton.h +19 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/impl/DeviceSecuritySingleton.m +106 -0
- data/lib/commonAPI/devicesecurity/ext/platform/iphone/impl/readme.txt +7 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/LocalFileProvider.java +5 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/Utils.java +9 -0
- data/platform/android/build/android.rake +42 -1
- data/platform/android/build/androidcommon.rb +4 -2
- data/platform/iphone/Classes/RhoWKWebView.m +4 -0
- data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.h +2 -0
- data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.m +195 -30
- data/platform/iphone/Classes/rho/net/IPhoneNetRequest.mm +91 -4
- data/platform/iphone/rbuild/iphone.rake +297 -231
- data/platform/iphone/rbuild/putsOverride.rake +8 -0
- data/platform/shared/common/RhoTime.cpp +81 -40
- data/platform/shared/common/RhodesApp.cpp +16 -18
- data/platform/shared/db/DBAdapter.cpp +33 -0
- data/platform/shared/db/DBAdapter.h +5 -0
- data/platform/shared/net/HttpServer.cpp +27 -1
- data/platform/shared/net/INetRequest.cpp +33 -6
- 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/wm/build/wm.rake +7 -3
- data/platform/wm/rhodes/browser/BrowserFactory.cpp +4 -6
- data/platform/wm/rhodes/browser/stubs.cpp +5 -0
- data/platform/wm/rhodes/rhodes.vcproj +31 -2
- data/rakefile.rb +24 -0
- data/res/generators/templates/application/app/Settings/home.erb +1 -1
- data/res/generators/templates/application/build.yml +61 -4
- data/res/generators/templates/application/icon/icon.png +0 -0
- 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
- data/res/generators/templates/iphone_project/Bremen7.xcodeproj/project.pbxproj +1 -0
- data/res/generators/templates/iphone_project/buildRhoBundle +23 -7
- data/res/generators/templates/iphone_project/root/Info.plist +0 -2
- 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/iphone_project/root/rhorunner_development.entitlements +6 -0
- data/rhodes.gemspec +19 -17
- data/version +1 -1
- metadata +118 -44
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
#import "IDeviceSecurity.h"
|
3
|
+
#import "DeviceSecurityFactoryBase.h"
|
4
|
+
|
5
|
+
static DeviceSecurityFactoryBase* ourDeviceSecurityFactory = nil;
|
6
|
+
|
7
|
+
@implementation DeviceSecurityFactorySingleton
|
8
|
+
|
9
|
+
+(id<IDeviceSecurityFactory>) getDeviceSecurityFactoryInstance {
|
10
|
+
if (ourDeviceSecurityFactory == nil) {
|
11
|
+
ourDeviceSecurityFactory = [[DeviceSecurityFactoryBase alloc] init];
|
12
|
+
}
|
13
|
+
return ourDeviceSecurityFactory;
|
14
|
+
}
|
15
|
+
|
16
|
+
@end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
#import "IDeviceSecurity.h"
|
3
|
+
#import "DeviceSecuritySingletonBase.h"
|
4
|
+
|
5
|
+
@interface DeviceSecuritySingleton : DeviceSecuritySingletonBase<IDeviceSecuritySingleton> {
|
6
|
+
}
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
-(void) isDeviceSecured:(id<IMethodResult>)methodResult;
|
11
|
+
-(void) isDeviceJailbroken:(id<IMethodResult>)methodResult;
|
12
|
+
-(void) isDeviceRooted:(id<IMethodResult>)methodResult;
|
13
|
+
-(void) isRunOnSimulator:(id<IMethodResult>)methodResult;
|
14
|
+
-(void) isDebugMode:(id<IMethodResult>)methodResult;
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
@end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
|
2
|
+
#import "DeviceSecuritySingleton.h"
|
3
|
+
#import <UIKit/UIKit.h>
|
4
|
+
|
5
|
+
@implementation DeviceSecuritySingleton
|
6
|
+
|
7
|
+
-(BOOL) isJailbroken
|
8
|
+
{
|
9
|
+
#if !(TARGET_IPHONE_SIMULATOR)
|
10
|
+
|
11
|
+
if ([[NSFileManager defaultManager] fileExistsAtPath:@"/Applications/Cydia.app"] ||
|
12
|
+
[[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/MobileSubstrate.dylib"] ||
|
13
|
+
[[NSFileManager defaultManager] fileExistsAtPath:@"/bin/bash"] ||
|
14
|
+
[[NSFileManager defaultManager] fileExistsAtPath:@"/usr/sbin/sshd"] ||
|
15
|
+
[[NSFileManager defaultManager] fileExistsAtPath:@"/etc/apt"] ||
|
16
|
+
[[NSFileManager defaultManager] fileExistsAtPath:@"/private/var/lib/apt/"] ||
|
17
|
+
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"cydia://package/com.example.package"]])
|
18
|
+
{
|
19
|
+
return YES;
|
20
|
+
}
|
21
|
+
|
22
|
+
FILE *f = NULL ;
|
23
|
+
if ((f = fopen("/bin/bash", "r")) ||
|
24
|
+
(f = fopen("/Applications/Cydia.app", "r")) ||
|
25
|
+
(f = fopen("/Library/MobileSubstrate/MobileSubstrate.dylib", "r")) ||
|
26
|
+
(f = fopen("/usr/sbin/sshd", "r")) ||
|
27
|
+
(f = fopen("/etc/apt", "r")))
|
28
|
+
{
|
29
|
+
fclose(f);
|
30
|
+
return YES;
|
31
|
+
}
|
32
|
+
fclose(f);
|
33
|
+
|
34
|
+
NSError *error;
|
35
|
+
NSString *stringToBeWritten = @"This is a test.";
|
36
|
+
[stringToBeWritten writeToFile:@"/private/jailbreak.txt" atomically:YES encoding:NSUTF8StringEncoding error:&error];
|
37
|
+
[[NSFileManager defaultManager] removeItemAtPath:@"/private/jailbreak.txt" error:nil];
|
38
|
+
if(error == nil)
|
39
|
+
{
|
40
|
+
return YES;
|
41
|
+
}
|
42
|
+
|
43
|
+
#endif
|
44
|
+
|
45
|
+
return NO;
|
46
|
+
}
|
47
|
+
|
48
|
+
-(BOOL) isSimulator {
|
49
|
+
#if !(TARGET_IPHONE_SIMULATOR)
|
50
|
+
return NO;
|
51
|
+
#else
|
52
|
+
return YES;
|
53
|
+
#endif
|
54
|
+
}
|
55
|
+
|
56
|
+
-(void) isDeviceSecured:(id<IMethodResult>)methodResult {
|
57
|
+
[methodResult setResult:[NSNumber numberWithBool:!([self isJailbroken] || [self isSimulator])]];
|
58
|
+
}
|
59
|
+
|
60
|
+
-(void) isDeviceJailbroken:(id<IMethodResult>)methodResult {
|
61
|
+
[methodResult setResult:[NSNumber numberWithBool:[self isJailbroken]]];
|
62
|
+
}
|
63
|
+
|
64
|
+
-(void) isDeviceRooted:(id<IMethodResult>)methodResult {
|
65
|
+
[methodResult setResult:[NSNumber numberWithBool:NO]];
|
66
|
+
}
|
67
|
+
|
68
|
+
-(void) isRunOnSimulator:(id<IMethodResult>)methodResult {
|
69
|
+
[methodResult setResult:[NSNumber numberWithBool:[self isSimulator]]];
|
70
|
+
}
|
71
|
+
|
72
|
+
-(void) isDebugMode:(id<IMethodResult>)methodResult {
|
73
|
+
[methodResult setResult:[NSNumber numberWithBool:NO]];
|
74
|
+
}
|
75
|
+
|
76
|
+
-(void) getAppCertificateSignatures:(id<IMethodResult>)methodResult {
|
77
|
+
NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:1];
|
78
|
+
[methodResult setResult:arr];
|
79
|
+
}
|
80
|
+
|
81
|
+
-(void) getAllowedCertificateSignatures:(id<IMethodResult>)methodResult {
|
82
|
+
NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:1];
|
83
|
+
[methodResult setResult:arr];
|
84
|
+
}
|
85
|
+
|
86
|
+
-(void) getInstallerPackageName:(id<IMethodResult>)methodResult {
|
87
|
+
NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:1];
|
88
|
+
[methodResult setResult:@""];
|
89
|
+
}
|
90
|
+
|
91
|
+
-(void) getAllowedInstallerPackages:(id<IMethodResult>)methodResult {
|
92
|
+
NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:1];
|
93
|
+
[methodResult setResult:arr];
|
94
|
+
}
|
95
|
+
|
96
|
+
-(void) haveAnySignatureIssues:(id<IMethodResult>)methodResult {
|
97
|
+
[methodResult setResult:[NSNumber numberWithBool:NO]];
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
-(void) haveAnyInstallerIssues:(id<IMethodResult>)methodResult {
|
102
|
+
[methodResult setResult:[NSNumber numberWithBool:NO]];
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
@end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
contains files with module API Implementation.
|
2
|
+
|
3
|
+
Developer should create it - after first generation this folder is empty and this folder do not changed with next generation processes !!!.
|
4
|
+
|
5
|
+
Developer should make at least <ModuleName>FactorySingleton.m with acees to <ModuleName>Factory interface!
|
6
|
+
All other files include base_impl can be removed from project if it wants by developer.
|
7
|
+
Default stub generated code placed in stub_impl folder - you can just copy all files from /generated/stub_impl to this folder and implement unemplemented methods.
|
@@ -137,7 +137,7 @@ public class LocalFileProvider extends ContentProvider
|
|
137
137
|
}
|
138
138
|
|
139
139
|
@Override
|
140
|
-
public AssetFileDescriptor openAssetFile(Uri uri, String mode) {
|
140
|
+
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
|
141
141
|
Logger.T(TAG, "Opening asset: " + uri);
|
142
142
|
|
143
143
|
if(mode.compareTo("r") != 0)
|
@@ -148,6 +148,10 @@ public class LocalFileProvider extends ContentProvider
|
|
148
148
|
File path = fileFromUri(uri);
|
149
149
|
|
150
150
|
AssetFileDescriptor fd = RhoFileApi.openAssetFd(path.getPath());
|
151
|
+
|
152
|
+
if ( null == fd ) {
|
153
|
+
return super.openAssetFile( uri, mode );
|
154
|
+
}
|
151
155
|
|
152
156
|
return fd;
|
153
157
|
}
|
@@ -33,6 +33,8 @@ import java.io.FileOutputStream;
|
|
33
33
|
import java.io.IOException;
|
34
34
|
import java.io.InputStream;
|
35
35
|
import java.io.OutputStream;
|
36
|
+
import java.io.StringWriter;
|
37
|
+
import java.io.PrintWriter;
|
36
38
|
|
37
39
|
import android.content.res.AssetManager;
|
38
40
|
|
@@ -221,5 +223,12 @@ public class Utils {
|
|
221
223
|
s.append(message);
|
222
224
|
android.util.Log.v(tag, s.toString());
|
223
225
|
}
|
226
|
+
|
227
|
+
public static String getExceptionDetails( Exception e ) {
|
228
|
+
StringWriter sw = new StringWriter();
|
229
|
+
PrintWriter pw = new PrintWriter(sw);
|
230
|
+
e.printStackTrace(pw);
|
231
|
+
return (e.toString() + "\n" + sw.toString());
|
232
|
+
}
|
224
233
|
|
225
234
|
}
|
@@ -256,6 +256,30 @@ def find_file(file_name, path_array)
|
|
256
256
|
result
|
257
257
|
end
|
258
258
|
|
259
|
+
def setup_ext_env( extpath, extname )
|
260
|
+
env = {}
|
261
|
+
env['RHO_PLATFORM'] = 'android'
|
262
|
+
env["RHO_APP_DIR"] = $app_path
|
263
|
+
env["ANDROID_SDK"] = $androidsdkpath
|
264
|
+
env["ANDROID_NDK"] = $androidndkpath
|
265
|
+
env["ANDROID_API_LEVEL"] = $found_api_level.to_s
|
266
|
+
env["RHO_ROOT"] = $startdir
|
267
|
+
env["BUILD_DIR"] ||= $startdir + "/platform/android/build"
|
268
|
+
env["RHO_INC"] = $appincdir
|
269
|
+
env["RHO_RES"] = $appres
|
270
|
+
env["RHO_ANDROID_TMP_DIR"] = $tmpdir
|
271
|
+
env["RHO_DEBUG"] = $debug.to_s
|
272
|
+
env['SOURCEPATH'] = extpath
|
273
|
+
sourcelist = Dir.glob(File.join(extpath,'**','android','ext_native.files'))
|
274
|
+
env['SOURCELIST'] = sourcelist.size == 1 ? sourcelist.first : File.join(extpath,'ext_native.files')
|
275
|
+
env["TARGET_TEMP_DIR"] = File.join($app_builddir, 'extensions', extname)
|
276
|
+
env['TARGETPATH'] = File.join($app_builddir, 'extensions', extname)
|
277
|
+
env['TARGETLIB'] = "lib#{extname}.a"
|
278
|
+
env['TEMP_FILES_DIR'] = File.join($tmpdir, extname)
|
279
|
+
|
280
|
+
env
|
281
|
+
end
|
282
|
+
|
259
283
|
namespace "config" do
|
260
284
|
task :set_android_platform do
|
261
285
|
$current_platform = "android"
|
@@ -709,6 +733,8 @@ namespace "config" do
|
|
709
733
|
manifest_changes = extconf["android_manifest_changes"]
|
710
734
|
manifest_changes = extconf_android['manifest_changes'] if manifest_changes.nil? and extconf_android
|
711
735
|
|
736
|
+
prebuild_rake_task = extconf_android['prebuild_rake_task'] if extconf_android
|
737
|
+
|
712
738
|
if manifest_changes
|
713
739
|
manifest_changes = [manifest_changes] unless manifest_changes.is_a? Array
|
714
740
|
manifest_changes.map! { |path| File.join(extpath,path) }
|
@@ -855,6 +881,13 @@ namespace "config" do
|
|
855
881
|
rakepath = extpath
|
856
882
|
end
|
857
883
|
$ext_android_build_scripts[ext] = [rakepath, 'rake']
|
884
|
+
|
885
|
+
if prebuild_rake_task
|
886
|
+
args = [ prebuild_rake_task ]
|
887
|
+
args << '--trace' if USE_TRACES
|
888
|
+
cc_run( 'rake', args, rakepath, true, setup_ext_env( extpath, ext ) ) or raise "Extension prebuild failed: #{extpath}"
|
889
|
+
end
|
890
|
+
|
858
891
|
elsif exttype != 'prebuilt'
|
859
892
|
build_script = File.join(extpath,'ext','build'+$bat_ext)
|
860
893
|
if File.exists? build_script
|
@@ -2245,11 +2278,19 @@ namespace "package" do
|
|
2245
2278
|
end
|
2246
2279
|
|
2247
2280
|
# Workaround: manually add files starting with '_' because aapt silently ignore such files when creating package
|
2281
|
+
args = [ USE_TRACES ? "uvf" : "uf", resourcepkg]
|
2282
|
+
|
2283
|
+
skip_underscores = true
|
2284
|
+
|
2248
2285
|
Dir.glob(File.join($appassets, "**/*")).each do |f|
|
2249
2286
|
next unless File.basename(f) =~ /^_/
|
2250
2287
|
relpath = Pathname.new(f).relative_path_from(Pathname.new($tmpdir)).to_s
|
2251
2288
|
puts "Add #{relpath} to #{resourcepkg}..."
|
2252
|
-
args
|
2289
|
+
args << relpath
|
2290
|
+
skip_underscores = false
|
2291
|
+
end
|
2292
|
+
|
2293
|
+
unless skip_underscores
|
2253
2294
|
Jake.run($jarbin, args, $tmpdir)
|
2254
2295
|
unless $?.success?
|
2255
2296
|
raise "Error packaging assets"
|
@@ -313,7 +313,7 @@ def cc_deps(filename, objdir, additional)
|
|
313
313
|
out.split(/\s+/)
|
314
314
|
end
|
315
315
|
|
316
|
-
def cc_run(command, args, chdir = nil, coloring = true)
|
316
|
+
def cc_run(command, args, chdir = nil, coloring = true, env = nil)
|
317
317
|
save_cwd = FileUtils.pwd
|
318
318
|
FileUtils.cd chdir unless chdir.nil?
|
319
319
|
argv = [command]
|
@@ -325,6 +325,8 @@ def cc_run(command, args, chdir = nil, coloring = true)
|
|
325
325
|
winName = `WMIC OS get Name`
|
326
326
|
isWinXP = true if winName =~ /Windows XP/
|
327
327
|
end
|
328
|
+
|
329
|
+
env = ENV unless env
|
328
330
|
|
329
331
|
if isWinXP
|
330
332
|
puts '-' * 80
|
@@ -332,7 +334,7 @@ def cc_run(command, args, chdir = nil, coloring = true)
|
|
332
334
|
else
|
333
335
|
out = StringIO.new
|
334
336
|
ret = nil
|
335
|
-
Open3.popen2e(cmdstr) do |i,f,t|
|
337
|
+
Open3.popen2e(env, cmdstr) do |i,f,t|
|
336
338
|
warning = false
|
337
339
|
error = false
|
338
340
|
while data = f.gets
|
@@ -176,6 +176,10 @@
|
|
176
176
|
}
|
177
177
|
|
178
178
|
- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation {
|
179
|
+
// force Ajax CommonAPI calls
|
180
|
+
NSString* jscode = @"window['__rho_nativeBridgeType']='ajax'";
|
181
|
+
[self stringByEvaluatingJavaScriptFromString:jscode];
|
182
|
+
|
179
183
|
[delegate webViewDidFinishLoad:self];
|
180
184
|
}
|
181
185
|
|
@@ -6,6 +6,25 @@
|
|
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
|
|
@@ -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,27 @@ 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
|
//NSLog(@"$$$ process Request: [%@:%@]", [theUrl absoluteString], jsonRequestTest);
|
102
|
+
if (is_net_trace()) {
|
103
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return YES by !__rhoNativeApi prefix");
|
104
|
+
}
|
68
105
|
return YES;
|
69
106
|
}
|
70
107
|
}
|
71
108
|
#if defined(RHO_NO_RUBY_API) && defined(RHO_NO_HTTP_SERVER)
|
72
109
|
if ([theRequest.URL.scheme isEqualToString:@"file"]) {
|
110
|
+
if (is_net_trace()) {
|
111
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return YES by file scheme when no Ruby API server");
|
112
|
+
}
|
73
113
|
return YES;
|
74
114
|
}
|
75
115
|
#endif
|
@@ -79,10 +119,21 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
79
119
|
canHandle = rho_conf_getBool("ios_direct_local_requests")!=0;
|
80
120
|
}
|
81
121
|
|
82
|
-
if ( canHandle
|
83
|
-
|
122
|
+
if ( canHandle ) {
|
123
|
+
if (is_net_trace()) {
|
124
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest: ios_direct_local_requests = true !");
|
125
|
+
}
|
126
|
+
if ([CRhoURLProtocol isLocalURL:theUrl]) {
|
127
|
+
if (is_net_trace()) {
|
128
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return YES URL is local !");
|
129
|
+
}
|
130
|
+
return YES;
|
131
|
+
}
|
84
132
|
}
|
85
133
|
|
134
|
+
if (is_net_trace()) {
|
135
|
+
RAWTRACE("$NetRequestProcess$ canInitWithRequest END: return NO");
|
136
|
+
}
|
86
137
|
return NO;
|
87
138
|
}
|
88
139
|
|
@@ -91,19 +142,27 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
91
142
|
return request;
|
92
143
|
}
|
93
144
|
|
94
|
-
- (void)
|
145
|
+
- (void)startLoadingInThread
|
95
146
|
{
|
147
|
+
if (is_net_trace()) {
|
148
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoadingInThread BEGIN: { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:[self request]]);
|
149
|
+
}
|
96
150
|
NSURL* theUrl = [[self request] URL];
|
97
151
|
|
98
152
|
|
99
153
|
if ([[theUrl path] isEqualToString:@"/!__rhoNativeApi"]) {
|
100
|
-
|
154
|
+
if (is_net_trace()) {
|
155
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading URL has !__rhoNativeApi", [self selfIDstring]);
|
156
|
+
}
|
101
157
|
NSString* jsonRequestTest = [[self request] valueForHTTPHeaderField:@"__rhoNativeApiCall"];
|
102
158
|
if (jsonRequestTest != nil) {
|
103
159
|
NSString* responseStr = [CJSEntryPoint js_entry_point:jsonRequestTest];
|
104
160
|
if (responseStr != nil) {
|
105
161
|
//NSLog(@"$$$ send responce for[%@:%@] = [%@]", [theUrl absoluteString], jsonRequestTest, responseStr);
|
106
162
|
[self sendResponseWithResponseCode:200 data:[responseStr dataUsingEncoding:NSUTF8StringEncoding]];
|
163
|
+
if (is_net_trace()) {
|
164
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading END", [self selfIDstring]);
|
165
|
+
}
|
107
166
|
return;
|
108
167
|
}
|
109
168
|
}
|
@@ -133,12 +192,13 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
133
192
|
textEncodingName:@"UTF-8"];
|
134
193
|
response.statusCode = 200;
|
135
194
|
|
136
|
-
|
137
|
-
|
138
|
-
|
195
|
+
if (!self.isStopped) {
|
196
|
+
[[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
197
|
+
if (data != nil) {
|
198
|
+
[[self client] URLProtocol:self didLoadData:data];
|
199
|
+
}
|
200
|
+
[[self client] URLProtocolDidFinishLoading:self];
|
139
201
|
}
|
140
|
-
[[self client] URLProtocolDidFinishLoading:self];
|
141
|
-
|
142
202
|
|
143
203
|
return;
|
144
204
|
}
|
@@ -147,6 +207,9 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
147
207
|
|
148
208
|
if ( [CRhoURLProtocol isLocalURL:theUrl] )
|
149
209
|
{
|
210
|
+
if (is_net_trace()) {
|
211
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: URL is local !", [self selfIDstring]);
|
212
|
+
}
|
150
213
|
NSURL* url = theUrl;
|
151
214
|
CRhoURLResponse* resp = nil;
|
152
215
|
|
@@ -154,7 +217,14 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
154
217
|
|
155
218
|
if ( resp != nil )
|
156
219
|
{
|
220
|
+
if (is_net_trace()) {
|
221
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading has Responce from local server", [self selfIDstring]);
|
222
|
+
}
|
157
223
|
if ( ((self.httpStatusCode==301)||(self.httpStatusCode==302)) && ( [self.httpHeaders objectForKey:@"location"] != nil ) ) {
|
224
|
+
|
225
|
+
if (is_net_trace()) {
|
226
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading we have REDIRECT from local server !", [self selfIDstring]);
|
227
|
+
}
|
158
228
|
NSString* loc = [self.httpHeaders objectForKey:@"location"];
|
159
229
|
|
160
230
|
NSString* escaped = [loc stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
@@ -172,18 +242,25 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
172
242
|
if (rho_conf_is_property_exists("ios_https_local_server")!=0) {
|
173
243
|
force_https = rho_conf_getBool("ios_https_local_server")!=0;
|
174
244
|
}
|
245
|
+
|
246
|
+
NSString* spath = [url path];
|
247
|
+
spath = [spath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
248
|
+
|
249
|
+
|
175
250
|
if (force_https) {
|
176
|
-
s = [NSMutableString stringWithFormat:@"https://127.0.0.1:%d%@",rho_http_get_port(),
|
251
|
+
s = [NSMutableString stringWithFormat:@"https://127.0.0.1:%d%@",rho_http_get_port(),spath];
|
177
252
|
}
|
178
253
|
else {
|
179
|
-
s = [NSMutableString stringWithFormat:@"http://127.0.0.1:%d%@",rho_http_get_port(),
|
254
|
+
s = [NSMutableString stringWithFormat:@"http://127.0.0.1:%d%@",rho_http_get_port(),spath];
|
180
255
|
}
|
181
256
|
|
182
257
|
|
183
|
-
|
258
|
+
NSString* squery = [url query];
|
259
|
+
if ( squery != nil )
|
184
260
|
{
|
185
|
-
|
186
|
-
|
261
|
+
// decode query back to original state
|
262
|
+
squery = [squery stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
263
|
+
[s appendFormat:@"?%@", squery];
|
187
264
|
}
|
188
265
|
|
189
266
|
if ( [url fragment] != nil )
|
@@ -195,34 +272,89 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
195
272
|
}
|
196
273
|
|
197
274
|
|
198
|
-
|
199
|
-
|
275
|
+
NSMutableURLRequest* redirReq = [NSMutableURLRequest requestWithURL:url];
|
276
|
+
|
277
|
+
// clone headers from original request to redirect request
|
278
|
+
NSDictionary* headers = [[self request] allHTTPHeaderFields];
|
279
|
+
for (NSString* key in headers) {
|
280
|
+
NSString* value = [headers objectForKey:key];
|
281
|
+
[redirReq setValue:value forHTTPHeaderField:key];
|
282
|
+
}
|
283
|
+
|
284
|
+
if (is_net_trace()) {
|
285
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading wasRedirectedToRequest with Request { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:redirReq]);
|
286
|
+
}
|
287
|
+
if (!self.isStopped) {
|
288
|
+
|
289
|
+
[[self client] URLProtocol:self wasRedirectedToRequest:redirReq redirectResponse:resp];
|
290
|
+
}
|
291
|
+
if (is_net_trace()) {
|
292
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading END", [self selfIDstring]);
|
293
|
+
}
|
200
294
|
return;
|
201
295
|
}
|
296
|
+
else {
|
297
|
+
RAWLOG_ERROR2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading Redirect response has no URL ! Initial request: { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:[self request]]);
|
298
|
+
}
|
202
299
|
}
|
203
300
|
else
|
204
301
|
{
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
302
|
+
if (is_net_trace()) {
|
303
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading just request - no redirection", [self selfIDstring]);
|
304
|
+
}
|
305
|
+
if (!self.isStopped) {
|
306
|
+
|
307
|
+
[[self client] URLProtocol:self didReceiveResponse:resp cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
308
|
+
}
|
309
|
+
if (self.httpBody != nil) {
|
310
|
+
if (!self.isStopped) {
|
311
|
+
[[self client] URLProtocol:self didLoadData:self.httpBody];
|
312
|
+
}
|
313
|
+
}
|
314
|
+
if (!self.isStopped) {
|
315
|
+
[[self client] URLProtocolDidFinishLoading:self];
|
316
|
+
}
|
317
|
+
|
318
|
+
if (is_net_trace()) {
|
319
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading END", [self selfIDstring]);
|
209
320
|
}
|
210
|
-
|
211
|
-
[[self client] URLProtocolDidFinishLoading:self];
|
212
321
|
return;
|
213
322
|
}
|
214
323
|
}
|
324
|
+
else {
|
325
|
+
RAWLOG_ERROR2("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading has NO Responce from local server !!! Initial request: { %s }", [self selfIDstring], [CRhoURLProtocol requestInfo:[self request]]);
|
326
|
+
}
|
215
327
|
}
|
216
328
|
|
217
329
|
//NSLog(@"$$$ responce ERROR: [%@]", [theUrl absoluteString]);
|
218
330
|
NSString* body = @"error";
|
219
331
|
[self sendResponseWithResponseCode:401 data:[body dataUsingEncoding:NSUTF8StringEncoding]];
|
220
|
-
|
332
|
+
if (is_net_trace()) {
|
333
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoadingInThread END", [self selfIDstring]);
|
334
|
+
}
|
221
335
|
}
|
222
336
|
|
337
|
+
- (void)startLoading
|
338
|
+
{
|
339
|
+
self.isStopped = NO;
|
340
|
+
if (is_net_trace()) {
|
341
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: startLoading()", [self selfIDstring]);
|
342
|
+
}
|
343
|
+
|
344
|
+
dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
|
345
|
+
[self startLoadingInThread];
|
346
|
+
});
|
347
|
+
}
|
348
|
+
|
349
|
+
|
223
350
|
- (CRhoURLResponse*) makeDirectHttpRequest:(NSURL*)theUrl
|
224
351
|
{
|
225
|
-
|
352
|
+
|
353
|
+
if (is_net_trace()) {
|
354
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: makeDirectHttpRequest : URL [ %s ]", [self selfIDstring], [[theUrl absoluteString] UTF8String]);
|
355
|
+
}
|
356
|
+
|
357
|
+
//NSLog(@"Will make local request to %@", [theUrl absoluteString]);
|
226
358
|
|
227
359
|
const char* uri = [[theUrl path] UTF8String];
|
228
360
|
const char* method = [[[self request] HTTPMethod] UTF8String];
|
@@ -295,6 +427,10 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
295
427
|
|
296
428
|
- (void)stopLoading
|
297
429
|
{
|
430
|
+
self.isStopped = YES;
|
431
|
+
if (is_net_trace()) {
|
432
|
+
RAWTRACE1("$NetRequestProcess$ CRhoURLProtocol %s :: stopLoading()", [self selfIDstring]);
|
433
|
+
}
|
298
434
|
|
299
435
|
}
|
300
436
|
|
@@ -305,7 +441,13 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
305
441
|
|
306
442
|
- (void)sendResponseWithResponseCode:(NSInteger)statusCode data:(NSData*)data
|
307
443
|
{
|
444
|
+
if (is_net_trace()) {
|
445
|
+
RAWTRACE2("$NetRequestProcess$ CRhoURLProtocol %s :: sendResponseWithResponseCode : code: [ %d ] ", [self selfIDstring], (int)statusCode);
|
446
|
+
}
|
308
447
|
|
448
|
+
if (self.isStopped) {
|
449
|
+
return;
|
450
|
+
}
|
309
451
|
CRhoURLResponse* response =
|
310
452
|
[[CRhoURLResponse alloc] initWithURL:[[self request] URL]
|
311
453
|
MIMEType:@"text/plain"
|
@@ -313,25 +455,39 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
313
455
|
textEncodingName:@"UTF-8"];
|
314
456
|
response.statusCode = statusCode;
|
315
457
|
|
316
|
-
|
458
|
+
if (!self.isStopped) {
|
459
|
+
[[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
|
460
|
+
}
|
317
461
|
if (data != nil) {
|
318
|
-
|
462
|
+
if (!self.isStopped) {
|
463
|
+
[[self client] URLProtocol:self didLoadData:data];
|
464
|
+
}
|
465
|
+
}
|
466
|
+
if (!self.isStopped) {
|
467
|
+
[[self client] URLProtocolDidFinishLoading:self];
|
319
468
|
}
|
320
|
-
[[self client] URLProtocolDidFinishLoading:self];
|
321
|
-
|
322
469
|
[response release];
|
323
470
|
}
|
324
471
|
|
325
472
|
+ (BOOL) isLocalURL:(NSURL*)url
|
326
473
|
{
|
474
|
+
if (is_net_trace()) {
|
475
|
+
RAWTRACE1("$NetRequestProcess$ isLocalURL BEGIN : URL: [ %s ] ", [[url absoluteString] UTF8String]);
|
476
|
+
}
|
327
477
|
if ( [[url absoluteString] isEqualToString:@""] )
|
328
478
|
{
|
479
|
+
if (is_net_trace()) {
|
480
|
+
RAWTRACE("isLocalURL END : return NO");
|
481
|
+
}
|
329
482
|
return NO;
|
330
483
|
}
|
331
484
|
|
332
485
|
const char* scheme = [[url scheme] UTF8String];
|
333
486
|
if (scheme != 0) {
|
334
487
|
if ((strcmp(scheme, "http") !=0 ) && (strcmp(scheme, "https") !=0 )) {
|
488
|
+
if (is_net_trace()) {
|
489
|
+
RAWTRACE("$NetRequestProcess$ isLocalURL END : return NO");
|
490
|
+
}
|
335
491
|
return NO;
|
336
492
|
}
|
337
493
|
}
|
@@ -340,7 +496,10 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
340
496
|
|
341
497
|
if ( 0 == host )
|
342
498
|
{
|
343
|
-
|
499
|
+
if (is_net_trace()) {
|
500
|
+
RAWTRACE("$NetRequestProcess$ isLocalURL END : return YES");
|
501
|
+
}
|
502
|
+
return YES;
|
344
503
|
}
|
345
504
|
|
346
505
|
NSNumber* p = [url port];
|
@@ -348,10 +507,15 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
348
507
|
|
349
508
|
int rhoPort = rho_http_get_port();
|
350
509
|
|
351
|
-
|
510
|
+
BOOL ret = (
|
352
511
|
((port == rhoPort))
|
353
512
|
&& ( (strcmp(host,"127.0.0.1")==0) || (strcmp(host,"localhost")==0) )
|
354
513
|
);
|
514
|
+
if (is_net_trace()) {
|
515
|
+
RAWTRACE1("$NetRequestProcess$ isLocalURL END : return [%s]", [[[NSNumber numberWithBool:ret] stringValue] UTF8String]);
|
516
|
+
}
|
517
|
+
|
518
|
+
return ret;
|
355
519
|
}
|
356
520
|
|
357
521
|
|
@@ -359,6 +523,7 @@ int on_http_cb(http_parser* parser) { return 0; }
|
|
359
523
|
@synthesize httpHeaderName;
|
360
524
|
@synthesize httpHeaders;
|
361
525
|
@synthesize httpBody;
|
526
|
+
@synthesize isStopped;
|
362
527
|
|
363
528
|
|
364
529
|
@end
|