platform/iphone/Classes/rho/net/NetRequestImpl.m in rhodes-3.5.1.12 vs platform/iphone/Classes/rho/net/NetRequestImpl.m in rhodes-5.5.0
- old
+ new
@@ -55,11 +55,12 @@
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = active ? YES : NO;
}
-VALUE rho_sys_has_wifi_network() {
+
+BOOL rho_sys_has_wifi_network_iphone() {
SCNetworkReachabilityFlags defaultRouteFlags;
int defaultRouteIsAvailable = 0;
int i = 0;
@@ -68,21 +69,29 @@
}
if (defaultRouteIsAvailable == 1) {
if (defaultRouteFlags & kSCNetworkReachabilityFlagsIsDirect) {
// Ad-Hoc network, not available
- return rho_ruby_create_boolean(0);
+ return NO;
}
else if (defaultRouteFlags & ReachableViaWiFiNetwork) {
// WiFi network available
- return rho_ruby_create_boolean(1);
+ return YES;
}
}
- return rho_ruby_create_boolean(0);
+ return NO;
}
-VALUE rho_sys_has_cell_network() {
+VALUE rho_sys_has_wifi_network() {
+ int res = 0;
+ if (rho_sys_has_wifi_network_iphone()) {
+ res = 1;
+ }
+ return rho_ruby_create_boolean(res);
+}
+
+BOOL rho_sys_has_cell_network_iphone() {
SCNetworkReachabilityFlags defaultRouteFlags;
int defaultRouteIsAvailable = 0;
int i = 0;
@@ -91,27 +100,35 @@
}
if (defaultRouteIsAvailable == 1) {
if (defaultRouteFlags & kSCNetworkReachabilityFlagsIsDirect) {
// Ad-Hoc network, not available
- return rho_ruby_create_boolean(0);
+ return NO;
}
else if (defaultRouteFlags & ReachableViaCarrierDataNetwork) {
// Cell network available
- return rho_ruby_create_boolean(1);
+ return YES;
}
else if (defaultRouteFlags & ReachableViaWiFiNetwork) {
// Wifi network available
- return rho_ruby_create_boolean(1);
+ return YES;
}
}
- return rho_ruby_create_boolean(0);
+ return NO;
+
}
+VALUE rho_sys_has_cell_network() {
+ int res = 0;
+ if (rho_sys_has_cell_network_iphone()) {
+ res = 1;
+ }
+ return rho_ruby_create_boolean(res);
+}
-// Determines network connectivity
-VALUE rho_sys_has_network() {
+
+BOOL rho_sys_has_network_iphone() {
SCNetworkReachabilityFlags defaultRouteFlags;
int defaultRouteIsAvailable = 0;
@@ -121,20 +138,30 @@
}
if (defaultRouteIsAvailable == 1) {
if (defaultRouteFlags & kSCNetworkReachabilityFlagsIsDirect) {
// Ad-Hoc network, not available
- return rho_ruby_create_boolean(0);
+ return NO;
}
else if (defaultRouteFlags & ReachableViaCarrierDataNetwork) {
// Cell network available
- return rho_ruby_create_boolean(1);
+ return YES;
}
// WIFI available
- return rho_ruby_create_boolean(1);
+ return YES;
}
- return rho_ruby_create_boolean(0);
+ return NO;
}
+
+// Determines network connectivity
+VALUE rho_sys_has_network() {
+ int res = 0;
+ if (rho_sys_has_network_iphone()) {
+ res = 1;
+ }
+ return rho_ruby_create_boolean(res);
+}
+
int rho_net_ping_network(const char* szHost)
{
RAWLOG_INFO("PING network.");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];