Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Add files from #16031 (#140)
Browse files Browse the repository at this point in the history
* [ios] Add changed files

* [ios] Add files to project

* [ios] Bumped submodule
  • Loading branch information
jmkiley committed Jan 9, 2020
1 parent ddef344 commit c8d097b
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 3 deletions.
8 changes: 8 additions & 0 deletions platform/darwin/src/MGLNetworkIntegrationManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
#include <mbgl/interface/native_apple_interface.h>

@interface MGLNetworkIntegrationManager : NSObject <MGLNativeNetworkDelegate>

+ (MGLNetworkIntegrationManager *)sharedManager;

@end
54 changes: 54 additions & 0 deletions platform/darwin/src/MGLNetworkIntegrationManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#import "MGLNetworkIntegrationManager.h"

#import "MGLLoggingConfiguration_Private.h"
#import "MGLNetworkConfiguration_Private.h"

#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#import "MGLAccountManager_Private.h"
#endif

@implementation MGLNetworkIntegrationManager

static MGLNetworkIntegrationManager *instance = nil;

+ (MGLNetworkIntegrationManager *)sharedManager {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[MGLNetworkIntegrationManager alloc] init];
});
return instance;
}

#pragma mark - MGLNativeAppleInterfaceManager delegate -

- (NSURLSessionConfiguration *)sessionConfiguration {
return [MGLNetworkConfiguration sharedManager].sessionConfiguration;
}

#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- (NSString *)skuToken {
return MGLAccountManager.skuToken;
}
#endif

- (void)startDownloadEvent:(NSString *)event type:(NSString *)type {
[[MGLNetworkConfiguration sharedManager] startDownloadEvent:event type:@"tile"];
}

- (void)cancelDownloadEventForResponse:(NSURLResponse *)response {
[[MGLNetworkConfiguration sharedManager] cancelDownloadEventForResponse:response];
}

- (void)stopDownloadEventForResponse:(NSURLResponse *)response {
[[MGLNetworkConfiguration sharedManager] stopDownloadEventForResponse:response];
}

- (void)debugLog:(NSString *)format, ... {
MGLLogDebug(format);
}

- (void)errorLog:(NSString *)format, ... {
MGLLogError(format);
}

@end
73 changes: 73 additions & 0 deletions platform/darwin/src/native_apple_interface.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#import <Foundation/Foundation.h>
#import <mbgl/interface/native_apple_interface.h>

@implementation MGLNativeNetworkManager

static MGLNativeNetworkManager *instance = nil;

+ (MGLNativeNetworkManager *)sharedManager {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[MGLNativeNetworkManager alloc] init];
});
return instance;
}

- (NSURLSessionConfiguration *)sessionConfiguration {
if (_delegate && [_delegate respondsToSelector:@selector(sessionConfiguration)]) {
return [_delegate sessionConfiguration];
}
// For testing. Since we get a `nil` return when SDK is modualar, we use this for testing requests.
// Same as `[MGLNetworkConfiguration defaultSessionConfiguration]` in `MGLNetworkConfiguration.m`.
return [self testSessionConfiguration];
}

- (NSURLSessionConfiguration *)testSessionConfiguration {
NSURLSessionConfiguration* sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];

sessionConfiguration.timeoutIntervalForResource = 30;
sessionConfiguration.HTTPMaximumConnectionsPerHost = 8;
sessionConfiguration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
sessionConfiguration.URLCache = nil;

return sessionConfiguration;
}

- (NSString *)skuToken {
if(_delegate && [_delegate respondsToSelector:@selector(skuToken)]) {
return [_delegate skuToken];
}
return nil;
}

- (void)startDownloadEvent:(NSString *)event type:(NSString *)type {
if (_delegate && [_delegate respondsToSelector:@selector(startDownloadEvent:type:)]) {
[_delegate startDownloadEvent:event type:type];
}
}

- (void)cancelDownloadEventForResponse:(NSURLResponse *)response {
if (_delegate && [_delegate respondsToSelector:@selector(cancelDownloadEventForResponse:)]) {
return [_delegate cancelDownloadEventForResponse:response];
}
}

- (void)stopDownloadEventForResponse:(NSURLResponse *)response {
if (_delegate && [_delegate respondsToSelector:@selector(stopDownloadEventForResponse:)]) {
return [_delegate stopDownloadEventForResponse:response];
}
}

- (void)debugLog:(NSString *)format, ...{
if (_delegate && [_delegate respondsToSelector:@selector(debugLog:)]) {
return [_delegate debugLog:format];
}
}

- (void)errorLog:(NSString *)format, ...{
if (_delegate && [_delegate respondsToSelector:@selector(errorLog:)]) {
return [_delegate errorLog:format];
}
}

@end
4 changes: 2 additions & 2 deletions platform/ios/common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_VARIABLE = YES

HEADER_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/platform/default/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/variant/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/geometry.hpp/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/value/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/geojson.hpp/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/optional" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/typewrapper/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/weak/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/extras/rapidjson/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/extras/expected-lite/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/polylabel/include" "$(PROJECT_DIR)/../../platform/darwin/include"
HEADER_SEARCH_PATHS = $(inherited) "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/platform/default/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/variant/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/geometry.hpp/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/value/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/geojson.hpp/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/optional" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/typewrapper/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/mapbox/weak/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/extras/rapidjson/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/mapbox-base/extras/expected-lite/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/vendor/polylabel/include" "$(PROJECT_DIR)/../../platform/darwin/include" "$(PROJECT_DIR)/../../vendor/mapbox-gl-native/platform/darwin/include"

LD_GENERATE_MAP_FILE = YES

Expand All @@ -79,4 +79,4 @@ CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = NO

// Add developer config
#include? "developer.xcconfig"
#include? "developer.xcconfig"
6 changes: 6 additions & 0 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
9C6E282D22A9815D0056B7BE /* MGLMapboxEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C6E282922A980E50056B7BE /* MGLMapboxEvents.h */; };
9C6E282F22A9824B0056B7BE /* MGLTelemetryConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = AC518DFD201BB55A00EBC820 /* MGLTelemetryConfig.h */; };
9C6E283022A9824F0056B7BE /* MGLMapboxEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C6E282922A980E50056B7BE /* MGLMapboxEvents.h */; };
A490C46D23C688CD009AC158 /* MGLNetworkIntegrationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A490C46B23C688CC009AC158 /* MGLNetworkIntegrationManager.m */; };
A4DE3DCB23038C98005B3473 /* MGLMockGestureRecognizers.h in Sources */ = {isa = PBXBuildFile; fileRef = A4DE3DCA23038A7F005B3473 /* MGLMockGestureRecognizers.h */; };
A4DE3DCC23038CCA005B3473 /* MGLMockGestureRecognizers.m in Sources */ = {isa = PBXBuildFile; fileRef = A4DE3DC823038A07005B3473 /* MGLMockGestureRecognizers.m */; };
A4F3FB1D2254865900A30170 /* missing_icon.json in Resources */ = {isa = PBXBuildFile; fileRef = A4F3FB1C2254865900A30170 /* missing_icon.json */; };
Expand Down Expand Up @@ -1038,6 +1039,8 @@
9C6E286522A9849E0056B7BE /* release-notes-jazzy.md.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = "release-notes-jazzy.md.ejs"; sourceTree = "<group>"; };
9C6E286622A9849E0056B7BE /* deploy-snapshot.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "deploy-snapshot.sh"; sourceTree = "<group>"; };
9C6E286722A9849E0056B7BE /* release-notes.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = "release-notes.js"; sourceTree = "<group>"; };
A490C46B23C688CC009AC158 /* MGLNetworkIntegrationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkIntegrationManager.m; sourceTree = "<group>"; };
A490C46C23C688CC009AC158 /* MGLNetworkIntegrationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLNetworkIntegrationManager.h; sourceTree = "<group>"; };
A4DE3DC823038A07005B3473 /* MGLMockGestureRecognizers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLMockGestureRecognizers.m; sourceTree = "<group>"; };
A4DE3DCA23038A7F005B3473 /* MGLMockGestureRecognizers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMockGestureRecognizers.h; sourceTree = "<group>"; };
A4F3FB1C2254865900A30170 /* missing_icon.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = missing_icon.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1956,6 +1959,8 @@
1F2B94BF221636D800210640 /* MGLNetworkConfiguration_Private.h */,
DD0902A21DB18DE700C5BDCE /* MGLNetworkConfiguration.m */,
3EA9337830C7738BF7F5493C /* MGLRendererConfiguration.h */,
A490C46C23C688CC009AC158 /* MGLNetworkIntegrationManager.h */,
A490C46B23C688CC009AC158 /* MGLNetworkIntegrationManager.m */,
3EA931BC4F087E166D538F21 /* MGLRendererConfiguration.mm */,
92F2C3EC1F0E3C3A00268EC0 /* MGLRendererFrontend.h */,
DA8847EC1CBAFA5100AB86E3 /* MGLStyle.h */,
Expand Down Expand Up @@ -2987,6 +2992,7 @@
files = (
DA1DC9971CB6E046006E619F /* main.m in Sources */,
354B839C1D2E9B48005D9406 /* MBXUserLocationAnnotationView.m in Sources */,
A490C46D23C688CD009AC158 /* MGLNetworkIntegrationManager.m in Sources */,
965DF51120F9430500438AAC /* MBXFrameTimeGraphView.m in Sources */,
DA1DC9991CB6E054006E619F /* MBXAppDelegate.m in Sources */,
6FA9341721EF372100AA9CA8 /* MBXOrnamentsViewController.m in Sources */,
Expand Down

0 comments on commit c8d097b

Please sign in to comment.