Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iphone/Maps/Classes/LocalNotificationManager.mm4
-rw-r--r--iphone/Maps/Classes/MapViewController.mm7
-rw-r--r--iphone/Maps/Classes/MapsAppDelegate.mm5
-rw-r--r--iphone/Maps/DownloaderParentVC.mm10
-rw-r--r--iphone/Maps/Maps.xcodeproj/project.pbxproj6
-rw-r--r--iphone/Maps/Statistics/Reachability.h43
-rw-r--r--iphone/Maps/Statistics/Reachability.m336
-rw-r--r--platform/platform.hpp13
-rw-r--r--platform/platform_android.cpp6
-rw-r--r--platform/platform_ios.mm26
-rw-r--r--platform/platform_linux.cpp6
-rw-r--r--platform/platform_mac.mm22
-rw-r--r--platform/platform_tizen.cpp6
-rw-r--r--platform/platform_win.cpp6
14 files changed, 96 insertions, 400 deletions
diff --git a/iphone/Maps/Classes/LocalNotificationManager.mm b/iphone/Maps/Classes/LocalNotificationManager.mm
index 536bb5d3da..3e86d9d620 100644
--- a/iphone/Maps/Classes/LocalNotificationManager.mm
+++ b/iphone/Maps/Classes/LocalNotificationManager.mm
@@ -6,13 +6,13 @@
#import "LocationManager.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
-#import "Reachability.h"
#import "Statistics.h"
#import "TimeUtils.h"
#import "UIKitCategories.h"
#import "3party/Alohalytics/src/alohalytics_objc.h"
+#include "platform/platform.hpp"
#include "storage/storage_defines.hpp"
static NSString * kDownloadMapActionName = @"DownloadMapAction";
@@ -322,7 +322,7 @@ typedef void (^CompletionHandler)(UIBackgroundFetchResult);
UIBackgroundFetchResult result = UIBackgroundFetchResultNoData;
BOOL const inBackground = [UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
- BOOL const onWiFi = Reachability.reachabilityForInternetConnection.isReachableViaWiFi;
+ BOOL const onWiFi = (Platform::ConnectionStatus() == Platform::EConnectionType::CONNECTION_WIFI);
if (inBackground && onWiFi)
{
Framework & f = GetFramework();
diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm
index adca2ebb29..6111ef6e40 100644
--- a/iphone/Maps/Classes/MapViewController.mm
+++ b/iphone/Maps/Classes/MapViewController.mm
@@ -7,7 +7,6 @@
#import "MWMMapViewControlsManager.h"
#import "MWMPlacePageViewManagerDelegate.h"
#import "MWMPlacePageViewManager.h"
-#import "Reachability.h"
#import "RouteState.h"
#import "RouteView.h"
#import "ShareActionSheet.h"
@@ -682,10 +681,10 @@ typedef NS_OPTIONS(NSUInteger, MapInfoView)
sizeToDownload += sizes.second;
NSString * name = [NSString stringWithUTF8String:layout.GetCountryName(idx).c_str()];
- Reachability * reachability = [Reachability reachabilityForInternetConnection];
- if ([reachability isReachable])
+ Platform::EConnectionType const connection = Platform::ConnectionStatus();
+ if (connection != Platform::EConnectionType::CONNECTION_NONE)
{
- if ([reachability isReachableViaWWAN] && sizeToDownload > 50 * 1024 * 1024)
+ if (connection == Platform::EConnectionType::CONNECTION_WWAN && sizeToDownload > 50 * 1024 * 1024)
{
NSString * title = [NSString stringWithFormat:L(@"no_wifi_ask_cellular_download"), name];
diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm
index 0548d8f498..961303703e 100644
--- a/iphone/Maps/Classes/MapsAppDelegate.mm
+++ b/iphone/Maps/Classes/MapsAppDelegate.mm
@@ -9,7 +9,6 @@
#import "MWMAlertViewController.h"
#import "MWMWatchEventInfo.h"
#import "Preferences.h"
-#import "Reachability.h"
#import "RouteState.h"
#import "Statistics.h"
#import "UIKitCategories.h"
@@ -569,7 +568,7 @@ void InitLocalizedStrings()
- (void)showFacebookAlert
{
- if (!Reachability.reachabilityForInternetConnection.isReachable)
+ if (!Platform::IsConnected())
return;
UIViewController *topViewController = [(UINavigationController*)m_window.rootViewController visibleViewController];
@@ -614,7 +613,7 @@ void InitLocalizedStrings()
- (void)showRateAlert
{
- if (!Reachability.reachabilityForInternetConnection.isReachable)
+ if (!Platform::IsConnected())
return;
UIViewController *topViewController = [(UINavigationController*)m_window.rootViewController visibleViewController];
diff --git a/iphone/Maps/DownloaderParentVC.mm b/iphone/Maps/DownloaderParentVC.mm
index a2f722f833..c5fefd9f13 100644
--- a/iphone/Maps/DownloaderParentVC.mm
+++ b/iphone/Maps/DownloaderParentVC.mm
@@ -3,10 +3,10 @@
#import "CustomAlertView.h"
#import "DiskFreeSpace.h"
#import "Statistics.h"
-#import "Reachability.h"
-@implementation DownloaderParentVC
+#include "platform/platform.hpp"
+@implementation DownloaderParentVC
- (void)viewDidLoad
{
@@ -77,10 +77,10 @@
uint64_t const size = [self selectedMapSizeWithOptions:self.selectedInActionSheetOptions];
NSString * name = [self selectedMapName];
- Reachability * reachability = [Reachability reachabilityForInternetConnection];
- if ([reachability isReachable])
+ Platform::EConnectionType const connection = Platform::ConnectionStatus();
+ if (connection != Platform::EConnectionType::CONNECTION_NONE)
{
- if ([reachability isReachableViaWWAN] && size > 50 * MB)
+ if (connection == Platform::EConnectionType::CONNECTION_WWAN && size > 50 * MB)
{
NSString * title = [NSString stringWithFormat:L(@"no_wifi_ask_cellular_download"), name];
[[[CustomAlertView alloc] initWithTitle:title message:nil delegate:self cancelButtonTitle:L(@"cancel") otherButtonTitles:L(@"use_cellular_data"), nil] show];
diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj
index 9f47ed5725..15ddc7f04c 100644
--- a/iphone/Maps/Maps.xcodeproj/project.pbxproj
+++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj
@@ -128,7 +128,6 @@
97A8001018B21395000C07A2 /* SearchBar.mm in Sources */ = {isa = PBXBuildFile; fileRef = 97A8000F18B21395000C07A2 /* SearchBar.mm */; };
97A8001418B2140A000C07A2 /* SearchResultCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97A8001318B2140A000C07A2 /* SearchResultCell.m */; };
97A8002718B2741C000C07A2 /* SearchCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97A8002618B2741C000C07A2 /* SearchCell.m */; };
- 97C9851E186AE3C500AF7E9E /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C9851C186AE3C500AF7E9E /* Reachability.m */; };
97C98522186AE3CF00AF7E9E /* AppInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 97C98520186AE3CF00AF7E9E /* AppInfo.mm */; };
97CC93BB19599F4700369B42 /* SearchSuggestCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 97CC93BA19599F4700369B42 /* SearchSuggestCell.m */; };
97D40C0A184D031900A1D572 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97D40C09184D031900A1D572 /* Images.xcassets */; };
@@ -481,8 +480,6 @@
97A8001318B2140A000C07A2 /* SearchResultCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchResultCell.m; sourceTree = "<group>"; };
97A8002518B2741C000C07A2 /* SearchCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchCell.h; sourceTree = "<group>"; };
97A8002618B2741C000C07A2 /* SearchCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchCell.m; sourceTree = "<group>"; };
- 97C9851C186AE3C500AF7E9E /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = "<group>"; };
- 97C9851D186AE3C500AF7E9E /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; };
97C98520186AE3CF00AF7E9E /* AppInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppInfo.mm; sourceTree = "<group>"; };
97C98521186AE3CF00AF7E9E /* AppInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppInfo.h; sourceTree = "<group>"; };
97C98647186C5E9900AF7E9E /* EventKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = EventKit.framework; path = System/Library/Frameworks/EventKit.framework; sourceTree = SDKROOT; };
@@ -1250,8 +1247,6 @@
children = (
97C98521186AE3CF00AF7E9E /* AppInfo.h */,
97C98520186AE3CF00AF7E9E /* AppInfo.mm */,
- 97C9851D186AE3C500AF7E9E /* Reachability.h */,
- 97C9851C186AE3C500AF7E9E /* Reachability.m */,
CB252D6B16FF82C8001E41E9 /* Statistics.h */,
CB252D6C16FF82C8001E41E9 /* Statistics.mm */,
97DD585B18A8EB120079837E /* Flurry.h */,
@@ -2132,7 +2127,6 @@
F66A8FA81B09F052001B9C97 /* MWMiPhoneLandscapePlacePage.mm in Sources */,
974386DD19373EA400FD5659 /* ToastView.m in Sources */,
F6C9343C1AE4F94A00DDC624 /* MWMAnimator.mm in Sources */,
- 97C9851E186AE3C500AF7E9E /* Reachability.m in Sources */,
977E26B919E2E64200BA2219 /* MapsObservers.mm in Sources */,
F66A8FB01B09F268001B9C97 /* MWMPlacePage.mm in Sources */,
EE7F29821219ECA300EB67A9 /* RenderContext.mm in Sources */,
diff --git a/iphone/Maps/Statistics/Reachability.h b/iphone/Maps/Statistics/Reachability.h
deleted file mode 100644
index f28c6a2424..0000000000
--- a/iphone/Maps/Statistics/Reachability.h
+++ /dev/null
@@ -1,43 +0,0 @@
-
-#import <Foundation/Foundation.h>
-#import <SystemConfiguration/SystemConfiguration.h>
-
-#import <sys/socket.h>
-#import <netinet/in.h>
-#import <netinet6/in6.h>
-#import <arpa/inet.h>
-#import <ifaddrs.h>
-#import <netdb.h>
-
-#if OS_OBJECT_USE_OBJC
-#define NEEDS_DISPATCH_RETAIN_RELEASE 0
-#else
-#define NEEDS_DISPATCH_RETAIN_RELEASE 1
-#endif
-
-#ifndef NS_ENUM
-#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
-#endif
-
-@class Reachability;
-
-typedef void (^NetworkReachable)(Reachability * reachability);
-typedef void (^NetworkUnreachable)(Reachability * reachability);
-
-@interface Reachability : NSObject
-
-@property (nonatomic, copy) NetworkReachable reachableBlock;
-@property (nonatomic, copy) NetworkUnreachable unreachableBlock;
-
-@property (nonatomic, assign) BOOL reachableOnWWAN;
-
-+ (Reachability *)reachabilityForInternetConnection;
-
-- (BOOL)startNotifier;
-- (void)stopNotifier;
-
-- (BOOL)isReachable;
-- (BOOL)isReachableViaWWAN;
-- (BOOL)isReachableViaWiFi;
-
-@end
diff --git a/iphone/Maps/Statistics/Reachability.m b/iphone/Maps/Statistics/Reachability.m
deleted file mode 100644
index 41ebc3b9a6..0000000000
--- a/iphone/Maps/Statistics/Reachability.m
+++ /dev/null
@@ -1,336 +0,0 @@
-
-#import "Reachability.h"
-
-NSString *const NetworkReachabilityChangedNotification = @"NetworkReachabilityChangedNotification";
-
-@interface Reachability ()
-
-@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef;
-
-
-#if NEEDS_DISPATCH_RETAIN_RELEASE
-@property (nonatomic, assign) dispatch_queue_t reachabilitySerialQueue;
-#else
-@property (nonatomic) dispatch_queue_t reachabilitySerialQueue;
-#endif
-
-
-@property (nonatomic) id reachabilityObject;
-
-- (void)reachabilityChanged:(SCNetworkReachabilityFlags)flags;
-- (BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags;
-
-@end
-
-// Start listening for reachability notifications on the current run loop
-static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
-{
-#pragma unused (target)
-
- Reachability *reachability = ((__bridge Reachability*)info);
-
- // We probably don't need an autoreleasepool here, as GCD docs state each queue has its own autorelease pool,
- // but what the heck eh?
- @autoreleasepool
- {
- [reachability reachabilityChanged:flags];
- }
-}
-
-
-@implementation Reachability
-
-@synthesize reachabilityRef;
-@synthesize reachabilitySerialQueue;
-
-@synthesize reachableOnWWAN;
-
-@synthesize reachableBlock;
-@synthesize unreachableBlock;
-
-@synthesize reachabilityObject;
-
-#pragma mark - Class Constructor Methods
-
-+ (Reachability *)reachabilityWithHostName:(NSString*)hostname
-{
- return [Reachability reachabilityWithHostname:hostname];
-}
-
-+ (Reachability *)reachabilityWithHostname:(NSString*)hostname
-{
- SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
- if (ref)
- {
- id reachability = [[self alloc] initWithReachabilityRef:ref];
-
- return reachability;
- }
-
- return nil;
-}
-
-+ (Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress
-{
- SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
- if (ref)
- {
- id reachability = [[self alloc] initWithReachabilityRef:ref];
-
- return reachability;
- }
-
- return nil;
-}
-
-+ (Reachability *)reachabilityForInternetConnection
-{
- struct sockaddr_in zeroAddress;
- bzero(&zeroAddress, sizeof(zeroAddress));
- zeroAddress.sin_len = sizeof(zeroAddress);
- zeroAddress.sin_family = AF_INET;
-
- return [self reachabilityWithAddress:&zeroAddress];
-}
-
-// Initialization methods
-
-- (Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref
-{
- self = [super init];
- if (self != nil)
- {
- self.reachableOnWWAN = YES;
- self.reachabilityRef = ref;
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [self stopNotifier];
-
- if (self.reachabilityRef)
- {
- CFRelease(self.reachabilityRef);
- self.reachabilityRef = nil;
- }
-
- self.reachableBlock = nil;
- self.unreachableBlock = nil;
-}
-
-#pragma mark - Notifier Methods
-
-// Notifier
-// NOTE: This uses GCD to trigger the blocks - they *WILL NOT* be called on THE MAIN THREAD
-// - In other words DO NOT DO ANY UI UPDATES IN THE BLOCKS.
-// INSTEAD USE dispatch_async(dispatch_get_main_queue(), ^{UISTUFF}) (or dispatch_sync if you want)
-
-- (BOOL)startNotifier
-{
- SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL };
-
- // this should do a retain on ourself, so as long as we're in notifier mode we shouldn't disappear out from under ourselves
- // woah
- self.reachabilityObject = self;
-
- // First, we need to create a serial queue.
- // We allocate this once for the lifetime of the notifier.
- self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL);
- if (!self.reachabilitySerialQueue)
- return NO;
-
- context.info = (__bridge void *)self;
-
- if (!SCNetworkReachabilitySetCallback(self.reachabilityRef, TMReachabilityCallback, &context))
- {
- // Clear out the dispatch queue
- if (self.reachabilitySerialQueue)
- {
-#if NEEDS_DISPATCH_RETAIN_RELEASE
- dispatch_release(self.reachabilitySerialQueue);
-#endif
- self.reachabilitySerialQueue = nil;
- }
-
- self.reachabilityObject = nil;
-
- return NO;
- }
-
- // Set it as our reachability queue, which will retain the queue
- if (!SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue))
- {
- // UH OH - FAILURE!
-
- // First stop, any callbacks!
- SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
-
- // Then clear out the dispatch queue.
- if (self.reachabilitySerialQueue)
- {
-#if NEEDS_DISPATCH_RETAIN_RELEASE
- dispatch_release(self.reachabilitySerialQueue);
-#endif
- self.reachabilitySerialQueue = nil;
- }
-
- self.reachabilityObject = nil;
-
- return NO;
- }
-
- return YES;
-}
-
-- (void)stopNotifier
-{
- // First stop, any callbacks!
- SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
-
- // Unregister target from the GCD serial dispatch queue.
- SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, NULL);
-
- if (self.reachabilitySerialQueue)
- {
-#if NEEDS_DISPATCH_RETAIN_RELEASE
- dispatch_release(self.reachabilitySerialQueue);
-#endif
- self.reachabilitySerialQueue = nil;
- }
-
- self.reachabilityObject = nil;
-}
-
-#pragma mark - reachability tests
-
-// This is for the case where you flick the airplane mode;
-// you end up getting something like this:
-//Reachability: WR ct-----
-//Reachability: -- -------
-//Reachability: WR ct-----
-//Reachability: -- -------
-// We treat this as 4 UNREACHABLE triggers - really apple should do better than this
-
-#define testcase (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection)
-
-- (BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags
-{
- BOOL connectionUP = YES;
-
- if(!(flags & kSCNetworkReachabilityFlagsReachable))
- connectionUP = NO;
-
- if( (flags & testcase) == testcase )
- connectionUP = NO;
-
-#if TARGET_OS_IPHONE
- if (flags & kSCNetworkReachabilityFlagsIsWWAN)
- {
- // We're on 3G.
- if (!self.reachableOnWWAN)
- {
- // We don't want to connect when on 3G.
- connectionUP = NO;
- }
- }
-#endif
-
- return connectionUP;
-}
-
-- (BOOL)isReachable
-{
- SCNetworkReachabilityFlags flags;
-
- if (!SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
- return NO;
-
- return [self isReachableWithFlags:flags];
-}
-
-- (BOOL)isReachableViaWWAN
-{
-#if TARGET_OS_IPHONE
-
- SCNetworkReachabilityFlags flags = 0;
-
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
- // Check we're REACHABLE
- if (flags & kSCNetworkReachabilityFlagsReachable)
- // Now, check we're on WWAN
- if (flags & kSCNetworkReachabilityFlagsIsWWAN)
- return YES;
-#endif
-
- return NO;
-}
-
-- (BOOL)isReachableViaWiFi
-{
- SCNetworkReachabilityFlags flags = 0;
-
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
- {
- // Check we're reachable
- if ((flags & kSCNetworkReachabilityFlagsReachable))
- {
-#if TARGET_OS_IPHONE
- // Check we're NOT on WWAN
- if ((flags & kSCNetworkReachabilityFlagsIsWWAN))
- return NO;
-#endif
- return YES;
- }
- }
-
- return NO;
-}
-
-- (BOOL)connectionRequired
-{
- SCNetworkReachabilityFlags flags;
-
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
- return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
-
- return NO;
-}
-
-#pragma mark - reachability status stuff
-
-- (SCNetworkReachabilityFlags)reachabilityFlags
-{
- SCNetworkReachabilityFlags flags = 0;
-
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
- return flags;
-
- return 0;
-}
-
-#pragma mark - Callback function calls this method
-
-- (void)reachabilityChanged:(SCNetworkReachabilityFlags)flags
-{
- if ([self isReachableWithFlags:flags])
- {
- if (self.reachableBlock)
- self.reachableBlock(self);
- }
- else
- {
- if (self.unreachableBlock)
- self.unreachableBlock(self);
- }
-
- // this makes sure the change notification happens on the MAIN THREAD
- dispatch_async(dispatch_get_main_queue(), ^{
- [[NSNotificationCenter defaultCenter] postNotificationName:NetworkReachabilityChangedNotification
- object:self];
- });
-}
-
-@end
diff --git a/platform/platform.hpp b/platform/platform.hpp
index 7effb78d90..14219736f1 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -42,6 +42,13 @@ public:
FILE_TYPE_DIRECTORY = 0x4
};
+ enum class EConnectionType : uint8_t
+ {
+ CONNECTION_NONE,
+ CONNECTION_WIFI,
+ CONNECTION_WWAN
+ };
+
protected:
/// Usually read-only directory for application resources
string m_resourcesDir;
@@ -195,9 +202,13 @@ public:
bool IsTablet() const { return m_isTablet; }
/// @return information about kinds of memory which are relevant for a platform.
- /// This methid is implemented for iOS and Android only.
+ /// This method is implemented for iOS and Android only.
+ /// @TODO Add implementation
string GetMemoryInfo() const;
+ static EConnectionType ConnectionStatus();
+ static bool IsConnected() { return ConnectionStatus() != EConnectionType::CONNECTION_NONE; };
+
private:
void GetSystemFontNames(FilesList & res) const;
};
diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp
index 225547015e..95e75cd5b4 100644
--- a/platform/platform_android.cpp
+++ b/platform/platform_android.cpp
@@ -286,3 +286,9 @@ void Platform::RunAsync(TFunctor const & fn, Priority p)
// doesn't attach to JVM threads.
threads::Thread().Create(make_unique<FunctorWrapper>(fn));
}
+
+Platform::EConnectionType Platform::ConnectionStatus()
+{
+ // @TODO Add implementation
+ return EConnectionType::CONNECTION_NONE;
+}
diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm
index cb14de0171..2cbc073dbb 100644
--- a/platform/platform_ios.mm
+++ b/platform/platform_ios.mm
@@ -30,6 +30,9 @@
#import <UIKit/UIScreen.h>
#import <UIKit/UIScreenMode.h>
+#import <SystemConfiguration/SystemConfiguration.h>
+#import <netinet/in.h>
+
Platform::Platform()
{
}
@@ -169,6 +172,29 @@ void Platform::RunAsync(TFunctor const & fn, Priority p)
dispatch_async_f(dispatch_get_global_queue(priority, 0), new TFunctor(fn), &PerformImpl);
}
+Platform::EConnectionType Platform::ConnectionStatus()
+{
+ struct sockaddr_in zero;
+ bzero(&zero, sizeof(zero));
+ zero.sin_len = sizeof(zero);
+ zero.sin_family = AF_INET;
+ SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)&zero);
+ if (!reachability)
+ return EConnectionType::CONNECTION_NONE;
+ SCNetworkReachabilityFlags flags;
+ bool const gotFlags = SCNetworkReachabilityGetFlags(reachability, &flags);
+ CFRelease(reachability);
+ if (!gotFlags || ((flags & kSCNetworkReachabilityFlagsReachable) == 0))
+ return EConnectionType::CONNECTION_NONE;
+ SCNetworkReachabilityFlags userActionRequired = kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsInterventionRequired;
+ if ((flags & userActionRequired) == userActionRequired)
+ return EConnectionType::CONNECTION_NONE;
+ if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
+ return EConnectionType::CONNECTION_WWAN;
+ else
+ return EConnectionType::CONNECTION_WIFI;
+}
+
CustomIOSPlatform::CustomIOSPlatform()
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp
index 52af71453b..e9b76209a5 100644
--- a/platform/platform_linux.cpp
+++ b/platform/platform_linux.cpp
@@ -126,3 +126,9 @@ void Platform::RunAsync(TFunctor const & fn, Priority p)
/// @todo
fn();
}
+
+Platform::EConnectionType Platform::ConnectionStatus()
+{
+ // @TODO Add implementation
+ return EConnectionType::CONNECTION_NONE;
+}
diff --git a/platform/platform_mac.mm b/platform/platform_mac.mm
index 6c415f08d2..72de53b855 100644
--- a/platform/platform_mac.mm
+++ b/platform/platform_mac.mm
@@ -14,6 +14,8 @@
#include <dispatch/dispatch.h>
+#import <SystemConfiguration/SystemConfiguration.h>
+#import <netinet/in.h>
Platform::Platform()
{
@@ -135,3 +137,23 @@ void Platform::RunAsync(TFunctor const & fn, Priority p)
}
dispatch_async_f(dispatch_get_global_queue(priority, 0), new TFunctor(fn), &PerformImpl);
}
+
+Platform::EConnectionType Platform::ConnectionStatus()
+{
+ struct sockaddr_in zero;
+ bzero(&zero, sizeof(zero));
+ zero.sin_len = sizeof(zero);
+ zero.sin_family = AF_INET;
+ SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)&zero);
+ if (!reachability)
+ return EConnectionType::CONNECTION_NONE;
+ SCNetworkReachabilityFlags flags;
+ bool const gotFlags = SCNetworkReachabilityGetFlags(reachability, &flags);
+ CFRelease(reachability);
+ if (!gotFlags || ((flags & kSCNetworkReachabilityFlagsReachable) == 0))
+ return EConnectionType::CONNECTION_NONE;
+ SCNetworkReachabilityFlags userActionRequired = kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsInterventionRequired;
+ if ((flags & userActionRequired) == userActionRequired)
+ return EConnectionType::CONNECTION_NONE;
+ return EConnectionType::CONNECTION_WIFI;
+}
diff --git a/platform/platform_tizen.cpp b/platform/platform_tizen.cpp
index 57e18b4ef8..65112bc256 100644
--- a/platform/platform_tizen.cpp
+++ b/platform/platform_tizen.cpp
@@ -108,6 +108,12 @@ int Platform::PreCachingDepth() const
return 3;
}
+Platform::EConnectionType Platform::ConnectionStatus()
+{
+ // @TODO Add implementation
+ return EConnectionType::CONNECTION_NONE;
+}
+
extern Platform & GetPlatform()
{
static Platform platform;
diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp
index 5e48ea360e..de63036a1b 100644
--- a/platform/platform_win.cpp
+++ b/platform/platform_win.cpp
@@ -144,6 +144,12 @@ void Platform::RunAsync(TFunctor const & fn, Priority p)
fn();
}
+Platform::EConnectionType Platform::ConnectionStatus()
+{
+ // @TODO Add implementation
+ return EConnectionType::CONNECTION_NONE;
+}
+
Platform::TStorageStatus Platform::GetWritableStorageStatus(uint64_t neededSize) const
{
ULARGE_INTEGER freeSpace;