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

[ios, macos]Remove iOS/macOS codes from native codes #16031

Merged
merged 31 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3d91301
add source/header
m-stephen Dec 9, 2019
32b55c1
add ios files
m-stephen Dec 9, 2019
99f0738
add configs
m-stephen Dec 9, 2019
bc3fb0b
modify name
m-stephen Dec 9, 2019
ca72384
http_file_source
m-stephen Dec 9, 2019
c09c622
add interface delegate when map init
m-stephen Dec 9, 2019
810cefd
fix name
m-stephen Dec 9, 2019
37d88fe
fix delegate name
m-stephen Dec 9, 2019
f9dfa38
support mac os
m-stephen Dec 9, 2019
65e7c29
add mac os support
m-stephen Dec 9, 2019
dfa567e
make optional delegate when mac os
m-stephen Dec 9, 2019
c1301ec
mac/ios difference
m-stephen Dec 9, 2019
ecf76fe
add ios change log
m-stephen Dec 9, 2019
5cd5aff
cancel iOS/mac OS judgement
m-stephen Dec 9, 2019
f0df7ba
cancel iOS/mac OS judgement
m-stephen Dec 9, 2019
357c8f7
cancel judgement in .m
m-stephen Dec 9, 2019
1c4c436
update
m-stephen Dec 12, 2019
29397ff
update
m-stephen Dec 12, 2019
a72e651
update http_file_source
m-stephen Dec 12, 2019
f72d5f5
update ios
m-stephen Dec 12, 2019
0f07dd3
update mac os
m-stephen Dec 12, 2019
82cf430
add mac os file
m-stephen Dec 12, 2019
0a5e2d1
add mac os file to `.cmake`
m-stephen Dec 12, 2019
6aeb46c
change names
m-stephen Dec 13, 2019
17d3e53
add log & fix format
m-stephen Dec 13, 2019
2b79561
reset changelog commit
m-stephen Dec 13, 2019
d5c9171
update changelog
m-stephen Dec 13, 2019
2c5415d
rename iOS network manager
m-stephen Dec 13, 2019
3afd98b
Add a test configuration(same as default configuration) when mac os r…
m-stephen Dec 13, 2019
84af097
re-add account type into `http_file_source`
m-stephen Dec 13, 2019
aabc7e9
refactor
m-stephen Dec 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions next/platform/macos/macos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ target_sources(
${MBGL_ROOT}/platform/darwin/src/run_loop.cpp
${MBGL_ROOT}/platform/darwin/src/string_nsstring.mm
${MBGL_ROOT}/platform/darwin/src/timer.cpp
${MBGL_ROOT}/platform/darwin/src/native_apple_interface.m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this files to next/platform/ios/ios.cmake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are using two building systems on iOS & mac OS, it shouldn't be added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm..it looks like this was needed after all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, looks like that. We need add all *.m files into ios.cmake, should we make another PR for this?

${MBGL_ROOT}/platform/darwin/src/MGLNetworkIntegrationManager.m
${MBGL_ROOT}/platform/default/src/mbgl/gfx/headless_backend.cpp
${MBGL_ROOT}/platform/default/src/mbgl/gfx/headless_frontend.cpp
${MBGL_ROOT}/platform/default/src/mbgl/gl/headless_backend.cpp
Expand Down
46 changes: 46 additions & 0 deletions platform/darwin/include/mbgl/interface/native_apple_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol MGLNativeAppleInterfaceDelegate <NSObject>
m-stephen marked this conversation as resolved.
Show resolved Hide resolved

@optional

- (NSString *)skuToken;
- (NSString *)accountTypeKey;

@required

- (NSURLSessionConfiguration *)sessionConfiguration;

- (void)startDownloadEvent:(NSString *)event type:(NSString *)type;

- (void)cancelDownloadEventForResponse:(NSURLResponse *)response;

- (void)stopDownloadEventForResponse:(NSURLResponse *)response;

@end

#define MGL_APPLE_EXPORT __attribute__((visibility ("default")))

@interface MGLNativeNetworkDelegate: NSObject
m-stephen marked this conversation as resolved.
Show resolved Hide resolved

+ (MGLNativeNetworkDelegate *)shared;
m-stephen marked this conversation as resolved.
Show resolved Hide resolved

@property (nonatomic, weak) id<MGLNativeAppleInterfaceDelegate> delegate;

@property (nonatomic, readonly) NSString *accountTypeKey;
@property (nonatomic, readonly) NSString *skuToken;

@property (nonatomic, readonly) NSURLSessionConfiguration *sessionConfiguration;

- (void)startDownloadEvent:(NSString *)event type:(NSString *)type;

- (void)cancelDownloadEventForResponse:(NSURLResponse *)response;

- (void)stopDownloadEventForResponse:(NSURLResponse *)response;


@end

NS_ASSUME_NONNULL_END
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 <MGLNativeAppleInterfaceDelegate>

+ (MGLNetworkIntegrationManager *)shared;

@end
50 changes: 50 additions & 0 deletions platform/darwin/src/MGLNetworkIntegrationManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#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 *)shared {
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 *)accountTypeKey {
m-stephen marked this conversation as resolved.
Show resolved Hide resolved
return MGLMapboxAccountTypeKey;
}

- (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];
}

@end
Loading