- custom deviceModel name can be transffered from UI

This commit is contained in:
overtake 2021-10-29 18:33:23 +02:00
parent 760f0e9e0b
commit 25f8d0d267
3 changed files with 16 additions and 16 deletions

View File

@ -55,7 +55,7 @@
@property (nonatomic) int32_t apiId;
@property (nonatomic, strong, readonly) NSString * _Nullable deviceModel;
@property (nonatomic, strong, readonly) NSDictionary<NSString *, NSString *> * _Nullable resolvedPlatformName;
@property (nonatomic, strong, readonly) NSDictionary<NSString *, NSString *> * _Nullable resolvedDeviceName;
@property (nonatomic, strong, readonly) NSString * _Nullable systemVersion;
@property (nonatomic, strong) NSString * _Nullable appVersion;
@ -83,6 +83,6 @@
- (MTApiEnvironment * _Nonnull)withUpdatedNetworkSettings:(MTNetworkSettings * _Nullable)networkSettings;
- (MTApiEnvironment * _Nonnull)withUpdatedSystemCode:(NSData * _Nullable)systemCode;
-(id _Nonnull)initWithResolvedPlatformName:(NSDictionary<NSString *, NSString *> * _Nullable)resolvedPlatformName;
-(id _Nonnull)initWithResolvedDeviceName:(NSDictionary<NSString *, NSString *> * _Nullable)resolvedDeviceName;
@end

View File

@ -428,7 +428,7 @@ static NSData *base64_decode(NSString *str) {
@implementation MTApiEnvironment
-(instancetype)init {
self = [self initWithResolvedPlatformName:nil];
self = [self initWithResolvedDeviceName:nil];
if (self != nil)
{
@ -436,13 +436,13 @@ static NSData *base64_decode(NSString *str) {
return self;
}
-(id _Nonnull)initWithResolvedPlatformName:(NSDictionary<NSString *, NSString *> * _Nullable)resolvedPlatformName {
-(id _Nonnull)initWithResolvedDeviceName:(NSDictionary<NSString *, NSString *> * _Nullable)resolvedDeviceName {
self = [super init];
if (self != nil)
{
if (resolvedPlatformName != nil) {
if (resolvedDeviceName != nil) {
NSString *model = [self platformString];
NSString* resolved = resolvedPlatformName[model];
NSString* resolved = resolvedDeviceName[model];
if (resolved != nil) {
_deviceModel = resolved;
} else {
@ -451,7 +451,7 @@ static NSData *base64_decode(NSString *str) {
} else {
_deviceModel = [self platformString];
}
_resolvedPlatformName = resolvedPlatformName;
_resolvedDeviceName = resolvedDeviceName;
#if TARGET_OS_IPHONE
_systemVersion = [[UIDevice currentDevice] systemVersion];
#else
@ -778,7 +778,7 @@ NSString *suffix = @"";
}
- (MTApiEnvironment *)withUpdatedLangPackCode:(NSString *)langPackCode {
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedPlatformName:_resolvedPlatformName];
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedDeviceName:_resolvedDeviceName];
result.apiId = self.apiId;
result.appVersion = self.appVersion;
@ -802,7 +802,7 @@ NSString *suffix = @"";
}
- (instancetype)copyWithZone:(NSZone *)__unused zone {
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedPlatformName:_resolvedPlatformName];
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedDeviceName:_resolvedDeviceName];
result.apiId = self.apiId;
result.appVersion = self.appVersion;
@ -826,7 +826,7 @@ NSString *suffix = @"";
}
- (MTApiEnvironment *)withUpdatedSocksProxySettings:(MTSocksProxySettings *)socksProxySettings {
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedPlatformName:_resolvedPlatformName];
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedDeviceName:_resolvedDeviceName];
result.apiId = self.apiId;
result.appVersion = self.appVersion;
@ -850,7 +850,7 @@ NSString *suffix = @"";
}
- (MTApiEnvironment *)withUpdatedNetworkSettings:(MTNetworkSettings *)networkSettings {
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedPlatformName:_resolvedPlatformName];
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedDeviceName:_resolvedDeviceName];
result.apiId = self.apiId;
result.appVersion = self.appVersion;
@ -874,7 +874,7 @@ NSString *suffix = @"";
}
- (MTApiEnvironment *)withUpdatedSystemCode:(NSData *)systemCode {
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedPlatformName:_resolvedPlatformName];
MTApiEnvironment *result = [[MTApiEnvironment alloc] initWithResolvedDeviceName:_resolvedDeviceName];
result.apiId = self.apiId;
result.appVersion = self.appVersion;

View File

@ -406,8 +406,8 @@ public struct NetworkInitializationArguments {
public let appData: Signal<Data?, NoError>
public let autolockDeadine: Signal<Int32?, NoError>
public let encryptionProvider: EncryptionProvider
public let resolvedPlatformName:[String: String]?
public init(apiId: Int32, apiHash: String, languagesCategory: String, appVersion: String, voipMaxLayer: Int32, voipVersions: [CallSessionManagerImplementationVersion], appData: Signal<Data?, NoError>, autolockDeadine: Signal<Int32?, NoError>, encryptionProvider: EncryptionProvider, resolvedPlatformName:[String: String]?) {
public let resolvedDeviceName:[String: String]?
public init(apiId: Int32, apiHash: String, languagesCategory: String, appVersion: String, voipMaxLayer: Int32, voipVersions: [CallSessionManagerImplementationVersion], appData: Signal<Data?, NoError>, autolockDeadine: Signal<Int32?, NoError>, encryptionProvider: EncryptionProvider, resolvedDeviceName:[String: String]?) {
self.apiId = apiId
self.apiHash = apiHash
self.languagesCategory = languagesCategory
@ -417,7 +417,7 @@ public struct NetworkInitializationArguments {
self.appData = appData
self.autolockDeadine = autolockDeadine
self.encryptionProvider = encryptionProvider
self.resolvedPlatformName = resolvedPlatformName
self.resolvedDeviceName = resolvedDeviceName
}
}
#if os(iOS)
@ -432,7 +432,7 @@ func initializedNetwork(accountId: AccountRecordId, arguments: NetworkInitializa
let serialization = Serialization()
var apiEnvironment = MTApiEnvironment(resolvedPlatformName: arguments.resolvedPlatformName)
var apiEnvironment = MTApiEnvironment(resolvedDeviceName: arguments.resolvedDeviceName)
apiEnvironment.apiId = arguments.apiId
apiEnvironment.langPack = arguments.languagesCategory