From db6190e9e99decc573d63c6b3d678cf7bff6c6b3 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 13 Apr 2015 19:24:03 +0300 Subject: [PATCH] no message --- MTProtoKit/MTApiEnvironment.m | 13 +++++++++++++ MTProtoKit/MTDiscoverTransportSchemeAction.m | 5 +++++ MTProtoKit/MTProto.mm | 4 ---- MTProtoKit/MTRequest.h | 1 + MTProtoKit/MTRequestErrorContext.h | 1 + MTProtoKit/MTRequestMessageService.m | 18 +++++++++++++----- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/MTProtoKit/MTApiEnvironment.m b/MTProtoKit/MTApiEnvironment.m index f087afac88..082b1e70ec 100644 --- a/MTProtoKit/MTApiEnvironment.m +++ b/MTProtoKit/MTApiEnvironment.m @@ -26,6 +26,9 @@ #define IPHONE_4_NAMESTRING @"iPhone 4" #define IPHONE_4S_NAMESTRING @"iPhone 4S" #define IPHONE_5_NAMESTRING @"iPhone 5" +#define IPHONE_5S_NAMESTRING @"iPhone 5S" +#define IPHONE_6_NAMESTRING @"iPhone 6" +#define IPHONE_6Plus_NAMESTRING @"iPhone 6 Plus" #define IPHONE_UNKNOWN_NAMESTRING @"Unknown iPhone" #define IPOD_1G_NAMESTRING @"iPod touch 1G" @@ -67,6 +70,9 @@ typedef enum { UIDevice4iPhone, UIDevice4SiPhone, UIDevice5iPhone, + UIDevice5SiPhone, + UIDevice6iPhone, + UIDevice6PlusiPhone, UIDevice1GiPod, UIDevice2GiPod, @@ -137,6 +143,9 @@ typedef enum { case UIDevice4iPhone: return IPHONE_4_NAMESTRING; case UIDevice4SiPhone: return IPHONE_4S_NAMESTRING; case UIDevice5iPhone: return IPHONE_5_NAMESTRING; + case UIDevice5SiPhone: return IPHONE_5S_NAMESTRING; + case UIDevice6iPhone: return IPHONE_6_NAMESTRING; + case UIDevice6PlusiPhone: return IPHONE_6Plus_NAMESTRING; case UIDeviceUnknowniPhone: return IPHONE_UNKNOWN_NAMESTRING; case UIDevice1GiPod: return IPOD_1G_NAMESTRING; @@ -185,6 +194,10 @@ typedef enum { if ([platform hasPrefix:@"iPhone3"]) return UIDevice4iPhone; if ([platform hasPrefix:@"iPhone4"]) return UIDevice4SiPhone; if ([platform hasPrefix:@"iPhone5"]) return UIDevice5iPhone; + if ([platform hasPrefix:@"iPhone6,1"]) return UIDevice5SiPhone; + if ([platform hasPrefix:@"iPhone6,2"]) return UIDevice5SiPhone; + if ([platform hasPrefix:@"iPhone7,1"]) return UIDevice6PlusiPhone; + if ([platform hasPrefix:@"iPhone7,2"]) return UIDevice6iPhone; // iPod if ([platform hasPrefix:@"iPod1"]) return UIDevice1GiPod; diff --git a/MTProtoKit/MTDiscoverTransportSchemeAction.m b/MTProtoKit/MTDiscoverTransportSchemeAction.m index 1f2531c1c1..dea9d350eb 100644 --- a/MTProtoKit/MTDiscoverTransportSchemeAction.m +++ b/MTProtoKit/MTDiscoverTransportSchemeAction.m @@ -539,6 +539,11 @@ typedef enum { bool success = [self isResponseValid:data]; +#ifdef DEBUG + //if (!success) + // NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); +#endif + httpWorker.delegate = nil; [self _removeActiveConnection:httpWorker]; diff --git a/MTProtoKit/MTProto.mm b/MTProtoKit/MTProto.mm index 5add32c882..1bb803d74d 100644 --- a/MTProtoKit/MTProto.mm +++ b/MTProtoKit/MTProto.mm @@ -268,11 +268,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; { MTTransport *transport = nil; -#if TARGET_IPHONE_SIMULATOR && false - transport = [[MTHttpTransport alloc] initWithDelegate:self context:_context datacenterId:_datacenterId address:[_context addressSetForDatacenterWithId:_datacenterId].addressList.firstObject]; -#else transport = [_transportScheme createTransportWithContext:_context datacenterId:_datacenterId delegate:self]; -#endif [self setTransport:transport]; } diff --git a/MTProtoKit/MTRequest.h b/MTProtoKit/MTRequest.h index 646350757c..599e2a7d8f 100644 --- a/MTProtoKit/MTRequest.h +++ b/MTProtoKit/MTRequest.h @@ -19,6 +19,7 @@ @property (nonatomic, strong) MTRequestErrorContext *errorContext; @property (nonatomic) bool hasHighPriority; @property (nonatomic) bool dependsOnPasswordEntry; +@property (nonatomic) bool passthroughPasswordEntryError; @property (nonatomic, copy) void (^completed)(id result, NSTimeInterval completionTimestamp, id error); @property (nonatomic, copy) void (^progressUpdated)(float progress, NSUInteger packetLength); diff --git a/MTProtoKit/MTRequestErrorContext.h b/MTProtoKit/MTRequestErrorContext.h index 9057679f07..b95c8d37c5 100644 --- a/MTProtoKit/MTRequestErrorContext.h +++ b/MTProtoKit/MTRequestErrorContext.h @@ -13,5 +13,6 @@ @property (nonatomic) MTAbsoluteTime minimalExecuteTime; @property (nonatomic) NSUInteger internalServerErrorCount; +@property (nonatomic) NSUInteger floodWaitSeconds; @end diff --git a/MTProtoKit/MTRequestMessageService.m b/MTProtoKit/MTRequestMessageService.m index b0eae9741a..902b01e5ca 100644 --- a/MTProtoKit/MTRequestMessageService.m +++ b/MTProtoKit/MTRequestMessageService.m @@ -473,7 +473,10 @@ { if ([errorText rangeOfString:@"SESSION_PASSWORD_NEEDED"].location != NSNotFound) { - [_context updatePasswordInputRequiredForDatacenterWithId:mtProto.datacenterId required:true]; + if (!request.passthroughPasswordEntryError) + { + [_context updatePasswordInputRequiredForDatacenterWithId:mtProto.datacenterId required:true]; + } } else { @@ -494,7 +497,7 @@ request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + 2.0); } } - else if (errorCode == 420) + else if (errorCode == 420 || [errorText rangeOfString:@"FLOOD_WAIT_"].location != NSNotFound) { if (request.errorContext == nil) request.errorContext = [[MTRequestErrorContext alloc] init]; @@ -508,10 +511,15 @@ [scanner scanString:@"FLOOD_WAIT_" intoString:nil]; if ([scanner scanInt:&errorWaitTime]) { - if (request.shouldContinueExecutionWithErrorContext != nil && request.shouldContinueExecutionWithErrorContext(request.errorContext)) + request.errorContext.floodWaitSeconds = errorWaitTime; + + if (request.shouldContinueExecutionWithErrorContext != nil) { - restartRequest = true; - request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + (MTAbsoluteTime)errorWaitTime); + if (request.shouldContinueExecutionWithErrorContext(request.errorContext)) + { + restartRequest = true; + request.errorContext.minimalExecuteTime = MAX(request.errorContext.minimalExecuteTime, MTAbsoluteSystemTime() + (MTAbsoluteTime)errorWaitTime); + } } else {