diff --git a/MTConnectionProbing.m b/MTConnectionProbing.m index f279f1a0be..c6a0cb1889 100644 --- a/MTConnectionProbing.m +++ b/MTConnectionProbing.m @@ -60,6 +60,33 @@ @end @implementation MTPingHelper + ++ (void)runLoopThreadFunc { + while (true) { + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]]; + } +} + ++ (NSThread *)runLoopThread { + static NSThread *thread = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + thread = [[NSThread alloc] initWithTarget:self selector:@selector(runLoopThreadFunc) object:nil]; + thread.name = @"MTPingHelper"; + [thread start]; + }); + return thread; +} + ++ (void)dispatchOnRunLoopThreadImpl:(void (^)())f { + if (f) { + f(); + } +} + ++ (void)dispatchOnRunLoopThread:(void (^)())block { + [self performSelector:@selector(dispatchOnRunLoopThreadImpl:) onThread:[self runLoopThread] withObject:[block copy] waitUntilDone:false]; +} - (instancetype)initWithSuccess:(void (^)())success { self = [super init]; @@ -81,11 +108,18 @@ } - (void)dealloc { - _ping.delegate = nil; - [_ping stop]; +#if DEBUG + assert(_ping.delegate == nil); +#endif + if (_ping.delegate != nil) { + _ping.delegate = nil; + [_ping stop]; + } } - (void)stop { + _ping.delegate = nil; + [_ping stop]; } - (void)pingFoundation:(PingFoundation *)pinger didReceivePingResponsePacket:(NSData *)packet sequenceNumber:(uint16_t)sequenceNumber { @@ -104,17 +138,18 @@ + (MTSignal *)pingAddress { return [[MTSignal alloc] initWithGenerator:^id(MTSubscriber *subscriber) { - MTQueue *queue = [MTQueue mainQueue]; MTMetaDisposable *disposable = [[MTMetaDisposable alloc] init]; - [queue dispatchOnQueue:^{ + [MTPingHelper dispatchOnRunLoopThread:^{ MTPingHelper *helper = [[MTPingHelper alloc] initWithSuccess:^{ [subscriber putNext:@true]; [subscriber putCompletion]; }]; [disposable setDisposable:[[MTBlockDisposable alloc] initWithBlock:^{ - [helper stop]; + [MTPingHelper dispatchOnRunLoopThread:^{ + [helper stop]; + }]; }]]; }]; diff --git a/MTProtoKit/MTApiEnvironment.h b/MTProtoKit/MTApiEnvironment.h index 102245f6fd..f92f353540 100644 --- a/MTProtoKit/MTApiEnvironment.h +++ b/MTProtoKit/MTApiEnvironment.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTApiEnvironment.m b/MTProtoKit/MTApiEnvironment.m index 0bc903097a..c32efee098 100644 --- a/MTProtoKit/MTApiEnvironment.m +++ b/MTProtoKit/MTApiEnvironment.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTApiEnvironment.h" diff --git a/MTProtoKit/MTDatacenterAddress.h b/MTProtoKit/MTDatacenterAddress.h index a95da2c547..8aada91a62 100644 --- a/MTProtoKit/MTDatacenterAddress.h +++ b/MTProtoKit/MTDatacenterAddress.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTDatacenterAddress.m b/MTProtoKit/MTDatacenterAddress.m index 58cfe02719..ecd8597ee7 100644 --- a/MTProtoKit/MTDatacenterAddress.m +++ b/MTProtoKit/MTDatacenterAddress.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTDatacenterAddress.h" diff --git a/MTProtoKit/MTDatacenterAddressSet.h b/MTProtoKit/MTDatacenterAddressSet.h index 987e5ca93a..bc7e71893a 100644 --- a/MTProtoKit/MTDatacenterAddressSet.h +++ b/MTProtoKit/MTDatacenterAddressSet.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTDatacenterAddressSet.m b/MTProtoKit/MTDatacenterAddressSet.m index b29137772b..f7f21f7bae 100644 --- a/MTProtoKit/MTDatacenterAddressSet.m +++ b/MTProtoKit/MTDatacenterAddressSet.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTDatacenterAddressSet.h" diff --git a/MTProtoKit/MTDatacenterAuthMessageService.h b/MTProtoKit/MTDatacenterAuthMessageService.h index 21c8e0d600..45210693ad 100644 --- a/MTProtoKit/MTDatacenterAuthMessageService.h +++ b/MTProtoKit/MTDatacenterAuthMessageService.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #if defined(MtProtoKitDynamicFramework) # import diff --git a/MTProtoKit/MTDatacenterSaltInfo.h b/MTProtoKit/MTDatacenterSaltInfo.h index c4e46679c9..c47d63472b 100644 --- a/MTProtoKit/MTDatacenterSaltInfo.h +++ b/MTProtoKit/MTDatacenterSaltInfo.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTDatacenterSaltInfo.m b/MTProtoKit/MTDatacenterSaltInfo.m index fd0225b93e..17f2e5d2f8 100644 --- a/MTProtoKit/MTDatacenterSaltInfo.m +++ b/MTProtoKit/MTDatacenterSaltInfo.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTDatacenterSaltInfo.h" diff --git a/MTProtoKit/MTDatacenterTransferAuthAction.h b/MTProtoKit/MTDatacenterTransferAuthAction.h index f9b6565ff7..f7bece4b4c 100644 --- a/MTProtoKit/MTDatacenterTransferAuthAction.h +++ b/MTProtoKit/MTDatacenterTransferAuthAction.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import @@ -25,4 +19,4 @@ - (void)execute:(MTContext *)context masterDatacenterId:(NSInteger)masterDatacenterId destinationDatacenterId:(NSInteger)destinationDatacenterId authToken:(id)authToken; - (void)cancel; -@end \ No newline at end of file +@end diff --git a/MTProtoKit/MTDatacenterTransferAuthAction.m b/MTProtoKit/MTDatacenterTransferAuthAction.m index 37ac8fddcf..ab803c7d46 100644 --- a/MTProtoKit/MTDatacenterTransferAuthAction.m +++ b/MTProtoKit/MTDatacenterTransferAuthAction.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTDatacenterTransferAuthAction.h" diff --git a/MTProtoKit/MTDiscoverDatacenterAddressAction.h b/MTProtoKit/MTDiscoverDatacenterAddressAction.h index 58352d78a4..a363fa978d 100644 --- a/MTProtoKit/MTDiscoverDatacenterAddressAction.h +++ b/MTProtoKit/MTDiscoverDatacenterAddressAction.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTDiscoverDatacenterAddressAction.m b/MTProtoKit/MTDiscoverDatacenterAddressAction.m index 39db58a672..45f0567430 100644 --- a/MTProtoKit/MTDiscoverDatacenterAddressAction.m +++ b/MTProtoKit/MTDiscoverDatacenterAddressAction.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTDiscoverDatacenterAddressAction.h" diff --git a/MTProtoKit/MTDropResponseContext.h b/MTProtoKit/MTDropResponseContext.h index 1627a6e80a..c0650f55f6 100644 --- a/MTProtoKit/MTDropResponseContext.h +++ b/MTProtoKit/MTDropResponseContext.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTDropResponseContext.m b/MTProtoKit/MTDropResponseContext.m index 13799be45a..5acc47f077 100644 --- a/MTProtoKit/MTDropResponseContext.m +++ b/MTProtoKit/MTDropResponseContext.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTDropResponseContext.h" diff --git a/MTProtoKit/MTEncryption.h b/MTProtoKit/MTEncryption.h index d209be2e8b..6bbe386f3f 100644 --- a/MTProtoKit/MTEncryption.h +++ b/MTProtoKit/MTEncryption.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #ifndef MTEncryption_H #define MTEncryption_H diff --git a/MTProtoKit/MTEncryption.m b/MTProtoKit/MTEncryption.m index 2152f6e524..0f77f231f1 100644 --- a/MTProtoKit/MTEncryption.m +++ b/MTProtoKit/MTEncryption.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTEncryption.h" diff --git a/MTProtoKit/MTHttpTransport.h b/MTProtoKit/MTHttpTransport.h index cfb815d0eb..487e5486e5 100644 --- a/MTProtoKit/MTHttpTransport.h +++ b/MTProtoKit/MTHttpTransport.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #if defined(MtProtoKitDynamicFramework) # import diff --git a/MTProtoKit/MTHttpTransport.m b/MTProtoKit/MTHttpTransport.m index 48428063df..87745418f4 100644 --- a/MTProtoKit/MTHttpTransport.m +++ b/MTProtoKit/MTHttpTransport.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTHttpTransport.h" @@ -63,9 +57,9 @@ return queue; } -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address proxySettings:(MTSocksProxySettings *)proxySettings usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { - self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address usageCalculationInfo:usageCalculationInfo]; + self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address proxySettings:proxySettings usageCalculationInfo:usageCalculationInfo]; if (self != nil) { _address = address; diff --git a/MTProtoKit/MTHttpWorker.h b/MTProtoKit/MTHttpWorker.h index 8121c1af58..69753b740f 100644 --- a/MTProtoKit/MTHttpWorker.h +++ b/MTProtoKit/MTHttpWorker.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "AFNetworking.h" diff --git a/MTProtoKit/MTHttpWorker.m b/MTProtoKit/MTHttpWorker.m index 3f513a7e2e..da52825752 100644 --- a/MTProtoKit/MTHttpWorker.m +++ b/MTProtoKit/MTHttpWorker.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTHttpWorker.h" diff --git a/MTProtoKit/MTHttpWorkerBehaviour.h b/MTProtoKit/MTHttpWorkerBehaviour.h index b09e17b3c1..bb721ca9db 100644 --- a/MTProtoKit/MTHttpWorkerBehaviour.h +++ b/MTProtoKit/MTHttpWorkerBehaviour.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTHttpWorkerBehaviour.m b/MTProtoKit/MTHttpWorkerBehaviour.m index 6d89f197c1..638401ab0a 100644 --- a/MTProtoKit/MTHttpWorkerBehaviour.m +++ b/MTProtoKit/MTHttpWorkerBehaviour.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTHttpWorkerBehaviour.h" diff --git a/MTProtoKit/MTIncomingMessage.h b/MTProtoKit/MTIncomingMessage.h index 5ad536e587..3652bbd913 100644 --- a/MTProtoKit/MTIncomingMessage.h +++ b/MTProtoKit/MTIncomingMessage.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTIncomingMessage.m b/MTProtoKit/MTIncomingMessage.m index 76b4119ada..3238516ec5 100644 --- a/MTProtoKit/MTIncomingMessage.m +++ b/MTProtoKit/MTIncomingMessage.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTIncomingMessage.h" diff --git a/MTProtoKit/MTInputStream.h b/MTProtoKit/MTInputStream.h index 080e09e06c..bc0bf67327 100644 --- a/MTProtoKit/MTInputStream.h +++ b/MTProtoKit/MTInputStream.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTInputStream.m b/MTProtoKit/MTInputStream.m index d0f012a13d..0793b43ca0 100644 --- a/MTProtoKit/MTInputStream.m +++ b/MTProtoKit/MTInputStream.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import #import "MTLogging.h" diff --git a/MTProtoKit/MTInternalId.h b/MTProtoKit/MTInternalId.h index 18c6d45cc5..ae5617ec1f 100644 --- a/MTProtoKit/MTInternalId.h +++ b/MTProtoKit/MTInternalId.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #ifndef MtProtoKit_MTInternalId_h #define MtProtoKit_MTInternalId_h diff --git a/MTProtoKit/MTKeychain.h b/MTProtoKit/MTKeychain.h index 0a5ffa1dd4..e3d20d8996 100644 --- a/MTProtoKit/MTKeychain.h +++ b/MTProtoKit/MTKeychain.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTKeychain.m b/MTProtoKit/MTKeychain.m index f4bb53a83a..8beaac734d 100644 --- a/MTProtoKit/MTKeychain.m +++ b/MTProtoKit/MTKeychain.m @@ -1,9 +1,3 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTKeychain.h" diff --git a/MTProtoKit/MTLogging.h b/MTProtoKit/MTLogging.h index 2f6e48b6a6..c5f61f82b7 100644 --- a/MTProtoKit/MTLogging.h +++ b/MTProtoKit/MTLogging.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #ifndef MTLogging_H #define MTLogging_H diff --git a/MTProtoKit/MTLogging.m b/MTProtoKit/MTLogging.m index 1668ebca69..415a3281f0 100644 --- a/MTProtoKit/MTLogging.m +++ b/MTProtoKit/MTLogging.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTLogging.h" diff --git a/MTProtoKit/MTMessageEncryptionKey.h b/MTProtoKit/MTMessageEncryptionKey.h index 364cef36a6..f9c76ae0e8 100644 --- a/MTProtoKit/MTMessageEncryptionKey.h +++ b/MTProtoKit/MTMessageEncryptionKey.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTMessageEncryptionKey.m b/MTProtoKit/MTMessageEncryptionKey.m index 1b14705d0d..75c6625d38 100644 --- a/MTProtoKit/MTMessageEncryptionKey.m +++ b/MTProtoKit/MTMessageEncryptionKey.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTMessageEncryptionKey.h" diff --git a/MTProtoKit/MTMessageService.h b/MTProtoKit/MTMessageService.h index 761c61072c..2b89f85ecf 100644 --- a/MTProtoKit/MTMessageService.h +++ b/MTProtoKit/MTMessageService.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTMessageTransaction.h b/MTProtoKit/MTMessageTransaction.h index 41302e384f..5aa700b2a2 100644 --- a/MTProtoKit/MTMessageTransaction.h +++ b/MTProtoKit/MTMessageTransaction.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTMessageTransaction.m b/MTProtoKit/MTMessageTransaction.m index c07e050e86..6bbcc6a94e 100644 --- a/MTProtoKit/MTMessageTransaction.m +++ b/MTProtoKit/MTMessageTransaction.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTMessageTransaction.h" diff --git a/MTProtoKit/MTNetworkAvailability.h b/MTProtoKit/MTNetworkAvailability.h index c06c71f7fe..e99de13236 100644 --- a/MTProtoKit/MTNetworkAvailability.h +++ b/MTProtoKit/MTNetworkAvailability.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTNetworkAvailability.m b/MTProtoKit/MTNetworkAvailability.m index 020a27e32d..96073ac465 100644 --- a/MTProtoKit/MTNetworkAvailability.m +++ b/MTProtoKit/MTNetworkAvailability.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTNetworkAvailability.h" diff --git a/MTProtoKit/MTOutgoingMessage.h b/MTProtoKit/MTOutgoingMessage.h index 20e52d39df..a4bf94e894 100644 --- a/MTProtoKit/MTOutgoingMessage.h +++ b/MTProtoKit/MTOutgoingMessage.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTOutgoingMessage.m b/MTProtoKit/MTOutgoingMessage.m index ed34c9bf50..ab44d65b4a 100644 --- a/MTProtoKit/MTOutgoingMessage.m +++ b/MTProtoKit/MTOutgoingMessage.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTOutgoingMessage.h" diff --git a/MTProtoKit/MTOutputStream.h b/MTProtoKit/MTOutputStream.h index 01cfe0b04e..0e416955fa 100644 --- a/MTProtoKit/MTOutputStream.h +++ b/MTProtoKit/MTOutputStream.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTOutputStream.m b/MTProtoKit/MTOutputStream.m index b20bf59ec6..4a5f2698c6 100644 --- a/MTProtoKit/MTOutputStream.m +++ b/MTProtoKit/MTOutputStream.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTOutputStream.h" diff --git a/MTProtoKit/MTPreparedMessage.h b/MTProtoKit/MTPreparedMessage.h index 55bb19b3b4..abeb65062b 100644 --- a/MTProtoKit/MTPreparedMessage.h +++ b/MTProtoKit/MTPreparedMessage.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTPreparedMessage.m b/MTProtoKit/MTPreparedMessage.m index 9fedc1c0f6..4f0757a6da 100644 --- a/MTProtoKit/MTPreparedMessage.m +++ b/MTProtoKit/MTPreparedMessage.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTPreparedMessage.h" diff --git a/MTProtoKit/MTProto.h b/MTProtoKit/MTProto.h index 4321a200d3..683f413f6e 100644 --- a/MTProtoKit/MTProto.h +++ b/MTProtoKit/MTProto.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTProto.m b/MTProtoKit/MTProto.m index 87bcde7cb3..08138c091f 100644 --- a/MTProtoKit/MTProto.m +++ b/MTProtoKit/MTProto.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTProto.h" @@ -773,10 +767,6 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; [messageService mtProtoConnectionStateChanged:self isConnected:isConnected]; } - if (isConnected || proxySettings == nil) { - _probingStatus = nil; - } - MTProtoConnectionState *connectionState = [[MTProtoConnectionState alloc] initWithIsConnected:isConnected proxyAddress:proxySettings.ip proxyHasConnectionIssues:[_probingStatus boolValue]]; _connectionState = connectionState; @@ -784,39 +774,6 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; if ([delegate respondsToSelector:@selector(mtProtoConnectionStateChanged:state:)]) { [delegate mtProtoConnectionStateChanged:self state:connectionState]; } - - if (isConnected || proxySettings == nil || !_checkForProxyConnectionIssues) { - if (_isProbing) { - _isProbing = false; - [_probingDisposable setDisposable:nil]; - _probingStatus = nil; - } - } else { - if (!_isProbing) { - _isProbing = true; - __weak MTProto *weakSelf = self; - MTSignal *checkSignal = [[MTConnectionProbing probeProxyWithContext:_context datacenterId:_datacenterId settings:proxySettings] delay:5.0 onQueue:[MTQueue concurrentDefaultQueue]]; - checkSignal = [[checkSignal then:[[MTSignal complete] delay:20.0 onQueue:[MTQueue concurrentDefaultQueue]]] restart]; - [_probingDisposable setDisposable:[checkSignal startWithNext:^(NSNumber *next) { - [[MTProto managerQueue] dispatchOnQueue:^{ - __strong MTProto *strongSelf = weakSelf; - if (strongSelf == nil) { - return; - } - if (strongSelf->_isProbing) { - strongSelf->_probingStatus = next; - if (strongSelf->_connectionState != nil) { - strongSelf->_connectionState = [[MTProtoConnectionState alloc] initWithIsConnected:strongSelf->_connectionState.isConnected proxyAddress:strongSelf->_connectionState.proxyAddress proxyHasConnectionIssues:[strongSelf->_probingStatus boolValue]]; - id delegate = strongSelf->_delegate; - if ([delegate respondsToSelector:@selector(mtProtoConnectionStateChanged:state:)]) { - [delegate mtProtoConnectionStateChanged:self state:connectionState]; - } - } - } - }]; - }]]; - } - } }]; } @@ -845,21 +802,58 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; - (void)transportConnectionProblemsStatusChanged:(MTTransport *)transport hasConnectionProblems:(bool)hasConnectionProblems isProbablyHttp:(bool)isProbablyHttp { - [[MTProto managerQueue] dispatchOnQueue:^ - { - if (_transport != transport || _transportScheme == nil) + [[MTProto managerQueue] dispatchOnQueue:^ { + if (_transport != transport || _transportScheme == nil) { return; - - if (hasConnectionProblems) - { - [_context invalidateTransportSchemeForDatacenterId:_datacenterId transportScheme:_transportScheme isProbablyHttp:isProbablyHttp media:_media]; } - else - { + + if (hasConnectionProblems) { + [_context invalidateTransportSchemeForDatacenterId:_datacenterId transportScheme:_transportScheme isProbablyHttp:isProbablyHttp media:_media]; + } else { [_context revalidateTransportSchemeForDatacenterId:_datacenterId transportScheme:_transportScheme media:_media]; } + + if (!hasConnectionProblems || transport.proxySettings == nil || !_checkForProxyConnectionIssues) { + if (_isProbing) { + _isProbing = false; + [_probingDisposable setDisposable:nil]; + if (_probingStatus != nil) { + _probingStatus = nil; + [self _updateConnectionIssuesStatus:false]; + } + } + } else { + if (!_isProbing) { + _isProbing = true; + __weak MTProto *weakSelf = self; + MTSignal *checkSignal = [[MTConnectionProbing probeProxyWithContext:_context datacenterId:_datacenterId settings:transport.proxySettings] delay:5.0 onQueue:[MTQueue concurrentDefaultQueue]]; + checkSignal = [[checkSignal then:[[MTSignal complete] delay:20.0 onQueue:[MTQueue concurrentDefaultQueue]]] restart]; + [_probingDisposable setDisposable:[checkSignal startWithNext:^(NSNumber *next) { + [[MTProto managerQueue] dispatchOnQueue:^{ + __strong MTProto *strongSelf = weakSelf; + if (strongSelf == nil) { + return; + } + if (strongSelf->_isProbing) { + strongSelf->_probingStatus = next; + [strongSelf _updateConnectionIssuesStatus:[strongSelf->_probingStatus boolValue]]; + } + }]; + }]]; + } + } }]; } + +- (void)_updateConnectionIssuesStatus:(bool)value { + if (_connectionState != nil) { + _connectionState = [[MTProtoConnectionState alloc] initWithIsConnected:_connectionState.isConnected proxyAddress:_connectionState.proxyAddress proxyHasConnectionIssues:value]; + id delegate = _delegate; + if ([delegate respondsToSelector:@selector(mtProtoConnectionStateChanged:state:)]) { + [delegate mtProtoConnectionStateChanged:self state:_connectionState]; + } + } +} - (NSString *)outgoingMessageDescription:(MTOutgoingMessage *)message messageId:(int64_t)messageId messageSeqNo:(int32_t)messageSeqNo { @@ -2119,7 +2113,7 @@ static NSString *dumpHexString(NSData *data, int maxLength) { for (MTIncomingMessage *incomingMessage in parsedMessages) { - [self _processIncomingMessage:incomingMessage withTransactionId:transactionId address:transport.address]; + [self _processIncomingMessage:incomingMessage totalSize:(int)decryptedData.length withTransactionId:transactionId address:transport.address]; } if (requestTransactionAfterProcessing) @@ -2412,7 +2406,7 @@ static NSString *dumpHexString(NSData *data, int maxLength) { return messages; } -- (void)_processIncomingMessage:(MTIncomingMessage *)incomingMessage withTransactionId:(id)transactionId address:(MTDatacenterAddress *)address +- (void)_processIncomingMessage:(MTIncomingMessage *)incomingMessage totalSize:(int)totalSize withTransactionId:(id)transactionId address:(MTDatacenterAddress *)address { if ([_sessionInfo messageProcessed:incomingMessage.messageId]) { @@ -2428,7 +2422,7 @@ static NSString *dumpHexString(NSData *data, int maxLength) { } if (MTLogEnabled()) { - MTLog(@"[MTProto#%p received %@]", self, [self incomingMessageDescription:incomingMessage]); + MTLog(@"[MTProto#%p [%d] received %@]", self, totalSize, [self incomingMessageDescription:incomingMessage]); } [_sessionInfo setMessageProcessed:incomingMessage.messageId]; diff --git a/MTProtoKit/MTQueue.h b/MTProtoKit/MTQueue.h index b5487a9f18..95fde2cc7c 100644 --- a/MTProtoKit/MTQueue.h +++ b/MTProtoKit/MTQueue.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTQueue.m b/MTProtoKit/MTQueue.m index dd2c9852cd..cc79357989 100644 --- a/MTProtoKit/MTQueue.m +++ b/MTProtoKit/MTQueue.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTQueue.h" diff --git a/MTProtoKit/MTRequest.h b/MTProtoKit/MTRequest.h index 1050efcebb..04dd8d52c4 100644 --- a/MTProtoKit/MTRequest.h +++ b/MTProtoKit/MTRequest.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTRequest.m b/MTProtoKit/MTRequest.m index cd49051adb..4dfead4bc5 100644 --- a/MTProtoKit/MTRequest.m +++ b/MTProtoKit/MTRequest.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTRequest.h" diff --git a/MTProtoKit/MTRequestContext.h b/MTProtoKit/MTRequestContext.h index 8a64dfeabb..46b17abcee 100644 --- a/MTProtoKit/MTRequestContext.h +++ b/MTProtoKit/MTRequestContext.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTRequestContext.m b/MTProtoKit/MTRequestContext.m index d713d52f8d..d3be83d166 100644 --- a/MTProtoKit/MTRequestContext.m +++ b/MTProtoKit/MTRequestContext.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTRequestContext.h" diff --git a/MTProtoKit/MTRequestErrorContext.h b/MTProtoKit/MTRequestErrorContext.h index 1ee405d3ff..fc190383be 100644 --- a/MTProtoKit/MTRequestErrorContext.h +++ b/MTProtoKit/MTRequestErrorContext.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTRequestMessageService.h b/MTProtoKit/MTRequestMessageService.h index c8317a7aae..cd39ffff27 100644 --- a/MTProtoKit/MTRequestMessageService.h +++ b/MTProtoKit/MTRequestMessageService.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #if defined(MtProtoKitDynamicFramework) # import diff --git a/MTProtoKit/MTRequestMessageService.m b/MTProtoKit/MTRequestMessageService.m index 6b065c9e0d..6acae37f17 100644 --- a/MTProtoKit/MTRequestMessageService.m +++ b/MTProtoKit/MTRequestMessageService.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTRequestMessageService.h" diff --git a/MTProtoKit/MTResendMessageService.h b/MTProtoKit/MTResendMessageService.h index a7052e33b0..e5d95e54a1 100644 --- a/MTProtoKit/MTResendMessageService.h +++ b/MTProtoKit/MTResendMessageService.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #if defined(MtProtoKitDynamicFramework) # import diff --git a/MTProtoKit/MTResendMessageService.m b/MTProtoKit/MTResendMessageService.m index 8a146e2602..98090381da 100644 --- a/MTProtoKit/MTResendMessageService.m +++ b/MTProtoKit/MTResendMessageService.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import #import "MTLogging.h" diff --git a/MTProtoKit/MTSerialization.h b/MTProtoKit/MTSerialization.h index bb3c29724b..e3731b7100 100644 --- a/MTProtoKit/MTSerialization.h +++ b/MTProtoKit/MTSerialization.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTSessionInfo.h b/MTProtoKit/MTSessionInfo.h index 829e8c1100..ec32fbbce6 100644 --- a/MTProtoKit/MTSessionInfo.h +++ b/MTProtoKit/MTSessionInfo.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTSessionInfo.m b/MTProtoKit/MTSessionInfo.m index 22ac33e945..8c21f04b21 100644 --- a/MTProtoKit/MTSessionInfo.m +++ b/MTProtoKit/MTSessionInfo.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTSessionInfo.h" diff --git a/MTProtoKit/MTTcpConnection.h b/MTProtoKit/MTTcpConnection.h index e843b1cce8..e9d7c95b64 100644 --- a/MTProtoKit/MTTcpConnection.h +++ b/MTProtoKit/MTTcpConnection.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTTcpConnection.m b/MTProtoKit/MTTcpConnection.m index ffa3a104ee..118e251956 100644 --- a/MTProtoKit/MTTcpConnection.m +++ b/MTProtoKit/MTTcpConnection.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTTcpConnection.h" diff --git a/MTProtoKit/MTTcpConnectionBehaviour.h b/MTProtoKit/MTTcpConnectionBehaviour.h index a79c4df6d5..f5437778e4 100644 --- a/MTProtoKit/MTTcpConnectionBehaviour.h +++ b/MTProtoKit/MTTcpConnectionBehaviour.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + @class MTQueue; @class MTTcpConnectionBehaviour; diff --git a/MTProtoKit/MTTcpConnectionBehaviour.m b/MTProtoKit/MTTcpConnectionBehaviour.m index ac4d8e6046..5381148058 100644 --- a/MTProtoKit/MTTcpConnectionBehaviour.m +++ b/MTProtoKit/MTTcpConnectionBehaviour.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTTcpTransport.h b/MTProtoKit/MTTcpTransport.h index 1632eff7f7..e0ac0caa50 100644 --- a/MTProtoKit/MTTcpTransport.h +++ b/MTProtoKit/MTTcpTransport.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #if defined(MtProtoKitDynamicFramework) # import diff --git a/MTProtoKit/MTTcpTransport.m b/MTProtoKit/MTTcpTransport.m index 2e1bcd6db2..29cd44af19 100644 --- a/MTProtoKit/MTTcpTransport.m +++ b/MTProtoKit/MTTcpTransport.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTTcpTransport.h" @@ -91,7 +85,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; return queue; } -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address proxySettings:(MTSocksProxySettings *)proxySettings usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { #ifdef DEBUG NSAssert(context != nil, @"context should not be nil"); @@ -99,7 +93,7 @@ static const NSTimeInterval MTTcpTransportSleepWatchdogTimeout = 60.0; NSAssert(address != nil, @"address should not be nil"); #endif - self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address usageCalculationInfo:usageCalculationInfo]; + self = [super initWithDelegate:delegate context:context datacenterId:datacenterId address:address proxySettings:proxySettings usageCalculationInfo:usageCalculationInfo]; if (self != nil) { _context = context; diff --git a/MTProtoKit/MTTime.h b/MTProtoKit/MTTime.h index 21e3871be0..0d6f0258f6 100644 --- a/MTProtoKit/MTTime.h +++ b/MTProtoKit/MTTime.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #ifndef MtProtoKit_MTTime_h #define MtProtoKit_MTTime_h diff --git a/MTProtoKit/MTTime.m b/MTProtoKit/MTTime.m index 0d79a469b7..dfdcd92d33 100644 --- a/MTProtoKit/MTTime.m +++ b/MTProtoKit/MTTime.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTTime.h" diff --git a/MTProtoKit/MTTimeSyncMessageService.h b/MTProtoKit/MTTimeSyncMessageService.h index 593d57e9f6..9aa52857a2 100644 --- a/MTProtoKit/MTTimeSyncMessageService.h +++ b/MTProtoKit/MTTimeSyncMessageService.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #if defined(MtProtoKitDynamicFramework) # import diff --git a/MTProtoKit/MTTimeSyncMessageService.m b/MTProtoKit/MTTimeSyncMessageService.m index 51c76f64d0..db7efd600b 100644 --- a/MTProtoKit/MTTimeSyncMessageService.m +++ b/MTProtoKit/MTTimeSyncMessageService.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTTimeSyncMessageService.h" diff --git a/MTProtoKit/MTTimer.h b/MTProtoKit/MTTimer.h index 851b3b25df..5b2f24c68b 100644 --- a/MTProtoKit/MTTimer.h +++ b/MTProtoKit/MTTimer.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTTimer.m b/MTProtoKit/MTTimer.m index 33b1a76077..04e1f3e799 100644 --- a/MTProtoKit/MTTimer.m +++ b/MTProtoKit/MTTimer.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTTimer.h" diff --git a/MTProtoKit/MTTransport.h b/MTProtoKit/MTTransport.h index a54687f790..11803700f2 100644 --- a/MTProtoKit/MTTransport.h +++ b/MTProtoKit/MTTransport.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import @@ -51,10 +45,11 @@ @property (nonatomic, strong, readonly) MTContext *context; @property (nonatomic, readonly) NSInteger datacenterId; @property (nonatomic, strong, readonly) MTDatacenterAddress *address; +@property (nonatomic, strong, readonly) MTSocksProxySettings *proxySettings; @property (nonatomic) bool simultaneousTransactionsEnabled; @property (nonatomic) bool reportTransportConnectionContextUpdateStates; -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address proxySettings:(MTSocksProxySettings *)proxySettings usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; - (void)setUsageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo; diff --git a/MTProtoKit/MTTransport.m b/MTProtoKit/MTTransport.m index fc65b59675..af1f785332 100644 --- a/MTProtoKit/MTTransport.m +++ b/MTProtoKit/MTTransport.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTTransport.h" @@ -20,7 +14,7 @@ @implementation MTTransport -- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address usageCalculationInfo:(MTNetworkUsageCalculationInfo *)__unused usageCalculationInfo +- (instancetype)initWithDelegate:(id)delegate context:(MTContext *)context datacenterId:(NSInteger)datacenterId address:(MTDatacenterAddress *)address proxySettings:(MTSocksProxySettings *)proxySettings usageCalculationInfo:(MTNetworkUsageCalculationInfo *)__unused usageCalculationInfo { #ifdef DEBUG NSAssert(context != nil, @"context should not be nil"); @@ -28,12 +22,12 @@ #endif self = [super init]; - if (self != nil) - { + if (self != nil) { _delegate = delegate; _context = context; _datacenterId = datacenterId; _address = address; + _proxySettings = proxySettings; _networkAvailability = [[MTNetworkAvailability alloc] initWithDelegate:self]; diff --git a/MTProtoKit/MTTransportScheme.h b/MTProtoKit/MTTransportScheme.h index 764f215d71..8e3c8279ec 100644 --- a/MTProtoKit/MTTransportScheme.h +++ b/MTProtoKit/MTTransportScheme.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTTransportScheme.m b/MTProtoKit/MTTransportScheme.m index 69dc11d188..43a7609041 100644 --- a/MTProtoKit/MTTransportScheme.m +++ b/MTProtoKit/MTTransportScheme.m @@ -1,11 +1,3 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ - #import "MTTransportScheme.h" #import "MTTransport.h" @@ -13,6 +5,9 @@ #import "MTTcpTransport.h" +#import "MTContext.h" +#import "MTApiEnvironment.h" + @interface MTTransportScheme () { } @@ -89,7 +84,7 @@ - (MTTransport *)createTransportWithContext:(MTContext *)context datacenterId:(NSInteger)datacenterId delegate:(id)delegate usageCalculationInfo:(MTNetworkUsageCalculationInfo *)usageCalculationInfo { - return [(MTTransport *)[_transportClass alloc] initWithDelegate:delegate context:context datacenterId:datacenterId address:_address usageCalculationInfo:usageCalculationInfo]; + return [(MTTransport *)[_transportClass alloc] initWithDelegate:delegate context:context datacenterId:datacenterId address:_address proxySettings:context.apiEnvironment.socksProxySettings usageCalculationInfo:usageCalculationInfo]; } - (NSString *)description diff --git a/MTProtoKit/MTTransportTransaction.h b/MTProtoKit/MTTransportTransaction.h index ba31b6f820..c2739c9296 100644 --- a/MTProtoKit/MTTransportTransaction.h +++ b/MTProtoKit/MTTransportTransaction.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import diff --git a/MTProtoKit/MTTransportTransaction.m b/MTProtoKit/MTTransportTransaction.m index 1608f0b3c1..93be090960 100644 --- a/MTProtoKit/MTTransportTransaction.m +++ b/MTProtoKit/MTTransportTransaction.m @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + #import "MTTransportTransaction.h" diff --git a/thirdparty/AFNetworking/AFHTTPClient.h b/thirdparty/AFNetworking/AFHTTPClient.h index 9239b66970..29242a1378 100644 --- a/thirdparty/AFNetworking/AFHTTPClient.h +++ b/thirdparty/AFNetworking/AFHTTPClient.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + // AFHTTPClient.h // diff --git a/thirdparty/AFNetworking/AFHTTPRequestOperation.h b/thirdparty/AFNetworking/AFHTTPRequestOperation.h index 8f4f4f4369..d053d35a68 100644 --- a/thirdparty/AFNetworking/AFHTTPRequestOperation.h +++ b/thirdparty/AFNetworking/AFHTTPRequestOperation.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + // AFHTTPOperation.h // diff --git a/thirdparty/AFNetworking/AFJSONUtilities.h b/thirdparty/AFNetworking/AFJSONUtilities.h index 934e6bd59a..b9256424ed 100644 --- a/thirdparty/AFNetworking/AFJSONUtilities.h +++ b/thirdparty/AFNetworking/AFJSONUtilities.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + // AFJSONUtilities.h // diff --git a/thirdparty/AFNetworking/AFNetworking.h b/thirdparty/AFNetworking/AFNetworking.h index 7eab8d5e73..0fedfd25bb 100644 --- a/thirdparty/AFNetworking/AFNetworking.h +++ b/thirdparty/AFNetworking/AFNetworking.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + // AFNetworking.h // diff --git a/thirdparty/AFNetworking/AFURLConnectionOperation.h b/thirdparty/AFNetworking/AFURLConnectionOperation.h index c07fb1a5c1..d9941f51a6 100644 --- a/thirdparty/AFNetworking/AFURLConnectionOperation.h +++ b/thirdparty/AFNetworking/AFURLConnectionOperation.h @@ -1,10 +1,4 @@ -/* - * This is the source code of Telegram for iOS v. 1.1 - * It is licensed under GNU GPL v. 2 or later. - * You should have received a copy of the license in this archive (see LICENSE). - * - * Copyright Peter Iakovlev, 2013. - */ + // AFURLConnectionOperation.h //