forked from organicmaps/organicmaps
[ios] Deleted GetActiveConnectionType
This commit is contained in:
parent
43e1898fe8
commit
4c6f28792d
5 changed files with 15 additions and 58 deletions
|
@ -1,10 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
enum TActiveConnectionType
|
||||
{
|
||||
ENotConnected,
|
||||
EConnectedByWiFi,
|
||||
EConnectedBy3G
|
||||
};
|
||||
|
||||
TActiveConnectionType GetActiveConnectionType();
|
|
@ -1,34 +0,0 @@
|
|||
#import "GetActiveConnectionType.h"
|
||||
#import <SystemConfiguration/SCNetworkReachability.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
TActiveConnectionType GetActiveConnectionType()
|
||||
{
|
||||
struct sockaddr_in zeroAddress;
|
||||
bzero(&zeroAddress, sizeof(zeroAddress));
|
||||
zeroAddress.sin_len = sizeof(zeroAddress);
|
||||
zeroAddress.sin_family = AF_INET;
|
||||
|
||||
// Recover reachability flags
|
||||
SCNetworkReachabilityRef defaultRoute = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress);
|
||||
SCNetworkReachabilityFlags flags;
|
||||
Boolean didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRoute, &flags);
|
||||
CFRelease(defaultRoute);
|
||||
if (!didRetrieveFlags)
|
||||
return ENotConnected;
|
||||
|
||||
Boolean isReachable = flags & kSCNetworkFlagsReachable;
|
||||
Boolean isWifi = !(flags & kSCNetworkReachabilityFlagsIsWWAN);
|
||||
Boolean needsConnection = flags & kSCNetworkFlagsConnectionRequired;
|
||||
Boolean isConnected = isReachable && !needsConnection;
|
||||
if (isConnected)
|
||||
{
|
||||
if (isWifi)
|
||||
return EConnectedByWiFi;
|
||||
else
|
||||
return EConnectedBy3G;
|
||||
}
|
||||
return ENotConnected;
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
#import "EAGLView.h"
|
||||
#import "BookmarksRootVC.h"
|
||||
#import "PlacePageVC.h"
|
||||
#import "GetActiveConnectionType.h"
|
||||
#import "PlacePreviewViewController.h"
|
||||
#import "MWMApi.h"
|
||||
#import "UIKitCategories.h"
|
||||
|
@ -12,6 +11,7 @@
|
|||
#import "UIViewController+Navigation.h"
|
||||
#import "Config.h"
|
||||
#import "ShareActionSheet.h"
|
||||
#import "Reachability.h"
|
||||
|
||||
#import "../Settings/SettingsManager.h"
|
||||
#import "../../Common/CustomAlertView.h"
|
||||
|
@ -533,7 +533,8 @@ const long long LITE_IDL = 431183278L;
|
|||
if (self.isViewLoaded && self.view.window)
|
||||
[self invalidate]; // only invalidate when map is displayed on the screen
|
||||
|
||||
if (GetActiveConnectionType() != ENotConnected)
|
||||
Reachability * reachability = [Reachability reachabilityForInternetConnection];
|
||||
if ([reachability isReachable])
|
||||
{
|
||||
if (dlg_settings::ShouldShow(dlg_settings::AppStore))
|
||||
[self showAppStoreRatingMenu];
|
||||
|
|
|
@ -185,7 +185,6 @@
|
|||
FA054613155C465E001F4E37 /* SelectSetVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA054611155C465E001F4E37 /* SelectSetVC.mm */; };
|
||||
FA065FED128614C400FEA989 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = FA065FEC128614C400FEA989 /* MainWindow-iPad.xib */; };
|
||||
FA09E01113F71F6C007E69CA /* SearchVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA09E01013F71F6C007E69CA /* SearchVC.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; };
|
||||
FA0B7E631487747B00CAB3F2 /* GetActiveConnectionType.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7E621487747B00CAB3F2 /* GetActiveConnectionType.mm */; };
|
||||
FA140651162A6288002BC1ED /* empty@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA14064D162A6288002BC1ED /* empty@2x.png */; };
|
||||
FA140652162A6288002BC1ED /* empty@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA14064D162A6288002BC1ED /* empty@2x.png */; };
|
||||
FA140653162A6288002BC1ED /* empty.png in Resources */ = {isa = PBXBuildFile; fileRef = FA14064E162A6288002BC1ED /* empty.png */; };
|
||||
|
@ -1281,7 +1280,6 @@
|
|||
FAFB08F4151215EE0041901D /* CompassView.mm in Sources */ = {isa = PBXBuildFile; fileRef = FABF223D13FAA97A003D4D49 /* CompassView.mm */; };
|
||||
FAFB08F5151215EE0041901D /* Preferences.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA29FDA9141E77F8004ADF66 /* Preferences.mm */; };
|
||||
FAFB08F6151215EE0041901D /* LocationManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAA5C2A1144F135F005337F6 /* LocationManager.mm */; };
|
||||
FAFB08F7151215EE0041901D /* GetActiveConnectionType.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7E621487747B00CAB3F2 /* GetActiveConnectionType.mm */; };
|
||||
FAFB08F8151215EE0041901D /* SearchCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA81AE3214D061BF00A0D70D /* SearchCell.mm */; };
|
||||
FAFB08FB151215EE0041901D /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12020311CD464100ABDD5D /* libfreetype.a */; };
|
||||
FAFB08FC151215EE0041901D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
|
||||
|
@ -1483,7 +1481,6 @@
|
|||
FA065FEC128614C400FEA989 /* MainWindow-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MainWindow-iPad.xib"; path = "Resources-iPad/MainWindow-iPad.xib"; sourceTree = SOURCE_ROOT; };
|
||||
FA09E00F13F71F6C007E69CA /* SearchVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchVC.h; sourceTree = "<group>"; };
|
||||
FA09E01013F71F6C007E69CA /* SearchVC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SearchVC.mm; sourceTree = "<group>"; };
|
||||
FA0B7E621487747B00CAB3F2 /* GetActiveConnectionType.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetActiveConnectionType.mm; sourceTree = "<group>"; };
|
||||
FA14064D162A6288002BC1ED /* empty@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "empty@2x.png"; path = "Bookmarks/empty@2x.png"; sourceTree = SOURCE_ROOT; };
|
||||
FA14064E162A6288002BC1ED /* empty.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = empty.png; path = Bookmarks/empty.png; sourceTree = SOURCE_ROOT; };
|
||||
FA14064F162A6288002BC1ED /* eye.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = eye.png; path = Bookmarks/eye.png; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -1524,7 +1521,6 @@
|
|||
FAA5C2A1144F135F005337F6 /* LocationManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = LocationManager.mm; path = Platform/LocationManager.mm; sourceTree = "<group>"; };
|
||||
FAA614B6155F16950031C345 /* AddSetVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddSetVC.h; path = Bookmarks/AddSetVC.h; sourceTree = SOURCE_ROOT; };
|
||||
FAA614B7155F16950031C345 /* AddSetVC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AddSetVC.mm; path = Bookmarks/AddSetVC.mm; sourceTree = SOURCE_ROOT; };
|
||||
FAAE8D5D1338FF8B003ECAD5 /* GetActiveConnectionType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetActiveConnectionType.h; sourceTree = "<group>"; };
|
||||
FAAEA7D0161BD26600CCD661 /* synonyms.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = synonyms.txt; path = ../../data/synonyms.txt; sourceTree = "<group>"; };
|
||||
FAAEA7D3161D8D3100CCD661 /* BookmarksRootVC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BookmarksRootVC.mm; path = Bookmarks/BookmarksRootVC.mm; sourceTree = SOURCE_ROOT; };
|
||||
FAAEA7D4161D8D3100CCD661 /* BookmarksRootVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BookmarksRootVC.h; path = Bookmarks/BookmarksRootVC.h; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -2335,6 +2331,10 @@
|
|||
CB252D6816FF82C8001E41E9 /* Statistics */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97C98521186AE3CF00AF7E9E /* AppInfo.h */,
|
||||
97C98520186AE3CF00AF7E9E /* AppInfo.m */,
|
||||
97C9851D186AE3C500AF7E9E /* Reachability.h */,
|
||||
97C9851C186AE3C500AF7E9E /* Reachability.m */,
|
||||
CB252D6916FF82C8001E41E9 /* Flurry.h */,
|
||||
ED3B8DB3182CD96F001F124F /* libFlurry_4.3.0.a */,
|
||||
CB252D6B16FF82C8001E41E9 /* Statistics.h */,
|
||||
|
@ -2415,8 +2415,6 @@
|
|||
FA34BEC71338D6DB00FFB2A7 /* Common */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FAAE8D5D1338FF8B003ECAD5 /* GetActiveConnectionType.h */,
|
||||
FA0B7E621487747B00CAB3F2 /* GetActiveConnectionType.mm */,
|
||||
FAFCB63413366E78001A5C59 /* WebViewController.h */,
|
||||
FAFCB63513366E78001A5C59 /* WebViewController.mm */,
|
||||
FA34BEC81338D72F00FFB2A7 /* CustomAlertView.mm */,
|
||||
|
@ -4324,6 +4322,7 @@
|
|||
FA4135ED120A263C0062D5B4 /* SettingsManager.mm in Sources */,
|
||||
EE7F29811219ECA300EB67A9 /* RenderBuffer.mm in Sources */,
|
||||
978F9253183BD530000D6C7C /* NavigationController.mm in Sources */,
|
||||
97C9851E186AE3C500AF7E9E /* Reachability.m in Sources */,
|
||||
EE7F29821219ECA300EB67A9 /* RenderContext.mm in Sources */,
|
||||
FAFCB63613366E78001A5C59 /* WebViewController.mm in Sources */,
|
||||
FA34BECA1338D72F00FFB2A7 /* CustomAlertView.mm in Sources */,
|
||||
|
@ -4335,7 +4334,6 @@
|
|||
FA29FDAA141E77F8004ADF66 /* Preferences.mm in Sources */,
|
||||
FAA5C2A2144F135F005337F6 /* LocationManager.mm in Sources */,
|
||||
97719D3E1843AEAF00BDD815 /* BuyButtonCell.mm in Sources */,
|
||||
FA0B7E631487747B00CAB3F2 /* GetActiveConnectionType.mm in Sources */,
|
||||
FA81AE3314D061BF00A0D70D /* SearchCell.mm in Sources */,
|
||||
978F9240183B660F000D6C7C /* SettingsViewController.mm in Sources */,
|
||||
F7B90CD31521E6D200C054EE /* CustomNavigationView.mm in Sources */,
|
||||
|
@ -4347,6 +4345,7 @@
|
|||
FAAEA7D5161D8D3100CCD661 /* BookmarksRootVC.mm in Sources */,
|
||||
F785EB4016386FC4003A38A8 /* BookmarkCell.mm in Sources */,
|
||||
97387546184E475000170BC4 /* MessageComposeViewController.m in Sources */,
|
||||
97C98522186AE3CF00AF7E9E /* AppInfo.m in Sources */,
|
||||
978F9242183B660F000D6C7C /* SelectableCell.m in Sources */,
|
||||
CB252D6F16FF82C9001E41E9 /* Statistics.mm in Sources */,
|
||||
9747277D18328E65006B7CB7 /* SideToolbarCell.m in Sources */,
|
||||
|
@ -4377,6 +4376,7 @@
|
|||
FAFB08EE151215EE0041901D /* SettingsManager.mm in Sources */,
|
||||
FAFB08EF151215EE0041901D /* RenderBuffer.mm in Sources */,
|
||||
978F9254183BD530000D6C7C /* NavigationController.mm in Sources */,
|
||||
97C9851F186AE3C500AF7E9E /* Reachability.m in Sources */,
|
||||
FAFB08F0151215EE0041901D /* RenderContext.mm in Sources */,
|
||||
FAFB08F1151215EE0041901D /* WebViewController.mm in Sources */,
|
||||
FAFB08F2151215EE0041901D /* CustomAlertView.mm in Sources */,
|
||||
|
@ -4388,7 +4388,6 @@
|
|||
FAFB08F5151215EE0041901D /* Preferences.mm in Sources */,
|
||||
FAFB08F6151215EE0041901D /* LocationManager.mm in Sources */,
|
||||
97719D3F1843AEAF00BDD815 /* BuyButtonCell.mm in Sources */,
|
||||
FAFB08F7151215EE0041901D /* GetActiveConnectionType.mm in Sources */,
|
||||
FAFB08F8151215EE0041901D /* SearchCell.mm in Sources */,
|
||||
978F9241183B660F000D6C7C /* SettingsViewController.mm in Sources */,
|
||||
F7B90CD41521E6D200C054EE /* CustomNavigationView.mm in Sources */,
|
||||
|
@ -4400,6 +4399,7 @@
|
|||
FAAEA7D6161D8D3100CCD661 /* BookmarksRootVC.mm in Sources */,
|
||||
F785EB4116386FC4003A38A8 /* BookmarkCell.mm in Sources */,
|
||||
97387547184E475000170BC4 /* MessageComposeViewController.m in Sources */,
|
||||
97C98523186AE3CF00AF7E9E /* AppInfo.m in Sources */,
|
||||
978F9243183B660F000D6C7C /* SelectableCell.m in Sources */,
|
||||
CB252D7016FF82C9001E41E9 /* Statistics.mm in Sources */,
|
||||
9747277E18328E65006B7CB7 /* SideToolbarCell.m in Sources */,
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#import "CustomAlertView.h"
|
||||
#import "DiskFreeSpace.h"
|
||||
#import "Statistics.h"
|
||||
#import "Reachability.h"
|
||||
|
||||
#include "Framework.h"
|
||||
#include "GetActiveConnectionType.h"
|
||||
|
||||
#include "../../platform/platform.hpp"
|
||||
#include "../../platform/preferred_languages.hpp"
|
||||
|
@ -341,8 +341,8 @@ static bool getGuideName(string & name, storage::TIndex const & index)
|
|||
}
|
||||
else
|
||||
{
|
||||
TActiveConnectionType const connType = GetActiveConnectionType();
|
||||
if (connType == ENotConnected)
|
||||
Reachability * reachability = [Reachability reachabilityForInternetConnection];
|
||||
if (![reachability isReachable])
|
||||
{
|
||||
// No any connection - skip downloading
|
||||
[[[[CustomAlertView alloc] initWithTitle:NSLocalizedString(@"no_internet_connection_detected", nil)
|
||||
|
@ -353,7 +353,7 @@ static bool getGuideName(string & name, storage::TIndex const & index)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (connType == EConnectedBy3G && m_downloadSize > MAX_3G_MEGABYTES * MB)
|
||||
if ([reachability isReachableViaWWAN] && m_downloadSize > MAX_3G_MEGABYTES * MB)
|
||||
{
|
||||
// If user uses 3G, show warning before downloading
|
||||
[[[[CustomAlertView alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"no_wifi_ask_cellular_download", nil), countryName]
|
||||
|
|
Loading…
Add table
Reference in a new issue